Remove Resource Monitor ; aka rmon, from the load

All rmon resource monitoring has been moved to collectd.

This update removes rmon from mtce and the load.

Story: 2002823
Task: 30045

Test Plan:
PASS: Build and install a standard system.
PASS: Inspect mtce rpm list
PASS: Inspect logs
PASS: Check pmon.d

Change-Id: I7cf1fa071eac89274e7fae1f307e14d548cc945b
Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
This commit is contained in:
Eric MacDonald 2019-03-16 19:23:40 -04:00
parent 64f9dd20cf
commit f55ef546a7
62 changed files with 16 additions and 13194 deletions

View File

@ -5,7 +5,6 @@
# mtce # mtce
mtce mtce
mtce-pmon mtce-pmon
mtce-rmon
mtce-hwmon mtce-hwmon
mtce-hostw mtce-hostw
mtce-lmon mtce-lmon

View File

@ -273,7 +273,6 @@ function install_mtce {
local unit_dir=${SYSCONFDIR}/systemd/system local unit_dir=${SYSCONFDIR}/systemd/system
local local_etc_pmond=${sysconf_dir}/pmon.d local local_etc_pmond=${sysconf_dir}/pmon.d
local local_etc_rmond=${sysconf_dir}/rmon.d
local local_etc_goenabledd=${sysconf_dir}/goenabled.d local local_etc_goenabledd=${sysconf_dir}/goenabled.d
local local_etc_servicesd=${sysconf_dir}/services.d local local_etc_servicesd=${sysconf_dir}/services.d
local local_etc_logrotated=${sysconf_dir}/logrotate.d local local_etc_logrotated=${sysconf_dir}/logrotate.d
@ -309,7 +308,6 @@ function install_mtce {
sudo install -m 644 -p -D fsmon/scripts/fsmond.conf ${sysconf_dir}/mtc/fsmond.conf sudo install -m 644 -p -D fsmon/scripts/fsmond.conf ${sysconf_dir}/mtc/fsmond.conf
sudo install -m 644 -p -D hwmon/scripts/hwmond.conf ${sysconf_dir}/mtc/hwmond.conf sudo install -m 644 -p -D hwmon/scripts/hwmond.conf ${sysconf_dir}/mtc/hwmond.conf
sudo install -m 644 -p -D pmon/scripts/pmond.conf ${sysconf_dir}/mtc/pmond.conf sudo install -m 644 -p -D pmon/scripts/pmond.conf ${sysconf_dir}/mtc/pmond.conf
sudo install -m 644 -p -D rmon/scripts/rmond.conf ${sysconf_dir}/mtc/rmond.conf
sudo install -m 644 -p -D hostw/scripts/hostwd.conf ${sysconf_dir}/mtc/hostwd.conf sudo install -m 644 -p -D hostw/scripts/hostwd.conf ${sysconf_dir}/mtc/hostwd.conf
sudo install -m 755 -d ${sysconf_dir}/bmc/server_profiles.d sudo install -m 755 -d ${sysconf_dir}/bmc/server_profiles.d
@ -324,12 +322,10 @@ function install_mtce {
sudo install -m 755 -p -D heartbeat/hbsClient ${bin_dir}/hbsClient sudo install -m 755 -p -D heartbeat/hbsClient ${bin_dir}/hbsClient
sudo install -m 755 -p -D pmon/pmond ${bin_dir}/pmond sudo install -m 755 -p -D pmon/pmond ${bin_dir}/pmond
sudo install -m 755 -p -D hostw/hostwd ${bin_dir}/hostwd sudo install -m 755 -p -D hostw/hostwd ${bin_dir}/hostwd
sudo install -m 755 -p -D rmon/rmond ${bin_dir}/rmond
sudo install -m 755 -p -D fsmon/fsmond ${bin_dir}/fsmond sudo install -m 755 -p -D fsmon/fsmond ${bin_dir}/fsmond
sudo install -m 755 -p -D hwmon/hwmond ${bin_dir}/hwmond sudo install -m 755 -p -D hwmon/hwmond ${bin_dir}/hwmond
sudo install -m 755 -p -D mtclog/mtclogd ${bin_dir}/mtclogd sudo install -m 755 -p -D mtclog/mtclogd ${bin_dir}/mtclogd
sudo install -m 755 -p -D alarm/mtcalarmd ${bin_dir}/mtcalarmd sudo install -m 755 -p -D alarm/mtcalarmd ${bin_dir}/mtcalarmd
sudo install -m 755 -p -D rmon/rmon_resource_notify/rmon_resource_notify ${bin_dir}/rmon_resource_notify
sudo install -m 755 -p -D scripts/wipedisk ${bin_dir}/wipedisk sudo install -m 755 -p -D scripts/wipedisk ${bin_dir}/wipedisk
$STX_SUDO install -m 755 -p -D fsync/fsync ${STX_INST_DIR}/sbin/fsync $STX_SUDO install -m 755 -p -D fsync/fsync ${STX_INST_DIR}/sbin/fsync
sudo install -m 700 -p -D pmon/scripts/pmon-restart ${sbin_dir}/pmon-restart sudo install -m 700 -p -D pmon/scripts/pmon-restart ${sbin_dir}/pmon-restart
@ -343,7 +339,6 @@ function install_mtce {
sudo install -m 755 -p -D fsmon/scripts/fsmon ${sysconf_dir}/init.d/fsmon sudo install -m 755 -p -D fsmon/scripts/fsmon ${sysconf_dir}/init.d/fsmon
sudo install -m 755 -p -D scripts/mtclog ${sysconf_dir}/init.d/mtclog sudo install -m 755 -p -D scripts/mtclog ${sysconf_dir}/init.d/mtclog
sudo install -m 755 -p -D pmon/scripts/pmon ${sysconf_dir}/init.d/pmon sudo install -m 755 -p -D pmon/scripts/pmon ${sysconf_dir}/init.d/pmon
sudo install -m 755 -p -D rmon/scripts/rmon ${sysconf_dir}/init.d/rmon
sudo install -m 755 -p -D hostw/scripts/hostw ${sysconf_dir}/init.d/hostw sudo install -m 755 -p -D hostw/scripts/hostw ${sysconf_dir}/init.d/hostw
sudo install -m 755 -p -D alarm/scripts/mtcalarm.init ${sysconf_dir}/init.d/mtcalarm sudo install -m 755 -p -D alarm/scripts/mtcalarm.init ${sysconf_dir}/init.d/mtcalarm
@ -354,7 +349,6 @@ function install_mtce {
# systemd service files # systemd service files
sudo install -m 644 -p -D fsmon/scripts/fsmon.service ${unit_dir}/devstack@fsmon.service sudo install -m 644 -p -D fsmon/scripts/fsmon.service ${unit_dir}/devstack@fsmon.service
sudo install -m 644 -p -D hwmon/scripts/hwmon.service ${unit_dir}/devstack@hwmon.service sudo install -m 644 -p -D hwmon/scripts/hwmon.service ${unit_dir}/devstack@hwmon.service
sudo install -m 644 -p -D rmon/scripts/rmon.service ${unit_dir}/devstack@rmon.service
sudo install -m 644 -p -D pmon/scripts/pmon.service ${unit_dir}/devstack@pmon.service sudo install -m 644 -p -D pmon/scripts/pmon.service ${unit_dir}/devstack@pmon.service
sudo install -m 644 -p -D hostw/scripts/hostw.service ${unit_dir}/devstack@hostw.service sudo install -m 644 -p -D hostw/scripts/hostw.service ${unit_dir}/devstack@hostw.service
sudo install -m 644 -p -D scripts/mtcClient.service ${unit_dir}/devstack@mtcClient.service sudo install -m 644 -p -D scripts/mtcClient.service ${unit_dir}/devstack@mtcClient.service
@ -388,31 +382,15 @@ function install_mtce {
sudo install -m 644 -p -D pmon/scripts/sshd.conf ${local_etc_pmond}/sshd.conf sudo install -m 644 -p -D pmon/scripts/sshd.conf ${local_etc_pmond}/sshd.conf
sudo install -m 644 -p -D pmon/scripts/syslog-ng.conf ${local_etc_pmond}/syslog-ng.conf sudo install -m 644 -p -D pmon/scripts/syslog-ng.conf ${local_etc_pmond}/syslog-ng.conf
sudo install -m 644 -p -D pmon/scripts/nslcd.conf ${local_etc_pmond}/nslcd.conf sudo install -m 644 -p -D pmon/scripts/nslcd.conf ${local_etc_pmond}/nslcd.conf
sudo install -m 644 -p -D rmon/scripts/rmon.conf ${local_etc_pmond}/rmon.conf
sudo install -m 644 -p -D fsmon/scripts/fsmon.conf ${local_etc_pmond}/fsmon.conf sudo install -m 644 -p -D fsmon/scripts/fsmon.conf ${local_etc_pmond}/fsmon.conf
sudo install -m 644 -p -D scripts/mtclogd.conf ${local_etc_pmond}/mtclogd.conf sudo install -m 644 -p -D scripts/mtclogd.conf ${local_etc_pmond}/mtclogd.conf
sudo install -m 644 -p -D alarm/scripts/mtcalarm.pmon.conf ${local_etc_pmond}/mtcalarm.conf sudo install -m 644 -p -D alarm/scripts/mtcalarm.pmon.conf ${local_etc_pmond}/mtcalarm.conf
# resource monitor config files
sudo install -m 755 -d ${local_etc_rmond}
sudo install -m 755 -d ${sysconf_dir}/rmonapi.d
sudo install -m 755 -d ${sysconf_dir}/rmonfiles.d
sudo install -m 755 -d ${sysconf_dir}/rmon_interfaces.d
sudo install -m 644 -p -D rmon/scripts/remotelogging_resource.conf ${local_etc_rmond}/remotelogging_resource.conf
sudo install -m 644 -p -D rmon/scripts/cinder_virtual_resource.conf ${local_etc_rmond}/cinder_virtual_resource.conf
sudo install -m 644 -p -D rmon/scripts/nova_virtual_resource.conf ${local_etc_rmond}/nova_virtual_resource.conf
sudo install -m 644 -p -D rmon/scripts/oam_resource.conf ${sysconf_dir}/rmon_interfaces.d/oam_resource.conf
sudo install -m 644 -p -D rmon/scripts/management_resource.conf ${sysconf_dir}/rmon_interfaces.d/management_resource.conf
sudo install -m 644 -p -D rmon/scripts/infrastructure_resource.conf ${sysconf_dir}/rmon_interfaces.d/infrastructure_resource.conf
# sudo install -m 755 -p -D rmon/scripts/query_ntp_servers.sh ${sysconf_dir}/rmonfiles.d/query_ntp_servers.sh
sudo install -m 755 -p -D rmon/scripts/rmon_reload_on_cpe.sh ${local_etc_goenabledd}/rmon_reload_on_cpe.sh
# log rotation # log rotation
sudo install -m 755 -d ${local_etc_logrotated} sudo install -m 755 -d ${local_etc_logrotated}
sudo install -m 644 -p -D scripts/mtce.logrotate ${local_etc_logrotated}/mtce.logrotate sudo install -m 644 -p -D scripts/mtce.logrotate ${local_etc_logrotated}/mtce.logrotate
sudo install -m 644 -p -D hostw/scripts/hostw.logrotate ${local_etc_logrotated}/hostw.logrotate sudo install -m 644 -p -D hostw/scripts/hostw.logrotate ${local_etc_logrotated}/hostw.logrotate
sudo install -m 644 -p -D pmon/scripts/pmon.logrotate ${local_etc_logrotated}/pmon.logrotate sudo install -m 644 -p -D pmon/scripts/pmon.logrotate ${local_etc_logrotated}/pmon.logrotate
sudo install -m 644 -p -D rmon/scripts/rmon.logrotate ${local_etc_logrotated}/rmon.logrotate
sudo install -m 644 -p -D fsmon/scripts/fsmon.logrotate ${local_etc_logrotated}/fsmon.logrotate sudo install -m 644 -p -D fsmon/scripts/fsmon.logrotate ${local_etc_logrotated}/fsmon.logrotate
sudo install -m 644 -p -D hwmon/scripts/hwmon.logrotate ${local_etc_logrotated}/hwmon.logrotate sudo install -m 644 -p -D hwmon/scripts/hwmon.logrotate ${local_etc_logrotated}/hwmon.logrotate
sudo install -m 644 -p -D alarm/scripts/mtcalarm.logrotate ${local_etc_logrotated}/mtcalarm.logrotate sudo install -m 644 -p -D alarm/scripts/mtcalarm.logrotate ${local_etc_logrotated}/mtcalarm.logrotate
@ -420,15 +398,11 @@ function install_mtce {
# software development files # software development files
$STX_SUDO install -m 644 -p -D heartbeat/mtceHbsCluster.h ${inc_dir}/mtceHbsCluster.h $STX_SUDO install -m 644 -p -D heartbeat/mtceHbsCluster.h ${inc_dir}/mtceHbsCluster.h
$STX_SUDO install -m 755 -p -D public/libamon.so.${major} ${lib64_dir}/libamon.so.${major} $STX_SUDO install -m 755 -p -D public/libamon.so.${major} ${lib64_dir}/libamon.so.${major}
$STX_SUDO install -m 755 -p -D rmon/rmonApi/librmonapi.so.${major} ${lib64_dir}/librmonapi.so.${major}
popd popd
pushd ${lib64_dir} pushd ${lib64_dir}
$STX_SUDO ln -sf libamon.so.${major} libamon.so.${major}.${minor} $STX_SUDO ln -sf libamon.so.${major} libamon.so.${major}.${minor}
$STX_SUDO ln -sf libamon.so.${major} libamon.so $STX_SUDO ln -sf libamon.so.${major} libamon.so
$STX_SUDO ln -sf librmonapi.so.${major} librmonapi.so.${major}.${minor}
$STX_SUDO ln -sf librmonapi.so.${major} librmonapi.so
popd popd
} }
@ -572,9 +546,6 @@ function start_maintenance {
if is_service_enabled mtce; then if is_service_enabled mtce; then
start_mtcClient start_mtcClient
fi fi
if is_service_enabled rmon; then
start_rmon
fi
if is_service_enabled mtclog; then if is_service_enabled mtclog; then
start_mtclog start_mtclog
fi fi
@ -604,10 +575,6 @@ function start_pmon {
run_process pmon "${SYSCONFDIR}/rc.d/init.d/pmon start" root root run_process pmon "${SYSCONFDIR}/rc.d/init.d/pmon start" root root
} }
function start_rmon {
run_process rmon "${SYSCONFDIR}/rc.d/init.d/rmon start" root root
}
function start_mtclog { function start_mtclog {
run_process mtclog "${SYSCONFDIR}/rc.d/init.d/mtclog start" root root run_process mtclog "${SYSCONFDIR}/rc.d/init.d/mtclog start" root root
} }
@ -678,10 +645,6 @@ function stop_hbsClient {
stop_process hbsClient stop_process hbsClient
} }
function stop_rmon {
stop_process rmon
}
function stop_mtclog { function stop_mtclog {
stop_process mtclog stop_process mtclog
} }
@ -710,9 +673,6 @@ function stop_maintenance {
if is_service_enabled hbs; then if is_service_enabled hbs; then
stop_hbsClient stop_hbsClient
fi fi
if is_service_enabled rmon; then
stop_rmon
fi
if is_service_enabled mtclog; then if is_service_enabled mtclog; then
stop_mtclog stop_mtclog
fi fi
@ -756,7 +716,6 @@ function cleanup_metal {
local unit_dir=${SYSCONFDIR}/systemd/system local unit_dir=${SYSCONFDIR}/systemd/system
local local_etc_pmond=${sysconf_dir}/pmon.d local local_etc_pmond=${sysconf_dir}/pmon.d
local local_etc_rmond=${sysconf_dir}/rmon.d
local local_etc_goenabledd=${sysconf_dir}/goenabled.d local local_etc_goenabledd=${sysconf_dir}/goenabled.d
local local_etc_servicesd=${sysconf_dir}/services.d local local_etc_servicesd=${sysconf_dir}/services.d
local local_etc_logrotated=${sysconf_dir}/logrotate.d local local_etc_logrotated=${sysconf_dir}/logrotate.d
@ -769,7 +728,6 @@ function cleanup_metal {
sudo rm -rf ${sysconf_dir}/mtc/fsmond.conf sudo rm -rf ${sysconf_dir}/mtc/fsmond.conf
sudo rm -rf ${sysconf_dir}/mtc/hwmond.conf sudo rm -rf ${sysconf_dir}/mtc/hwmond.conf
sudo rm -rf ${sysconf_dir}/mtc/pmond.conf sudo rm -rf ${sysconf_dir}/mtc/pmond.conf
sudo rm -rf ${sysconf_dir}/mtc/rmond.conf
sudo rm -rf ${sysconf_dir}/mtc/hostwd.conf sudo rm -rf ${sysconf_dir}/mtc/hostwd.conf
sudo rm -rf ${sysconf_dir}/bmc/server_profiles.d/sensor_hp360_v1_ilo_v4.profile sudo rm -rf ${sysconf_dir}/bmc/server_profiles.d/sensor_hp360_v1_ilo_v4.profile
@ -783,12 +741,10 @@ function cleanup_metal {
sudo rm -rf ${bin_dir}/hbsClient sudo rm -rf ${bin_dir}/hbsClient
sudo rm -rf ${bin_dir}/pmond sudo rm -rf ${bin_dir}/pmond
sudo rm -rf ${bin_dir}/hostwd sudo rm -rf ${bin_dir}/hostwd
sudo rm -rf ${bin_dir}/rmond
sudo rm -rf ${bin_dir}/fsmond sudo rm -rf ${bin_dir}/fsmond
sudo rm -rf ${bin_dir}/hwmond sudo rm -rf ${bin_dir}/hwmond
sudo rm -rf ${bin_dir}/mtclogd sudo rm -rf ${bin_dir}/mtclogd
sudo rm -rf ${bin_dir}/mtcalarmd sudo rm -rf ${bin_dir}/mtcalarmd
sudo rm -rf ${bin_dir}/rmon_resource_notify
sudo rm -rf ${bin_dir}/wipedisk sudo rm -rf ${bin_dir}/wipedisk
rm -rf ${STX_INST_DIR}/sbin/fsync rm -rf ${STX_INST_DIR}/sbin/fsync
sudo rm -rf ${sbin_dir}/pmon-restart sudo rm -rf ${sbin_dir}/pmon-restart
@ -802,7 +758,6 @@ function cleanup_metal {
sudo rm -rf ${sysconf_dir}/init.d/fsmon sudo rm -rf ${sysconf_dir}/init.d/fsmon
sudo rm -rf ${sysconf_dir}/init.d/mtclog sudo rm -rf ${sysconf_dir}/init.d/mtclog
sudo rm -rf ${sysconf_dir}/init.d/pmon sudo rm -rf ${sysconf_dir}/init.d/pmon
sudo rm -rf ${sysconf_dir}/init.d/rmon
sudo rm -rf ${sysconf_dir}/init.d/hostw sudo rm -rf ${sysconf_dir}/init.d/hostw
sudo rm -rf ${sysconf_dir}/init.d/mtcalarm sudo rm -rf ${sysconf_dir}/init.d/mtcalarm
@ -813,7 +768,6 @@ function cleanup_metal {
# systemd service files # systemd service files
sudo rm -rf ${unit_dir}/devstack@fsmon.service sudo rm -rf ${unit_dir}/devstack@fsmon.service
sudo rm -rf ${unit_dir}/devstack@hwmon.service sudo rm -rf ${unit_dir}/devstack@hwmon.service
sudo rm -rf ${unit_dir}/devstack@rmon.service
sudo rm -rf ${unit_dir}/devstack@pmon.service sudo rm -rf ${unit_dir}/devstack@pmon.service
sudo rm -rf ${unit_dir}/devstack@hostw.service sudo rm -rf ${unit_dir}/devstack@hostw.service
sudo rm -rf ${unit_dir}/devstack@mtcClient.service sudo rm -rf ${unit_dir}/devstack@mtcClient.service
@ -842,26 +796,14 @@ function cleanup_metal {
sudo rm -rf ${local_etc_pmond}/sshd.conf sudo rm -rf ${local_etc_pmond}/sshd.conf
sudo rm -rf ${local_etc_pmond}/syslog-ng.conf sudo rm -rf ${local_etc_pmond}/syslog-ng.conf
sudo rm -rf ${local_etc_pmond}/nslcd.conf sudo rm -rf ${local_etc_pmond}/nslcd.conf
sudo rm -rf ${local_etc_pmond}/rmon.conf
sudo rm -rf ${local_etc_pmond}/fsmon.conf sudo rm -rf ${local_etc_pmond}/fsmon.conf
sudo rm -rf ${local_etc_pmond}/mtclogd.conf sudo rm -rf ${local_etc_pmond}/mtclogd.conf
sudo rm -rf ${local_etc_pmond}/mtcalarm.conf sudo rm -rf ${local_etc_pmond}/mtcalarm.conf
# resource monitor config files
sudo rm -rf ${local_etc_rmond}/remotelogging_resource.conf
sudo rm -rf ${local_etc_rmond}/cinder_virtual_resource.conf
sudo rm -rf ${local_etc_rmond}/nova_virtual_resource.conf
sudo rm -rf ${sysconf_dir}/rmon_interfaces.d/oam_resource.conf
sudo rm -rf ${sysconf_dir}/rmon_interfaces.d/management_resource.conf
sudo rm -rf ${sysconf_dir}/rmon_interfaces.d/infrastructure_resource.conf
sudo rm -rf ${sysconf_dir}/rmonfiles.d/query_ntp_servers.sh
sudo rm -rf ${local_etc_goenabledd}/rmon_reload_on_cpe.sh
# log rotation # log rotation
sudo rm -rf ${local_etc_logrotated}/mtce.logrotate sudo rm -rf ${local_etc_logrotated}/mtce.logrotate
sudo rm -rf ${local_etc_logrotated}/hostw.logrotate sudo rm -rf ${local_etc_logrotated}/hostw.logrotate
sudo rm -rf ${local_etc_logrotated}/pmon.logrotate sudo rm -rf ${local_etc_logrotated}/pmon.logrotate
sudo rm -rf ${local_etc_logrotated}/rmon.logrotate
sudo rm -rf ${local_etc_logrotated}/fsmon.logrotate sudo rm -rf ${local_etc_logrotated}/fsmon.logrotate
sudo rm -rf ${local_etc_logrotated}/hwmon.logrotate sudo rm -rf ${local_etc_logrotated}/hwmon.logrotate
sudo rm -rf ${local_etc_logrotated}/mtcalarm.logrotate sudo rm -rf ${local_etc_logrotated}/mtcalarm.logrotate
@ -869,14 +811,10 @@ function cleanup_metal {
# software development files # software development files
$STX_SUDO rm -rf ${inc_dir}/mtceHbsCluster.h $STX_SUDO rm -rf ${inc_dir}/mtceHbsCluster.h
$STX_SUDO rm -rf ${lib64_dir}/libamon.so.${major} $STX_SUDO rm -rf ${lib64_dir}/libamon.so.${major}
$STX_SUDO rm -rf ${lib64_dir}/librmonapi.so.${major}
$STX_SUDO rm -rf ${lib64_dir}/libamon.so.${major}.${minor} $STX_SUDO rm -rf ${lib64_dir}/libamon.so.${major}.${minor}
$STX_SUDO rm -rf ${lib64_dir}/libamon.so $STX_SUDO rm -rf ${lib64_dir}/libamon.so
$STX_SUDO rm -rf ${lib64_dir}/librmonapi.so.${major}.${minor}
$STX_SUDO rm -rf ${lib64_dir}/librmonapi.so
#remove mtce_common #remove mtce_common
local inc_dir_common=${STX_INST_DIR}/include/mtce-common local inc_dir_common=${STX_INST_DIR}/include/mtce-common
local inc_dir_daemon=${STX_INST_DIR}/include/mtce-daemon local inc_dir_daemon=${STX_INST_DIR}/include/mtce-daemon

View File

@ -27,7 +27,6 @@
# mtcalarm # mtcalarm
# mtclog # mtclog
# pmon # pmon
# rmon
STX_METAL_NAME=stx-metal STX_METAL_NAME=stx-metal
@ -41,7 +40,7 @@ define_plugin stx-metal
plugin_requires stx-metal stx-fault plugin_requires stx-metal stx-fault
if is_service_enabled mtce-components; then if is_service_enabled mtce-components; then
enable_service fsmon hbs hwmon mtce mtcalarm mtclog pmon rmon enable_service fsmon hbs hwmon mtce mtcalarm mtclog pmon
fi fi
# Be careful to enable hostw, it will restart your host # Be careful to enable hostw, it will restart your host

View File

@ -47,7 +47,6 @@
#define MTC_CMD_FIT__MGMNT_TXSOCK ("/var/run/fit/mgmnt_txsock") /* mtcClient */ #define MTC_CMD_FIT__MGMNT_TXSOCK ("/var/run/fit/mgmnt_txsock") /* mtcClient */
#define MTC_CMD_FIT__INFRA_RXSOCK ("/var/run/fit/infra_rxsock") /* mtcClient */ #define MTC_CMD_FIT__INFRA_RXSOCK ("/var/run/fit/infra_rxsock") /* mtcClient */
#define MTC_CMD_FIT__INFRA_TXSOCK ("/var/run/fit/infra_txsock") /* mtcClient */ #define MTC_CMD_FIT__INFRA_TXSOCK ("/var/run/fit/infra_txsock") /* mtcClient */
#define MTC_CMD_FIT__RMON_SOCK ("/var/run/fit/rmon_sock") /* mtcClient */
#define MTC_CMD_FIT__AMON_SOCK ("/var/run/fit/amon_sock") /* mtcClient */ #define MTC_CMD_FIT__AMON_SOCK ("/var/run/fit/amon_sock") /* mtcClient */
#define MTC_CMD_FIT__NO_INFRA_RSP ("/var/run/fit/no_infra_rsp") /* hbsClient */ #define MTC_CMD_FIT__NO_INFRA_RSP ("/var/run/fit/no_infra_rsp") /* hbsClient */
#define MTC_CMD_FIT__NO_MGMNT_RSP ("/var/run/fit/no_mgmnt_rsp") /* hbsClient */ #define MTC_CMD_FIT__NO_MGMNT_RSP ("/var/run/fit/no_mgmnt_rsp") /* hbsClient */

View File

@ -109,10 +109,6 @@ typedef struct
int pmon_event_port ; /**< process monitor tx event port */ int pmon_event_port ; /**< process monitor tx event port */
int pmon_pulse_port ; /**< process Monitor I'm Alive pulse port */ int pmon_pulse_port ; /**< process Monitor I'm Alive pulse port */
int pmon_cmd_port ; /**< process Monitor command receive port */ int pmon_cmd_port ; /**< process Monitor command receive port */
int rmon_api_tx_port ; /**< resource monitor api tx port */
int rmon_event_port ; /**< resource monitor api event port */
int rmon_critical_thr ; /**< resmon critical threshold in use */
int rmon_tx_port ; /**< resource monitor tx event port */
int log_step ; /**< used to throttle logging at step rate */ int log_step ; /**< used to throttle logging at step rate */
int event_port ; /**< daemon specific event tx port */ int event_port ; /**< daemon specific event tx port */
int cmd_port ; /**< daemon specific command rx port */ int cmd_port ; /**< daemon specific command rx port */

View File

@ -201,14 +201,6 @@ const char * get_mtcNodeCommand_str ( int cmd )
case MTC_EVENT_PMON_LOG: return("pmon log"); case MTC_EVENT_PMON_LOG: return("pmon log");
case MTC_EVENT_PMOND_RAISE: return("pmon raise"); case MTC_EVENT_PMOND_RAISE: return("pmon raise");
/* rmon events */
case MTC_EVENT_RMON_READY: return("rmon ready event");
case MTC_EVENT_RMON_CLEAR: return("rmon clear");
case MTC_EVENT_RMON_CRIT: return("rmon critical event");
case MTC_EVENT_RMON_MAJOR: return("rmon major event");
case MTC_EVENT_RMON_MINOR: return("rmon minor event");
case MTC_EVENT_RMON_LOG: return("rmon log");
/* data port events */ /* data port events */
case MTC_EVENT_AVS_CLEAR: return("AVS clear"); case MTC_EVENT_AVS_CLEAR: return("AVS clear");
case MTC_EVENT_AVS_MAJOR: return("AVS major"); case MTC_EVENT_AVS_MAJOR: return("AVS major");
@ -246,7 +238,6 @@ const char * get_mtcNodeCommand_str ( int cmd )
/* service events */ /* service events */
case MTC_SERVICE_PMOND: return ("pmond service"); case MTC_SERVICE_PMOND: return ("pmond service");
case MTC_SERVICE_RMOND: return ("rmond service");
case MTC_SERVICE_HWMOND: return ("hwmond service"); case MTC_SERVICE_HWMOND: return ("hwmond service");
case MTC_SERVICE_HEARTBEAT: return ("heartbeat service"); case MTC_SERVICE_HEARTBEAT: return ("heartbeat service");
default: default:

View File

@ -396,12 +396,6 @@ void daemon_exit ( void );
#define MAX_MTCE_EVENT_NAME_LEN 64 #define MAX_MTCE_EVENT_NAME_LEN 64
#define MAX_RESOURCE_NAME_LEN 64 #define MAX_RESOURCE_NAME_LEN 64
/** RMON message codes **/
#define RMON_CRITICAL (3)
#define RMON_MAJOR (2)
#define RMON_MINOR (1)
#define RMON_CLEAR (0)
/** Interface Codes **/ /** Interface Codes **/
#define MGMNT_INTERFACE (0) #define MGMNT_INTERFACE (0)
#define INFRA_INTERFACE (1) #define INFRA_INTERFACE (1)
@ -545,7 +539,6 @@ typedef struct
#define MTC_CMD_NOTIFY_INST (0x11110025) /* Notify Inst */ #define MTC_CMD_NOTIFY_INST (0x11110025) /* Notify Inst */
#define MTC_SERVICE_PMOND (0xB00BF00D) #define MTC_SERVICE_PMOND (0xB00BF00D)
#define MTC_SERVICE_RMOND (0xFAABF00D)
#define MTC_SERVICE_HWMOND (0xF00BF00D) #define MTC_SERVICE_HWMOND (0xF00BF00D)
#define MTC_SERVICE_HEARTBEAT (0xBABEF00D) #define MTC_SERVICE_HEARTBEAT (0xBABEF00D)
@ -564,9 +557,6 @@ typedef struct
/* Generic Monitor Service ready event */ /* Generic Monitor Service ready event */
#define MTC_EVENT_MONITOR_READY (0xf0f0f0f0) #define MTC_EVENT_MONITOR_READY (0xf0f0f0f0)
/* TODO: Obsolete code */
#define MTC_EVENT_RMON_READY (0x0f0f0f0f)
/** Process Monitor Event codes */ /** Process Monitor Event codes */
#define MTC_EVENT_PMON_CLEAR (0x02020202) /**< Clear Action */ #define MTC_EVENT_PMON_CLEAR (0x02020202) /**< Clear Action */
#define MTC_EVENT_PMON_CRIT (0x04040404) /**< Crit Failed Action */ #define MTC_EVENT_PMON_CRIT (0x04040404) /**< Crit Failed Action */
@ -574,13 +564,6 @@ typedef struct
#define MTC_EVENT_PMON_MINOR (0x08080808) /**< Minor Log action */ #define MTC_EVENT_PMON_MINOR (0x08080808) /**< Minor Log action */
#define MTC_EVENT_PMON_LOG (0x03030303) /**< Minor Log action */ #define MTC_EVENT_PMON_LOG (0x03030303) /**< Minor Log action */
/** Process Monitor Event codes */
#define MTC_EVENT_RMON_CLEAR (0x10101010) /**< Clear Action */
#define MTC_EVENT_RMON_CRIT (0x20202020) /**< Crit Failed Action */
#define MTC_EVENT_RMON_MAJOR (0x30303030) /**< Major Degrade Action */
#define MTC_EVENT_RMON_MINOR (0x40404040) /**< Minor Log action */
#define MTC_EVENT_RMON_LOG (0x50505050) /**< Minor Log action */
/** Process Monitor Daemon Running - Event Raise / Clear Codes */ /** Process Monitor Daemon Running - Event Raise / Clear Codes */
#define MTC_EVENT_PMOND_CLEAR (0x06060606) #define MTC_EVENT_PMOND_CLEAR (0x06060606)
#define MTC_EVENT_PMOND_RAISE (0x07070707) #define MTC_EVENT_PMOND_RAISE (0x07070707)

View File

@ -1368,26 +1368,21 @@ string get_event_str ( int event_code )
{ {
switch ( event_code ) switch ( event_code )
{ {
case MTC_EVENT_RMON_READY:
case MTC_EVENT_MONITOR_READY: case MTC_EVENT_MONITOR_READY:
return "ready" ; return "ready" ;
case MTC_EVENT_PMOND_CLEAR: case MTC_EVENT_PMOND_CLEAR:
case MTC_EVENT_PMON_CLEAR: case MTC_EVENT_PMON_CLEAR:
case MTC_EVENT_RMON_CLEAR:
case MTC_EVENT_HWMON_CLEAR: case MTC_EVENT_HWMON_CLEAR:
return "clear" ; return "clear" ;
case MTC_EVENT_PMON_CRIT: case MTC_EVENT_PMON_CRIT:
case MTC_EVENT_RMON_CRIT:
case MTC_EVENT_HWMON_CRIT: case MTC_EVENT_HWMON_CRIT:
return "critical" ; return "critical" ;
case MTC_EVENT_PMON_LOG: case MTC_EVENT_PMON_LOG:
return "log" ; return "log" ;
case MTC_EVENT_PMON_MAJOR: case MTC_EVENT_PMON_MAJOR:
case MTC_EVENT_RMON_MAJOR:
case MTC_EVENT_HWMON_MAJOR: case MTC_EVENT_HWMON_MAJOR:
return "major" ; return "major" ;
case MTC_EVENT_PMON_MINOR: case MTC_EVENT_PMON_MINOR:
case MTC_EVENT_RMON_MINOR:
case MTC_EVENT_HWMON_MINOR: case MTC_EVENT_HWMON_MINOR:
return "minor" ; return "minor" ;
case MTC_EVENT_HWMON_CONFIG: case MTC_EVENT_HWMON_CONFIG:

View File

@ -232,7 +232,6 @@ int daemon_run_testhead ( void );
#define CONFIG_CLIENT_PULSE_PORT 0x10000000 /**< Pmon pulse port */ #define CONFIG_CLIENT_PULSE_PORT 0x10000000 /**< Pmon pulse port */
#define CONFIG_AGENT_SECRET_PORT 0x20000000 /**< Barbican HTTP port */ #define CONFIG_AGENT_SECRET_PORT 0x20000000 /**< Barbican HTTP port */
#define CONFIG_AGENT_VIM_EVENT_PORT 0x40000000 /**< VIM Event Port Mask */ #define CONFIG_AGENT_VIM_EVENT_PORT 0x40000000 /**< VIM Event Port Mask */
#define CONFIG_CLIENT_RMON_PORT 0x80000000 /**< Rmon client port */
#define CONFIG_AGENT_PORT CONFIG_AGENT_MTC_MGMNT_PORT #define CONFIG_AGENT_PORT CONFIG_AGENT_MTC_MGMNT_PORT
#define CONFIG_CLIENT_PORT CONFIG_CLIENT_MTC_MGMNT_PORT #define CONFIG_CLIENT_PORT CONFIG_CLIENT_MTC_MGMNT_PORT

View File

@ -342,7 +342,6 @@ void daemon_dump_cfg ( void )
if ( ptr->hbs_to_mtc_event_port) { ilog ("hbs_to_mtc_event_port = %d\n", ptr->hbs_to_mtc_event_port);} if ( ptr->hbs_to_mtc_event_port) { ilog ("hbs_to_mtc_event_port = %d\n", ptr->hbs_to_mtc_event_port);}
if ( ptr->inv_event_port ) { ilog ("inv_event_port = %d\n", ptr->inv_event_port );} if ( ptr->inv_event_port ) { ilog ("inv_event_port = %d\n", ptr->inv_event_port );}
/* rmond */
if ( ptr->per_node ) { ilog ("per_node = %d\n", ptr->per_node );} if ( ptr->per_node ) { ilog ("per_node = %d\n", ptr->per_node );}
if ( ptr->audit_period ) { ilog ("audit_period = %d\n", ptr->audit_period );} if ( ptr->audit_period ) { ilog ("audit_period = %d\n", ptr->audit_period );}
if ( ptr->pm_period ) { ilog ("pm_period = %d\n", ptr->pm_period );} if ( ptr->pm_period ) { ilog ("pm_period = %d\n", ptr->pm_period );}
@ -350,10 +349,6 @@ void daemon_dump_cfg ( void )
if ( ptr->pmon_amon_port ) { ilog ("pmon_amon_port = %d\n", ptr->pmon_amon_port );} if ( ptr->pmon_amon_port ) { ilog ("pmon_amon_port = %d\n", ptr->pmon_amon_port );}
if ( ptr->pmon_event_port ) { ilog ("pmon_event_port = %d\n", ptr->pmon_event_port );} if ( ptr->pmon_event_port ) { ilog ("pmon_event_port = %d\n", ptr->pmon_event_port );}
if ( ptr->pmon_pulse_port ) { ilog ("pmon_pulse_port = %d\n", ptr->pmon_pulse_port );} if ( ptr->pmon_pulse_port ) { ilog ("pmon_pulse_port = %d\n", ptr->pmon_pulse_port );}
if ( ptr->rmon_api_tx_port ) { ilog ("rmon_api_tx_port = %d\n", ptr->rmon_api_tx_port );}
if ( ptr->rmon_event_port ) { ilog ("rmon_event_port = %d\n", ptr->rmon_event_port );}
if ( ptr->rmon_critical_thr ) { ilog ("rmon_critical_thr = %d\n", ptr->rmon_critical_thr );}
if ( ptr->rmon_tx_port ) { ilog ("rmon_tx_port = %d\n", ptr->rmon_tx_port );}
if ( ptr->event_port ) { ilog ("event_port = %d\n", ptr->event_port );} if ( ptr->event_port ) { ilog ("event_port = %d\n", ptr->event_port );}
if ( ptr->cmd_port ) { ilog ("cmd_port = %d\n", ptr->cmd_port );} if ( ptr->cmd_port ) { ilog ("cmd_port = %d\n", ptr->cmd_port );}
if ( ptr->sensor_port ) { ilog ("sensor_port = %d\n", ptr->sensor_port );} if ( ptr->sensor_port ) { ilog ("sensor_port = %d\n", ptr->sensor_port );}

View File

@ -32,7 +32,6 @@ Requires: /bin/bash
Requires: /bin/systemctl Requires: /bin/systemctl
Requires: dpkg Requires: dpkg
Requires: time Requires: time
Requires: mtce-rmon >= 1.0
Requires: libevent-2.0.so.5()(64bit) Requires: libevent-2.0.so.5()(64bit)
Requires: expect Requires: expect
Requires: libfmcommon.so.1()(64bit) Requires: libfmcommon.so.1()(64bit)
@ -49,7 +48,6 @@ Requires: libc.so.6(GLIBC_2.3)(64bit)
Requires: libc.so.6(GLIBC_2.14)(64bit) Requires: libc.so.6(GLIBC_2.14)(64bit)
Requires: libjson-c.so.2()(64bit) Requires: libjson-c.so.2()(64bit)
Requires: libpthread.so.0(GLIBC_2.2.5)(64bit) Requires: libpthread.so.0(GLIBC_2.2.5)(64bit)
Requires: librmonapi.so.1()(64bit)
Requires: librt.so.1(GLIBC_2.3.3)(64bit) Requires: librt.so.1(GLIBC_2.3.3)(64bit)
Requires: libgcc_s.so.1(GCC_3.0)(64bit) Requires: libgcc_s.so.1(GCC_3.0)(64bit)
Requires: libstdc++.so.6(CXXABI_1.3)(64bit) Requires: libstdc++.so.6(CXXABI_1.3)(64bit)
@ -80,9 +78,7 @@ Monitor service (pmond) add both passive and active process monitoring and
automatic recovery of stopped or killed processes. The File System Monitor automatic recovery of stopped or killed processes. The File System Monitor
Service (fsmond) adds detection and reporting of local file system Service (fsmond) adds detection and reporting of local file system
problems. The Hardware Monitor Service (hwmond) adds present and predictive problems. The Hardware Monitor Service (hwmond) adds present and predictive
hardware failure detection, reporting and recovery. The Resource Monitor hardware failure detection, reporting and recovery.
Service (rmond) adds resource monitoring with present and predictive
failure and overload detection and reporting.
The Host Watchdog (hostwd) daemon watches for errors in The Host Watchdog (hostwd) daemon watches for errors in
pmond and logs system information on error. All of these maintenance pmond and logs system information on error. All of these maintenance
services improve MTTD of node failures as well as resource overload and out services improve MTTD of node failures as well as resource overload and out
@ -138,48 +134,6 @@ Titanium Cloud Maintenance Process Monitor service (pmond) with
passive (pid), active (msg) and status (qry) process monitoring with passive (pid), active (msg) and status (qry) process monitoring with
automatic recovery and failure reporting of registered failed processes. automatic recovery and failure reporting of registered failed processes.
%package -n mtce-rmon
Summary: Titanuim Server Maintenance Resource Monitor Package
Group: base
Requires: /bin/bash
Requires: util-linux
Requires: /bin/systemctl
Requires: dpkg
Requires: time
Requires: libjson-c.so.2()(64bit)
Requires: libstdc++.so.6(CXXABI_1.3)(64bit)
Requires: libevent-2.0.so.5()(64bit)
Requires: libfmcommon.so.1()(64bit)
Requires: librmonapi.so.1()(64bit)
Requires: fm-common >= 1.0
Requires: libc.so.6(GLIBC_2.2.5)(64bit)
Requires: libstdc++.so.6(GLIBCXX_3.4.11)(64bit)
Requires: /bin/sh
Requires: librt.so.1()(64bit)
Requires: libc.so.6(GLIBC_2.3)(64bit)
Requires: libc.so.6(GLIBC_2.14)(64bit)
Requires: libpthread.so.0(GLIBC_2.2.5)(64bit)
Requires: librt.so.1(GLIBC_2.3.3)(64bit)
Requires: libgcc_s.so.1(GCC_3.0)(64bit)
Requires: libevent >= 2.0.21
Requires: librt.so.1(GLIBC_2.2.5)(64bit)
Requires: libuuid.so.1()(64bit)
Requires: libm.so.6()(64bit)
Requires: rtld(GNU_HASH)
Requires: libstdc++.so.6()(64bit)
Requires: libc.so.6()(64bit)
Requires: libgcc_s.so.1()(64bit)
Requires: libstdc++.so.6(GLIBCXX_3.4)(64bit)
Requires: libstdc++.so.6(GLIBCXX_3.4.15)(64bit)
Requires: libpthread.so.0()(64bit)
Provides: librmonapi.so.1()(64bit)
%description -n mtce-rmon
Titanium Cloud Host Maintenance Resource Monitor Service (rmond) adds
threshold based monitoring with predictive severity level alarming for
out of tolerance utilization of critical resourses such as memory, cpu
file system, etc.
%package -n mtce-hwmon %package -n mtce-hwmon
Summary: Titanuim Server Maintenance Hardware Monitor Package Summary: Titanuim Server Maintenance Hardware Monitor Package
Group: base Group: base
@ -255,9 +209,7 @@ Monitor service (pmond) add both passive and active process monitoring and
automatic recovery of stopped or killed processes. The File System Monitor automatic recovery of stopped or killed processes. The File System Monitor
Service (fsmond) adds detection and reporting of local file system Service (fsmond) adds detection and reporting of local file system
problems. The Hardware Monitor Service (hwmond) adds present and predictive problems. The Hardware Monitor Service (hwmond) adds present and predictive
hardware failure detection, reporting and recovery. The Resource Monitor hardware failure detection, reporting and recovery. The Guest Services
Service (rmond) adds resource monitoring with present and predictive
failure and overload detection and reporting. The Guest Services
(guestAgent/guestServer) daemons control access into and heartbeat of guest (guestAgent/guestServer) daemons control access into and heartbeat of guest
VMs on the worker. The Host Watchdog (hostwd) daemon watches for errors in VMs on the worker. The Host Watchdog (hostwd) daemon watches for errors in
pmond and logs system information on error. All of these maintenance pmond and logs system information on error. All of these maintenance
@ -303,7 +255,6 @@ netlink monitoring for provisioned oam, mgmt and infra interfaces.
%define local_bindir %{local_dir}/bin %define local_bindir %{local_dir}/bin
%define local_sbindir %{local_dir}/sbin %define local_sbindir %{local_dir}/sbin
%define local_etc_pmond %{_sysconfdir}/pmon.d %define local_etc_pmond %{_sysconfdir}/pmon.d
%define local_etc_rmond %{_sysconfdir}/rmon.d
%define local_etc_goenabledd %{_sysconfdir}/goenabled.d %define local_etc_goenabledd %{_sysconfdir}/goenabled.d
%define local_etc_servicesd %{_sysconfdir}/services.d %define local_etc_servicesd %{_sysconfdir}/services.d
%define local_etc_logrotated %{_sysconfdir}/logrotate.d %define local_etc_logrotated %{_sysconfdir}/logrotate.d
@ -355,7 +306,6 @@ install -m 644 -p -D %{_buildsubdir}/fsmon/scripts/fsmond.conf %{buildroot}%{_sy
install -m 644 -p -D %{_buildsubdir}/hwmon/scripts/hwmond.conf %{buildroot}%{_sysconfdir}/mtc/hwmond.conf install -m 644 -p -D %{_buildsubdir}/hwmon/scripts/hwmond.conf %{buildroot}%{_sysconfdir}/mtc/hwmond.conf
install -m 644 -p -D %{_buildsubdir}/pmon/scripts/pmond.conf %{buildroot}%{_sysconfdir}/mtc/pmond.conf install -m 644 -p -D %{_buildsubdir}/pmon/scripts/pmond.conf %{buildroot}%{_sysconfdir}/mtc/pmond.conf
install -m 644 -p -D %{_buildsubdir}/lmon/scripts/lmond.conf %{buildroot}%{_sysconfdir}/mtc/lmond.conf install -m 644 -p -D %{_buildsubdir}/lmon/scripts/lmond.conf %{buildroot}%{_sysconfdir}/mtc/lmond.conf
install -m 644 -p -D %{_buildsubdir}/rmon/scripts/rmond.conf %{buildroot}%{_sysconfdir}/mtc/rmond.conf
install -m 644 -p -D %{_buildsubdir}/hostw/scripts/hostwd.conf %{buildroot}%{_sysconfdir}/mtc/hostwd.conf install -m 644 -p -D %{_buildsubdir}/hostw/scripts/hostwd.conf %{buildroot}%{_sysconfdir}/mtc/hostwd.conf
install -m 755 -d %{buildroot}/%{_sysconfdir}/etc/bmc/server_profiles.d install -m 755 -d %{buildroot}/%{_sysconfdir}/etc/bmc/server_profiles.d
@ -371,12 +321,10 @@ install -m 755 -p -D %{_buildsubdir}/heartbeat/hbsClient %{buildroot}/%{local_bi
install -m 755 -p -D %{_buildsubdir}/pmon/pmond %{buildroot}/%{local_bindir}/pmond install -m 755 -p -D %{_buildsubdir}/pmon/pmond %{buildroot}/%{local_bindir}/pmond
install -m 755 -p -D %{_buildsubdir}/lmon/lmond %{buildroot}/%{local_bindir}/lmond install -m 755 -p -D %{_buildsubdir}/lmon/lmond %{buildroot}/%{local_bindir}/lmond
install -m 755 -p -D %{_buildsubdir}/hostw/hostwd %{buildroot}/%{local_bindir}/hostwd install -m 755 -p -D %{_buildsubdir}/hostw/hostwd %{buildroot}/%{local_bindir}/hostwd
install -m 755 -p -D %{_buildsubdir}/rmon/rmond %{buildroot}/%{local_bindir}/rmond
install -m 755 -p -D %{_buildsubdir}/fsmon/fsmond %{buildroot}/%{local_bindir}/fsmond install -m 755 -p -D %{_buildsubdir}/fsmon/fsmond %{buildroot}/%{local_bindir}/fsmond
install -m 755 -p -D %{_buildsubdir}/hwmon/hwmond %{buildroot}/%{local_bindir}/hwmond install -m 755 -p -D %{_buildsubdir}/hwmon/hwmond %{buildroot}/%{local_bindir}/hwmond
install -m 755 -p -D %{_buildsubdir}/mtclog/mtclogd %{buildroot}/%{local_bindir}/mtclogd install -m 755 -p -D %{_buildsubdir}/mtclog/mtclogd %{buildroot}/%{local_bindir}/mtclogd
install -m 755 -p -D %{_buildsubdir}/alarm/mtcalarmd %{buildroot}/%{local_bindir}/mtcalarmd install -m 755 -p -D %{_buildsubdir}/alarm/mtcalarmd %{buildroot}/%{local_bindir}/mtcalarmd
install -m 755 -p -D %{_buildsubdir}/rmon/rmon_resource_notify/rmon_resource_notify %{buildroot}/%{local_bindir}/rmon_resource_notify
install -m 755 -p -D %{_buildsubdir}/scripts/wipedisk %{buildroot}/%{local_bindir}/wipedisk install -m 755 -p -D %{_buildsubdir}/scripts/wipedisk %{buildroot}/%{local_bindir}/wipedisk
install -m 755 -p -D %{_buildsubdir}/fsync/fsync %{buildroot}/%{_sbindir}/fsync install -m 755 -p -D %{_buildsubdir}/fsync/fsync %{buildroot}/%{_sbindir}/fsync
install -m 700 -p -D %{_buildsubdir}/pmon/scripts/pmon-restart %{buildroot}/%{local_sbindir}/pmon-restart install -m 700 -p -D %{_buildsubdir}/pmon/scripts/pmon-restart %{buildroot}/%{local_sbindir}/pmon-restart
@ -391,7 +339,6 @@ install -m 755 -p -D %{_buildsubdir}/fsmon/scripts/fsmon %{buildroot}%{_sysconfd
install -m 755 -p -D %{_buildsubdir}/scripts/mtclog %{buildroot}%{_sysconfdir}/init.d/mtclog install -m 755 -p -D %{_buildsubdir}/scripts/mtclog %{buildroot}%{_sysconfdir}/init.d/mtclog
install -m 755 -p -D %{_buildsubdir}/pmon/scripts/pmon %{buildroot}%{_sysconfdir}/init.d/pmon install -m 755 -p -D %{_buildsubdir}/pmon/scripts/pmon %{buildroot}%{_sysconfdir}/init.d/pmon
install -m 755 -p -D %{_buildsubdir}/lmon/scripts/lmon %{buildroot}%{_sysconfdir}/init.d/lmon install -m 755 -p -D %{_buildsubdir}/lmon/scripts/lmon %{buildroot}%{_sysconfdir}/init.d/lmon
install -m 755 -p -D %{_buildsubdir}/rmon/scripts/rmon %{buildroot}%{_sysconfdir}/init.d/rmon
install -m 755 -p -D %{_buildsubdir}/hostw/scripts/hostw %{buildroot}%{_sysconfdir}/init.d/hostw install -m 755 -p -D %{_buildsubdir}/hostw/scripts/hostw %{buildroot}%{_sysconfdir}/init.d/hostw
install -m 755 -p -D %{_buildsubdir}/alarm/scripts/mtcalarm.init %{buildroot}%{_sysconfdir}/init.d/mtcalarm install -m 755 -p -D %{_buildsubdir}/alarm/scripts/mtcalarm.init %{buildroot}%{_sysconfdir}/init.d/mtcalarm
@ -404,7 +351,6 @@ install -m 644 -p -D %{_buildsubdir}/scripts/hwclock.service %{buildroot}%{_unit
# systemd service files # systemd service files
install -m 644 -p -D %{_buildsubdir}/fsmon/scripts/fsmon.service %{buildroot}%{_unitdir}/fsmon.service install -m 644 -p -D %{_buildsubdir}/fsmon/scripts/fsmon.service %{buildroot}%{_unitdir}/fsmon.service
install -m 644 -p -D %{_buildsubdir}/hwmon/scripts/hwmon.service %{buildroot}%{_unitdir}/hwmon.service install -m 644 -p -D %{_buildsubdir}/hwmon/scripts/hwmon.service %{buildroot}%{_unitdir}/hwmon.service
install -m 644 -p -D %{_buildsubdir}/rmon/scripts/rmon.service %{buildroot}%{_unitdir}/rmon.service
install -m 644 -p -D %{_buildsubdir}/pmon/scripts/pmon.service %{buildroot}%{_unitdir}/pmon.service install -m 644 -p -D %{_buildsubdir}/pmon/scripts/pmon.service %{buildroot}%{_unitdir}/pmon.service
install -m 644 -p -D %{_buildsubdir}/hostw/scripts/hostw.service %{buildroot}%{_unitdir}/hostw.service install -m 644 -p -D %{_buildsubdir}/hostw/scripts/hostw.service %{buildroot}%{_unitdir}/hostw.service
install -m 644 -p -D %{_buildsubdir}/scripts/mtcClient.service %{buildroot}%{_unitdir}/mtcClient.service install -m 644 -p -D %{_buildsubdir}/scripts/mtcClient.service %{buildroot}%{_unitdir}/mtcClient.service
@ -440,28 +386,17 @@ install -m 644 -p -D %{_buildsubdir}/pmon/scripts/acpid.conf %{buildroot}%{local
install -m 644 -p -D %{_buildsubdir}/pmon/scripts/sshd.conf %{buildroot}%{local_etc_pmond}/sshd.conf install -m 644 -p -D %{_buildsubdir}/pmon/scripts/sshd.conf %{buildroot}%{local_etc_pmond}/sshd.conf
install -m 644 -p -D %{_buildsubdir}/pmon/scripts/syslog-ng.conf %{buildroot}%{local_etc_pmond}/syslog-ng.conf install -m 644 -p -D %{_buildsubdir}/pmon/scripts/syslog-ng.conf %{buildroot}%{local_etc_pmond}/syslog-ng.conf
install -m 644 -p -D %{_buildsubdir}/pmon/scripts/nslcd.conf %{buildroot}%{local_etc_pmond}/nslcd.conf install -m 644 -p -D %{_buildsubdir}/pmon/scripts/nslcd.conf %{buildroot}%{local_etc_pmond}/nslcd.conf
install -m 644 -p -D %{_buildsubdir}/rmon/scripts/rmon.conf %{buildroot}%{local_etc_pmond}/rmon.conf
install -m 644 -p -D %{_buildsubdir}/fsmon/scripts/fsmon.conf %{buildroot}%{local_etc_pmond}/fsmon.conf install -m 644 -p -D %{_buildsubdir}/fsmon/scripts/fsmon.conf %{buildroot}%{local_etc_pmond}/fsmon.conf
install -m 644 -p -D %{_buildsubdir}/scripts/mtclogd.conf %{buildroot}%{local_etc_pmond}/mtclogd.conf install -m 644 -p -D %{_buildsubdir}/scripts/mtclogd.conf %{buildroot}%{local_etc_pmond}/mtclogd.conf
install -m 644 -p -D %{_buildsubdir}/alarm/scripts/mtcalarm.pmon.conf %{buildroot}%{local_etc_pmond}/mtcalarm.conf install -m 644 -p -D %{_buildsubdir}/alarm/scripts/mtcalarm.pmon.conf %{buildroot}%{local_etc_pmond}/mtcalarm.conf
install -m 644 -p -D %{_buildsubdir}/lmon/scripts/lmon.pmon.conf %{buildroot}%{local_etc_pmond}/lmon.conf install -m 644 -p -D %{_buildsubdir}/lmon/scripts/lmon.pmon.conf %{buildroot}%{local_etc_pmond}/lmon.conf
# resource monitor config files
install -m 755 -d %{buildroot}%{local_etc_rmond}
install -m 755 -d %{buildroot}%{_sysconfdir}/rmonapi.d
install -m 755 -d %{buildroot}%{_sysconfdir}/rmonfiles.d
install -m 644 -p -D %{_buildsubdir}/rmon/scripts/remotelogging_resource.conf %{buildroot}%{local_etc_rmond}/remotelogging_resource.conf
install -m 644 -p -D %{_buildsubdir}/rmon/scripts/cinder_virtual_resource.conf %{buildroot}%{local_etc_rmond}/cinder_virtual_resource.conf
install -m 644 -p -D %{_buildsubdir}/rmon/scripts/nova_virtual_resource.conf %{buildroot}%{local_etc_rmond}/nova_virtual_resource.conf
install -m 755 -p -D %{_buildsubdir}/rmon/scripts/rmon_reload_on_cpe.sh %{buildroot}%{local_etc_goenabledd}/rmon_reload_on_cpe.sh
# log rotation # log rotation
install -m 755 -d %{buildroot}%{_sysconfdir}/logrotate.d install -m 755 -d %{buildroot}%{_sysconfdir}/logrotate.d
install -m 644 -p -D %{_buildsubdir}/scripts/mtce.logrotate %{buildroot}%{local_etc_logrotated}/mtce.logrotate install -m 644 -p -D %{_buildsubdir}/scripts/mtce.logrotate %{buildroot}%{local_etc_logrotated}/mtce.logrotate
install -m 644 -p -D %{_buildsubdir}/hostw/scripts/hostw.logrotate %{buildroot}%{local_etc_logrotated}/hostw.logrotate install -m 644 -p -D %{_buildsubdir}/hostw/scripts/hostw.logrotate %{buildroot}%{local_etc_logrotated}/hostw.logrotate
install -m 644 -p -D %{_buildsubdir}/pmon/scripts/pmon.logrotate %{buildroot}%{local_etc_logrotated}/pmon.logrotate install -m 644 -p -D %{_buildsubdir}/pmon/scripts/pmon.logrotate %{buildroot}%{local_etc_logrotated}/pmon.logrotate
install -m 644 -p -D %{_buildsubdir}/lmon/scripts/lmon.logrotate %{buildroot}%{local_etc_logrotated}/lmon.logrotate install -m 644 -p -D %{_buildsubdir}/lmon/scripts/lmon.logrotate %{buildroot}%{local_etc_logrotated}/lmon.logrotate
install -m 644 -p -D %{_buildsubdir}/rmon/scripts/rmon.logrotate %{buildroot}%{local_etc_logrotated}/rmon.logrotate
install -m 644 -p -D %{_buildsubdir}/fsmon/scripts/fsmon.logrotate %{buildroot}%{local_etc_logrotated}/fsmon.logrotate install -m 644 -p -D %{_buildsubdir}/fsmon/scripts/fsmon.logrotate %{buildroot}%{local_etc_logrotated}/fsmon.logrotate
install -m 644 -p -D %{_buildsubdir}/hwmon/scripts/hwmon.logrotate %{buildroot}%{local_etc_logrotated}/hwmon.logrotate install -m 644 -p -D %{_buildsubdir}/hwmon/scripts/hwmon.logrotate %{buildroot}%{local_etc_logrotated}/hwmon.logrotate
install -m 644 -p -D %{_buildsubdir}/alarm/scripts/mtcalarm.logrotate %{buildroot}%{local_etc_logrotated}/mtcalarm.logrotate install -m 644 -p -D %{_buildsubdir}/alarm/scripts/mtcalarm.logrotate %{buildroot}%{local_etc_logrotated}/mtcalarm.logrotate
@ -473,10 +408,6 @@ install -m 755 -p -D %{_buildsubdir}/public/libamon.so.$MAJOR %{buildroot}%{_lib
cd %{buildroot}%{_libdir} ; ln -s libamon.so.$MAJOR libamon.so.$MAJOR.$MINOR cd %{buildroot}%{_libdir} ; ln -s libamon.so.$MAJOR libamon.so.$MAJOR.$MINOR
cd %{buildroot}%{_libdir} ; ln -s libamon.so.$MAJOR libamon.so cd %{buildroot}%{_libdir} ; ln -s libamon.so.$MAJOR libamon.so
install -m 755 -p -D %{_buildsubdir}/rmon/rmonApi/librmonapi.so.$MAJOR %{buildroot}%{_libdir}/librmonapi.so.$MAJOR
cd %{buildroot}%{_libdir} ; ln -s librmonapi.so.$MAJOR librmonapi.so.$MAJOR.$MINOR
cd %{buildroot}%{_libdir} ; ln -s librmonapi.so.$MAJOR librmonapi.so
# volatile directories # volatile directories
install -m 755 -d %{buildroot}/var install -m 755 -d %{buildroot}/var
install -m 755 -d %{buildroot}/var/run install -m 755 -d %{buildroot}/var/run
@ -498,9 +429,6 @@ install -m 755 -d %{buildroot}/var/run
%post -n mtce-pmon %post -n mtce-pmon
/bin/systemctl enable pmon.service /bin/systemctl enable pmon.service
%post -n mtce-rmon
/bin/systemctl enable rmon.service
%post -n mtce-lmon %post -n mtce-lmon
/bin/systemctl enable lmon.service /bin/systemctl enable lmon.service
@ -604,34 +532,6 @@ install -m 755 -d %{buildroot}/var/run
%{_sysconfdir}/init.d/pmon %{_sysconfdir}/init.d/pmon
%{local_bindir}/pmond %{local_bindir}/pmond
###############################
# Resource Monitor RPM Files
###############################
%files -n mtce-rmon
%defattr(-,root,root,-)
# Config files - Non-Modifiable
%{_sysconfdir}/mtc/rmond.conf
%{local_etc_pmond}/rmon.conf
%{local_etc_logrotated}/rmon.logrotate
%{_unitdir}/rmon.service
%{local_etc_rmond}/remotelogging_resource.conf
%{local_etc_rmond}/cinder_virtual_resource.conf
%{local_etc_rmond}/nova_virtual_resource.conf
%{_libdir}/librmonapi.so.1.0
%{_libdir}/librmonapi.so.1
%{_libdir}/librmonapi.so
%dir %{_sysconfdir}/rmonapi.d
%{_sysconfdir}/init.d/rmon
%{local_bindir}/rmond
%{local_bindir}/rmon_resource_notify
%{local_etc_goenabledd}/rmon_reload_on_cpe.sh
############################### ###############################
# Hardware Monitor RPM Files # Hardware Monitor RPM Files
############################### ###############################

View File

@ -9,7 +9,6 @@ VER_MJR=1
build: build:
(cd public ; make lib VER=$(VER) VER_MJR=$(VER_MJR)) (cd public ; make lib VER=$(VER) VER_MJR=$(VER_MJR))
(cd rmon/rmonApi ; make lib VER=$(VER) VER_MJR=$(VER_MJR))
(cd common ; make lib VER=$(VER) VER_MJR=$(VER_MJR)) (cd common ; make lib VER=$(VER) VER_MJR=$(VER_MJR))
(cd alarm ; make build VER=$(VER) VER_MJR=$(VER_MJR)) (cd alarm ; make build VER=$(VER) VER_MJR=$(VER_MJR))
(cd heartbeat ; make build VER=$(VER) VER_MJR=$(VER_MJR)) (cd heartbeat ; make build VER=$(VER) VER_MJR=$(VER_MJR))
@ -19,15 +18,12 @@ build:
(cd lmon ; make build VER=$(VER) VER_MJR=$(VER_MJR)) (cd lmon ; make build VER=$(VER) VER_MJR=$(VER_MJR))
(cd pmon ; make build VER=$(VER) VER_MJR=$(VER_MJR)) (cd pmon ; make build VER=$(VER) VER_MJR=$(VER_MJR))
(cd fsmon ; make build VER=$(VER) VER_MJR=$(VER_MJR)) (cd fsmon ; make build VER=$(VER) VER_MJR=$(VER_MJR))
(cd rmon ; make build VER=$(VER) VER_MJR=$(VER_MJR))
(cd rmon/rmon_resource_notify ; make build VER=$(VER) VER_MJR=$(VER_MJR))
(cd hostw ; make build VER=$(VER) VER_MJR=$(VER_MJR)) (cd hostw ; make build VER=$(VER) VER_MJR=$(VER_MJR))
(cd fsync ; make build VER=$(VER) VER_MJR=$(VER_MJR)) (cd fsync ; make build VER=$(VER) VER_MJR=$(VER_MJR))
clean: clean:
@( cd common ; make clean ) @( cd common ; make clean )
@( cd public ; make clean ) @( cd public ; make clean )
@( cd rmon/rmonApi ; make clean )
@( cd alarm ; make clean ) @( cd alarm ; make clean )
@( cd mtclog ; make clean ) @( cd mtclog ; make clean )
@( cd hwmon ; make clean ) @( cd hwmon ; make clean )
@ -36,8 +32,6 @@ clean:
@( cd fsmon ; make clean ) @( cd fsmon ; make clean )
@( cd heartbeat ; make clean ) @( cd heartbeat ; make clean )
@( cd maintenance ; make clean ) @( cd maintenance ; make clean )
@( cd rmon ; make clean )
@( cd rmon/rmon_resource_notify ; make clean )
@( cd hostw ; make clean ) @( cd hostw ; make clean )
@( cd fsync ; make clean ) @( cd fsync ; make clean )
@( rm -rf release ) @( rm -rf release )

View File

@ -691,9 +691,7 @@ nodeLinkClass::node* nodeLinkClass::addNode( string hostname )
ptr->degrade_mask = ptr->degrade_mask_save = DEGRADE_MASK_NONE ; ptr->degrade_mask = ptr->degrade_mask_save = DEGRADE_MASK_NONE ;
ptr->degraded_resources_list.clear () ;
ptr->pmond_ready = false ; ptr->pmond_ready = false ;
ptr->rmond_ready = false ;
ptr->hwmond_ready = false ; ptr->hwmond_ready = false ;
ptr->hbsClient_ready = false ; ptr->hbsClient_ready = false ;
@ -4766,12 +4764,6 @@ int nodeLinkClass::declare_service_ready ( string & hostname,
} }
return (PASS); return (PASS);
} }
else if ( service == MTC_SERVICE_RMOND )
{
node_ptr->rmond_ready = true ;
plog ("%s got rmond ready event\n", hostname.c_str());
return (PASS);
}
else if ( service == MTC_SERVICE_HEARTBEAT ) else if ( service == MTC_SERVICE_HEARTBEAT )
{ {
if ( node_ptr->hbsClient_ready == false ) if ( node_ptr->hbsClient_ready == false )
@ -4857,73 +4849,6 @@ int nodeLinkClass::collectd_notify_handler ( string & hostname,
return (rc); return (rc);
} }
/** Resource Monitor 'Clear' Event handler.
*
* The resource specified will be removed from the
* 'degraded_resources_list' for specified host.
* if there are no other degraded resources or other
* degraded services/reasons against that host then
* this handler will clear the degrade state for the
* specified host all together. */
int nodeLinkClass::degrade_resource_clear ( string & hostname,
string & resource )
{
/* lr - Log Prefix Rmon */
string lr = hostname ;
lr.append (" rmond:");
nodeLinkClass::node * node_ptr = nodeLinkClass::getNode ( hostname );
if ( node_ptr == NULL )
{
wlog ("%s Unknown Host\n", lr.c_str());
return FAIL_UNKNOWN_HOSTNAME ;
}
else if ( node_ptr->adminState == MTC_ADMIN_STATE__UNLOCKED )
{
/* Clear all resource degrade conditions if there is no resource specified */
/* this is used as a cleanup audit just in case things get stuck */
if ( resource.empty() )
{
node_ptr->degrade_mask &= ~DEGRADE_MASK_RESMON ;
node_ptr->degraded_resources_list.clear () ;
}
else if (( node_ptr->degraded_resources_list.empty()) ||
( node_ptr->degrade_mask == DEGRADE_MASK_NONE ))
{
dlog ("%s '%s' Non-Degraded Clear\n",
lr.c_str(), resource.c_str());
}
else
{
if (is_string_in_string_list (node_ptr->degraded_resources_list, resource))
{
node_ptr->degraded_resources_list.remove(resource);
ilog ("%s '%s' Degrade Clear\n",
lr.c_str(), resource.c_str());
}
else
{
wlog ("%s '%s' Unexpected Degrade Clear\n",
lr.c_str(), resource.c_str());
}
if ( node_ptr->degraded_resources_list.empty() )
{
node_ptr->degrade_mask &= ~DEGRADE_MASK_RESMON ; ;
}
else
{
string degraded_resources =
get_strings_in_string_list ( node_ptr->degraded_resources_list );
wlog ("%s Degraded Resource List: %s\n",
lr.c_str(), degraded_resources.c_str());
}
}
}
return (PASS);
}
/********************************************************************************* /*********************************************************************************
* *
* Name : node_degrade_control * Name : node_degrade_control
@ -4940,9 +4865,6 @@ int nodeLinkClass::degrade_resource_clear ( string & hostname,
* *
* "hwmon" - The Hardware Monitor process * "hwmon" - The Hardware Monitor process
* *
*
* Future services might be rmon and pmon
*
**********************************************************************************/ **********************************************************************************/
int nodeLinkClass::node_degrade_control ( string & hostname, int state, string service ) int nodeLinkClass::node_degrade_control ( string & hostname, int state, string service )
{ {
@ -5266,28 +5188,6 @@ int nodeLinkClass::alarm_process_failure ( string & hostname, string & process
return (PASS); return (PASS);
} }
/* Generate a log for the reported failed resource if that host is
* unlocked */
int nodeLinkClass::log_resource_failure ( string & hostname, string & resource )
{
/* lr - Log Prefix Rmond */
string lr = hostname ;
lr.append (" rmond:");
nodeLinkClass::node * node_ptr = nodeLinkClass::getNode ( hostname );
if ( node_ptr == NULL )
{
wlog ("%s Unknown Host ; '%s' failed (minor)\n",
lr.c_str(), resource.c_str());
return FAIL_UNKNOWN_HOSTNAME ;
}
else if ( node_ptr->operState == MTC_OPER_STATE__ENABLED )
{
ilog ("%s '%s' failed (minor)\n",
lr.c_str(), resource.c_str());
}
return (PASS);
}
/** Process Monitor Degrade Event handler. /** Process Monitor Degrade Event handler.
* *
* The host will enter degrade state due to the specified process * The host will enter degrade state due to the specified process
@ -5443,54 +5343,6 @@ int nodeLinkClass::update_dport_states ( struct nodeLinkClass::node * node_ptr,
return (rc); return (rc);
} }
/** Resource Monitor 'Raise' Event handler.
*
* The host will enter degrade state due to the specified resource
* threshold being surpased. The resource name is recorded in the
* 'degraded_resources_list' for specified host.
* Clearing degrade against this resource requires that host to
* send a clear event against that resource or for that host to
* fully re-enable */
int nodeLinkClass::degrade_resource_raise ( string & hostname,
string & resource )
{
/* lr - Log Prefix Rmond */
string lr = hostname ;
lr.append (" rmond:");
nodeLinkClass::node * node_ptr = nodeLinkClass::getNode ( hostname );
if ( node_ptr == NULL )
{
wlog ("%s Unknown Host\n", lr.c_str());
return FAIL_UNKNOWN_HOSTNAME ;
}
else if ( node_ptr->adminState == MTC_ADMIN_STATE__UNLOCKED )
{
if ( is_string_in_string_list ( node_ptr->degraded_resources_list, resource ) == false )
{
string degraded_resources = "";
ilog ("%s '%s' Degraded\n", lr.c_str(), resource.c_str());
node_ptr->degraded_resources_list.push_back (resource);
node_ptr->degrade_mask |= DEGRADE_MASK_RESMON ;
/* Cleanup the list */
node_ptr->degraded_resources_list.sort ();
node_ptr->degraded_resources_list.unique ();
degraded_resources =
get_strings_in_string_list ( node_ptr->degraded_resources_list );
wlog ("%s Failing Resources: %s\n",
lr.c_str(), degraded_resources.c_str());
}
else
{
dlog ("%s '%s' Degraded (again)\n", lr.c_str(), resource.c_str());
}
}
return (PASS);
}
/** Process Monitor 'Critical Process Failed' Event handler. /** Process Monitor 'Critical Process Failed' Event handler.
* *
* This utility handles critical process failure event notifications. * This utility handles critical process failure event notifications.
@ -5557,36 +5409,6 @@ int nodeLinkClass::critical_process_failed( string & hostname,
return (PASS); return (PASS);
} }
/** Resource Monitor 'Failed' Event handler.
*
* The host will go out of service, be reset and
* automatically re-enabled. */
int nodeLinkClass::critical_resource_failed( string & hostname,
string & resource )
{
nodeLinkClass::node * node_ptr = nodeLinkClass::getNode ( hostname );
if ( node_ptr == NULL )
{
wlog ("%s rmond: Unknown host\n", hostname.c_str());
return FAIL_UNKNOWN_HOSTNAME ;
}
if (( node_ptr->adminState == MTC_ADMIN_STATE__UNLOCKED ) &&
( node_ptr->operState == MTC_OPER_STATE__ENABLED ))
{
/* Start fresh the next time we enter graceful recovery handler */
node_ptr->graceful_recovery_counter = 0 ;
elog ("%s rmond: Critical Resource '%s' Failure\n", hostname.c_str(), resource.c_str());
/* Set node as unlocked-enabled */
allStateChange ( node_ptr, MTC_ADMIN_STATE__UNLOCKED,
MTC_OPER_STATE__DISABLED,
MTC_AVAIL_STATUS__FAILED );
}
return (PASS);
}
bool nodeLinkClass::is_active_controller ( string hostname ) bool nodeLinkClass::is_active_controller ( string hostname )
{ {
if ( nodeLinkClass::my_hostname.compare(hostname) ) if ( nodeLinkClass::my_hostname.compare(hostname) )

View File

@ -602,9 +602,9 @@ private:
* @addtogroup private_monitoring_services_variables * @addtogroup private_monitoring_services_variables
* @{ * @{
* *
* A grouping a of flags, mask and degrade resource lists * A grouping a of flags, mask and lists used to
* used to manage the degrade state of a host for process * manage the degrade state of a host for process
* and resource monitoring services. * monitoring services.
*/ */
/* Bit mask of degrade reasons */ /* Bit mask of degrade reasons */
@ -631,16 +631,6 @@ private:
recovery_ctrl_type hwmon_reset ; recovery_ctrl_type hwmon_reset ;
recovery_ctrl_type hwmon_powercycle ; recovery_ctrl_type hwmon_powercycle ;
/** Resource Monitor Daemon Flag Missing count */
int rmond_missing_count ;
/** Host degraded due to loss of Resource Monitor running flag */
bool rmond_degraded ;
/** Resource Monitor Ready flag and degrade list */
bool rmond_ready ;
std::list<string> degraded_resources_list ;
/** process or resource list string iterator */ /** process or resource list string iterator */
std::list<string>::iterator string_iter_ptr ; std::list<string>::iterator string_iter_ptr ;
@ -1797,16 +1787,6 @@ public:
* specified host all together. */ * specified host all together. */
int degrade_pmond_clear ( string & hostname ); int degrade_pmond_clear ( string & hostname );
/** Resource Monitor 'Clear' Event handler.
*
* The resource specified will be removed from the
* 'degraded_resources_list' for specified host.
* if there are no other degraded resources or other
* degraded services/reasons against that host then
* this handler will clear the degrade state for the
* specified host all together. */
int degrade_resource_clear ( string & hostname, string & resource );
/** /**
* If the pmond degrade flag is not set then do so. * If the pmond degrade flag is not set then do so.
* if the host is not degraded then set it to degraded. */ * if the host is not degraded then set it to degraded. */
@ -1818,19 +1798,6 @@ public:
/** if host is unlocked-enabled generate a process failure alarm */ /** if host is unlocked-enabled generate a process failure alarm */
int alarm_process_failure ( string & hostname, string & process ); int alarm_process_failure ( string & hostname, string & process );
/** Resource Monitor Raise Event handler.
*
* The host will enter degrade state due to the specified resource
* not running properly. The resource name is recorded in the
* 'degraded_resources_list' for specified host.
* Clearing degrade against this resource requires that host to
* send a clear event against that resource or for that host to
* fully re-enable */
int degrade_resource_raise ( string & hostname, string & resource );
/** Generate a resource failure log if the host is unlocked */
int log_resource_failure ( string & hostname, string & resource );
/** Hardware Process Monitor Degrade Event handler. /** Hardware Process Monitor Degrade Event handler.
* see implementation for details */ * see implementation for details */
int node_degrade_control ( string & hostname, int state, string service ); int node_degrade_control ( string & hostname, int state, string service );
@ -1849,12 +1816,6 @@ public:
* automatically re-enabled. */ * automatically re-enabled. */
int critical_process_failed( string & hostname, string & process, unsigned int nodetype ); int critical_process_failed( string & hostname, string & process, unsigned int nodetype );
/** Resource Monitor Failed Event handler.
*
* The host will go out of service and be reset and
* automatically re-enabled. */
int critical_resource_failed( string & hostname, string & resource );
/************************************************************/ /************************************************************/
/** /**

View File

@ -86,24 +86,6 @@ typedef struct
char bond[IF_NAMESIZE] ; /* bonded interface name */ char bond[IF_NAMESIZE] ; /* bonded interface name */
bool lagged ; /* Lagged interface=true or not=false */ bool lagged ; /* Lagged interface=true or not=false */
// unsigned int debounce_cnt ; /* running monitor debounce count */
// unsigned int minorlog_cnt ; /* track minor log count for thresholding */
// unsigned int count ; /* track the number of times the condition has been occured */
// bool failed ; /* track if the resource needs to be serviced by the resource handler */
// int resource_value ; /* 1 if the interface is up and 0 if it is down */
// int resource_value_lagged ; /* 1 if the interface is up and 0 if it is down for lagged interfaces */
// int sev ; /* The severity of the failed resource */
// rmonStage_enum stage ; /* The stage the resource is in within the resource handler fsm */
// char alarm_id[FM_MAX_BUFFER_LENGTH] ; /* Used by FM API, type of alarm being raised */
// char alarm_id_port[FM_MAX_BUFFER_LENGTH] ; /* Used by FM API, type of alarm being raised for the ports */
// char errorMsg[ERR_SIZE];
// rmon_api_socket_type msg;
// bool link_up_and_running; /* whether the interface is up or down initially */
// bool alarm_raised;
// int failed_send; /* The number of times the rmon api failed to send a message */
} interface_ctrl_type ; } interface_ctrl_type ;

View File

@ -51,9 +51,9 @@ CONTROL_OBJS += ../common/nodeClass.o
OBJS = $(SRCS:.cpp=.o) OBJS = $(SRCS:.cpp=.o)
BINS = mtcAgent mtcClient BINS = mtcAgent mtcClient
LDLIBS += -lstdc++ -ldaemon -lcommon -lthreadUtil -lipmiUtil -lfmcommon -lrmonapi -lalarm -lpthread -lrt -levent -ljson-c -lamon -lcrypto -luuid LDLIBS += -lstdc++ -ldaemon -lcommon -lthreadUtil -lipmiUtil -lfmcommon -lalarm -lpthread -lrt -levent -ljson-c -lamon -lcrypto -luuid
INCLUDES = -I. -I/usr/include/mtce-daemon -I/usr/include/mtce-common INCLUDES = -I. -I/usr/include/mtce-daemon -I/usr/include/mtce-common
INCLUDES += -I../common -I../alarm -I../heartbeat -I../hwmon -I../public -I../rmon/rmonApi INCLUDES += -I../common -I../alarm -I../heartbeat -I../hwmon -I../public
CCFLAGS += -g -O2 -Wall -Wextra -Werror -Wno-missing-braces CCFLAGS += -g -O2 -Wall -Wextra -Werror -Wno-missing-braces
STATIC_ANALYSIS_TOOL = cppcheck STATIC_ANALYSIS_TOOL = cppcheck
@ -77,10 +77,10 @@ common:
( cd ../common ; make clean ; make lib VER=$(VER) VER_MJR=$(VER_MJR)) ( cd ../common ; make clean ; make lib VER=$(VER) VER_MJR=$(VER_MJR))
mtcAgent: $(OBJS) mtcAgent: $(OBJS)
$(CXX) $(CONTROL_OBJS) -L../public -L../alarm -L../rmon/rmonApi $(LDLIBS) $(EXTRALDFLAGS) -o mtcAgent $(CXX) $(CONTROL_OBJS) -L../public -L../alarm $(LDLIBS) $(EXTRALDFLAGS) -o mtcAgent
mtcClient: $(OBJS) mtcClient: $(OBJS)
$(CXX) $(COMPUTE_OBJS) -L../public -L../alarm -L../rmon/rmonApi $(LDLIBS) $(EXTRALDFLAGS) -o mtcClient $(CXX) $(COMPUTE_OBJS) -L../public -L../alarm $(LDLIBS) $(EXTRALDFLAGS) -o mtcClient
remove_bins: remove_bins:
@rm -v -f $(BINS) @rm -v -f $(BINS)

View File

@ -55,122 +55,6 @@ extern char *program_invocation_short_name;
int mtcAlive_mgmnt_sequence = 0 ; int mtcAlive_mgmnt_sequence = 0 ;
int mtcAlive_infra_sequence = 0 ; int mtcAlive_infra_sequence = 0 ;
/*****************************************************************************
* Also handles: Accelerated Virtual Switch 'events' handler
* for receiving data port state change event
*
* Event strings are:-
* {"type":"port-state", "severity":"critical|major|clear"}
* severity:
* critical - port has failed and is not part of an aggregate
* or is the last port in an aggregate
* (degrade, disable services)
* major - port has failed and is part of an aggregate
* with other inservice-ports (degrade only)
* clear - port has recovered from a failed state and is
* operational (clear degrade, enable services)
*
* NOTE : The port status can transition from any of the above
* states to any other state.
*
* RMON monitors the vswitch ports at a 20 second interval(debounce value).
* If a port changes link state during the polling period, it will
* raise/clear the alarm, but now also calculates the impact of that port
* failure on the provider network data interface.
*
* The overall aggregated state across all provider network interfaces will
* be reported to maintenance when ports enter a link down or up state.
* The agent will also periodically send the current provider network port
* status to maintenance every 20 seconds.
*
* Return : MTC_EVENT_AVS_CLEAR|MAJOR|CRITICAL
*****************************************************************************/
/** Receive and process event messages from rmon **/
static int rmon_message_error = 0 ;
int service_rmon_inbox ( mtc_socket_type * sock_ptr, int & rmon_code, string & resource_name )
{
/* Max rmon message length */
#define RMON_MAX_LEN (100)
/* Max tries to receive rmon message */
#define MAX_TRIES (3)
char buf[RMON_MAX_LEN];
char res_name[RMON_MAX_LEN];
socklen_t len = sizeof(struct sockaddr_in) ;
char str[RMON_MAX_LEN];
int rc = FAIL;
int sequence = 0;
int bytes = 0 ;
int num_tries = 0;
do
{
memset ( buf,0,RMON_MAX_LEN);
memset ( str,0,RMON_MAX_LEN);
bytes = recvfrom( sock_ptr->rmon_socket, buf, RMON_MAX_LEN, 0,
(struct sockaddr *)&sock_ptr->mtc_cmd_addr, &len);
if ( bytes > 0 )
{
sscanf ( buf, "%99s %99s %d", res_name, str, &sequence );
string r_name(res_name);
resource_name = r_name;
if ( str[0] != '\0' )
{
mlog("%s \n",str);
// check if it is an AVS type message
if (regexUtil_string_startswith(str, "AVS_clear")) {
rmon_code = MTC_EVENT_AVS_CLEAR;
} else if (regexUtil_string_startswith(str, "AVS_major")) {
rmon_code = MTC_EVENT_AVS_MAJOR;
} else if (regexUtil_string_startswith(str, "AVS_critical")) {
rmon_code = MTC_EVENT_AVS_CRITICAL;
// process generic RMON messages
} else if (regexUtil_string_startswith(str, "cleared")) {
rmon_code = RMON_CLEAR;
} else if (regexUtil_string_startswith(str, "minor")) {
rmon_code = RMON_MINOR;
} else if (regexUtil_string_startswith(str, "major")) {
rmon_code = RMON_MAJOR;
} else if (regexUtil_string_startswith(str, "critical")) {
rmon_code = RMON_CRITICAL;
} else {
elog("Invalid rmon string: %s \n", str);
rc = FAIL;
return rc;
}
rmon_message_error = 0 ;
rc = PASS;
return rc;
}
else
{
wlog_throttled (rmon_message_error, 1, "rmond message with no severity specified (%s)\n",
resource_name.empty() ? "no resource" : resource_name.c_str());
if (( rmon_message_error == 1 ) && ( buf[0] != '\0' ))
{
ilog ("rmon message: [%s]\n", buf );
}
rc = FAIL_NULL_POINTER;
return rc;
}
}
else if (( 0 > bytes ) && ( errno != EINTR ) && ( errno != EAGAIN ))
{
elog("rmon event recv error (%d:%s) \n", errno, strerror(errno));
rc = FAIL;
}
} while (( bytes > 0 ) && ( ++num_tries < MAX_TRIES)) ;
return rc;
}
/* Receive and process commands from controller maintenance */ /* Receive and process commands from controller maintenance */
int mtc_service_command ( mtc_socket_type * sock_ptr, int interface ) int mtc_service_command ( mtc_socket_type * sock_ptr, int interface )
{ {
@ -627,26 +511,7 @@ int mtce_send_event ( mtc_socket_type * sock_ptr, int cmd , const char * mtce_na
memset (&event, 0 , sizeof(mtc_message_type)); memset (&event, 0 , sizeof(mtc_message_type));
if (( cmd == MTC_EVENT_RMON_READY) || if ( cmd == MTC_EVENT_LOOPBACK )
( cmd == MTC_EVENT_RMON_MINOR) ||
( cmd == MTC_EVENT_RMON_MAJOR) ||
( cmd == MTC_EVENT_RMON_CRIT ) ||
( cmd == MTC_EVENT_RMON_CLEAR ))
{
snprintf ( &event.hdr[0] , MSG_HEADER_SIZE, "%s", get_mtce_event_header() );
if ( mtce_name_ptr )
{
size_t len = strnlen ( mtce_name_ptr, MAX_MTCE_EVENT_NAME_LEN );
/* We don't use the buffer for mtce events to remove it from the size */
bytes = ((sizeof(mtc_message_type))-(BUF_SIZE-len));
snprintf ( &event.buf[0], MAX_MTCE_EVENT_NAME_LEN , "%s", mtce_name_ptr );
} else {
slog ("Internal Error - mtce_name_ptr is null\n");
}
}
else if ( cmd == MTC_EVENT_LOOPBACK )
{ {
snprintf ( &event.hdr[0] , MSG_HEADER_SIZE, "%s", get_loopback_header() ); snprintf ( &event.hdr[0] , MSG_HEADER_SIZE, "%s", get_loopback_header() );

View File

@ -502,44 +502,6 @@ int mtc_service_inbox ( nodeLinkClass * obj_ptr,
break ; break ;
} }
/*****************************************************************
* Resource Monitor Events *
*****************************************************************/
/* TODO: Remove - Suspecting OBS Command */
case MTC_EVENT_RMON_READY:
{
mlog ("%s RMON Ready\n", hostname.c_str());
obj_ptr->declare_service_ready ( hostname, MTC_SERVICE_RMOND );
break ;
}
case MTC_EVENT_RMON_CLEAR:
{
mlog ("%s rmond: '%s' recovered (clear)\n", hostname.c_str(), event.c_str());
obj_ptr->degrade_resource_clear ( hostname , event );
break ;
}
case MTC_EVENT_RMON_CRIT:
{
mlog ("%s rmond: '%s' failed (critical)\n", hostname.c_str(), event.c_str());
obj_ptr->critical_resource_failed ( hostname, event );
break ;
}
case MTC_EVENT_RMON_MAJOR:
{
mlog ("%s rmond: '%s' failed (major)\n", hostname.c_str(), event.c_str());
obj_ptr->degrade_resource_raise ( hostname, event );
break ;
}
case MTC_EVENT_RMON_MINOR:
{
mlog ("%s rmond: '%s' failed (minor)\n", hostname.c_str(), event.c_str());
/* Clear the degrade condition if one is present */
obj_ptr->degrade_resource_clear ( hostname , event );
obj_ptr->log_resource_failure ( hostname, event );
break ;
}
case MTC_EVENT_HWMON_CLEAR: case MTC_EVENT_HWMON_CLEAR:
case MTC_DEGRADE_CLEAR: case MTC_DEGRADE_CLEAR:
{ {

View File

@ -63,7 +63,6 @@ using namespace std;
extern "C" extern "C"
{ {
#include "amon.h" /* for ... active monitoring utilities */ #include "amon.h" /* for ... active monitoring utilities */
#include "rmon_api.h" /* for ... resource monitoring utilities */
} }
@ -181,15 +180,6 @@ void _close_infra_tx_socket ( void )
} }
} }
void _close_rmon_sock ( void )
{
if ( mtc_sock.rmon_socket )
{
close (mtc_sock.rmon_socket);
mtc_sock.rmon_socket = 0 ;
}
}
void _close_amon_sock ( void ) void _close_amon_sock ( void )
{ {
if ( mtc_sock.amon_socket ) if ( mtc_sock.amon_socket )
@ -207,7 +197,6 @@ void daemon_exit ( void )
_close_infra_rx_socket (); _close_infra_rx_socket ();
_close_mgmnt_tx_socket (); _close_mgmnt_tx_socket ();
_close_infra_tx_socket (); _close_infra_tx_socket ();
_close_rmon_sock ();
_close_amon_sock (); _close_amon_sock ();
exit (0) ; exit (0) ;
@ -232,11 +221,6 @@ static int mtc_config_handler ( void * user,
config_ptr->mtc_rx_mgmnt_port = atoi(value); config_ptr->mtc_rx_mgmnt_port = atoi(value);
config_ptr->mask |= CONFIG_CLIENT_MTC_MGMNT_PORT ; config_ptr->mask |= CONFIG_CLIENT_MTC_MGMNT_PORT ;
} }
else if (MATCH("client", "rmon_event_port"))
{
config_ptr->rmon_event_port = atoi(value);
config_ptr->mask |= CONFIG_CLIENT_RMON_PORT ;
}
else if (MATCH("timeouts", "failsafe_shutdown_delay")) else if (MATCH("timeouts", "failsafe_shutdown_delay"))
{ {
config_ptr->failsafe_shutdown_delay = atoi(value); config_ptr->failsafe_shutdown_delay = atoi(value);
@ -471,33 +455,6 @@ void setup_amon_socket ( void )
} }
mtc_sock.amon_socket = 0 ; mtc_sock.amon_socket = 0 ;
} }
void setup_rmon_socket ( void )
{
mtc_sock.rmon_socket =
resource_monitor_initialize ( program_invocation_short_name, mtc_config.rmon_event_port, ALL_USAGE );
if ( mtc_sock.rmon_socket )
{
int val = 1;
/* Make the active monitor socket non-blocking */
if ( 0 > ioctl(mtc_sock.rmon_socket, FIONBIO, (char *)&val) )
{
elog ("failed to set rmon event port non-blocking (%d:%s),\n", errno, strerror(errno));
close ( mtc_sock.rmon_socket );
}
else
{
ilog ("Resource Monitor Socket %d\n", mtc_sock.rmon_socket );
return ;
}
}
else
{
elog ("failed to register as client with rmond\n");
}
mtc_sock.rmon_socket = 0 ;
}
/****************************************************************** /******************************************************************
* *
@ -509,7 +466,6 @@ void setup_rmon_socket ( void )
* 4. Unicast transmit socket infra (mtc_client_infra_tx_socket) * 4. Unicast transmit socket infra (mtc_client_infra_tx_socket)
* *
* 5. socket for pmond acive monitoring * 5. socket for pmond acive monitoring
* 6. socket to receive rmond events (including AVS)
* *
*******************************************************************/ *******************************************************************/
int mtc_socket_init ( void ) int mtc_socket_init ( void )
@ -557,11 +513,6 @@ int mtc_socket_init ( void )
/*************************************************************/ /*************************************************************/
setup_amon_socket (); setup_amon_socket ();
/*************************************************************/
/* Setup and Open the resource monitor event socket */
/*************************************************************/
setup_rmon_socket ();
return (PASS); return (PASS);
} }
@ -1059,9 +1010,6 @@ int daemon_init ( string iface, string nodetype_str )
int select_log_count = 0 ; int select_log_count = 0 ;
void daemon_service_run ( void ) void daemon_service_run ( void )
{ {
int rmon_code;
string resource_name;
int rc = PASS ; int rc = PASS ;
int file_not_present_count = 0 ; int file_not_present_count = 0 ;
@ -1075,7 +1023,7 @@ void daemon_service_run ( void )
std::list<int> socks ; std::list<int> socks ;
/* Run heartbeat service forever or until stop condition */ /* Run heartbeat service forever or until stop condition */
for ( ; ; ) for ( ; ; )
{ {
/* set the master fd_set */ /* set the master fd_set */
@ -1103,13 +1051,6 @@ void daemon_service_run ( void )
FD_SET(mtc_sock.amon_socket, &mtc_sock.readfds); FD_SET(mtc_sock.amon_socket, &mtc_sock.readfds);
} }
mtc_sock.rmon_socket = resource_monitor_get_sel_obj ();
if ( mtc_sock.rmon_socket )
{
socks.push_front (mtc_sock.rmon_socket);
FD_SET(mtc_sock.rmon_socket, &mtc_sock.readfds);
}
/* Initialize the timeval struct to wait for 50 mSec */ /* Initialize the timeval struct to wait for 50 mSec */
mtc_sock.waitd.tv_sec = 0; mtc_sock.waitd.tv_sec = 0;
mtc_sock.waitd.tv_usec = SOCKET_WAIT; mtc_sock.waitd.tv_usec = SOCKET_WAIT;
@ -1118,11 +1059,10 @@ void daemon_service_run ( void )
socks.sort(); socks.sort();
#ifdef WANT_SELECTS #ifdef WANT_SELECTS
ilog_throttled ( select_log_count, 200 , "Selects: mgmnt:%d infra:%d amon:%d rmon:%d - Size:%ld First:%d Last:%d\n", ilog_throttled ( select_log_count, 200 , "Selects: mgmnt:%d infra:%d amon:%d - Size:%ld First:%d Last:%d\n",
mtc_sock.mtc_client_rx_socket, mtc_sock.mtc_client_rx_socket,
mtc_sock.mtc_client_infra_rx_socket, mtc_sock.mtc_client_infra_rx_socket,
mtc_sock.amon_socket, mtc_sock.amon_socket,
mtc_sock.rmon_socket,
socks.size(), socks.front(), socks.back()); socks.size(), socks.front(), socks.back());
#endif #endif
@ -1159,40 +1099,6 @@ void daemon_service_run ( void )
dlog3 ("Active Monitor Select Fired\n"); dlog3 ("Active Monitor Select Fired\n");
active_monitor_dispatch (); active_monitor_dispatch ();
} }
if ( FD_ISSET(mtc_sock.rmon_socket, &mtc_sock.readfds))
{
dlog3 ("Resource Monitor Select Fired\n");
rc = service_rmon_inbox( sock_ptr, rmon_code, resource_name );
if (rc == PASS) {
switch ( rmon_code ) {
case RMON_CLEAR:
mtce_send_event ( sock_ptr, MTC_EVENT_RMON_CLEAR, resource_name.c_str() );
break;
case RMON_MINOR:
mtce_send_event ( sock_ptr, MTC_EVENT_RMON_MINOR, resource_name.c_str() );
break;
case RMON_MAJOR:
mtce_send_event ( sock_ptr, MTC_EVENT_RMON_MAJOR, resource_name.c_str() );
break;
case RMON_CRITICAL:
mtce_send_event ( sock_ptr, MTC_EVENT_RMON_CRIT, resource_name.c_str() );
break;
case MTC_EVENT_AVS_CLEAR:
case MTC_EVENT_AVS_MAJOR:
case MTC_EVENT_AVS_CRITICAL:
mtce_send_event ( sock_ptr, rmon_code, "" );
break;
default:
break;
}
}
}
} }
if (( ctrl.active_script_set == GOENABLED_MAIN_SCRIPTS ) || if (( ctrl.active_script_set == GOENABLED_MAIN_SCRIPTS ) ||
@ -1353,14 +1259,6 @@ void daemon_service_run ( void )
socket_reinit = true ; socket_reinit = true ;
} }
/* RMON event notifications */
else if ( mtc_sock.rmon_socket <= 0 )
{
setup_rmon_socket ();
wlog ("calling setup_rmon_socket (auto-recovery)\n");
socket_reinit = true ;
}
else if ( mtc_sock.amon_socket <= 0 ) else if ( mtc_sock.amon_socket <= 0 )
{ {
setup_amon_socket (); setup_amon_socket ();
@ -1426,10 +1324,6 @@ void daemon_service_run ( void )
_close_infra_tx_socket (); _close_infra_tx_socket ();
} }
} }
if ( daemon_is_file_present ( MTC_CMD_FIT__RMON_SOCK ))
{
_close_rmon_sock ();
}
if ( daemon_is_file_present ( MTC_CMD_FIT__AMON_SOCK )) if ( daemon_is_file_present ( MTC_CMD_FIT__AMON_SOCK ))
{ {
_close_amon_sock (); _close_amon_sock ();

View File

@ -19,8 +19,7 @@
/** Compute Config mask */ /** Compute Config mask */
#define CONFIG_CLIENT_MASK (CONFIG_AGENT_PORT |\ #define CONFIG_CLIENT_MASK (CONFIG_AGENT_PORT |\
CONFIG_CLIENT_MTC_MGMNT_PORT |\ CONFIG_CLIENT_MTC_MGMNT_PORT)
CONFIG_CLIENT_RMON_PORT)
#define MAX_RUN_SCRIPTS (20) #define MAX_RUN_SCRIPTS (20)

View File

@ -725,7 +725,6 @@ int nodeLinkClass::enable_handler ( struct nodeLinkClass::node * node_ptr )
/* Clear all degrade flags except for the HWMON one */ /* Clear all degrade flags except for the HWMON one */
clear_host_degrade_causes ( node_ptr->degrade_mask ); clear_host_degrade_causes ( node_ptr->degrade_mask );
node_ptr->degraded_resources_list.clear();
/* Purge this hosts work and done queues */ /* Purge this hosts work and done queues */
workQueue_purge ( node_ptr ); workQueue_purge ( node_ptr );
@ -1840,7 +1839,6 @@ int nodeLinkClass::recovery_handler ( struct nodeLinkClass::node * node_ptr )
/* Clear all degrade flags except for the HWMON one */ /* Clear all degrade flags except for the HWMON one */
clear_host_degrade_causes ( node_ptr->degrade_mask ); clear_host_degrade_causes ( node_ptr->degrade_mask );
node_ptr->degraded_resources_list.clear();
if ( is_controller(node_ptr) ) if ( is_controller(node_ptr) )
{ {
@ -2754,7 +2752,6 @@ int nodeLinkClass::disable_handler ( struct nodeLinkClass::node * node_ptr )
/* Clear all degrade flags except for the HWMON one */ /* Clear all degrade flags except for the HWMON one */
clear_host_degrade_causes ( node_ptr->degrade_mask ); clear_host_degrade_causes ( node_ptr->degrade_mask );
node_ptr->degraded_resources_list.clear();
if ( is_controller(node_ptr) ) if ( is_controller(node_ptr) )
{ {

View File

@ -109,9 +109,6 @@ typedef struct
/** Active Monitor Socket */ /** Active Monitor Socket */
int amon_socket ; int amon_socket ;
/** Resource Monitor Socket */
int rmon_socket ;
bool main_go_enabled_reply_ack ; bool main_go_enabled_reply_ack ;
bool subf_go_enabled_reply_ack ; bool subf_go_enabled_reply_ack ;
@ -131,7 +128,6 @@ int recv_mtc_reply_noblock ( void );
int send_mtc_cmd ( string & hostname, int cmd, int interface ); int send_mtc_cmd ( string & hostname, int cmd, int interface );
int mtc_service_command ( mtc_socket_type * sock_ptr , int interface ); int mtc_service_command ( mtc_socket_type * sock_ptr , int interface );
int mtc_set_availStatus ( string & hostname, mtc_nodeAvailStatus_enum status ); int mtc_set_availStatus ( string & hostname, mtc_nodeAvailStatus_enum status );
int service_rmon_inbox ( mtc_socket_type * sock_ptr, int & rmon_code, string & resource_name );
int mtce_send_event ( mtc_socket_type * sock_ptr, int cmd , const char * mtce_name_ptr ); int mtce_send_event ( mtc_socket_type * sock_ptr, int cmd , const char * mtce_name_ptr );
int mtc_infra_init ( mtc_socket_type * sock_ptr , char * iface ); int mtc_infra_init ( mtc_socket_type * sock_ptr , char * iface );
string get_who_i_am ( void ); string get_who_i_am ( void );

View File

@ -40,7 +40,6 @@
# ntpd does not support restart # ntpd does not support restart
# ptp4l does not support restart # ptp4l does not support restart
# phc2sys does not support restart # phc2sys does not support restart
# rmond restart PASSED [13893]:[5129]
# sm-api restart PASSED [8896]:[8460] # sm-api restart PASSED [8896]:[8460]
# skipping 'sm' process # skipping 'sm' process
# sm-eru restart PASSED [8904]:[10993] # sm-eru restart PASSED [8904]:[10993]

View File

@ -1,43 +0,0 @@
#
# Copyright (c) 2014-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
SHELL = /bin/bash
SRCS = rmonInit.cpp rmonMsg.cpp rmonHdlr.cpp rmonHttp.cpp interfaceHdlr.cpp rmonFM.cpp remoteloggingHdlr.cpp thinmetaHdlr.cpp
OBJS = $(SRCS:.cpp=.o)
LDLIBS = -lstdc++ -ldaemon -lcommon -lfmcommon -lrmonapi -lrt -levent -lcrypto -luuid -lpthread -ljson-c
INCLUDES = -I. -I/usr/include/mtce-daemon -I/usr/include/mtce-common
INCLUDES += -IrmonApi
CCFLAGS = -g -O2 -Wall -Werror -Wextra
STATIC_ANALYSIS_TOOL = cppcheck
STATIC_ANALYSIS_TOOL_EXISTS = $(shell [[ -e `which $(STATIC_ANALYSIS_TOOL)` ]] && echo 1 || echo 0)
all: clean static_analysis common daemon build
.cpp.o:
$(CXX) $(INCLUDES) $(CCFLAGS) $(EXTRACCFLAGS) -c $< -o $@
static_analysis:
ifeq ($(STATIC_ANALYSIS_TOOL_EXISTS), 1)
$(STATIC_ANALYSIS_TOOL) --language=c++ --enable=warning -U__AREA__ -DWANT_FIT_TESTING *.cpp *.h
else
echo "Warning: '$(STATIC_ANALYSIS_TOOL)' static analysis tool not installed ; bypassing ..."
endif
build: clean static_analysis $(OBJS)
$(CXX) $(CCFLAGS) $(OBJS) -L../daemon -L../common -LrmonApi/ $(LDLIBS) $(EXTRALDFLAGS) -o rmond
lib: build $(OBJS)
common:
( cd ../common ; make lib VER=$(VER) VER_MJR=$(VER_MJR))
daemon:
( cd ../daemon ; make lib VER=$(VER) VER_MJR=$(VER_MJR))
clean:
@rm -v -f $(OBJ) rmond *.o *.a

File diff suppressed because it is too large Load Diff

View File

@ -1,376 +0,0 @@
/*
* Copyright (c) 2013-2017 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
/**
* @file
* Wind River Titanium Cloud Platform remote logging Monitor Handler
*/
#include <iostream>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <dirent.h>
#include <list>
#include <map>
#include <syslog.h>
#include <sys/wait.h>
#include <time.h>
#include <fstream>
#include <sstream>
#include <ctime>
#include <vector> /* for storing dynamic resource names */
#include <dirent.h>
#include <signal.h>
#include "rmon.h" /* rmon header file */
#include "rmonHttp.h" /* for rmon HTTP libEvent utilties */
#include "rmonApi.h"
#include <algorithm>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <cctype>
#include <pthread.h>
#include <linux/rtnetlink.h> /* for ... RTMGRP_LINK */
#include "nlEvent.h" /* for ... open_netlink_socket */
#include "nodeEvent.h" /* for inotify */
#include <json-c/json.h> /* for ... json-c json string parsing */
#include "jsonUtil.h"
#include <cstring>
#include <iomanip>
#include <cstdlib>
static libEvent_type remoteLoggingAudit; // for system remotelogging-show
static inline SFmAlarmDataT
create_remoteLogging_controller_connectivity_alarm (SFmAlarmDataT data,
AlarmFilter filter)
{
snprintf (data.alarm_id, FM_MAX_BUFFER_LENGTH, "%s",
filter.alarm_id);
data.alarm_state = FM_ALARM_STATE_SET;
snprintf(data.entity_type_id, FM_MAX_BUFFER_LENGTH, "system.host");
snprintf(data.entity_instance_id, FM_MAX_BUFFER_LENGTH, "%s",
filter.entity_instance_id);
data.severity = FM_ALARM_SEVERITY_MINOR;
snprintf(data.reason_text, sizeof(data.reason_text),
"Controller cannot establish connection with remote logging server.");
data.alarm_type = FM_ALARM_COMM;
data.probable_cause = FM_ALARM_COMM_SUBSYS_FAILURE;
data.service_affecting = FM_FALSE;
snprintf(data.proposed_repair_action, sizeof(data.proposed_repair_action),
"Ensure Remote Log Server IP is reachable from Controller through "
"OAM interface; otherwise contact next level of support.");
return data;
}
// alarm data for all remote loggin alarms
static SFmAlarmDataT alarmData;
int rmonHdlr_remotelogging_query (resource_config_type * ptr);
// this is used to create a buffer to store output from a command
// that gets the connection status of a port.
// the command filters the /proc/net/tcp(udp) files leaving only the status
// you generally expect a 1 character integer value for the status
#define CONNECTION_STATUS_COMMAND_OUTPUT_BUFFER_SIZE 8
/*****************************************************************************
*
* Name : rmonHdlr_remotelogging_handler
*
* Purpose : Handles the remote logging response message
*
*****************************************************************************/
void rmonHdlr_remotelogging_handler ( struct evhttp_request *req, void *arg )
{
if ( !req )
{
elog (" Request Timeout\n");
remoteLoggingAudit.status = FAIL_TIMEOUT ;
goto _remote_logging_handler_done ;
}
remoteLoggingAudit.status = rmonHttpUtil_status ( remoteLoggingAudit ) ;
if ( remoteLoggingAudit.status == HTTP_NOTFOUND )
{
goto _remote_logging_handler_done ;
}
else if ( remoteLoggingAudit.status != PASS )
{
dlog (" remote logging HTTP Request Failed (%d)\n",
remoteLoggingAudit.status);
goto _remote_logging_handler_done ;
}
if ( rmonHttpUtil_get_response ( remoteLoggingAudit ) != PASS )
goto _remote_logging_handler_done ;
_remote_logging_handler_done:
/* This is needed to get out of the loop */
event_base_loopbreak((struct event_base *)arg);
}
/*****************************************************************************
*
* Name : rmonHdlr_remotelogging_query
*
* Purpose : Send a HTTP remotelogging show request
*
*****************************************************************************/
int rmonHdlr_remotelogging_query (resource_config_type * ptr)
{
// we want this handler to run once every 5 minutes
// rmon currently runs once every 30 seconds
static bool first_execution = true;
static int exec_counter = 9;
exec_counter = (exec_counter + 1) % 10;
if(exec_counter != 0)
{
return 0;
}
// extract the ip and port for the remote logging server
FILE* pFile;
string remote_ip_address = "";
string remote_port = "";
string transport_type = "";
string line;
bool feature_enabled = false;
std::ifstream syslog_config("/etc/syslog-ng/syslog-ng.conf");
// look for this line in the config file:
// destination remote_log_server {tcp("128.224.140.219" port(514));};
while(std::getline(syslog_config, line))
{
// include remotelogging.conf is present if the feature is enabled
if(line.find("@include \"remotelogging.conf\"") == 0)
{
feature_enabled = true;
}
if(line.find("destination remote_log_server") != 0)
{
continue;
}
int start = line.find("{") + 1;
int end = line.find("(", start + 1);
transport_type= line.substr(start, end - start);
start = line.find("\"") + 1;
end = line.find("\"", start + 1);
remote_ip_address = line.substr(start, end - start);
start = line.find("port(") + 5;
end = line.find(")", start + 1);
remote_port = line.substr(start, end - start);
}
syslog_config.close();
// cleanup of any alarms if the remotelogging feature is not enabled
// this is important for when users turn off the remote logging feature when an alarm is active
// if the line containing this information is not in config, remote logging is not used
if(remote_ip_address.empty() || remote_port.empty() || transport_type.empty() || !feature_enabled)
{
// currently, only controllers raise alarms
if(is_controller())
{
// clear any raised alarms
if(ptr->alarm_raised)
{
rmon_ctrl_type* _rmon_ctrl_ptr;
_rmon_ctrl_ptr = get_rmon_ctrl_ptr();
AlarmFilter alarmFilter;
snprintf(alarmFilter.alarm_id, FM_MAX_BUFFER_LENGTH, REMOTE_LOGGING_CONTROLLER_CONNECTIVITY_ALARM_ID);
snprintf(alarmFilter.entity_instance_id, FM_MAX_BUFFER_LENGTH,
"%s", _rmon_ctrl_ptr->my_hostname);
int rc;
if ((rc = rmon_fm_clear(&alarmFilter)) != FM_ERR_OK)
{
wlog ("Failed to clear stale remotelogging connectivity alarm for"
"entity instance id: %s error: %d",
alarmFilter.entity_instance_id, rc);
}
else
{
ptr->alarm_raised = false;
}
}
}
return 0;
}
// construct the remote logging server IP string
// the files being looked at(/proc/net/tcp(udp)) uses hex values, so convert the
// string we got from the config file to that format
// - convert all numbers to hex and hex to capitals
// reverse ordering of the "ipv4" values
std::stringstream config_ip(remote_ip_address); // the ip string from the config file
std::stringstream proc_file_ip; // the ip string formatted to compare to /proc/net/tcp(udp)
int ipv = 4;
// IPv4
if(remote_ip_address.find(".") != string::npos)
{
// ipv4 example: config file 10.10.10.45, /proc/net/tcp 2D0A0A0A
int a, b, c, d;
char trash;
config_ip >> a >> trash >> b >> trash >> c >> trash >> d;
proc_file_ip << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << d;
proc_file_ip << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << c;
proc_file_ip << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << b;
proc_file_ip << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << a;
proc_file_ip << ":";
proc_file_ip << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << atoi(remote_port.c_str());
}
// IPv6
else if (remote_ip_address.find(":") != string::npos)
{
ipv = 6;
// ipv6 example: config file 0:0:0:0:ffff:0:80e0:8d6c , /proc/net/tcp6 0000000000000000FFFF00006C8D0E080
int a, b, c, d;
char trash;
// first, the hex that are in the same order from config to /proc/net/...
for(int i = 0; i < 6; i++)
{
config_ip >> std::hex >> a >> trash;
proc_file_ip << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << a;
}
// now the hex that needs to be re ordered
config_ip >> std::hex >> a >> trash >> c;
b = (a & 0xFF);
a = (a >> 8);
d = (c & 0xFF);
c = (c >> 8);
proc_file_ip << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << d;
proc_file_ip << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << c;
proc_file_ip << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << b;
proc_file_ip << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << a;
proc_file_ip << ":";
proc_file_ip << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << atoi(remote_port.c_str());
}
// garbage
else
{
wlog("Unrecognized ip format in syslog config file\n");
}
string connection_check_filename;
if(transport_type == "tcp")
{
connection_check_filename = "tcp";
}
else if (transport_type == "udp")
{
connection_check_filename = "udp";
}
// todo: eventually we will have TLS as a transport type and potentially others
else
{
wlog("Unrecognized remote logging transport type: %s \n", transport_type.c_str());
}
if(ipv == 6)
{
connection_check_filename = connection_check_filename + "6";
}
std::string command = "cat /proc/net/" + connection_check_filename +" | awk '{print $3 \" \" $4}' | grep " \
+ proc_file_ip.str() + " | awk '{print $2}'";
if(!(pFile = popen(command.c_str(), "r")))
{
elog ("Failed to execute command for getting remotelogging tcp port status");
}
else
{
char cmd_output[CONNECTION_STATUS_COMMAND_OUTPUT_BUFFER_SIZE];
int connection_status = 0;
rmon_ctrl_type* _rmon_ctrl_ptr;
_rmon_ctrl_ptr = get_rmon_ctrl_ptr();
AlarmFilter alarmFilter;
SFmAlarmDataT active_alarm;
memset(cmd_output, 0, CONNECTION_STATUS_COMMAND_OUTPUT_BUFFER_SIZE);
fgets((char*) &cmd_output, CONNECTION_STATUS_COMMAND_OUTPUT_BUFFER_SIZE, pFile);
pclose(pFile);
std::stringstream s(cmd_output);
s >> std::hex >> connection_status;
snprintf(alarmFilter.alarm_id, FM_MAX_BUFFER_LENGTH, REMOTE_LOGGING_CONTROLLER_CONNECTIVITY_ALARM_ID);
snprintf(alarmFilter.entity_instance_id, FM_MAX_BUFFER_LENGTH,
"%s", _rmon_ctrl_ptr->my_hostname);
if(first_execution)
{
if (fm_get_fault (&alarmFilter, &active_alarm) == FM_ERR_OK)
{
ptr->alarm_raised = true;
}
else
{
ptr->alarm_raised = false;
}
}
if(connection_status == 1)
{
if(is_controller())
{
// connection is established, clear the alarm
if(ptr->alarm_raised)
{
int rc;
if ((rc = rmon_fm_clear(&alarmFilter)) != FM_ERR_OK)
{
wlog ("Failed to clear stale remotelogging connectivity alarm for"
"entity instance id: %s error: %d",
alarmFilter.entity_instance_id, rc);
}
else
{
ptr->alarm_raised = false;
}
}
}
}
else
{
if(is_controller())
{
// connection is not established, raise an alarm
if (!ptr->alarm_raised)
{
int rc;
alarmData = \
create_remoteLogging_controller_connectivity_alarm(alarmData,
alarmFilter);
if ((rc = rmon_fm_set(&alarmData, NULL)) != FM_ERR_OK)
{
wlog("Failed to create alarm %s for entity instance id: %s"
"error: %d \n", REMOTE_LOGGING_CONTROLLER_CONNECTIVITY_ALARM_ID,
alarmData.entity_instance_id, (int) rc);
}
else
{
ptr->alarm_raised = true;
}
}
}
else
{
elog ("%s cannot connect to remote log server", _rmon_ctrl_ptr->my_hostname);
}
}
}
return 0;
}

View File

@ -1,852 +0,0 @@
#ifndef __INCLUDE_RMON_HH__
#define __INCLUDE_RMON_HH__
/*
* Copyright (c) 2013-2017 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
/*
* This implements the CGCS Resource Monitor ; /usr/local/bin/rmond
* The Resource monitor or rmon is a utility to provide: cpu, memory and
* filesystem usage and alarm stats both to the user and to registered client
* processes on the host it is running on.
*
* Call trace is as follows:
* daemon_init
* rmon_timer_init
* rmon_hdlr_init
* daemon_files_init
* daemon_signal_init
* daemon_configure
* ini_parse
* get_debug_options
* get_iface_macaddr
* get_iface_address
* get_iface_hostname
* socket_init
* rmon_msg_init
* setup_tx_port
*
* daemon_service_run
* wait for goenable signal
* rmon_send_event ( READY )
* rmon_service
* _config_dir_load
* _config_files_load
* _forever
* service_events:
* _get_events every audit period seconds
* resource_handler handles the resource values and sends
* alarm messages through fm api to set or clear resource
* thresholds as well as notifying registered clients through
* the rmon client api.
*
*
*
*
* This daemon waits for a "goenabled" signal an then reads all the resource
* configuration files in: /etc/rmon.d and begins monitoring them accordingly.
* A resource confguration file is expected to contain the following information:
*
* [resource]
* resource = <string> ; name of resource being monitored
* debounce = <int> ; number of seconds to wait before degrade clear
* severity = <string> ; minor, major, critical
* minor_threshold = <int> ; minor resource utilization threshold
* major_threshold = <int> ; major resource utilization threshold
* critical_threshold = <int> ; critical resource utilization threshold
* num_tries = <int> ; number of tries before the alarm is raised or cleared
* alarm_on = <int> ; dictates whether maintainance gets alarms from rmon
* 1 for on, 0 for off
*
* Here is how it works ...
*
* Every audit period seconds the resources defined in the config files get
* monitored. If the resource ie. CPU usage crosses a threshold:
* (minor, major or critical) count times an alarm is raised and message is sent to
* all clients registered for the resource. If the resource usage drops below
* that threshold count times, the alarms are cleared and a message is sent to
* all registered clients in order to clear the alarm. The audit period as well as
* other rmon config options are specifiedin the: /etc/mtc/rmond.conf file with
* the following (example) information:
*
* ; CGTS Resource Monitor Configuration File
* [config] ; Configuration
* audit_period = 10 ; Resource polling period in seconds (1 - 120)
*
* rmon_tx_port = 2101 ; Transmit Event and Command Reply Port
* per_node = 0 ; enable (1) or disable (0) memory checking per processor node
* rmon_api_port = 2300 : Resource Monitor API Receive Port
*
* [defaults]
*
* [timeouts]
* start_delay = 10 ; managed range 1 .. 120 seconds
*
* [features]
*
* [debug] ; SIGHUP to reload
* debug_timer = 0 ; enable(1) or disable(0) timer logs (tlog)
* debug_msg = 0 ; enable(1) or disable(0) message logs (mlog)
* debug_state = 0 ; enable(1) or disable(0) state change logs (clog)
* debug_level = 0 ; decimal mask 0..15 (8,4,2,1)
*
* flush = 0 ; enable(1) or disable(0) force log flush (main loop)
* flush_thld = 2 ; if enabled - force flush after this number of loops
*
* debug_event = none ; Not used
* debug_filter = none ; Not used
* stress_test = 0 ; In-Service Stress test number
*
* To check the alarms that are raised the command:
* system alarm-list can be used. Rmon alarms have the following codes:
*
* 100.101: CPU usage threshold crossed
* 100.102: vSwitch CPU usage threshold crossed
* 100.103: Memory usage threshold crossed
* 100.104: Filesystem usage threshold crossed
*
* To register your process for rmon notifications using the rmon client api
* please see the files: rmon_api.h for usage of the api as well as:
* rmon_api_client_test.cpp and rmon_api_client_test.h for an example
* implementation for your process.
*
*/
/**
* @file
* Wind River CGCS Platform Resource Monitor Service Header
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netdb.h> /* for hostent */
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h> /* for close and usleep */
#include <sys/stat.h>
#include <math.h> /* for round */
#include "nodeBase.h"
#include "daemon_ini.h" /* Ini Parser Header */
#include "daemon_common.h" /* Common definitions and types for daemons */
#include "daemon_option.h" /* Common options for daemons */
#include "nodeTimers.h" /* maintenance timer utilities start/stop */
#include "nodeUtil.h" /* common utilities */
#include "tokenUtil.h" /* for ... keystone_config_handler */
#include "fmAPI.h"
#include "httpUtil.h" /* for ... libEvent */
extern "C"
{
#include "rmon_api.h" /* for ... resource monitoring utilities */
}
/**
* @addtogroup RMON_base
* @{
*/
using namespace std;
#ifdef __AREA__
#undef __AREA__
#endif
#define __AREA__ "mon"
/* openstack Identity version */
#define OS_IDENTITY_VERSION_PREFIX ((const char *)"/v3")
/* Config and resource files used by rmon */
#define CONFIG_DIR ((const char *)"/etc/rmon.d")
#define INT_CONFIG_DIR ((const char *)"/etc/rmon_interfaces.d")
#define COMPUTE_VSWITCH_DIR ((const char *)"/etc/nova/compute_extend.conf")
#define COMPUTE_RESERVED_CONF ((const char *)"/etc/platform/worker_reserved.conf")
#define DYNAMIC_FS_FILE ((const char *)"/etc/rmonfiles.d/dynamic.conf")
#define STATIC_FS_FILE ((const char *)"/etc/rmonfiles.d/static.conf")
// this path is different in Wind River Linux vs. CentOS.
// For the latter, we shall look specifically within
// the bonding interface device directory
#define INTERFACES_DIR ((const char *)"/sys/class/net/")
#define PLATFORM_DIR ((const char *)"/etc/platform/platform.conf")
#define MOUNTS_DIR ((const char *)"/proc/mounts")
#define COMPUTE_CONFIG_PASS ((const char *)"/var/run/.config_pass")
#define COMPUTE_CONFIG_FAIL ((const char *)"/var/run/.config_fail")
#define RMON_FILES_DIR ((const char *)"/etc/rmonfiles.d")
#define NTPQ_QUERY_SCRIPT ((const char *)"query_ntp_servers.sh")
/* Constant search keys used to update rmon resource usage */
#define CPU_RESOURCE_NAME ((const char *)"Platform CPU Usage")
#define V_CPU_RESOURCE_NAME ((const char *)"vSwitch CPU Usage")
#define MEMORY_RESOURCE_NAME ((const char *)"Platform Memory Usage")
#define FS_RESOURCE_NAME ((const char *)"Platform Filesystem Usage")
#define INSTANCE_RESOURCE_NAME ((const char *)"Platform Nova Instances")
#define V_MEMORY_RESOURCE_NAME ((const char *)"vSwitch Memory Usage")
#define V_PORT_RESOURCE_NAME ((const char *)"vSwitch Port Usage")
#define V_INTERFACE_RESOURCE_NAME ((const char *)"vSwitch Interface Usage")
#define V_LACP_INTERFACE_RESOURCE_NAME ((const char *)"vSwitch LACP Interface Usage")
#define V_OVSDB_RESOURCE_NAME ((const char *)"vSwitch OVSDB Usage")
#define V_NETWORK_RESOURCE_NAME ((const char *)"vSwitch Network Usage")
#define V_OPENFLOW_RESOURCE_NAME ((const char *)"vSwitch Openflow Usage")
#define V_CINDER_THINPOOL_RESOURCE_NAME ((const char *)"Cinder LVM Thinpool Usage")
#define V_NOVA_THINPOOL_RESOURCE_NAME ((const char *)"Nova LVM Thinpool Usage")
#define REMOTE_LOGGING_RESOURCE_NAME ((const char *)"Remote Logging Connectivity")
/* dynamic resources used for thin provisioning monitoring */
#define CINDER_VOLUMES ((const char *)"cinder-volumes")
#define NOVA_LOCAL ((const char *)"nova-local")
#define RMON_RESOURCE_NOT ((const char *)"read_dynamic_file_system")
#define RESPONSE_RMON_RESOURCE_NOT ((const char *)"/var/run/.dynamicfs_registered")
#define POSTGRESQL_FS_PATH ((const char *)"/var/lib/postgresql")
#define RESOURCE_DISABLE (0)
/* Thin provisioning metadata monitoring */
#define THINMETA_FSM_RETRY 3
#define THINMETA_CONFIG_SECTION "thinpool_metadata"
#define THINMETA_DEFAULT_CRITICAL_THRESHOLD 0 // feature is disabled by default
#define THINMETA_DEFAULT_ALARM_ON 1 // alarm is enabled
#define THINMETA_DEFAULT_AUTOEXTEND_ON 1 // autoextend is enabled (only if monitoring is enabled!)
#define THINMETA_DEFAULT_AUTOEXTEND_BY 20 // autoextend by 20%, same as example in /etc/lvm/lvm.conf
#define THINMETA_DEFAULT_AUTOEXTEND_PERCENT 1 // autoextend by a percentage
#define THINMETA_DEFAULT_AUDIT_PERIOD 10 // seconds to perform audit, same as LVM (broken) audit of lvmetad
#define THINMETA_RESULT_BUFFER_SIZE (1024) // result for lvm commands may be bigger than default BUFFER_SIZE
#define THINMETA_INVALID_NAME ((const char *) "invalid name!")
/* Constant search keys used to update rmon interface usage */
#define MGMT_INTERFACE_NAME ((const char *)"mgmt")
#define INFRA_INTERFACE_NAME ((const char *)"infra")
#define OAM_INTERFACE_NAME ((const char *)"oam")
#define MGMT_INTERFACE_FULLNAME ((const char *)"management_interface")
#define OAM_INTERFACE_FULLNAME ((const char *)"oam_interface")
#define INFRA_INTERFACE_FULLNAME ((const char *)"infrastructure_interface")
/* Daemon Config Constants */
#define CONFIG_AUDIT_PERIOD 1
#define PM_AUDIT_PERIOD 15
#define NTP_AUDIT_PERIOD 600 //10 minutes
#define NTPQ_CMD_TIMEOUT 60 //1 minute
#define CONFIG_TX_PORT 2
#define CONFIG_RX_PORT 4
#define CONFIG_CRITICAL_THR 5
#define CONFIG_NODE 12
#define CONFIG_START_DELAY 20
/* rmon resource default percent thresholds */
#define DEFAULT_MINOR (80)
#define DEFAULT_MAJOR (90)
#define DEFAULT_CRITICAL (95)
#define UNUSED_CRITICAL (101)
/* processor node0 default memory thresholds */
#define DEFAULT_MINOR_ABS_NODE0 (512)
#define DEFAULT_MAJOR_ABS_NODE0 (307)
#define DEFAULT_CRITICAL_ABS_NODE0 (102)
#define UNUSED_CRITICAL_ABS_NODE0 (0)
/* processor node1 default memory thresholds */
#define DEFAULT_MINOR_ABS_NODE1 (0)
#define DEFAULT_MAJOR_ABS_NODE1 (0)
#define DEFAULT_CRITICAL_ABS_NODE1 (0)
/* absolute threshold array index */
#define RMON_MINOR_IDX (0)
#define RMON_MAJOR_IDX (1)
#define RMON_CRITICAL_IDX (2)
/* Defualt startup settings */
#define DEFAULT_NUM_TRIES (2) /* Number of tries before an alarm is set or cleared */
#define DEFAULT_ALARM_STATUS (1) /* Alarms are on by default */
#define DEFAULT_PERCENT (1) /* Percentage thresholds are used by default */
#define PERCENT_USED (1) /* Percent is used for the resource */
#define PERCENT_UNUSED (0) /* Absolute values are used for the resource */
#define DYNAMIC_ALARM (1) /* Filesystem alarm is a dynamic alarm, persisting among nodes */
#define STATIC_ALARM (2) /* Filesystem alarm is a local, static resource */
#define STANDARD_ALARM (3) /* Alarm is not a filesystem alarm */
#define HUGEPAGES_NODE 0 /* 0 or 1 for per hugepages node memory stats */
#define PROCESSOR_NODE 0 /* 0 or 1 for per processor node memory stats */
#define ALARM_OFF 0 /* Do not notify maintainance if alarm off */
#define ALARM_ON 1 /* Notify maintainance if alarm on */
#define PASS (0)
#define FAIL (1)
/* Monitored Resource severity levels */
#define SEVERITY_MINOR 0
#define SEVERITY_MAJOR 1
#define SEVERITY_CRITICAL 2
#define SEVERITY_CLEARED 3
#define MINORLOG_THRESHOLD (20)
#define PROCLOSS_THRESHOLD (5)
#define MAX_RESOURCES (100)
#define MAX_FILESYSTEMS (100)
#define MAX_BASE_CPU (100)
#define DEGRADE_CLEAR_MSG ((const char *)("cleared_degrade_for_resource"))
/* File System Custum Thresholds */
#define TMPFS_MINOR (8)
#define TMPFS_MAJOR (6)
#define TMPFS_CRITICAL (4)
#define BOOTFS_MINOR (200)
#define BOOTFS_MAJOR (100)
#define BOOTFS_CRITICAL (50)
#define MAX_FAIL_SEND (10)
#define MAX_SWACT_COUNT (10)
/* Percent thresholds Database monitoring */
#define FS_MINOR (70)
#define FS_MAJOR (80)
#define FS_CRITICAL (90)
/* Resource Alarm ids */
#define CPU_ALARM_ID ((const char *)"100.101")
#define V_CPU_ALARM_ID ((const char *)"100.102")
#define MEMORY_ALARM_ID ((const char *)"100.103")
#define FS_ALARM_ID ((const char *)"100.104")
#define INSTANCE_ALARM_ID ((const char *)"100.105")
#define OAM_PORT_ALARM_ID ((const char *)"100.106")
#define OAM_ALARM_ID ((const char *)"100.107")
#define MGMT_PORT_ALARM_ID ((const char *)"100.108")
#define MGMT_ALARM_ID ((const char *)"100.109")
#define INFRA_PORT_ALARM_ID ((const char *)"100.110")
#define INFRA_ALARM_ID ((const char *)"100.111")
#define VRS_PORT_ALARM_ID ((const char *)"100.112") //used for HP branch only
#define VRS_ALARM_ID ((const char *)"100.113") //used for HP branch only
#define NTP_ALARM_ID ((const char *)"100.114")
#define V_MEMORY_ALARM_ID ((const char *)"100.115")
#define V_CINDER_THINPOOL_ALARM_ID ((const char *)"100.116")
#define V_NOVA_THINPOOL_ALARM_ID ((const char *)"100.117")
#define THINMETA_ALARM_ID ((const char *)"800.103")
// ripped from fm-api constants for Neutron AVS alarms
// being moved over to RMON
#define V_PORT_ALARM_ID ((const char *)"300.001")
#define V_INTERFACE_ALARM_ID ((const char *)"300.002")
// remote logging alarm ID
#define REMOTE_LOGGING_CONTROLLER_CONNECTIVITY_ALARM_ID ((const char *)"100.118")
// SDN specific alarms
#define V_OPENFLOW_CONTROLLER_ALARM_ID ((const char *)"300.012")
#define V_OPENFLOW_NETWORK_ALARM_ID ((const char *)"300.013")
#define V_OVSDB_MANAGER_ALARM_ID ((const char *)"300.014")
#define V_OVSDB_ALARM_ID ((const char *)"300.015")
#define INTERFACE_NAME_LEN (10)
#define INTERFACE_UP (1)
#define INTERFACE_DOWN (0)
#define MAX_CLIENTS (100)
#define RMON_MAX_LEN (100)
#define MOUNTED (1)
#define NOT_MOUNTED (0)
#define MTC_EVENT_RMON_READY (0x0f0f0f0f)
#define NTP_ERROR (255)
/** Daemon Config Mask */
#define CONF_MASK (CONFIG_AUDIT_PERIOD |\
PM_AUDIT_PERIOD |\
NTP_AUDIT_PERIOD |\
NTPQ_CMD_TIMEOUT |\
CONFIG_NODE |\
CONFIG_START_DELAY |\
CONFIG_TX_PORT |\
CONFIG_RX_PORT |\
CONFIG_CRITICAL_THR)
#define CONF_RMON_API_MASK (CONF_PORT | \
CONF_PERIOD | \
CONF_TIMEOUT | \
CONF_THRESHOLD)
#define RMON_MIN_START_DELAY (1)
#define RMON_MAX_START_DELAY (120)
#define RMON_MIN_AUDIT_PERIOD (10) /* Minimum audit period for resource if none specified */
#define RMON_MAX_AUDIT_PERIOD (120) /* Maximum audit period for resource if none specified */
#define RMON_MIN_PM_PERIOD (60) /* Minimum pm period for resource if none specified */
#define RMON_MAX_PM_PERIOD (600) /* Maximum pm period for resource if none specified */
#define RMON_MIN_NTP_AUDIT_PERIOD (10) /* Minimum audit period for resource if none specified */
#define RMON_MAX_NTP_AUDIT_PERIOD (1200) /* Maximum audit period for resource if none specified */
/* Monitored Resource Config Bit Mask */
#define CONF_RESOURCE (0x01)
#define CONF_STYLE (0x04)
#define CONF_SEVERITY (0x20)
#define CONF_INTERVAL (0x40)
#define CONF_DEBOUNCE (0x80)
/* Usual buffer sizes */
#define RATE_THROTTLE (6)
#define BUFFER_SIZE (128)
/* Monitored Resource stages for resource handler fsm */
typedef enum
{
RMON_STAGE__INIT,
RMON_STAGE__START,
RMON_STAGE__MANAGE,
RMON_STAGE__MONITOR_WAIT,
RMON_STAGE__MONITOR,
RMON_STAGE__RESTART_WAIT,
RMON_STAGE__IGNORE,
RMON_STAGE__FINISH,
RMON_STAGE__FAILED,
RMON_STAGE__FAILED_CLR,
RMON_STAGE__STAGES,
} rmonStage_enum ;
typedef enum
{
NTP_STAGE__BEGIN,
NTP_STAGE__EXECUTE_NTPQ,
NTP_STAGE__EXECUTE_NTPQ_WAIT,
NTP_STAGE__STAGES,
} ntpStage_enum ;
/* The return values from the ntpq querie */
typedef enum
{
NTP_OK = 0, /* All NTP servers are reachable and one is selected */
NTP_NOT_PROVISIONED = 1, /* No NTP servers are provisioned */
NTP_NONE_REACHABLE = 2, /* None of the NTP servers are reachable */
NTP_SOME_REACHABLE = 3, /* Some NTP servers are reachable and one selected */
NTP_SOME_REACHABLE_NONE_SELECTED = 4 /* Some NTP servers are reachable but none is selected, will treat at as none reachable */
} NTPQueryStatus;
typedef enum
{
RESOURCE_TYPE__UNKNOWN,
RESOURCE_TYPE__FILESYSTEM_USAGE,
RESOURCE_TYPE__MEMORY_USAGE,
RESOURCE_TYPE__CPU_USAGE,
RESOURCE_TYPE__DATABASE_USAGE,
RESOURCE_TYPE__NETWORK_USAGE,
RESOURCE_TYPE__PORT,
RESOURCE_TYPE__INTERFACE,
RESOURCE_TYPE__CONNECTIVITY,
} resType_enum ;
/* Structure to store memory stats (KiB) */
typedef struct
{
unsigned long int MemTotal;
unsigned long int MemFree;
unsigned long int Buffers;
unsigned long int Cached;
unsigned long int SlabReclaimable;
unsigned long int CommitLimit;
unsigned long int Committed_AS;
unsigned long int HugePages_Total;
unsigned long int HugePages_Free;
unsigned long int FilePages;
unsigned long int Hugepagesize;
unsigned long int AnonPages;
} memoryinfo;
#define RMON_API_MAX_LEN (100)
typedef struct
{
int tx_sock ; /**< socket to monitored process */
int tx_port ; /**< port to monitored process */
struct sockaddr_in tx_addr ; /**< process socket attributes */
char tx_buf[RMON_API_MAX_LEN]; /**< Server receive buffer */
socklen_t len ; /**< Socket Length */
} rmon_api_socket_type ;
typedef struct
{
/* Config Items */
unsigned int mask ;
resType_enum res_type ; /* specifies the generic resource type */
const char * resource ; /* The name of the Resource being monitored */
const char * severity ; /* MINOR, MAJOR or CRITICAL for each resource */
unsigned int debounce ; /* Period to wait before clearing alarms */
unsigned int minor_threshold; /* % Value for minor threshold crossing */
unsigned int major_threshold; /* % Value for major threshold crossing */
unsigned int critical_threshold; /* % Value for critical threshold crossing */
unsigned int minor_threshold_abs_node0; /* Absolute value for minor threshold crossing processor node 0 */
unsigned int major_threshold_abs_node0; /* Absolute value for major threshold crossing processor node 0 */
unsigned int critical_threshold_abs_node0; /* Absolute value for critical threshold crossing processor node 0 */
unsigned int minor_threshold_abs_node1; /* Absolute value for minor threshold crossing processor node 1 */
unsigned int major_threshold_abs_node1; /* Absolute value for major threshold crossing processor node 1 */
unsigned int critical_threshold_abs_node1; /* Absolute value for critical threshold crossing processor node 1 */
unsigned int num_tries ; /* Number of times a resource has to be in
failed or cleared state before sending alarm */
unsigned int alarm_status ; /* 1 or 0. If it is 0 threshold crossing alarms are not sent */
unsigned int percent ; /* 1 or 0. If it is 1, the percentage is used, otherwise if 0,
the absolute value is used for thresholds crossing values */
unsigned int alarm_type; /* standard, dynamic or static */
/* Dynamic Data */
const char * type ;
const char * device ;
int i ; /* timer array index */
unsigned int debounce_cnt ; /* running monitor debounce count */
unsigned int minorlog_cnt ; /* track minor log count for thresholding */
unsigned int count ; /* track the number of times the condition has been occured */
bool failed ; /* track if the resource needs to be serviced by the resource handler */
double resource_value ; /* Usage for the Linux blades: controller, worker and storage */
double resource_prev ; /* the previous resource_value */
int sev ; /* The severity of the failed resource */
rmonStage_enum stage ; /* The stage the resource is in within the resource handler fsm */
char alarm_id[FM_MAX_BUFFER_LENGTH] ; /* Used by FM API, type of alarm being raised */
char errorMsg[ERR_SIZE];
rmon_api_socket_type msg;
bool alarm_raised ;
int failed_send ; /* The number of times the rmon api failed to send a message */
int mounted ; /* 1 or 0 depending on if the dynamic fs resource is mounted */
int socket_id ; /* socket id corresponding to a physical processor */
int response_error_log_throttle; /* log throttle counter for error in receiving response for resource info */
int parse_error_log_throttle ; /* log throttle counter for failing to parse resource info */
int key_error_log_throttle ; /* log throttle counter for failing to obtain resource info */
int resource_monitor_throttle ; /* log throttle for the this resource being monitored */
} resource_config_type ;
typedef struct
{
/* Config Items */
unsigned int mask ;
const char * resource ; /* The name of the Resource being monitored */
const char * severity ; /* MINOR, MAJOR or CRITICAL for each resource */
unsigned int debounce ; /* Period to wait before clearing alarms */
unsigned int num_tries ; /* Number of times a resource has to be in
failed or cleared state before sending alarm */
unsigned int alarm_status ; /* 1 or 0. If it is 0 threshold crossing alarms are not sent */
/* Dynamic Data */
int i ; /* timer array index */
char interface_one[20] ; /* primary interface */
char interface_two[20] ; /* second interface if lagged */
char bond[20] ; /* bonded interface name */
bool lagged ; /* Lagged interface=true or not=false */
unsigned int debounce_cnt ; /* running monitor debounce count */
unsigned int minorlog_cnt ; /* track minor log count for thresholding */
unsigned int count ; /* track the number of times the condition has been occured */
bool failed ; /* track if the resource needs to be serviced by the resource handler */
int resource_value ; /* 1 if the interface is up and 0 if it is down */
int resource_value_lagged ; /* 1 if the interface is up and 0 if it is down for lagged interfaces */
int sev ; /* The severity of the failed resource */
rmonStage_enum stage ; /* The stage the resource is in within the resource handler fsm */
char int_name[INTERFACE_NAME_LEN] ; /* Name of the tracked interface ex: eth1 */
char alarm_id[FM_MAX_BUFFER_LENGTH] ; /* Used by FM API, type of alarm being raised */
char alarm_id_port[FM_MAX_BUFFER_LENGTH] ; /* Used by FM API, type of alarm being raised for the ports */
char errorMsg[ERR_SIZE];
rmon_api_socket_type msg;
bool link_up_and_running; /* whether the interface is up or down initially */
bool interface_used; /* true if the interface is configured */
bool alarm_raised;
int failed_send; /* The number of times the rmon api failed to send a message */
} interface_resource_config_type ;
typedef struct
{
/* Config Items */
const char * vg_name ; /* LVM Volume Group name */
const char * thinpool_name ; /* LVM Thin Pool in VG to monitor */
unsigned int critical_threshold ; /* critical alarm threshold percentage for metadata utilization,
0 to disable monitoring*/
unsigned int alarm_on ; /* 1 or 0. 1 to enable critical alarm, 0 to disable it */
unsigned int autoextend_on ; /* 1 or 0. 1 to first try extending the metadata before
raising alarm, 0 for autoextend off */
unsigned int autoextend_by ; /* autoextend by percentage or absolute value in MiB */
unsigned int autoextend_percent ; /* use percent or MiB in autoexent_by */
unsigned int audit_period ; /* frequency at which resources are polled, in seconds */
/* Dynamic Data */
bool section_exists ; /* will be 1 if [THINMDA_CONFIG_SECTION] section is defined in
configuration file */
double resource_value ; /* metadata usage percent */
double resource_prev ; /* the previous value */
bool alarm_raised ; /* track if alarm is raised to avoid re-raising */
bool first_run ; /* to check for state consistency on first run */
rmonStage_enum stage ; /* The stage the resource is in within the resource handler fsm */
} thinmeta_resource_config_type;
/** Daemon Service messaging socket control structure **/
typedef struct
{
int rmon_tx_sock; /**< RMON API Tx Socket */
int rmon_tx_port; /**< RMON API Tx Port */
struct sockaddr_in rmon_tx_addr; /**< RMON API Tx Address */
int rmon_rx_sock; /**< RMON API Rx Socket */
int rmon_rx_port; /**< RMON API Rx Port */
struct sockaddr_in rmon_rx_addr; /**< RMON API Rx Address */
int netlink_sock; /**< Netlink event socket */
int ioctl_sock;
msgSock_type mtclogd ;
} rmon_socket_type ;
rmon_socket_type * rmon_getSock_ptr ( void );
typedef struct
{ char resource[50];
char registered_not[NOT_SIZE] ; /* The api notification the client has registerted for */
char client_name[NOT_SIZE] ; /* The api notification the client has registerted for */
/** RMON API socket */
/* ------------------------------------ */
rmon_api_socket_type msg ; /**< Resource monitoring messaging interface */
/* RMON API Dynamic Data */
/* ------------------------------ */
bool resource_failed ; /**< resource monitoring failed signal */
unsigned int tx_sequence ; /**< outgoing sequence number */
unsigned int rx_sequence ; /**< incoming sequence number */
bool waiting ; /**< waiting for response */
int port ;
unsigned int msg_count ;/**< running pulse count */
unsigned int b2b_miss_peak ; /**< max number of back to back misses */
unsigned int b2b_miss_count ; /**< current back to back miss count */
unsigned int afailed_count ; /**< total resouce mon'ing failed count */
unsigned int recv_err_cnt ; /**< counts the receive errors */
unsigned int send_err_cnt ; /**< counts the transmit errors */
unsigned int send_msg_count ; /**< number of messages sent */
unsigned int mesg_err_cnt ; /**< response message error count */
unsigned int mesg_err_peak ; /**< response message error count */
unsigned int adebounce_cnt ; /**< resource monitor debounce counter */
bool resource_debounce ; /**< true = in resource mon'ing debounce */
rmon_socket_type rx_sock ; /* rx socket for that client */
} registered_clients;
void rmon_msg_init ( void );
void rmon_msg_fini ( void );
int setup_tx_port ( const char * iface , const char * mcast , int port );
int rmon_send_event ( unsigned int event_cmd , const char * process_name_ptr );
/* Note: Any addition to this struct requires explicit
* init in daemon_init.
* Cannot memset a struct contianing a string type.
**/
typedef struct
{
/* iface attributes ; hostname, ip, audit period and mac address */
char my_hostname [MAX_HOST_NAME_SIZE+1];
string my_macaddr ;
int audit_period ; /* Frequency at which resources are polled */
int pm_period ; /* Frequency at which ceilometer PM's are created */
int ntp_audit_period; /* Frequency at which we check if the NTP servers are still reachable */
int ntpq_cmd_timeout; /* Max amount of time in seconds to wait for the ntpq command to complete */
string my_address ;
int resources ; /**< Number of Monitored resources */
int interface_resources ; /**< Number of monitored interface resources */
int thinmeta_resources; /**< Number of monitored thinpool metadata resources */
int per_node ; /* Memory checking per node enabled: 1 or disabled: 0 */
int clients ;
int rmon_critical_thr ;
int fd; /* Used for inotify */
int wd; /* Used for inotify */
unsigned int function ;
unsigned int subfunction ;
unsigned int nodetype ;
} rmon_ctrl_type ;
bool is_controller ( void );
/* Init tx message */
void rmon_msg_init ( void );
/* Delete tx message */
void rmon_msg_fini ( void );
/* Initizialize the settings from the rmond.conf file */
int rmon_hdlr_init ( rmon_ctrl_type * ctrl_ptr );
/* Initialize the timers */
void rmon_timer_init( void );
/* Service client register and deregister requests
* when rmon was not alive */
void rmon_alive_notification (int & clients);
/* Service inbox when rmon is born */
int rmon_service_file_inbox ( int clients, char buf[RMON_MAX_LEN], bool add=true );
/* rmon_api functions */
int rmon_service_inbox ( int clients );
/* Send set or clear alarm notification to registered clients */
int rmon_send_request ( resource_config_type * ptr, int clients);
/* send rmon interface resource set and clear alarm messages to registered client processes */
int send_interface_msg ( interface_resource_config_type * ptr, int clients);
/* Init rmon api tx and rx ports */
int rmon_port_init ( int tx_port );
/* Main loop to poll and handle resource monitoring */
void rmon_service (rmon_ctrl_type * ctrl_ptr);
/* Update the number of registered clients */
void update_total_clients (int total_clients);
/* Add a registered client to the list of clients */
void add_registered_client (registered_clients client);
/* Read in the per resource specific thresholds */
int rmon_resource_config ( void * user,
const char * section,
const char * name,
const char * value);
/* Read in the per interface resource specific values */
int rmon_interface_config ( void * user,
const char * section,
const char * name,
const char * value);
/* Read in LVM Thinpool metadata resource specific values */
int rmon_thinmeta_config ( void * user,
const char * section,
const char * name,
const char * value);
/* Returns a registered client at a given index */
registered_clients * get_registered_clients_ptr ( int index );
/* read the dynamic file systems file and send a response back */
void process_dynamic_fs_file();
/* send the notification that the file has been read */
int rmon_resource_response ( int clients );
/* Updates the interface data structure with the state (up or down) of the interface */
void check_interface_status( interface_resource_config_type * ptr );
/* Check if the node is a worker node */
bool check_worker();
/* Handle failed platform interfaces */
void interface_handler( interface_resource_config_type * ptr );
/* Handle LVM thinpool metadata usage */
int thinmeta_handler( thinmeta_resource_config_type * ptr );
/* Compute the thinpool metadata usage for a specific LVM thinpool */
int calculate_metadata_usage(thinmeta_resource_config_type * ptr);
/* Returns the reference to the rmon control pointer */
rmon_ctrl_type * get_rmon_ctrl_ptr ();
/* Initialize LVM Thin Pool Metadata monitoring */
void thinmeta_init(thinmeta_resource_config_type * res, struct mtc_timer * timers, int count);
/* Clears any previously raised interface alarms if rmon is restarted */
void interface_alarming_init ( interface_resource_config_type * ptr );
/* Map an interface (mgmt, oam or infra) to a physical port */
void init_physical_interfaces ( interface_resource_config_type * ptr );
/* returns true if the link is up for the specified interface */
int get_link_state ( int ioctl_socket, char iface[20], bool * running_ptr );
/* Service state changes for monitored interfaces */
int service_interface_events ( int nl_socket , int ioctl_socket );
/* Set the interface resource in the correct state for the interface resource handler */
void service_resource_state ( interface_resource_config_type * ptr );
/* Get the interface resource by index */
interface_resource_config_type * get_interface_ptr ( int index );
/* Get the resource by index */
resource_config_type * get_resource_ptr ( int index );
/* Resource monitor handler cleanup */
void rmon_hdlr_fini ( rmon_ctrl_type * ctrl_ptr );
void build_entity_instance_id ( resource_config_type *ptr, char *entity_instance_id);
/* Resource monitor FM interface */
void rmon_fm_init ( void );
void rmon_fm_handler ( void );
EFmErrorT rmon_fm_set ( const SFmAlarmDataT *alarm, fm_uuid_t *fm_uuid );
EFmErrorT rmon_fm_clear ( AlarmFilter *alarmFilter );
EFmErrorT rmon_fm_get ( AlarmFilter *alarmFilter, SFmAlarmDataT **alarm, unsigned int *num_alarm );
/* Save dynamic memory resource (both system memory and AVS memory) */
int save_dynamic_mem_resource ( string resource_name, string criticality,
double r_value, int percent, int abs_values[3],
const char * alarm_id, int socket_id /*=0*/ );
/* Resource failure processing for percentage based thresholds */
void process_failures ( resource_config_type * ptr );
/* Resource failure processing for absolute based thresholds */
void process_failures_absolute ( resource_config_type * ptr );
// convert Severity level into literal defination
static inline string FmAlarmSeverity_to_string(EFmAlarmSeverityT severity)
{
switch (severity) {
case FM_ALARM_SEVERITY_CLEAR:
return "clear";
case FM_ALARM_SEVERITY_WARNING:
return "warning";
case FM_ALARM_SEVERITY_MINOR:
return "minor";
case FM_ALARM_SEVERITY_MAJOR:
return "major";
case FM_ALARM_SEVERITY_CRITICAL:
return "critical";
default:
return NULL;
}
}
/****************************************************************************
*
* Name : log_value
*
* Purpose : Log resource state values while avoiding log flooding for
* trivial fluxuations.
*
* Description: Recommends whether the current resource state value should
* be logged based on current, previous and step values.
*
* Caller should not generate such log if a false is returned.
*
* A true is returned if the currrent and previous resource values differ
* by +/- step amount.
*
* The caller specifies the step that can be overridden by a smaller value
* in rmond.conf:log_step value.
*
* If step is zero then a true is always returned in support of a debug mode
* where we get the current reading as a log on every audit.
*
* The callers previous value is updated to current whenever true is returned.
*
****************************************************************************/
/* a default step value ; change of + or - 5 triggers log */
#define DEFAULT_LOG_VALUE_STEP (5)
bool log_value ( double & current, double & previous, int step );
#endif /* __INCLUDE_RMON_HH__ */

View File

@ -1,50 +0,0 @@
#ifndef __INCLUDE_RMONAPI_H__
#define __INCLUDE_RMONAPI_H__
/*
* Copyright (c) 2013, 2017 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
#include <iostream>
#include <string>
#include "rmonHttp.h"
/**
* @file
* Wind River CGTS Platform
*
* rmon API Header
*/
#define RMON_PUT_VSWITCH_OPER_LABEL "v1"
#define RMON_PUT_VSWITCH "/engine/stats"
/* Poll request is a GET operation that looks like this ...
*
* http://localhost:9000/v1/engine/stats
* The following defines are used to help construct that request
*
*/
/** Initializes the module */
int rmonApi_init ( string ip, int port );
/** Frees the module's dynamically allocated resources */
void rmonApi_fini ( void );
/**remote logging service request handlers */
void rmonHdlr_remotelogging_handler ( struct evhttp_request *req, void *arg );
int rmonHdlr_remotelogging_query (resource_config_type * ptr);
/**ceilometer sample create request handlers */
void rmonHdlr_ceilometer_handler ( struct evhttp_request *req, void *arg );
#endif

View File

@ -1,51 +0,0 @@
#
# Copyright (c) 2014-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
SRCS = rmon_api.c
OBJS = $(SRCS:.c=.o)
INCLUDES = -I.
LDFLAGS = -shared
CFLAGS = -fPIC -g -O2 -Wall -Wextra -Werror
TARGET_LIB = librmonapi.so
lib: build
ifeq (,$(shell which ${CC}))
CC=gcc
endif
STATIC_ANALYSIS_TOOL = cppcheck
STATIC_ANALYSIS_TOOL_EXISTS = $(shell [[ -e `which $(STATIC_ANALYSIS_TOOL)` ]] && echo 1 || echo 0)
.c.o:
$(CC) $(INCLUDES) $(CFLAGS) $(EXTRACCFLAGS) -c $< -o $@
static_analysis:
ifeq ($(STATIC_ANALYSIS_TOOL_EXISTS), 1)
$(STATIC_ANALYSIS_TOOL) --language=c++ --enable=warning -U__AREA__ -DWANT_FIT_TESTING *.cpp *.h
else
echo "Warning: '$(STATIC_ANALYSIS_TOOL)' static analysis tool not installed ; bypassing ..."
endif
build: static_analysis ${TARGET_LIB}
${TARGET_LIB}: ${TARGET_LIB}.${VER_MJR}
ln -sf $^ $@
${TARGET_LIB}.${VER_MJR}: ${TARGET_LIB}.${VER}
ln -sf $^ $@
${TARGET_LIB}.${VER}: $(OBJS)
$(CC) ${LDFLAGS} -Wl,-soname,${TARGET_LIB}.${VER_MJR} -o $@ $^
$(SRCS:.c=.d):%.d:%.c
$(CC) $(CFLAGS) -MM $< >$@
include $(SRCS:.c=.d)
clean:
@rm -v -f *.o
@rm -v -f *.so
@rm -v -f *.so.*
@rm -v -f *.d

View File

@ -1,475 +0,0 @@
/*
* Copyright (c) 2013, 2016 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
/**
* @file
* Wind River CGCS Platform Resource Monitor Client Notification API Library
* See rmon_api.h for API header.
*
**/
#include "rmon_api.h"
#include <sys/file.h>
/* Pass code */
#ifndef PASS
#define PASS (0)
#endif
/* Fail Code */
#ifndef FAIL
#define FAIL (1)
#endif
/* Retry Code */
#ifndef RETRY
#define RETRY (2)
#endif
/* maximum string and socket endpoint path length */
#define RMON_MAX_LEN (100)
/* initialization signature to gate functional
* api calls made prior to initialization */
#define INIT_SIG (0xffffdead)
/* rmon default messaging port */
#define RMONTXPORT 2300
/** Control Structure */
typedef struct
{
unsigned int init ; /**< Init signature */
int client_rx_sock ; /**< inet pulse request rx socket */
int client_rx_port ; /**< inet pulse request rx port number */
struct sockaddr_in client_rx_addr ; /**< inet pulse request rx attributes */
char client_rx_buf[RMON_MAX_LEN] ;
int rmon_tx_sock ; /**< inet pulse response tx socket */
int rmon_tx_port ; /**< inet pulse response tx port number */
struct sockaddr_in rmon_tx_addr ; /**< inet pulse response tx attributes */
char rmon_tx_buf[RMON_MAX_LEN] ;
int rmon_rx_sock ; /**< inet pulse response rx socket */
int rmon_rx_port ; /**< inet pulse response rx port number */
struct sockaddr_in rmon_rx_addr ; /**< inet pulse response rx attributes */
char rmon_rx_buf[RMON_MAX_LEN] ;
char name[RMON_MAX_LEN] ; /**< name of process using this instance */
bool debug_mode ; /**< debug mode if true */
int fit_code ; /**< fit code MAGIC, SEQ, PROCESS */
} resource_mon_socket_type ;
/* Instance Control Structure - Per Process Private Data */
static resource_mon_socket_type rmon ;
/* Mutex For sending client process information to rmon */
pthread_mutex_t client_mutex;
int remove_rmon_client( const char * process_name_ptr, int socket );
int add_rmon_client ( const char * process_name_ptr, int port , const char * registration, int rx_port);
int resource_monitor_initialize ( const char * process_name_ptr, int port , const char * registration);
int resource_monitor_deregister( const char * process_name_ptr, int socket );
int resource_monitor_get_sel_obj ( void );
int remove_rmon_client( const char * process_name_ptr, int socket );
void resource_monitor_finalize ();
int create_tx_socket();
/* Create and Setup Inet Transmit Socket
* return PASS (0) on success
* -# on kernel call error
* non-zero on internal error
*
**/
int create_tx_socket( int rx_port )
{
int val = 1 ;
int ok = 1 ;
rmon.rmon_tx_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if ( 0 >= rmon.rmon_tx_sock )
{
syslog ( LOG_ERR, "create_tx_socket failed to create 'tx' socket (%d:%m)", errno );
return (-errno);
}
if ( setsockopt ( rmon.rmon_tx_sock , SOL_SOCKET, SO_REUSEADDR, &val, sizeof(int)) == -1 )
{
syslog ( LOG_WARNING, "create_tx_socket failed to set 'tx' socket as reusable (%d:%m)", errno );
}
/* Setup with localhost ip */
memset(&rmon.rmon_tx_addr, 0, sizeof(struct sockaddr_in));
rmon.rmon_tx_addr.sin_family = AF_INET ;
rmon.rmon_tx_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
rmon.rmon_tx_addr.sin_port = htons(RMONTXPORT) ;
rmon.rmon_tx_port = RMONTXPORT ;
/* Set socket to be non-blocking. */
int rc = ioctl(rmon.rmon_tx_sock, FIONBIO, (char *)&ok);
if ( 0 > rc )
{
syslog ( LOG_WARNING, "create_tx_socket failed to set 'tx' socket as non-blocking (%d:%m)\n", errno );
}
/* if the sock is already open then close it first */
if ( rmon.rmon_rx_sock )
{
close (rmon.rmon_rx_sock);
}
rmon.rmon_rx_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if ( 0 >= rmon.rmon_rx_sock )
{
syslog ( LOG_WARNING, "create_rx_socket failed (%d:%m)\n", errno );
return (-errno);
}
if ( setsockopt ( rmon.rmon_rx_sock , SOL_SOCKET, SO_REUSEADDR, &val, sizeof(int)) == -1 )
{
syslog ( LOG_WARNING, "create_tx_socket failed to set 'rx' socket as reusable (%d:%m)", errno );
}
/* Setup with localhost ip */
memset(&rmon.rmon_rx_addr, 0, sizeof(struct sockaddr_in));
rmon.rmon_rx_addr.sin_family = AF_INET ;
rmon.rmon_rx_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
rmon.rmon_rx_addr.sin_port = htons(rx_port) ;
rmon.rmon_rx_port = rx_port ;
/* Set socket to be non-blocking. */
rc = ioctl(rmon.rmon_rx_sock, FIONBIO, (char *)&ok);
if ( 0 > rc )
{
syslog ( LOG_ERR, "create_tx_socket failed to set 'rx' socket as non-blocking (%d:%m)\n", errno );
return -errno;
}
/* bind socket to the receive addr */
if ( bind ( rmon.rmon_rx_sock, (const struct sockaddr *)&rmon.rmon_rx_addr, sizeof(struct sockaddr_in)) == -1 )
{
syslog ( LOG_ERR, "failed to bind rmon 'rx' socket with port %d (%d:%m)\n", rx_port, errno );
close (rmon.rmon_rx_sock);
rmon.rmon_rx_sock = 0 ;
return -errno;
}
return PASS;
}
/* open lo socket */
int add_rmon_client ( const char * process_name_ptr, int port , const char * registration, int rx_port)
{
struct stat p ;
int val = 1 ;
memset ( &rmon, 0, sizeof(rmon));
memset ( &p, 0 , sizeof(struct stat));
if ( registration == NULL )
{
syslog ( LOG_INFO, "resource_monitor_initialize called with null registration info");
return (0);
}
syslog ( LOG_INFO , "Add Client '%s' to rmon (port:%d)\n", registration, port );
sprintf ( rmon.name, "/var/run/%s.rmon", process_name_ptr );
stat ( rmon.name, &p ) ;
if ((p.st_ino != 0 ) && (p.st_dev != 0))
{
rmon.debug_mode = true ;
syslog ( LOG_INFO, "Enabling resource Monitor Debug Mode\n");
if ( p.st_size )
{
FILE * filename = fopen ( rmon.name, "rb" ) ;
if ( filename != NULL )
{
memset ( &rmon.name, 0, RMON_MAX_LEN);
if ( fgets ( rmon.name, 20, filename ) != NULL )
{
if ( !strncmp ( rmon.name, FIT_MAGIC_STRING, strlen (FIT_MAGIC_STRING)))
{
rmon.fit_code = FIT_MAGIC ;
syslog ( LOG_INFO, "Enabling FIT on 'magic calculation'\n");
}
else if ( !strncmp ( rmon.name, FIT_SEQUENCE_STRING, strlen(FIT_SEQUENCE_STRING)))
{
rmon.fit_code = FIT_SEQ ;
syslog ( LOG_INFO, "Enabling FIT on 'sequence number'\n");
}
else if ( !strncmp ( rmon.name, FIT_PROCESS_STRING, strlen(FIT_PROCESS_STRING)))
{
rmon.fit_code = FIT_PROCESS ;
syslog ( LOG_INFO, "Enabling FIT on 'process name'\n");
}
else
{
syslog ( LOG_INFO, "Unsupported FIT string (%s)\n", rmon.name );
}
}
fclose (filename);
}
else
{
syslog ( LOG_INFO, "Failed to open %s\n", rmon.name);
}
}
}
/* Init the control struct - includes all members */
memset ( rmon.name, 0, RMON_MAX_LEN);
if ( process_name_ptr )
{
memcpy ( rmon.name, process_name_ptr, strlen (process_name_ptr)) ;
}
else
{
syslog ( LOG_INFO, "resource_monitor_initialize called with null process name");
return (0);
}
/*******************************************************/
/* Create and Setup Inet Receive Socket */
/*******************************************************/
rmon.client_rx_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if ( 0 >= rmon.client_rx_sock )
{
syslog ( LOG_INFO, "add_rmon_client error:1");
return (0);
}
if ( setsockopt ( rmon.client_rx_sock , SOL_SOCKET, SO_REUSEADDR, &val, sizeof(int)) == -1 )
{
syslog ( LOG_INFO, "%s failed to set socket as re-useable (%d:%s)\n",
process_name_ptr, errno, strerror(errno));
}
/* Setup with localhost ip */
memset(&rmon.client_rx_addr, 0, sizeof(struct sockaddr_in));
rmon.client_rx_addr.sin_family = AF_INET ;
rmon.client_rx_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
rmon.client_rx_addr.sin_port = htons(port) ;
rmon.client_rx_port = port ;
/* bind socket to the receive addr */
if ( bind ( rmon.client_rx_sock, (const struct sockaddr *)&rmon.client_rx_addr, sizeof(struct sockaddr_in)) == -1 )
{
syslog ( LOG_ERR, "failed to bind to rx socket with port %d\n", port );
close (rmon.client_rx_sock);
rmon.client_rx_sock = 0 ;
return (0);
}
int rc = create_tx_socket ( rx_port );
if (rc != PASS )
{
syslog ( LOG_ERR, "add_rmon_client failed to create_tx_socket (rc:%d)", rc );
return (0);
}
if ((registration != NULL) && (rc == PASS))
{
int bytes = 0;
#ifdef WANT_CLIENT_REGISTER_SOCKET_SEND
socklen_t len = sizeof(struct sockaddr_in) ;
/* client registering, send rmon the resources registered for */
memset(rmon.rmon_tx_buf, 0, sizeof(rmon.rmon_tx_buf));
snprintf(rmon.rmon_tx_buf, sizeof(rmon.rmon_tx_buf), "%s %s %d", process_name_ptr, registration, port);
bytes = sendto ( rmon.rmon_tx_sock, &rmon.rmon_tx_buf, strlen(rmon.rmon_tx_buf), 0,
(struct sockaddr *) &rmon.rmon_tx_addr, sizeof(struct sockaddr_in));
fd_set readfds;
struct timeval waitd;
bytes = 0;
FD_ZERO(&readfds);
FD_SET(rmon.rmon_rx_sock, &readfds);
waitd.tv_sec = WAIT_DELAY;
waitd.tv_usec = 0;
/* This is used as a delay up to select_timeout */
select(FD_SETSIZE, &readfds, NULL, NULL, &waitd);
if (FD_ISSET(rmon.rmon_rx_sock, &readfds))
{
/* wait for the response from rmon to verify that the client is registered */
memset(rmon.rmon_rx_buf, 0, sizeof(rmon.rmon_rx_buf));
rmon.rmon_rx_buf[0] = 0;
bytes = recvfrom( rmon.rmon_rx_sock, rmon.rmon_rx_buf, RMON_MAX_LEN, 0, (struct sockaddr *)&rmon.rmon_rx_addr, &len );
}
#endif
if (bytes <= 0) {
/* no respone, write the client name and notification to a file for later use */
FILE * pFile;
memset(rmon.rmon_rx_buf, 0, sizeof(rmon.rmon_rx_buf));
snprintf(rmon.rmon_rx_buf, sizeof(rmon.rmon_rx_buf), "%s %s %d", process_name_ptr, registration, port);
pFile = fopen (RMON_API_REG_DIR , "a+");
if ( pFile )
{
// take out a writer lock on this file to
// ensure that no other entity is writing to it
// at this time
int lock = flock(fileno(pFile), LOCK_EX);
if (lock < 0) {
syslog (LOG_ERR, "Failed to get exclusive lock on"
" '%s' (errno: %d)", RMON_API_REG_DIR, errno);
} else {
fprintf(pFile, "%s\n", rmon.rmon_rx_buf);
// release write lock
flock(fileno(pFile), LOCK_UN);
}
fclose(pFile);
}
else
{
syslog ( LOG_ERR, "Failed to open '%s'\n", RMON_API_REG_DIR );
}
}
else
{
syslog ( LOG_ERR, "add_rmon_client send message succeeded");
}
/* Set init sig */
rmon.init = INIT_SIG ;
/* Return the socket descriptor */
return (rmon.client_rx_sock);
}
else
{
syslog ( LOG_ERR, "Failed register due to previous failure\n");
}
return (0);
}
int rmon_notification ( const char * notification_name )
{
int port = RMONTXPORT;
int rc;
/* send the message to check the dynamic file */
memset(rmon.rmon_tx_buf, 0, sizeof(rmon.rmon_tx_buf));
snprintf(rmon.rmon_tx_buf, sizeof(rmon.rmon_tx_buf), "%s %s %d", notification_name, RESOURCE_NOT, port);
rc = sendto ( rmon.rmon_tx_sock, &rmon.rmon_tx_buf, strlen(rmon.rmon_tx_buf), 0,
(struct sockaddr *) &rmon.rmon_tx_addr, sizeof(struct sockaddr_in));
return rc;
}
int resource_monitor_initialize ( const char * process_name_ptr, int port , const char * registration)
{
/* use a mutex to prevent multiple clients from registering at once */
int clt_rx_sock;
int rx_port = port - 1;
pthread_mutex_lock(&client_mutex);
clt_rx_sock = add_rmon_client(process_name_ptr, port , registration, rx_port );
pthread_mutex_unlock(&client_mutex);
return clt_rx_sock;
}
int resource_monitor_deregister( const char * process_name_ptr, int socket )
{
/* use a mutex to prevent multiple clients from de-registering at once */
int rc;
pthread_mutex_lock(&client_mutex);
rc = remove_rmon_client(process_name_ptr, socket);
pthread_mutex_unlock(&client_mutex);
return rc;
}
/* */
int resource_monitor_get_sel_obj ( void )
{
if (( rmon.init != INIT_SIG ) || ( rmon.client_rx_sock <= 0 ))
{
syslog (LOG_WARNING , "'%s' called with invalid init (sock:%d)\n",
__FUNCTION__, rmon.client_rx_sock);
}
return (rmon.client_rx_sock);
}
int remove_rmon_client( const char * process_name_ptr, int socket )
{
int rc;
int port = RMONTXPORT;
int bytes;
socklen_t len = sizeof(struct sockaddr_in);
/* client deregistering, send rmon the client process name */
memset(rmon.rmon_tx_buf, 0, sizeof(rmon.rmon_tx_buf));
snprintf(rmon.rmon_tx_buf, sizeof(rmon.rmon_tx_buf), "%s %s %d", process_name_ptr, CLR_CLIENT, port);
rc = sendto ( rmon.rmon_tx_sock, &rmon.rmon_tx_buf, strlen(rmon.rmon_tx_buf), 0,
(struct sockaddr *) &rmon.rmon_tx_addr, sizeof(struct sockaddr_in));
sleep(WAIT_DELAY);
/* wait for the response from rmon to verify that the client is de-registered */
memset(rmon.rmon_rx_buf, 0, sizeof(rmon.rmon_rx_buf));
rmon.rmon_rx_buf[0] = 0;
bytes = recvfrom( rmon.rmon_rx_sock, rmon.rmon_rx_buf, RMON_MAX_LEN, 0, (struct sockaddr *)&rmon.rmon_rx_addr, &len);
if ((bytes <= 0) || (rmon.rmon_rx_buf[0] == 0)) {
FILE * pFile;
memset(rmon.rmon_rx_buf, 0, sizeof(rmon.rmon_rx_buf));
snprintf(rmon.rmon_tx_buf, sizeof(rmon.rmon_tx_buf), "%s %s %d",
process_name_ptr, CLR_CLIENT, port);
pFile = fopen (RMON_API_DEREG_DIR , "a+");
if (pFile) {
// take out a writer lock on this file to
// ensure that no other entity is writing to it
// at this time
int lock = flock(fileno(pFile), LOCK_EX);
if (lock < 0) {
syslog (LOG_ERR, "Failed to get exclusive lock on"
" '%s' (errno: %d)", RMON_API_DEREG_DIR, errno);
} else{
fprintf(pFile, "%s\n", rmon.rmon_rx_buf);
// release the lock
flock(fileno(pFile), LOCK_UN);
}
fclose(pFile);
} else {
syslog (LOG_ERR, "Failed to open '%s'\n",
RMON_API_DEREG_DIR );
}
}
if ( socket )
{
/* close the client receive port */
close (socket);
}
rc = PASS ;
return rc;
}
/* close the rmon ports */
void resource_monitor_finalize ()
{
if ( rmon.rmon_tx_sock )
{
close (rmon.rmon_tx_sock);
}
if ( rmon.rmon_rx_sock )
{
close (rmon.rmon_rx_sock);
}
}

View File

@ -1,142 +0,0 @@
/*
* Copyright (c) 2014, 2016 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
/**
* @file
* Wind River CGCS Platform Resource Monitor Client Notification API Library Header
*/
#include <stdio.h> /* for ... snprintf */
#include <unistd.h> /* for ... unlink, close and usleep */
#include <sys/socket.h> /* for ... socket */
#include <sys/un.h> /* for ... domain socket type */
#include <netinet/in.h> /* for ... inet socket type */
#include <arpa/inet.h> /* for ... inet_addr, inet_ntoa macro */
#include <syslog.h> /* for ... syslog */
#include <errno.h> /* for ... EINTR, errno, strerror */
#include <stdbool.h> /* for ... true and false */
#include <sys/stat.h> /* for ... file stat */
#include <pthread.h> /* for ... mutual exclusion */
#include <stdlib.h>
#include <sys/ioctl.h>
/**
* This is a convenience module in support of resource monitoring notificiations to
* client processes
*
* Packaged as a shared library that processes can link to.
*
* This module provides four simple interfaces to that provide the following general functions
*
* - open an abstract socket interface for resource monitoring messaging
* - return the socket file descriptor for event driven selection
* - service events on socket
* - close the socket when done
*
* *Interfaces including work flow are*
*
* Init:
*
* resource_monitor_initialize ( "testClient" , 2302, CPU_USAGE );
*
* Setup event driven handling:
*
* int resource_monitor_socket = resource_monitor_get_sel_obj();
* FD_SET( resource_monitor_socket, &readfds);
*
* Main loop:
*
* if ( FD_ISSET(resource_monitor_socket, &readfds))
* resource_monitor_dispatch ();
*
* Exit:
*
* resource_monitor_deregister("testClient", 2302);
*
*/
/** Initialize the library and open the messaging socket(s).
*
* Creates socket and binds to named endpoint.
*
* Prints status or errors to syslog.
*
* @param process_name_ptr - char pointer to string containing monitored process name
* @param port - integer specifying the port number this process is listening on
*
* @returns The socket file descriptor on success or negative version of
* standard Linux error numbers (errno) codes from socket(2) or bind(2)
*
**/
/* Notification resource types */
#define CPU_USAGE ((const char *)"cpuUsage")
#define MEMORY_USAGE ((const char *)"memoryUsage")
#define FS_USAGE ((const char *)"fsUsage")
#define ALL_USAGE ((const char *)"allUsage")
#define CLR_CLIENT ((const char *)"clearClient")
#define RESOURCE_NOT ((const char *)"resourceNotification")
#define NOT_SIZE (100)
#define ERR_SIZE (100)
#define MAX_ERR_CNT (5)
/** Supplies the messaging socket file descriptor.
*
* @returns The created socket file descriptor for event driven select
* or zero if initialize was not called of there was error creating
* the socket. A notification message is sent to rmon to tell it that a new client
* is registering for a notification of type resource. From then on, rmon will send
* alarm set and clear messages for that resource to the process until it deregisters.
**/
int resource_monitor_initialize ( const char * process_name_ptr, int port, const char * resource );
int rmon_notification ( const char * notification_name );
/* returns the client socket fd */
int resource_monitor_get_sel_obj ( void );
/** Close the rmon tx socket */
void resource_monitor_finalize ( void );
/** Debug mode is enabled if the following file is found during initialize
*
* /var/run/<process>.debug
*
* Failt Insertion Mode is enabled if the first word of line one
* of this file contains one of the following words
*
* sequence - corrupt the sequence number returned
* magic - corrupt the magic number returned
* process - corrupt the process name returned
*
*/
/* Deregister a client process from rmon notifications */
int resource_monitor_deregister( const char * process_name_ptr, int socket );
/** FAult Insertion Mode Strings */
#define FIT_MAGIC_STRING "magic"
#define FIT_SEQUENCE_STRING "sequence"
#define FIT_PROCESS_STRING "process"
/** Fault Insertion Codes */
#define FIT_NONE 0
#define FIT_MAGIC 1
#define FIT_SEQ 2
#define FIT_PROCESS 3
#define WAIT_DELAY (3)
#define PASS (0)
#define FAIL (1)
/* location of file for registering clients */
#define RMON_API_REG_DIR ((const char *)"/etc/rmonapi.d/register.txt")
/* location of file for deregistering clients */
#define RMON_API_DEREG_DIR ((const char *)"/etc/rmonapi.d/deregister.txt")
/* location of file for the current registered clients */
#define RMON_API_ACTIVE_DIR ((const char *)"/etc/rmonapi.d/active.txt")

View File

@ -1,76 +0,0 @@
/*
* Copyright (c) 2013-2014 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
#define CREATE_REUSABLE_INET_UDP_TX_SOCKET(ip, port, s, a, p, l, n, rc) \
{ \
int on = 1 ; \
s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); \
if ( 0 >= s ) \
{ \
printf ("failed to create '%s' socket (%d:%s)\n", n, errno, strerror(errno)); \
rc = FAIL_SOCKET_CREATE ; \
} \
else if ( setsockopt ( s , SOL_SOCKET, SO_REUSEADDR, &on, sizeof(int)) == -1 ) \
{ \
printf ("failed to make '%s' socket re-useable (%d:%s)\n", n, errno, strerror(errno)); \
close(s); \
s = 0 ; \
rc = FAIL_SOCKET_OPTION ; \
} \
else \
{ \
memset(&a, 0, sizeof(struct sockaddr_in)); \
l = sizeof(a); \
p = port ; \
a.sin_family = AF_INET ; \
a.sin_addr.s_addr = inet_addr(ip); \
a.sin_port = htons(p) ; \
} \
}
#define CREATE_NONBLOCK_INET_UDP_RX_SOCKET(ip, port, s, a, p, l, n, rc) \
{ \
int on = 1 ; \
s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); \
if ( 0 >= s ) \
{ \
printf ("failed to create '%s' socket (%d:%s)\n", n, errno, strerror(errno)); \
rc = FAIL_SOCKET_CREATE ; \
} \
else if ( setsockopt ( s , SOL_SOCKET, SO_REUSEADDR, &on, sizeof(int)) == -1 ) \
{ \
printf ("failed to make '%s' socket re-useable (%d:%s)\n", n, errno, strerror(errno)); \
close(s); \
s = 0 ; \
rc = FAIL_SOCKET_OPTION ; \
} \
else if ( 0 > ioctl(s, FIONBIO, (char *)&on)) \
{ \
printf ("failed to set '%s' socket non-blocking (%d:%s)\n", n, errno, strerror(errno)); \
close(s); \
s = 0 ; \
rc = FAIL_SOCKET_NOBLOCK ; \
} \
else \
{ \
memset(&a, 0, sizeof(struct sockaddr_in)); \
l = sizeof(a); \
p = port ; \
a.sin_family = AF_INET ; \
a.sin_addr.s_addr = inet_addr(ip); \
a.sin_port = htons(p) ; \
if ( bind ( s, (const struct sockaddr *)&a, sizeof(struct sockaddr_in)) == -1 ) \
{ \
printf ( "failed to bind '%s' socket with port %d\n", n, p ); \
close (s); \
s = 0 ; \
rc = -errno; \
} \
printf ("Listening on '%s' socket %s port %d\n", n, inet_ntoa(a.sin_addr), p); \
} \
}

View File

@ -1,22 +0,0 @@
#
# Copyright (c) 2014-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
SRCS = rmon_api_client_test.cpp
OBJS = $(SRCS:.cpp=.o)
LDLIBS = -lstdc++ -lrmonapi
INCLUDES = -I../ -I.
CCFLAGS = -g -O2 -Wall -Wextra -Werror
all: build
.cpp.o:
$(CXX) $(INCLUDES) $(CCFLAGS) $(EXTRACCFLAGS) -c $< -o $@
build: $(OBJS)
$(CXX) $(CCFLAGS) $(OBJS) -L../ -L/usr/lib64/ $(LDLIBS) -o rmond_api_test
clean:
@rm -v -f $(OBJ) rmond_api_test *.o *.a

View File

@ -1,262 +0,0 @@
/*
* Copyright (c) 2014-2015 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
/**
* @file
* Wind River CGTS Platform Resource Monitor API Test Client
*/
/*
*This simulates a test client process to test out the rmon client notification
*api. To run: ./rmond_api_test <port> <processname>
*If left blank it runs with the default port: 2302 and default process name. When testing
*with more than one client test process, these values must be entered. For help:
*./rmond_api_test --help
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netdb.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <list>
using namespace std;
#include "../rmon_nodeMacro.h" /* for ... CREATE_NONBLOCK_INET_UDP_RX_SOCKET */
#include "rmon_api_client_test.h"
extern "C"
{
#include "../rmon_api.h"
}
#define MAX_HOST_NAME_SIZE (100)
#define FAIL_SOCKET_INIT -1
#define FAIL_SOCKET_CREATE -2
#define PASS 0
#define FAIL 1
#define LOOPBACK_IP "127.0.0.1"
#define RX_PORT 2302
static char my_hostname [MAX_HOST_NAME_SIZE+1];
/**
* Messaging Socket Control Struct - The allocated struct
* @see rmon_api_client_test.h for rmon_socket_type struct format.
*/
static rmon_socket_type rmon_sock ;
static rmon_socket_type * sock_ptr ;
/** Client Config mask */
#define CONFIG_CLIENT_MASK (CONFIG_AGENT_PORT |\
CONFIG_CLIENT_API_PORT |\
CONFIG_CLIENT_PORT)
/****************************/
/* Initialization Utilities */
/****************************/
/* Initialize the unicast api response message */
/* One time thing ; tx same message all the time. */
int rmon_message_init ( void )
{
/* Build the transmit api response message */
memset ( &sock_ptr->tx_message, 0, sizeof (rmon_message_type));
memcpy ( &sock_ptr->tx_message.m[RMON_HEADER_SIZE], my_hostname, strlen(my_hostname));
return (PASS);
}
int rmon_socket_init ( int port, const char * process_name )
{
int on = 1 ;
int rc = PASS ;
/***********************************************************/
/* Setup the RMON API Message Receive Socket */
/***********************************************************/
CREATE_NONBLOCK_INET_UDP_RX_SOCKET ( LOOPBACK_IP,
port,
rmon_sock.rmon_api_sock,
rmon_sock.rmon_api_addr,
rmon_sock.rmon_api_port,
rmon_sock.rmon_api_len,
"rmon api socket receive",
rc );
if ( rc ) return (rc) ;
/* Open the active monitoring socket */
rmon_sock.rmon_socket = resource_monitor_initialize ( process_name, port, ALL_USAGE );
printf("Resource Monitor API Socket %d\n", rmon_sock.rmon_socket );
if ( 0 > rmon_sock.rmon_socket )
rmon_sock.rmon_socket = 0 ;
/* Make the resource monitor api socket non-blocking */
rc = ioctl(rmon_sock.rmon_socket, FIONBIO, (char *)&on);
if ( 0 > rc )
{
printf("Failed to set rmon socket non-blocking (%d:%m)\n", errno );
return (FAIL_SOCKET_NOBLOCK);
}
return (PASS);
}
int daemon_init (int port, const char * process_name )
{
int rc = PASS ;
/* Initialize socket construct and pointer to it */
memset ( &rmon_sock, 0, sizeof(rmon_sock));
sock_ptr = &rmon_sock ;
/* Setup the resmon api rx messaging sockets */
if ( (rc = rmon_socket_init (port, process_name)) != PASS )
{
printf ("socket initialization failed (rc:%d)\n", rc );
rc = FAIL_SOCKET_INIT;
}
return (rc);
}
#define RMON_MAX_LEN (100)
int client_service_inbox ( const char * process_name)
{
#define MAX_T 100
int bytes = 0 ;
char buf[RMON_MAX_LEN] ;
socklen_t len = sizeof(struct sockaddr_in) ;
char str[RMON_MAX_LEN];
int sequence = 0;
int rc = FAIL;
do
{
memset ( buf,0,RMON_MAX_LEN);
memset ( str,0,RMON_MAX_LEN);
bytes = recvfrom( rmon_sock.rmon_socket, buf, RMON_MAX_LEN, 0, (struct sockaddr *)&rmon_sock.client_sockAddr, &len);
if ( bytes > 0 )
{
sscanf ( buf, "%s %d", str, &sequence );
if ( str[0] != '\0' )
{
printf("%s \n",str);
if (strstr(str, "cleared_alarms_for_resource:") != NULL) {
/* Sleep for 10 secs */
sleep (10);
rc = resource_monitor_deregister( process_name, rmon_sock.rmon_socket );
if ( rc == PASS ) {
printf("deregistered test client\n");
break;
}
}
}
else
{
printf("Null string !\n");
}
}
else if (( 0 > bytes ) && ( errno != EINTR ) && ( errno != EAGAIN ))
{
printf("problem with test client recv \n");
}
} while ( bytes > 0 ) ;
return rc;
}
#define MAX_LEN 300
int main ( int argc, char *argv[] )
{
int rc = 0 ;
int port = RX_PORT;
const char * process_name = PROCESS_NAME;
if ((argc > 1) && (strcmp(argv[1],"--help") == 0)) {
printf("usage: ./rmond_api_test <port> <process name> \n");
return 0;
}
else if (argc > 1) {
port = atoi(argv[1]);
}
if (argc > 2) {
process_name = argv[2];
}
daemon_init(port, process_name);
rc = rmon_message_init();
if (rc == PASS) {
printf("socket initialized \n");
}
rmon_sock.rmon_socket = resource_monitor_get_sel_obj ();
std::list<int> socks;
socks.clear();
socks.push_front ( rmon_sock.rmon_socket );
socks.sort();
/* Run test loop forever or until stop condition */
for ( ; ; )
{
/* Initialize the timeval struct */
rmon_sock.waitd.tv_sec = 20;
rmon_sock.waitd.tv_usec = 0;
/* Initialize the master fd_set */
FD_ZERO(&rmon_sock.readfds);
FD_SET(rmon_sock.rmon_socket, &rmon_sock.readfds);
rc = select( socks.back()+1,
&rmon_sock.readfds, NULL, NULL,
&rmon_sock.waitd);
/* If the select time out expired then */
if (( rc < 0 ) || ( rc == 0 ))
{
/* Check to see if the select call failed. */
/* ... but filter Interrupt signal */
if (( rc < 0 ) && ( errno != EINTR ))
{
printf ("Socket Select Failed (rc:%d) %s \n", errno, strerror(errno));
}
}
if ( FD_ISSET(rmon_sock.rmon_socket, &rmon_sock.readfds))
{
printf("Resource Monitor API Select Fired got message from rmon:\n");
rc = client_service_inbox(process_name);
if (rc == PASS) {
break;
}
}
}
return 0;
}

View File

@ -1,109 +0,0 @@
/*
* Copyright (c) 2014 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
/**
* @file
* Wind River CGTS Platform Resource Monitor API Test Client Header
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <netdb.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include <signal.h>
/** Maximum service fail count before action */
#define MAX_FAIL_COUNT (1)
#define RMON_HEADER_SIZE (15)
#define RMON_MAX_MSG (50)
#define FAIL_SOCKET_NOBLOCK (36)
#define FAIL_SOCKET_OPTION (38)
/* default process name if none is specified */
#define PROCESS_NAME ((const char *)"testClient")
typedef struct
{
/** Message buffer */
char m [RMON_MAX_MSG];
/** Sequence number */
unsigned int s ;
/* Fast Lookup Clue Info */
unsigned int c ;
/* Status Flags */
/* bit 0: Process Monitor Status: 1=running
* bit 1: tbd */
unsigned int f ;
/* reserved for future use */
unsigned int r ;
} rmon_message_type ;
/** rmon notification api messaging socket control structure */
typedef struct
{
/** Client (compute) socket address attributes
*
* Used by both controller and compute nodes
* when messaging to and from the compute
* node maintenance.
*/
struct sockaddr_in client_addr ;
socklen_t client_addr_len ;
/** Unix domain socket used to transmit on-node event messages
* to from other local services such as rmon - heartbeat service */
int send_event_socket ;
struct sockaddr_un agent_domain ;
socklen_t agent_domain_len ;
/** rmon api Socket using UDP Inet over 'lo' interface */
int rmon_api_sock ; /**< receive rmon pulses socket */
int rmon_api_port ; /**< the port */
struct sockaddr_in rmon_api_addr ; /**< attributes */
socklen_t rmon_api_len ; /**< length */
int rmon_socket ; /**< Active monitor socket */
/** The addr and port are stored in the shared librmonapi.so library */
struct sockaddr_in client_sockAddr ; /**< Client socket attributes */
socklen_t agentLen ; /**< Agent socket attr struct len */
socklen_t clientLen ; /**< Client socket attr struct len */
int tx_socket ; /**< general transmit socket ID */
int rx_socket ; /**< general receive socket ID */
rmon_message_type tx_message ; /**< transmit message */
rmon_message_type rx_message ; /**< receive message */
int rmon_client_port ;
int fail_count ; /**< Socket retry thresholding */
/* For select dispatch */
struct timeval waitd ;
fd_set readfds;
msgSock_type mtclogd ;
} rmon_socket_type ;

View File

@ -1,203 +0,0 @@
/*
* Copyright (c) 2015-2016 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
/**
* @file
* Wind River CGCS Platform Resource Monitor Fault Management
* retry mechanism for fault set/clear failures due to communication
* error.
*/
#include <pthread.h>
#include "rmon.h"
typedef enum
{
CLR_REQUEST = 0,
SET_REQUEST = 1
} fm_req_type_t;
typedef struct fm_req_info
{
fm_req_type_t req_type;
union
{
AlarmFilter alarm_filter;
SFmAlarmDataT alarm;
} _data;
struct fm_req_info *next;
} fm_req_info_t;
typedef struct fm_req_queue
{
fm_req_info_t *head;
fm_req_info_t *tail;
pthread_mutex_t mutex;
} fm_req_queue_t;
static fm_req_queue_t fm_req_q;
static void rmon_fm_enq(fm_req_type_t req, void *data);
static void rmon_fm_deq(void);
/****************************/
/* Initialization Utilities */
/****************************/
void rmon_fm_init (void)
{
fm_req_q.head = NULL;
fm_req_q.tail = NULL;
pthread_mutex_init(&fm_req_q.mutex, NULL);
}
void rmon_fm_fini (void)
{
pthread_mutex_lock(&fm_req_q.mutex);
fm_req_info_t *i = fm_req_q.head;
while (i != NULL) {
fm_req_info_t *n = i->next;
delete i;
i = n;
}
fm_req_q.head = fm_req_q.tail = NULL;
pthread_mutex_unlock(&fm_req_q.mutex);
pthread_mutex_destroy(&fm_req_q.mutex);
}
/***************************/
/* handler function */
/***************************/
void rmon_fm_handler (void)
{
while (fm_req_q.head != NULL) {
EFmErrorT err;
fm_req_info_t *fm_req = fm_req_q.head;
if (fm_req->req_type == CLR_REQUEST) {
ilog("clearing alarm %s", fm_req->_data.alarm_filter.entity_instance_id);
err = fm_clear_fault (&fm_req->_data.alarm_filter);
}
else {
ilog("setting alarm %s", fm_req->_data.alarm.entity_instance_id);
err = fm_set_fault (&fm_req->_data.alarm, NULL);
}
if (err == FM_ERR_NOCONNECT) {
ilog("FM_ERR_NOCONNECT");
return;
}
rmon_fm_deq();
}
}
/*****************************/
/* request functions */
/*****************************/
EFmErrorT rmon_fm_clear (AlarmFilter *alarmFilter)
{
EFmErrorT err = FM_ERR_NOCONNECT;
if (fm_req_q.head == NULL)
err = fm_clear_fault (alarmFilter);
if (err == FM_ERR_NOCONNECT) {
ilog("retry clearing alarm %s", alarmFilter->entity_instance_id);
rmon_fm_enq (CLR_REQUEST, (void *) alarmFilter);
return FM_ERR_OK;
}
return err;
}
EFmErrorT rmon_fm_set (const SFmAlarmDataT *alarm, fm_uuid_t *fm_uuid)
{
EFmErrorT err = FM_ERR_NOCONNECT;
if (fm_req_q.head == NULL)
err = fm_set_fault (alarm, fm_uuid);
if (err == FM_ERR_NOCONNECT) {
ilog("retry setting alarm %s", alarm->entity_instance_id);
rmon_fm_enq (SET_REQUEST, (void *) alarm);
return FM_ERR_OK;
}
return err;
}
EFmErrorT rmon_fm_get (AlarmFilter *alarmFilter, SFmAlarmDataT **alarm, unsigned int *num_alarm)
{
unsigned int n = 0;
EFmErrorT err = FM_ERR_NOT_ENOUGH_SPACE;
while (err == FM_ERR_NOT_ENOUGH_SPACE) {
/* get additional 3 more alarms at a time, as max. number of port alarms
is 6 (2 ports per interface: OAM, INFRA, MGMT */
n += 3;
SFmAlarmDataT *list = (SFmAlarmDataT *) malloc(sizeof(SFmAlarmDataT) * n);
if (list != NULL) {
err = fm_get_faults (&alarmFilter->entity_instance_id, list, &n);
if (err == FM_ERR_OK) {
*alarm = list;
*num_alarm = n;
return FM_ERR_OK;
}
free(list);
}
else {
err = FM_ERR_NOMEM;
}
}
*alarm = NULL;
*num_alarm = 0;
return err;
}
/****************************/
/* queue functions */
/****************************/
void rmon_fm_deq (void)
{
pthread_mutex_lock (&fm_req_q.mutex);
fm_req_info_t *fm_req = fm_req_q.head;
if (fm_req->next == NULL) {
fm_req_q.head = fm_req_q.tail = NULL;
}
else {
fm_req_q.head = fm_req->next;
}
pthread_mutex_unlock (&fm_req_q.mutex);
delete fm_req;
}
void rmon_fm_enq (fm_req_type_t req, void *data)
{
fm_req_info_t *fm_req = new fm_req_info_t;
fm_req->next = NULL;
fm_req->req_type = req;
if (req == CLR_REQUEST)
fm_req->_data.alarm_filter = *((AlarmFilter *)data);
else
fm_req->_data.alarm = *((SFmAlarmDataT *)data);
pthread_mutex_lock (&fm_req_q.mutex);
if (fm_req_q.tail == NULL) {
fm_req_q.head = fm_req_q.tail = fm_req;
}
else {
fm_req_q.tail->next = fm_req;
fm_req_q.tail = fm_req;
}
pthread_mutex_unlock (&fm_req_q.mutex);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,674 +0,0 @@
/*
* Copyright (c) 2013, 2017 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
/**
* @file
* Wind River CGTS Platform rmon HTTP Utilities.
*
*/
#include <time.h>
#include <iostream>
#include <stdio.h>
#include <unistd.h> /* for .. close and usleep */
#include <stdlib.h> /* for .. system */
#include <dirent.h> /* for config dir reading */
#include <list> /* for the list of conf file names */
#include <syslog.h> /* for ... syslog */
#include <sys/wait.h> /* for ... waitpid */
#include "rmon.h"
#include "tokenUtil.h" /* for ... tokenUtil_get_ptr */
using namespace std;
//#include "nodeClass.h" /* for ... maintenance class nodeLinkClass */
#include "rmonHttp.h" /* this module header */
//#include "rmonJsonUtil.h" /* Json Utilities */
#include "rmonApi.h"
extern void rmonHdlr_remotelogging_handler ( struct evhttp_request *req, void *arg );
extern void rmonHdlr_ceilometer_handler( struct evhttp_request *req, void *arg );
void rmonHttpUtil_free_base ( libEvent_type & event );
static node_inv_type default_inv ;
/*****************************************************************************
*
* Name : rmonHttpUtil_libEvent_init
*
* Purpose : Initialize the libEvent message for the HTTP request
*
*****************************************************************************/
int rmonHttpUtil_libEvent_init ( libEvent_type *ptr ,
string service,
string ip,
int port )
{
ptr->type = EVHTTP_REQ_GET ; /* request type GET/PUT/PATCH etc */
/* Characteristics */
ptr->ip = ip ;
ptr->port = port ;
ptr->hostname = "default" ;
/* Controls */
ptr->status = FAIL ; /* The handler must run to make this PASS */
ptr->active = false ;
ptr->mutex = false ;
ptr->stuck = 0 ;
ptr->found = false ;
ptr->count = 0 ;
//ptr->stage = 0 ;
ptr->result = "" ;
ptr->timeout = 0 ;
/* Personality */
ptr->service = service ;
ptr->request = RMON_SERVICE_NONE ;
/* Execution Data */
ptr->entity_path.clear() ;
ptr->entity_path_next.clear() ;
ptr->address.clear();
ptr->payload.clear();
ptr->response.clear();
ptr->user_agent.clear();
/* Better to access a default struct than a bad pointer */
ptr->inv_info_ptr = &default_inv ;
/* Check for memory leaks */
if ( ptr->base )
{
slog ("rmon http base memory leak avoidance (%p) fixme !!\n", ptr->base);
event_base_free(ptr->base);
}
/* Create event base - like opening a socket */
ptr->base = event_base_new();
if ( ! ptr->base )
{
elog ("Failed to create '%s' libEvent (event_base_new)\n",
ptr->service.c_str());
return(FAIL_EVENT_BASE) ;
}
return (PASS);
}
void rmonHttpUtil_start_timer ( libEvent_type & event )
{
clock_gettime (CLOCK_MONOTONIC, &event.start_ts );
}
void rmonHttpUtil_stop_timer ( libEvent_type & event )
{
clock_gettime (CLOCK_MONOTONIC, &event.stop_ts );
}
/* ***********************************************************************
*
* Name : rmonHttpUtil_free_conn
*
* Description: Free an event's connection memory if it exists.
*
* ************************************************************************/
void rmonHttpUtil_free_conn ( libEvent_type & event )
{
if ( event.conn )
{
dlog ("rmond Free Connection (%p)\n", event.conn );
evhttp_connection_free ( event.conn );
event.conn = NULL ;
}
else
{
wlog ("rmond Already Freed Connection\n");
}
}
/* ***********************************************************************
*
* Name : rmonHttpUtil_free_base
*
* Description: Free an event's base memory if it exists.
*
* ************************************************************************/
void rmonHttpUtil_free_base ( libEvent_type & event )
{
/* Free the base */
if ( event.base )
{
dlog ("rmond Free Base (%p)\n", event.base );
event_base_free(event.base);
event.base = NULL ;
if ( event.conn )
{
dlog ("rmond Free Connection (%p) --------- along with base\n", event.conn );
evhttp_connection_free ( event.conn );
event.conn = NULL ;
}
}
else
{
wlog ("rmond Already Freed Event Base\n");
}
}
/*****************************************************************************
*
* Name : rmonHttpUtil_connect_new
*
* Purpose : generic HTTP Conect utility
*
*****************************************************************************/
int rmonHttpUtil_connect_new ( libEvent_type & event )
{
if ( event.base )
{
/* Open an http connection to specified IP and port */
event.conn = evhttp_connection_base_new ( event.base, NULL,
event.ip.c_str(),
event.port );
if ( event.conn )
{
dlog("connect successfull \n");
return(PASS) ;
}
else
{
elog ("Failed to create http connection (evhttp_connection_base_new)\n");
return (FAIL_CONNECT);
}
}
else
{
elog ("Null Event base\n");
return (FAIL_EVENT_BASE);
}
}
/* generic HTTP Conect utility */
int rmonHttpUtil_request_new ( libEvent_type & event,
void(*hdlr)(struct evhttp_request *, void *))
{
int rc = PASS ;
/* make a new request and bind the event handler to it */
event.req = evhttp_request_new( hdlr , event.base );
if ( ! event.req )
{
dlog ("call to 'evhttp_request_new' returned NULL\n");
rc = FAIL ;
}
return (rc);
}
/* Fill in the output buffer */
/* return of 0 or -1 are errors */
int rmonHttpUtil_payload_add ( libEvent_type & event )
{
int rc = PASS ;
/* Returns the output buffer. */
event.buf = evhttp_request_get_output_buffer ( event.req );
/* Check for no buffer */
if ( ! event.buf )
{
elog ("evhttp_request_get_output_buffer returned null (%p)\n", event.req );
rc = FAIL ;
}
else
{
/* write the payload into the buffer */
rc = evbuffer_add_printf ( event.buf, "%s", event.payload.c_str());
if ( rc == -1 )
{
elog ("evbuffer_add_printf returned error (-1)\n");
rc = FAIL ;
}
else if ( rc == 0 )
{
elog ("no data added to output buffer (len=0)\n");
rc = FAIL ;
}
else
{
rc = PASS ;
}
}
return (rc);
}
/* get the output buffer length and convert it to a string that is returned */
string rmonHttpUtil_payload_len ( libEvent_type * ptr )
{
string body_len ;
char len_str[10] ;
int len = evbuffer_get_length ( ptr->req->output_buffer ) ;
if (( len == -1 ) || ( len == 0 ))
{
body_len = "" ;
}
else
{
memset ( &len_str[0], 0 , 10 );
sprintf ( &len_str[0], "%d", len );
body_len = len_str ;
dlog3 ("%s Buffer Len:%s\n", ptr->hostname.c_str(), body_len.c_str() );
}
return ( body_len );
}
int rmonHttpUtil_header_add ( libEvent_type * ptr, http_headers_type * hdrs_ptr )
{
int rc = PASS ;
if ( hdrs_ptr->entries > MAX_HEADERS )
{
elog ("%s Too many headers (%d:%d)\n",
ptr->hostname.c_str(), MAX_HEADERS, hdrs_ptr->entries );
return FAIL ;
}
for ( int i = 0 ; i < hdrs_ptr->entries ; i++ )
{
/* Add the header */
rc = evhttp_add_header( ptr->req->output_headers,
hdrs_ptr->entry[i].key.c_str() ,
hdrs_ptr->entry[i].value.c_str());
if ( rc )
{
elog ("evhttp_add_header returned failure (%d:%s:%s)\n", rc,
hdrs_ptr->entry[i].key.c_str(),
hdrs_ptr->entry[i].value.c_str());
rc = FAIL ;
break ;
}
}
return (rc);
}
/*****************************************************************************
*
* Name : rmonHttpUtil_request_make
*
* Purpose : Make the HTTP request
*
*****************************************************************************/
int rmonHttpUtil_request_make ( libEvent_type * ptr,
enum evhttp_cmd_type type,
string path )
{
return (evhttp_make_request( ptr->conn, ptr->req, type, path.data()));
}
/*****************************************************************************
*
* Name : rmonHttpUtil_status
*
* Purpose : Get the status of the HTTP request
*
*****************************************************************************/
int rmonHttpUtil_status ( libEvent_type & event )
{
int rc = PASS ;
event.status = evhttp_request_get_response_code (event.req);
switch (event.status)
{
case HTTP_OK:
case 201:
case 202:
case 203:
case 204:
{
dlog3 ("%s HTTP_OK (%d)\n", event.hostname.c_str(), event.status );
event.status = PASS ;
break;
}
case 401:
{
/* Authentication error - refresh the token */
rc = RETRY ;
break ;
}
case 0:
{
dlog ("%s Status: 0\n", event.hostname.c_str());
event.status = FAIL_HTTP_ZERO_STATUS ;
rc = FAIL_HTTP_ZERO_STATUS ;
break ;
}
default:
{
dlog ("%s Status: %d\n", event.hostname.c_str(), event.status );
rc = event.status ;
break;
}
}
return (rc);
}
/*****************************************************************************
*
* Name : rmonHttpUtil_api_request
*
* Purpose : Issue a HTTP REST API Request
*
*****************************************************************************/
#define URL_LEN 200
int rmonHttpUtil_api_request ( rmon_libEvent_enum request,
libEvent_type & event,
string command_path )
{
http_headers_type hdrs ;
enum evhttp_cmd_type type = EVHTTP_REQ_PUT ;
int timeout = 1 ;
int hdr_entry = 0 ;
string payload = "" ;
int rc = FAIL ;
void(*handler)(struct evhttp_request *, void *) = NULL ;
if ( request == REMOTE_LOGGING_REQUEST )
{
/* Bind the handler for the request */
handler = &rmonHdlr_remotelogging_handler ;
/* The type of HTTP request */
type = EVHTTP_REQ_GET ;
/* set the timeout */
timeout = HTTP_REMOTELOGGING_TIMEOUT ;
}
else if ( request == CEILOMETER_SAMPLE_CREATE )
{
/* Bind the handler for the request */
handler = &rmonHdlr_ceilometer_handler ;
/* The type of HTTP request */
type = EVHTTP_REQ_POST ;
/* set the timeout */
timeout = HTTP_CEILOMETER_TIMEOUT ;
}
else
{
slog ("%s Unsupported Request (%d)\n", event.hostname.c_str(), request);
return (FAIL_BAD_CASE);
}
/* Establish connection */
if ( rmonHttpUtil_connect_new ( event ))
{
return (FAIL_CONNECT);
}
/* Create request */
if ( rmonHttpUtil_request_new ( event, handler ))
{
return (FAIL_REQUEST_NEW);
}
if ( type == EVHTTP_REQ_POST )
{
/* Add payload to the output buffer but only for POST request. */
if ( rmonHttpUtil_payload_add ( event ) )
{
event.status = FAIL_PAYLOAD_ADD;
return ( event.status );
}
if ( daemon_get_cfg_ptr()->debug_json )
{
if ((!string_contains(event.payload,"token")) &&
(!string_contains(event.payload,"assword")))
{
jlog ("%s Payload : %s\n", event.hostname.c_str(),
event.payload.c_str() );
}
else
{
jlog ("%s Payload : ... contains private content ...\n",
event.hostname.c_str());
}
}
}
if ( !command_path.empty() )
{
event.address = command_path ;
dlog (" Address : %s\n", event.address.c_str());
}
/* Build the HTTP Header */
hdrs.entry[hdr_entry].key = "Host" ;
hdrs.entry[hdr_entry].value = event.ip ;
hdr_entry++;
hdrs.entry[hdr_entry].key = "X-Auth-Project-Id" ;
hdrs.entry[hdr_entry].value = "admin";
hdr_entry++;
hdrs.entry[hdr_entry].key = "Content-Type" ;
hdrs.entry[hdr_entry].value = "application/json" ;
hdr_entry++;
hdrs.entry[hdr_entry].key = "Accept" ;
hdrs.entry[hdr_entry].value = "application/json" ;
hdr_entry++;
if ( request == CEILOMETER_SAMPLE_CREATE )
{
hdrs.entry[hdr_entry].key = "User-Agent" ;
hdrs.entry[hdr_entry].value = event.user_agent ;
hdr_entry++;
hdrs.entry[hdr_entry].key = "X-Auth-Token" ;
hdrs.entry[hdr_entry].value = tokenUtil_get_ptr()->token ;
hdr_entry++;
}
hdrs.entry[hdr_entry].key = "Connection" ;
hdrs.entry[hdr_entry].value = "close" ;
hdr_entry++;
hdrs.entries = hdr_entry ;
/* Add the headers */
if ( rmonHttpUtil_header_add ( &event, &hdrs ))
{
return (FAIL_HEADER_ADD);
}
rc = rmonHttpUtil_request_make ( &event, type, event.address.data() );
if ( rc == PASS )
{
/* Send the message with timeout */
evhttp_connection_set_timeout(event.req->evcon, timeout);
event_base_dispatch(event.base);
rmonHttpUtil_free_conn ( event );
rmonHttpUtil_free_base ( event );
return(event.status) ;
}
elog ("%s Call to 'evhttp_make_request' failed (rc:%d)\n",
event.hostname.c_str(), rc);
return (FAIL_MAKE_REQUEST);
}
/*****************************************************************************
*
* Name : rmonHttpUtil_receive
*
* Purpose : Get the HTTP request response into a libEvent object
*
*****************************************************************************/
int rmonHttpUtil_receive ( libEvent_type & event )
{
/* Send the request but don't wait for the response */
// int rc = event_base_loop(event.base, EVLOOP_NONBLOCK) ;
int rc = event_base_loop(event.base, EVLOOP_ONCE) ;
switch ( rc )
{
case PASS: /* 0 */
{
/* Set in-progress flag */
if ( event.active == false )
{
/* look at the reported handler status */
if ( event.status != PASS )
rc = event.status ;
rmonHttpUtil_log_event ( event );
}
else
{
rc = RETRY ;
}
break ;
}
case 1:
{
dlog ("%s %s No Events Pending (1)\n",
event.hostname.c_str(),
event.service.c_str());
rc = FAIL ;
break ;
}
case -1:
{
event.active = false ;
elog ("%s %s Failed event_base_loop (-1)\n",
event.hostname.c_str(),
event.service.c_str());
rc = FAIL ;
break ;
}
default:
{
event.active = false ;
slog ("%s %s Failed event_base_loop - Unexpected Return (%d)\n",
event.hostname.c_str(),
event.service.c_str(), rc );
rc = FAIL ;
break ;
}
}
return (rc);
}
/* Get the length of the json response
* Deal with oversized messages.
*
* Get the length of the buffer so we can
* allocate one big enough to copy too.
*/
int rmonHttpUtil_get_length ( libEvent_type & event )
{
event.response_len = evbuffer_get_length (event.req->input_buffer);
if ( event.response_len == 0 )
{
dlog ("%s %s Request Failed - Zero Length Response\n",
event.hostname.c_str(),
event.service.c_str());
event.status = FAIL_JSON_ZERO_LEN ;
}
else
{
event.status = PASS ;
}
return ( event.status );
}
/* Load the response string into the event struct */
int rmonHttpUtil_get_response ( libEvent_type & event )
{
if ( rmonHttpUtil_get_length ( event ) == PASS )
{
size_t real_len ;
/* Get a stack buffer, zero it, copy to it and terminate it */
char * stack_buf_ptr = (char*)malloc (event.response_len+1);
memset ( stack_buf_ptr, 0, event.response_len+1 );
real_len = evbuffer_remove( event.req->input_buffer, stack_buf_ptr,
event.response_len);
if ( real_len != event.response_len )
{
wlog ("%s %s Length differs from removed length (%ld:%ld)\n",
event.hostname.c_str(),
event.service.c_str(),
event.response_len,
real_len );
}
/* Terminate the buffer , this is where the +1 above is required.
* Without it there is memory corruption reported by Linux */
*(stack_buf_ptr+event.response_len) = '\0';
/* Store the response */
event.response = stack_buf_ptr ;
dlog ("%s Response: %s\n", event.hostname.c_str(), event.response.c_str());
free (stack_buf_ptr);
}
return ( event.status );
}
/*****************************************************************************
*
* Name : rmonHttpUtil_log_event
*
* Purpose : Log the HTTP event
*
*****************************************************************************/
void rmonHttpUtil_log_event ( libEvent_type & event )
{
string event_sig = daemon_get_cfg_ptr()->debug_event ;
dlog3 ("Event Signature (%s)\n", event_sig.c_str());
if ( !event_sig.compare(event.service) || (event.status))
{
if ( !event.address.empty() )
{
log_event ("%s %s Address : %s\n", event.hostname.c_str(), event_sig.c_str(), event.address.c_str());
}
if (!event.payload.empty())
{
if ((!string_contains(event.payload,"token")) &&
(!string_contains(event.payload,"assword")))
{
log_event ("%s %s Payload : %s\n", event.hostname.c_str(), event_sig.c_str(), event.payload.c_str());
}
else
{
log_event ("%s %s Payload : ... contains private content ...\n", event.hostname.c_str(), event_sig.c_str());
}
}
if ( !event.response.empty() )
{
if ((!string_contains(event.payload,"token")) &&
(!string_contains(event.payload,"assword")))
{
log_event ("%s %s Response: %s\n", event.hostname.c_str(), event_sig.c_str(), event.response.c_str());
}
else
{
log_event ("%s %s Response: ... contains private content ...\n", event.hostname.c_str(), event_sig.c_str());
}
}
}
}

View File

@ -1,161 +0,0 @@
#ifndef __INCLUDE_rmonHTTPUTIL_H__
#define __INCLUDE_rmonHTTPUTIL_H__
/*
* Copyright (c) 2013, 2017 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
/**
* @file
* Wind River CGTS Platform rmon
*
* libevent HTTP support utilities and control structure support header
*/
#include <iostream> /* for ... string */
#include <evhttp.h> /* for ... http libevent client */
using namespace std;
/** Maximum libevent response message size in bytes. */
#define MAX_EVENT_LEN (16384)
#define HTTP_VSWITCH_TIMEOUT (10)
#define HTTP_REMOTELOGGING_TIMEOUT (10)
#define HTTP_CEILOMETER_TIMEOUT (10)
#define VSWITCH_EVENT_SIG "vswitchEvent"
#define REMOTE_LOGGING_EVENT_SIG "remoteLoggingEvent"
#define CEILOMETER_EVENT_SIG "ceilometerEvent"
/** Request Type Enums for the common rmonHttpUtil_request utility */
typedef enum {
RMON_SERVICE_NONE,
VSWITCH_REQUEST,
REMOTE_LOGGING_REQUEST,
CEILOMETER_SAMPLE_CREATE
} rmon_libEvent_enum ;
/** Local event control structure for REST API services
*
* Keystone and Inventory
*
*/
typedef struct
{
/** Execution Controls */
bool mutex ; /**< single operation at a time */
bool active ; /**< true if waiting on response */
int stuck ; /**< Count mutex active stuck state */
int status ; /**< Execution Status */
string result ; /**< Command specific result str */
bool found ; /**< true if query was found */
int timeout ; /**< Request timeout */
int count ; /**< retry recover counter */
int fails ; /**< fail counter */
int retries ; /**< retry counter ; for receive */
string service ; /**< Service being executed */
string hostname ; /**< Target hostname */
string uuid ; /**< The UUID for this request */
string ip ; /**< Server IP address */
rmon_libEvent_enum request ;
int port ; /**< Server port number */
string user_agent ; /**< set the User-Agent header */
enum evhttp_cmd_type type; /**< HTTP Request Type ; PUT/GET */
struct event_base *base; /**< libEvent API service base */
struct evhttp_connection *conn; /**< HTTP connection ptr */
struct evhttp_request *req ; /**< HTTP request ptr */
struct evbuffer *buf ; /**< HTTP output buffer ptr */
struct evbuffer_ptr evp ; /**< HTTP output buffer ptr */
/** Timestamps used to measure the responsiveness of REST API */
struct timespec start_ts ; /**< Request Dispatch Timestamp */
struct timespec stop_ts ; /**< Response Handler Timestamp */
string entity_path ; /**< HTTP entity request string */
string entity_path_next ; /**< next entity request string */
/** Result Info */
node_inv_type * inv_info_ptr ; /**< Inventory data pointer */
string address ; /**< http url address */
string payload ; /**< the request's payload */
size_t response_len ; /**< the json response length */
string response ; /**< the json response string */
} libEvent_type;
int rmonHttpUtil_libEvent_init ( libEvent_type * ptr ,
string service,
string ip,
int port );
void rmonHttpUtil_start_timer ( libEvent_type & event );
void rmonHttpUtil_stop_timer ( libEvent_type & event );
void rmonHttpUtil_log_time ( libEvent_type & event );
/** Maximum number of headers that can be added to an HTTP message. */
#define MAX_HEADERS (10)
#if 0
/** A header entry type. */
typedef struct
{
string key ; /**< the header label. */
string value ; /**< the header value. */
} http_header_entry_type;
/** The header entry table. */
typedef struct
{
int entries ; /**< Number of entries in the header table. */
http_header_entry_type entry[MAX_HEADERS]; /**< entry array. */
} http_headers_type ;
#endif
/** Add payload to the HTTP message body. */
int rmonHttpUtil_payload_add ( libEvent_type & event );
/** Add all headers in header table to the HTTP connection message. */
int rmonHttpUtil_header_add ( libEvent_type * ptr, http_headers_type * hdrs_ptr );
/** Create an HTTP request. */
int rmonHttpUtil_request_make ( libEvent_type * ptr, enum evhttp_cmd_type type, string path );
/** Open a connection to an HTTP server. */
int rmonHttpUtil_connect_new ( libEvent_type & event );
/** Get a new HTTP request pointer. */
int rmonHttpUtil_request_new ( libEvent_type & event,
void(*hdlr)(struct evhttp_request *, void *));
/** Common REST API Request Utility */
int rmonHttpUtil_api_request ( rmon_libEvent_enum request,
libEvent_type & event,
string command_path );
/** Common REST API Request Utility */
int rmonHttpUtil_request ( libEvent_type & event , bool block,
void(*hdlr)(struct evhttp_request *, void *));
/** Common REST API Receive Utility for non-blocking requests */
int rmonHttpUtil_receive ( libEvent_type & event );
/** HTTP response status checker */
int rmonHttpUtil_status ( libEvent_type & event );
/** TODO: FIXME: Get the payload string length. */
string rmonHttpUtil_payload_len ( libEvent_type * ptr );
/** Get the length of the json response */
int rmonHttpUtil_get_length ( libEvent_type & event );
/** Load the json response into the event struct */
int rmonHttpUtil_get_response ( libEvent_type & event );
/** print event filtered event */
void rmonHttpUtil_log_event ( libEvent_type & event );
#endif /* __INCLUDE_rmonHTTPUTIL_H__ */

View File

@ -1,616 +0,0 @@
/*
* Copyright (c) 2013-2017 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
/**
* @file
* Wind River CGCS Platform Resource Monitor Service Initialization
*/
#include "rmon.h"
/* File definitions */
#define CONFIG_FILE ((const char *)"/etc/mtc/rmond.conf")
static rmon_ctrl_type rmon_ctrl ;
rmon_ctrl_type * get_ctrlPtr ( void ) ;
static daemon_config_type rmon_config ;
daemon_config_type * daemon_get_cfg_ptr () { return &rmon_config ; }
/* Cleanup exit handler */
void daemon_exit ( void )
{
rmon_msg_fini ();
rmon_hdlr_fini ( &rmon_ctrl );
daemon_dump_info ();
daemon_files_fini ();
exit (0);
}
bool is_worker ( void )
{
if (( rmon_ctrl.function == WORKER_TYPE ) && ( rmon_ctrl.subfunction == CGTS_NODE_NULL ))
return (true);
else
return (false);
}
bool is_controller ( void )
{
if ( rmon_ctrl.function == CONTROLLER_TYPE )
return (true);
else
return (false);
}
bool is_cpe ( void )
{
if (( rmon_ctrl.function == CONTROLLER_TYPE ) && ( rmon_ctrl.subfunction == WORKER_TYPE ))
return (true);
else
return (false);
}
/*****************************************************************************
*
* Name : rmon_config_handler
*
* Purpose : Startup config read from file: rmond.conf
*
*****************************************************************************/
static int rmon_config_handler ( void * user,
const char * section,
const char * name,
const char * value)
{
daemon_config_type* config_ptr = (daemon_config_type*)user;
if (MATCH("config", "audit_period"))
{
config_ptr->audit_period = atoi(value);
config_ptr->mask |= CONFIG_AUDIT_PERIOD ;
}
else if (MATCH("config", "pm_period"))
{
config_ptr->pm_period = atoi(value);
config_ptr->mask |= PM_AUDIT_PERIOD ;
}
else if (MATCH("config", "ntp_audit_period"))
{
config_ptr->ntp_audit_period = atoi(value);
config_ptr->mask |= NTP_AUDIT_PERIOD ;
}
else if (MATCH("config", "ntpq_cmd_timeout"))
{
config_ptr->ntpq_cmd_timeout = atoi(value);
config_ptr->mask |= NTPQ_CMD_TIMEOUT ;
}
else if (MATCH("config", "rmon_tx_port"))
{
config_ptr->rmon_tx_port = atoi(value);
config_ptr->mask |= CONFIG_TX_PORT ;
}
else if (MATCH("config", "per_node"))
{
config_ptr->per_node = atoi(value);
config_ptr->mask |= CONFIG_NODE ;
}
else if (MATCH("timeouts", "start_delay"))
{
config_ptr->start_delay = atoi(value);
config_ptr->mask |= CONFIG_START_DELAY ;
}
else if (MATCH("config", "rmon_api_tx_port"))
{
config_ptr->rmon_api_tx_port = atoi(value);
config_ptr->mask |= CONFIG_TX_PORT ;
}
else if (MATCH("config", "critical_threshold"))
{
config_ptr->rmon_critical_thr = atoi(value);
config_ptr->mask |= CONFIG_CRITICAL_THR ;
}
else if (MATCH("config", "log_step"))
{
config_ptr->log_step = atoi(value);
}
return (PASS);
}
/*****************************************************************************
*
* Name : rmon_interface_config
*
* Purpose : Read interface resource config file settings into the daemon configuration
*
*****************************************************************************/
int rmon_interface_config ( void * user,
const char * section,
const char * name,
const char * value)
{
int rc = FAIL ;
interface_resource_config_type * ptr = (interface_resource_config_type*)user;
if (MATCH("resource", "resource"))
{
ptr->mask |= CONF_RESOURCE ;
ptr->resource = strdup(value);
dlog ("Resource : %s\n", ptr->resource);
rc = PASS ;
}
else if (MATCH("resource", "severity"))
{
ptr->mask |= CONF_SEVERITY ;
ptr->severity = strdup(value);
dlog ("Severity : %s\n", ptr->severity );
rc = PASS ;
}
else if (MATCH("resource", "debounce"))
{
/* A zero value prevents degrade accompanying any alarm */
ptr->mask |= CONF_DEBOUNCE ;
ptr->debounce = atoi(value);
dlog ("Debounce : %d\n", ptr->debounce );
rc = PASS ;
}
else if (MATCH("resource", "num_tries"))
{
ptr->num_tries = atoi(value);
dlog ("Number of Tries : %d\n", ptr->num_tries );
rc = PASS ;
}
else if (MATCH("resource", "alarm_on"))
{
ptr->alarm_status= atoi(value);
dlog ("Resource Alarm Status : %d\n", ptr->alarm_status);
rc = PASS ;
}
return (rc);
}
/*****************************************************************************
*
* Name : rmon_thinmeta_config
*
* Purpose : Read resource config file settings into the daemon configuration
*
*****************************************************************************/
int rmon_thinmeta_config ( void * user,
const char * section,
const char * name,
const char * value)
{
int rc = FAIL ;
thinmeta_resource_config_type * ptr = (thinmeta_resource_config_type*)user;
if(strcmp(section, "thinpool_metadata") == 0)
{
// This configuration item has the thinpool metadata section
ptr->section_exists = true;
}
if (MATCH(THINMETA_CONFIG_SECTION, "vg_name"))
{
ptr->vg_name = strdup(value);
dlog ("Thinpool VG Name : %s\n", ptr->vg_name);
rc = PASS ;
}
else if (MATCH(THINMETA_CONFIG_SECTION, "thinpool_name"))
{
ptr->thinpool_name = strdup(value);
dlog ("Thinpool Thinpool Name : %s\n", ptr->thinpool_name);
rc = PASS ;
}
else if (MATCH(THINMETA_CONFIG_SECTION, "critical_threshold"))
{
ptr->critical_threshold = atoi(value);
dlog ("Thinpool Critical Alarm Threshold : %d%%\n", ptr->critical_threshold);
rc = PASS ;
}
else if (MATCH(THINMETA_CONFIG_SECTION, "alarm_on"))
{
ptr->alarm_on = atoi(value);
dlog ("Thinpool Metadata alarm_on : %s\n", ptr->alarm_on? "On": "Off");
rc = PASS ;
}
else if (MATCH(THINMETA_CONFIG_SECTION, "autoextend_on"))
{
ptr->autoextend_on = atoi(value);
dlog ("Thinpool Metadata autoextend : %s\n", ptr->autoextend_on? "On": "Off");
rc = PASS ;
}
else if (MATCH(THINMETA_CONFIG_SECTION, "autoexent_by"))
{
ptr->autoextend_by = atoi(value);
dlog ("Metadata Autoextend by : %d\n", ptr->autoextend_by);
rc = PASS ;
}
else if (MATCH(THINMETA_CONFIG_SECTION, "autoextend_percent"))
{
ptr->autoextend_percent = atoi(value);
dlog ("Thinpool Metadata Autoextend by : %s\n",
ptr->autoextend_percent? "percents": "absolute value (MiB)");
rc = PASS ;
}
else if (MATCH(THINMETA_CONFIG_SECTION, "audit_period"))
{
ptr->audit_period = atoi(value);
dlog ("Metadata Audit Period : %ds\n", ptr->audit_period);
rc = PASS ;
}
return (rc);
}
/*****************************************************************************
*
* Name : rmon_resource_config
*
* Purpose : Read resource config file settings into the daemon configuration
*
*****************************************************************************/
int rmon_resource_config ( void * user,
const char * section,
const char * name,
const char * value)
{
int rc = FAIL ;
resource_config_type * ptr = (resource_config_type*)user;
if (MATCH("resource", "resource"))
{
ptr->mask |= CONF_RESOURCE ;
ptr->resource = strdup(value);
dlog ("Resource : %s\n", ptr->resource);
rc = PASS ;
}
else if (MATCH("resource", "severity"))
{
ptr->mask |= CONF_SEVERITY ;
ptr->severity = strdup(value);
dlog ("Severity : %s\n", ptr->severity );
rc = PASS ;
}
else if (MATCH("resource", "debounce"))
{
ptr->mask |= CONF_DEBOUNCE ;
ptr->debounce = atoi(value);
dlog ("Debounce : %d\n", ptr->debounce );
rc = PASS ;
}
else if (MATCH("resource", "minor_threshold"))
{
ptr->minor_threshold = atoi(value);
dlog ("Minor Threshold : %d\n", ptr->minor_threshold );
rc = PASS ;
}
else if (MATCH("resource", "major_threshold"))
{
ptr->major_threshold = atoi(value);
dlog ("Major Threshold : %d\n", ptr->major_threshold );
rc = PASS ;
}
else if (MATCH("resource", "critical_threshold"))
{
ptr->critical_threshold = atoi(value);
dlog ("Critical Threshold : %d\n", ptr->critical_threshold );
rc = PASS ;
}
else if (MATCH("resource", "minor_threshold_abs_node0"))
{
ptr->minor_threshold_abs_node0 = atoi(value);
dlog ("Minor Threshold Absolute Node 0 : %d\n", ptr->minor_threshold_abs_node0 );
rc = PASS ;
}
else if (MATCH("resource", "major_threshold_abs_node0"))
{
ptr->major_threshold_abs_node0 = atoi(value);
dlog ("Major Threshold Absolute Node 0 : %d\n", ptr->major_threshold_abs_node0 );
rc = PASS ;
}
else if (MATCH("resource", "critical_threshold_abs_node0"))
{
ptr->critical_threshold_abs_node0 = atoi(value);
dlog ("Critical Threshold Absolute Node 0 : %d\n", ptr->critical_threshold_abs_node0 );
rc = PASS ;
}
else if (MATCH("resource", "minor_threshold_abs_node1"))
{
ptr->minor_threshold_abs_node1 = atoi(value);
dlog ("Minor Threshold Absolute Node 1 : %d\n", ptr->minor_threshold_abs_node1 );
rc = PASS ;
}
else if (MATCH("resource", "major_threshold_abs_node1"))
{
ptr->major_threshold_abs_node1 = atoi(value);
dlog ("Major Threshold Absolute Node 1 : %d\n", ptr->major_threshold_abs_node1 );
rc = PASS ;
}
else if (MATCH("resource", "critical_threshold_abs_node1"))
{
ptr->critical_threshold_abs_node1 = atoi(value);
dlog ("Critical Threshold Absolute Node 1 : %d\n", ptr->critical_threshold_abs_node1 );
rc = PASS ;
}
else if (MATCH("resource", "num_tries"))
{
ptr->num_tries = atoi(value);
dlog ("Number of Tries : %d\n", ptr->num_tries );
rc = PASS ;
}
else if (MATCH("resource", "alarm_on"))
{
ptr->alarm_status= atoi(value);
dlog ("Resource Alarm Status : %d\n", ptr->alarm_status);
rc = PASS ;
}
else if (MATCH("resource", "percent"))
{
ptr->percent= atoi(value);
dlog ("Resource Percent : %d\n", ptr->percent);
rc = PASS ;
}
return (rc);
}
/*****************************************************************************
*
* Name : daemon_configure
*
* Purpose : Read process config file settings into the daemon configuration
*
*****************************************************************************/
int daemon_configure ( void )
{
int rc = PASS ;
if (ini_parse( CONFIG_FILE, rmon_config_handler, &rmon_config) < 0)
{
elog("Can't load '%s'\n", CONFIG_FILE );
return (FAIL_LOAD_INI);
}
if (ini_parse(MTCE_INI_FILE, keystone_config_handler, &rmon_config) < 0)
{
elog ("Can't load '%s'\n", MTCE_INI_FILE );
return (FAIL_LOAD_INI);
}
get_debug_options ( CONFIG_FILE, &rmon_config );
/* Verify loaded config against an expected mask
* as an ini file fault detection method */
if ( rmon_config.mask != CONF_MASK )
{
elog ("Error: Agent configuration failed (%x)\n",
((-1 ^ rmon_config.mask) & CONF_MASK));
return (FAIL_INI_CONFIG);
}
/* Manage the daemon pulse period setting - ensure in bound values */
if ( rmon_config.audit_period < RMON_MIN_AUDIT_PERIOD )
{
rmon_ctrl.audit_period = RMON_MIN_AUDIT_PERIOD ;
}
else if ( rmon_config.audit_period > RMON_MAX_AUDIT_PERIOD )
{
rmon_ctrl.audit_period = RMON_MAX_AUDIT_PERIOD ;
}
else
{
rmon_ctrl.audit_period = rmon_config.audit_period ;
}
ilog("Event Audit Period: %d secs\n", rmon_ctrl.audit_period );
rmon_ctrl.rmon_critical_thr = rmon_config.rmon_critical_thr;
/* Manage the ceilometer pm period setting - ensure in bound values */
if ( rmon_config.pm_period < RMON_MIN_PM_PERIOD )
{
rmon_ctrl.pm_period = RMON_MIN_PM_PERIOD ;
}
else if ( rmon_config.pm_period > RMON_MAX_PM_PERIOD )
{
rmon_ctrl.pm_period = RMON_MAX_PM_PERIOD ;
}
else
{
rmon_ctrl.pm_period = rmon_config.pm_period ;
}
ilog("PM Audit Period: %d\n", rmon_ctrl.pm_period );
/* Manage the NTP query pulse period setting - ensure in bound values */
if ( rmon_config.ntp_audit_period < RMON_MIN_NTP_AUDIT_PERIOD )
{
rmon_ctrl.ntp_audit_period = RMON_MIN_NTP_AUDIT_PERIOD ;
}
else if ( rmon_config.ntp_audit_period > RMON_MAX_NTP_AUDIT_PERIOD )
{
rmon_ctrl.ntp_audit_period = RMON_MAX_NTP_AUDIT_PERIOD ;
}
else
{
rmon_ctrl.ntp_audit_period = rmon_config.ntp_audit_period ;
}
ilog("NTP Audit Period: %d secs\n", rmon_ctrl.ntp_audit_period );
// NTPQ Command timeout
if ( rmon_config.ntpq_cmd_timeout >= rmon_ctrl.ntp_audit_period )
{
rmon_ctrl.ntpq_cmd_timeout = NTPQ_CMD_TIMEOUT ;
wlog("NTPQ command timeout (%d secs) should be less than ntp_audit_period (%d secs) ; forcing default\n",
rmon_ctrl.ntpq_cmd_timeout, rmon_ctrl.ntp_audit_period );
}
else
{
rmon_ctrl.ntpq_cmd_timeout = rmon_config.ntpq_cmd_timeout ;
}
ilog("NTPQ command timeout: %d secs\n", rmon_ctrl.ntpq_cmd_timeout );
rmon_ctrl.per_node = rmon_config.per_node;
return (rc);
}
/****************************/
/* Initialization Utilities */
/****************************/
/* Construct the messaging sockets *
* 1. receive socket (mtc_client_rx_socket) *
* 2. transmit socket (mtc_client_tx_socket) */
int socket_init ( void )
{
int rc;
rmon_msg_init ( );
/* Init the resource monitor api tx port.
* This is the port that the rmon client api uses to
* inform rmon of any registering or deregistering client
* processes */
rc = rmon_port_init ( rmon_config.rmon_api_tx_port );
return (rc);
}
/*****************************************************************************
*
* Name : daemon_init
*
* Purpose : initialize the daemon and sockets
*
*****************************************************************************/
int daemon_init ( string iface, string nodetype_str )
{
int rc = PASS ;
char temp_hostname [MAX_HOST_NAME_SIZE+1];
/* init the control struct */
memset ( &rmon_ctrl.my_hostname[0], 0, MAX_HOST_NAME_SIZE+1);
rmon_ctrl.my_macaddr = "" ;
rmon_ctrl.my_address = "" ;
rmon_ctrl.resources = 0 ;
rmon_ctrl.clients = 0 ;
/* Assign interface to config */
rmon_config.mgmnt_iface = (char*)iface.data() ;
if ( daemon_files_init ( ) != PASS )
{
elog ("Pid, log or other files could not be opened\n");
return ( FAIL_FILES_INIT ) ;
}
if ( set_host_functions ( nodetype_str, &rmon_ctrl.nodetype, &rmon_ctrl.function, &rmon_ctrl.subfunction ) != PASS )
{
elog ("failed to extract nodetype\n");
return ( FAIL_NODETYPE );
}
/* Bind signal handlers */
if ( daemon_signal_init () != PASS )
{
elog ("daemon_signal_init failed\n");
return ( FAIL_SIGNAL_INIT );
}
/************************************************************************
* There is no point continuing with init ; i.e. running daemon_configure,
* initializing sockets and trying to query for an ip address until the
* daemon's configuration requirements are met. Here we wait for those
* flag files to be present before continuing.
************************************************************************
* Wait for /etc/platform/.initial_config_complete & /var/run/goenabled */
daemon_wait_for_file ( CONFIG_COMPLETE_FILE , 0);
daemon_wait_for_file ( GOENABLED_MAIN_PASS , 0);
/* Configure the daemon */
if ( (rc = daemon_configure ( )) != PASS )
{
elog ("Daemon service configuration failed (rc:%i)\n", rc );
rc = FAIL_DAEMON_CONFIG ;
}
/* This ensures any link aggregation interface overrides the physical */
rmon_config.mgmnt_iface = daemon_get_iface_master ( rmon_config.mgmnt_iface );
/* Log the startup settings */
ilog("Interface : %s\n", rmon_config.mgmnt_iface );
ilog("TX Interface: %d\n", rmon_config.rmon_tx_port );
get_iface_macaddr ( rmon_config.mgmnt_iface, rmon_ctrl.my_macaddr );
get_iface_address ( rmon_config.mgmnt_iface, rmon_ctrl.my_address , true );
get_iface_hostname ( rmon_config.mgmnt_iface, &temp_hostname[0] );
strcat(rmon_ctrl.my_hostname, "host=" );
strcat(rmon_ctrl.my_hostname, temp_hostname);
if ( (rc = rmon_hdlr_init (&rmon_ctrl)) != PASS )
{
ilog ("rmon_hdlt_init failed\n");
rc = FAIL_HDLR_INIT ;
}
/* Setup the messaging sockets */
else if ( (rc = socket_init ( )) != PASS )
{
elog ("socket initialization failed (rc:%d)\n", rc );
rc = FAIL_SOCKET_INIT ;
}
return (rc);
}
/*****************************************************************************
*
* Name : daemon_service_run
*
* Purpose : The main rmon service launch
*
* Waits for initial config complete and then go enabled pass flag files
* before starting resource monitoring.
*
*****************************************************************************/
void daemon_service_run ( void )
{
rmon_service ( &rmon_ctrl );
daemon_exit ();
}
/* Push daemon state to log file */
void daemon_dump_info ( void )
{
daemon_dump_membuf_banner ();
daemon_dump_membuf();
}
const char MY_DATA [100] = { "eieio\n" } ;
const char * daemon_stream_info ( void )
{
return (&MY_DATA[0]);
}
/*****************************************************************************
*
* Name : daemon_run_testhead
*
* Purpose : Run the rmon test suite by sending alarms to maintainance
* (To be used in Sprint 11 for testing)
*
*****************************************************************************/
int daemon_run_testhead ( void )
{
/* Clear All */
return (FAIL);
}

View File

@ -1,778 +0,0 @@
/*
* Copyright (c) 2013-2014, 2016 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
/**
* @file
* Wind River CGCS Platform Resource Monitor Messaging API
* This class implements a server that accepts client processes
* registering and deregistering for rmon notifications. This class
* also implements a send function to send alarm messages and clear
* messages to the clients registered for a particular resource.
*/
#include <dirent.h> /* for config dir reading */
#include <list> /* for the list of conf file names */
#include <vector>
#include <fstream>
#include <algorithm>
#include <sys/file.h>
#include "rmon.h"
#include "rmonApi/rmon_nodeMacro.h"
/**
* Messaging Socket Control Struct - The allocated struct
*/
static rmon_socket_type rmon_sock;
rmon_socket_type * rmon_getSock_ptr ( void )
{
return ( &rmon_sock );
}
msgSock_type * get_mtclogd_sockPtr ( void )
{
return (&rmon_sock.mtclogd);
}
/****************************/
/* Initialization Utilities */
/****************************/
/* Init the messaging socket control structure
* The following messaging interfaces use this structure and
* are initialized separately
* */
void rmon_msg_init ( void )
{
memset(&rmon_sock, 0, sizeof(rmon_sock));
}
void rmon_msg_fini ( void )
{
if ( rmon_sock.rmon_tx_sock ) {
close (rmon_sock.rmon_tx_sock);
} if ( rmon_sock.rmon_rx_sock ) {
close (rmon_sock.rmon_rx_sock);
} if ( rmon_sock.netlink_sock ) {
close (rmon_sock.netlink_sock);
} if ( rmon_sock.ioctl_sock ) {
close (rmon_sock.ioctl_sock);
}
}
/*Initialize the default rmon tx socket from the socket provided in:
/etc/rmond.conf */
int rmon_port_init ( int tx_port )
{
int val = 1 ;
int rc = FAIL ;
if ( tx_port )
{
rmon_sock.rmon_tx_port = tx_port ;
rmon_sock.rmon_tx_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if ( 0 >= rmon_sock.rmon_tx_sock )
return (-errno);
if ( setsockopt ( rmon_sock.rmon_tx_sock , SOL_SOCKET, SO_REUSEADDR, &val, sizeof(int)) == -1 )
{
wlog ( "rmon: failed to set rmon api tx socket as re-useable (%d:%m)\n", errno );
}
/* Set socket to be non-blocking. */
rc = ioctl(rmon_sock.rmon_tx_sock, FIONBIO, (char *)&val);
if ( 0 > rc )
{
elog ("Failed to set rmon tx socket non-blocking\n");
}
/* Setup with localhost ip */
memset(&rmon_sock.rmon_tx_addr, 0, sizeof(struct sockaddr_in));
rmon_sock.rmon_tx_addr.sin_family = AF_INET ;
// rmon_sock.rmon_addr.sin_addr.s_addr = htonl(INADDR_ANY);
rmon_sock.rmon_tx_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
rmon_sock.rmon_tx_addr.sin_port = htons(rmon_sock.rmon_tx_port) ;
/* bind socket to the receive addr */
if ( bind ( rmon_sock.rmon_tx_sock, (const struct sockaddr *)&rmon_sock.rmon_tx_addr, sizeof(struct sockaddr_in)) == -1 )
{
elog ( "failed to bind to 'tx' socket with port %d (%d:%m)\n", tx_port, errno );
close (rmon_sock.rmon_tx_sock);
rmon_sock.rmon_tx_sock = 0 ;
return (-errno);
}
}
else
{
elog ("No tx port specified\n");
}
return (rc) ;
}
/* Open a socket for a new client process */
int open_resource_socket ( char str[RMON_MAX_LEN], char registered_not[RMON_MAX_LEN], int port )
{
int rc = FAIL ;
int on = 1;
registered_clients clt;
memset((char*)&clt, 0, sizeof(clt));
strcpy(clt.registered_not, registered_not);
clt.rx_sock.rmon_rx_port = port - 1 ;
clt.rx_sock.rmon_rx_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if ( 0 >= clt.rx_sock.rmon_rx_sock )
{
elog ("failed to open 'rx' socket (%d:%m)", errno );
return (-errno);
}
if ( setsockopt ( clt.rx_sock.rmon_rx_sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(int)) == -1 )
{
wlog ( "rmon: failed to set rmon api rx socket as re-useable (%d:%m)\n", errno);
}
/* Set socket to be non-blocking. */
rc = ioctl(clt.rx_sock.rmon_rx_sock, FIONBIO, (char *)&on);
if ( 0 > rc )
{
elog ("Failed to set rmon rx socket non-blocking\n");
}
/* Setup with localhost ip */
memset(&clt.rx_sock.rmon_rx_addr, 0, sizeof(struct sockaddr_in));
clt.rx_sock.rmon_rx_addr.sin_family = AF_INET ;
// rmon_sock.rmon_addr.sin_addr.s_addr = htonl(INADDR_ANY);
clt.rx_sock.rmon_rx_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
clt.rx_sock.rmon_rx_addr.sin_port = htons(clt.rx_sock.rmon_rx_port) ;
clt.port = port;
strcpy(clt.client_name, str);
/* Prop the port numnber into the message struct */
if ( clt.port ) {
clt.msg.tx_port = clt.port ;
}
if ( clt.msg.tx_port )
{
/* if the sock is already open then close it first */
if ( clt.msg.tx_sock )
{
wlog ("%s open on already open socket %d, closing first\n",
clt.client_name, clt.msg.tx_sock );
close (clt.msg.tx_sock);
}
clt.msg.tx_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if ( 0 >= clt.msg.tx_sock )
{
elog ("failed to open 'tx' socket (%d:%m)", errno );
return (-errno);
}
/* Setup with localhost ip */
memset(&clt.msg.tx_addr, 0, sizeof(struct sockaddr_in));
clt.msg.tx_addr.sin_family = AF_INET ;
clt.msg.tx_addr.sin_addr.s_addr = inet_addr(LOOPBACK_IP);
clt.msg.tx_addr.sin_port = htons(clt.msg.tx_port) ;
/* Make the resource monitor client api socket non-blocking */
rc = ioctl(clt.msg.tx_sock , FIONBIO, (char *)&on);
if ( 0 > rc )
{
elog("Failed to set rmon socket non-blocking\n");
}
add_registered_client(clt);
rc = PASS ;
}
else
{
elog ("%s has no port specified\n", clt.client_name );
}
return (rc) ;
}
/* close the client process socket */
void close_resource_socket ( registered_clients * ptr )
{
if ( ptr->msg.tx_sock ) {
close ( ptr->msg.tx_sock );
}
}
/* remove a client from the list of registered clients */
int delete_client ( int clients, int index )
{
/* close the client socket first */
close_resource_socket( get_registered_clients_ptr(index));
if (index == (clients -1 )) {
registered_clients *tmp_ptr = get_registered_clients_ptr(index);
memset(tmp_ptr, 0 , sizeof(*tmp_ptr));
}
else {
for (int j = index; j < (clients - 1); j++)
{
registered_clients * clt = get_registered_clients_ptr(j);
registered_clients * cltTwo = get_registered_clients_ptr(j+1);
*clt = *cltTwo;
cltTwo = clt;
}
}
clients--;
ilog("deleted registered client, %d clients left \n",clients);
return clients;
}
void send_response( char message[RMON_MAX_LEN], registered_clients * clt )
{
int rc;
/* send a message to the rmon api to tell it the client is registered or deregistered */
rc = sendto ( clt->rx_sock.rmon_rx_sock,
&message ,
strlen ( message ), 0,
(struct sockaddr *) &clt->rx_sock.rmon_rx_addr,
sizeof(struct sockaddr_in));
if ( 0 >= rc )
{
elog ("sendto error (%d:%s)\n", errno , strerror(errno));
}
}
/* Send the outstanding registration and deregistration messages to rmon */
void rmon_alive_notification (int & clients)
{
FILE * pFile;
char * line = NULL;
size_t len = RMON_MAX_LEN;
ssize_t read;
vector<string> active_clients;
vector<string> dereg_clients;
char buf[RMON_MAX_LEN];
active_clients.clear();
dereg_clients.clear();
/* service deregister requests in queue */
pFile = fopen (RMON_API_DEREG_DIR , "r");
if (pFile != NULL) {
// take out a reader lock on this file incase another
// entity is exclusively writing to it at this time
flock(fileno(pFile), LOCK_SH);
while ((read = getline(&line, &len, pFile)) != -1) {
clients = rmon_service_file_inbox(clients, line, false );
string str(line, find(line, line + len, '\0'));
/* add the deregistered clients to the list to avoid relaunching them */
dereg_clients.push_back(str);
}
// release shared lock
flock(fileno(pFile), LOCK_UN);
fclose(pFile);
}
/* In the case that rmon restarts or rmon_alive_notifaction()
* is called periodically, and the clients have not re-registered,
* then attempt registration from active.txt, ONLY for clients
* that are not already in the registered_client framework
*/
pFile = fopen (RMON_API_ACTIVE_DIR , "r");
if (pFile != NULL) {
// take out a reader lock on this file incase another
// entity is exclusively writing to it at this time
flock(fileno(pFile), LOCK_SH);
ifstream fin( RMON_API_ACTIVE_DIR );
string readLine;
while (getline(fin, readLine)) {
if ((dereg_clients.empty()) ||
(find(dereg_clients.begin(), dereg_clients.end(), readLine) == dereg_clients.end())) {
/* only add a previously active client if it has not de-registered */
active_clients.push_back(readLine);
}
}
// release shared lock
flock(fileno(pFile), LOCK_UN);
fclose(pFile);
}
// remove(RMON_API_ACTIVE_DIR);
for (unsigned int i=0; i<active_clients.size(); i++)
{
/* reconnect the previously connected clients */
strcpy(buf, (active_clients.at(i)).c_str());
clients = rmon_service_file_inbox(clients, buf, false );
}
/* service register requests in queue */
pFile = fopen (RMON_API_REG_DIR , "r");
if (pFile != NULL) {
// take out a reader lock on this file incase another
// entity is exclusively writing to it at this time
flock(fileno(pFile), LOCK_SH);
while ((read = getline(&line, &len, pFile)) != -1)
{
clients = rmon_service_file_inbox(clients, line );
}
flock(fileno(pFile), LOCK_UN);
fclose(pFile);
}
if (line) {
free(line);
}
remove(RMON_API_REG_DIR);
remove(RMON_API_DEREG_DIR);
}
/* Remove a client from the active client list if it is being de-registered */
void remove_active_client( char buf[NOT_SIZE] )
{
FILE * pFile;
vector<string> active_clients;
vector<string> new_active_clients;
char lineBuf[NOT_SIZE];
active_clients.clear();
new_active_clients.clear();
pFile = fopen (RMON_API_ACTIVE_DIR , "r");
if (pFile != NULL) {
// take out a reader lock which will block
// if a writer has exclusive access to this
// file.
flock(fileno(pFile), LOCK_SH);
ifstream fin( RMON_API_ACTIVE_DIR );
string readLine;
while (getline(fin, readLine)) {
active_clients.push_back(readLine);
}
// release shared lock
flock(fileno(pFile), LOCK_UN);
fclose(pFile);
}
for (unsigned int i=0; i<active_clients.size(); i++)
{
strcpy(lineBuf, (active_clients.at(i)).c_str());
if (strcmp(lineBuf, buf) != 0)
{
/* put back all the clients except the one de-registering */
new_active_clients.push_back(active_clients.at(i));
}
}
/* Create a new active clients file and add all the remaining clients */
pFile = fopen (RMON_API_ACTIVE_DIR , "w");
if (pFile)
{
// take out a writer lock on this file to
// ensure that no other entity is writing to it
// at this time
int lock = flock(fileno(pFile), LOCK_EX);
if (lock < 0)
{
elog("Failed to get an exclusive on '%s' (%d:%m)", RMON_API_ACTIVE_DIR, errno);
}
else
{
for (unsigned int i=0; i<new_active_clients.size(); i++)
{
strcpy(lineBuf, (new_active_clients.at(i)).c_str());
fprintf(pFile, "%s\n", lineBuf);
}
// release lock
flock(fileno(pFile), LOCK_UN);
}
fclose(pFile);
} else {
elog("Cannot open %s to deregister: %s\n",
RMON_API_ACTIVE_DIR, buf);
}
}
/* Service client registratgion and deregistration requests from file
*
* Added new 'add' bool that defaults to true but if called with false
* suggests not to add this new client reg string to active.txt cause
* it is already there */
int rmon_service_file_inbox ( int clients, char buf[RMON_MAX_LEN], bool add )
{
int rc;
bool found = false;
char active_buf[RMON_MAX_LEN] ;
int total_clients = clients;
char str[RMON_MAX_LEN] ;
char registered_not[RMON_MAX_LEN];
unsigned int port = 0;
FILE * pFile;
memset ( str,0,RMON_MAX_LEN);
int len = strlen(buf);
if( buf[len-1] == '\n' )
{
/* ensure that the buffer does not have a carriage return */
buf[len-1] = 0;
}
// the format for each registered client is as follows:
// clientName resourceName port
sscanf ( buf, "%99s %99s %u", str, registered_not, &port ); //RMON_MAX_LEN is defined as 100
strcpy( active_buf, buf );
for (int j=0; j<clients; j++) {
registered_clients * clt = get_registered_clients_ptr(j);
if( strcmp(clt->client_name, str) == 0 )
{
found = true;
if (strcmp(CLR_CLIENT, registered_not) == 0) {
/* the client process wants to deregister, delete it and close it's socket */
remove_active_client(clt->client_name);
total_clients = delete_client(clients, j);
break;
}
break;
}
}
/* only add a client process if it is not already added */
if (!found) {
ilog("registering client \n");
if ( str[0] != '\0' )
{
rc = open_resource_socket(str, registered_not, port);
if (rc == FAIL) {
wlog("resource client port open failed \n");
} else if (rc==PASS) {
total_clients++;
if ( add == true )
{
/* Add the client to the active clients file */
pFile = fopen (RMON_API_ACTIVE_DIR , "a+");
if (pFile)
{
// take out a writer lock on this file to
// ensure that no other entity is writing to it
// at this time
int lock = flock(fileno(pFile), LOCK_EX);
if (lock < 0)
{
elog("Failed to get an exclusive on"
" '%s' (errno: %d)", RMON_API_ACTIVE_DIR, errno);
}
else
{
ilog ("adding %s to %s\n", active_buf, RMON_API_ACTIVE_DIR );
fprintf(pFile, "%s\n", active_buf);
// release the lock
flock(fileno(pFile), LOCK_UN);
}
fclose(pFile);
}
else
{
elog("Failed to open file %s", RMON_API_ACTIVE_DIR);
}
}
else
{
dlog ("avoid adding duplicate entry\n");
}
}
}
else
{
wlog ("Null string !\n");
}
}
return total_clients;
}
/* Service client registration and deregistration requests from select */
int rmon_service_inbox ( int clients )
{
#define MAX_T (3)
int count = 0 ;
int bytes = 0 ;
char buf[RMON_MAX_LEN] ;
char active_buf[RMON_MAX_LEN] ;
socklen_t len = sizeof(struct sockaddr_in) ;
int rc;
unsigned int port = 0 ;
bool found = false;
int total_clients = clients;
char str[RMON_MAX_LEN] ;
char registered_not[RMON_MAX_LEN];
FILE * pFile;
memset ( buf,0,RMON_MAX_LEN);
memset ( str,0,RMON_MAX_LEN);
bytes = recvfrom( rmon_sock.rmon_tx_sock, buf, RMON_MAX_LEN, 0, (struct sockaddr *)&rmon_sock.rmon_tx_addr, &len);
if ( bytes > 0 )
{
buf[RMON_MAX_LEN-1] = '\0';
sscanf ( buf, "%99s %99s %u", str, registered_not, &port ); //RMON_MAX_LEN is defined as 100
strcpy( active_buf, buf );
if ( strcmp(str, RMON_RESOURCE_NOT) != 0 )
{
for (int j=0; j<clients; j++) {
registered_clients * clt = get_registered_clients_ptr(j);
if( strcmp(clt->client_name, str) == 0 ) {
found = true;
memset ( buf,0,RMON_MAX_LEN );
strcpy( buf, "client_already_registered");
send_response(buf, clt);
if (strcmp(CLR_CLIENT, registered_not) == 0) {
/* the client process wants to deregister, delete it and close it's socket */
total_clients = delete_client(clients, j);
memset ( buf,0,RMON_MAX_LEN);
strcpy( buf, "deregistered_client");
send_response(buf, clt);
break;
}
break;
}
}
/* only add a client process if it is not already added */
if (!found) {
ilog("registering client \n");
if ( str[0] != '\0' )
{
rc = open_resource_socket(str, registered_not, port);
if (rc == FAIL) {
dlog("resource client port open failed \n");
} else if (rc==PASS) {
memset ( buf,0,RMON_MAX_LEN );
strcpy( buf, "registered_client");
registered_clients * clt = get_registered_clients_ptr(clients);
send_response(buf, clt);
total_clients++;
/* Add the client to the active clients file */
pFile = fopen (RMON_API_ACTIVE_DIR , "a+");
if (pFile)
{
// take out a writer lock on this file to
// ensure that no other entity is writing to it
// at this time
int lock = flock(fileno(pFile), LOCK_EX);
if (lock < 0)
{
elog("Failed to get an exclusive on"
" '%s' (errno: %d)", RMON_API_ACTIVE_DIR, errno);
}
else
{
fprintf(pFile, "%s\n", active_buf);
// release the lock
flock(fileno(pFile), LOCK_UN);
}
fclose(pFile);
}
else
{
elog("Failed to open file %s", RMON_API_ACTIVE_DIR);
}
}
}
else
{
wlog ("Null string !\n");
}
}
}
else if ( strcmp(str, RMON_RESOURCE_NOT) == 0 ) {
/* read the dynamic file systems file and send a response back */
process_dynamic_fs_file();
}
}
else if (( 0 > bytes ) && ( errno != EINTR ) && ( errno != EAGAIN ))
{
wlog_throttled ( count , MAX_T, "receive error (%d:%s)\n", errno, strerror(errno));
}
return total_clients;
}
/* send resource response */
int rmon_resource_response ( int clients )
{
int rc = FAIL ;
for (int j=0; j<clients; j++) {
registered_clients * clt = get_registered_clients_ptr(j);
clt->waiting = true;
if(( strcmp(clt->registered_not, RMON_RESOURCE_NOT) == 0)) {
/* only send to clients that are registered for the rmon api updates */
clt->rx_sequence = 0 ;
memset ( clt->msg.tx_buf, 0, RMON_MAX_LEN );
strcpy( clt->msg.tx_buf, "done_reading_dynamic_file_systems") ;
dlog("sending: %s on socket: %d bytes: %lu \n", clt->msg.tx_buf, clt->msg.tx_sock, strlen(clt->msg.tx_buf));
rc = sendto (clt->msg.tx_sock,
clt->msg.tx_buf ,
strlen ( clt->msg.tx_buf), 0,
(struct sockaddr *) &clt->msg.tx_addr,
sizeof(struct sockaddr_in));
if ( rc < 0 )
{
elog ("%s sendto error (%d:%s) (%s) (%s)\n",
clt->client_name,
errno , strerror(errno),
clt->msg.tx_buf,
inet_ntoa(clt->msg.tx_addr.sin_addr));
clt->send_err_cnt++ ;
}
else
{
mlog ("%s\n", &clt->msg.tx_buf[0] );
clt->waiting = false;
clt->send_err_cnt = 0;
clt->send_msg_count++ ;
rc = PASS ;
}
/*
* In certain rare instances, the UDP response packet
* sent back to the rmon client (over localhost), may
* be lost, resulting in the rmon client waiting indefinately
* (or until timeout). As a fail-safe, we will also set an
* the acknowledgement flag file that the client can
* look at on timeout
*/
daemon_log(RESPONSE_RMON_RESOURCE_NOT, "");
}
}
return (rc);
}
/* send rmon resource set and clear alarm messages to registered client processes */
int rmon_send_request ( resource_config_type * ptr, int clients)
{
dlog("%s, number of clients: %d\n", ptr->resource, clients);
int rc = FAIL ;
int total_clients = clients;
for (int j=0; j<clients; j++) {
registered_clients * clt = get_registered_clients_ptr(j);
clt->waiting = true;
dlog("registered notification client: %s\n", clt->registered_not);
if(( strcmp(clt->registered_not, ptr->resource) == 0) || ( strcmp(clt->registered_not, ALL_USAGE) == 0)) {
/* only send to clients that are registered for the resource type in question */
clt->rx_sequence = 0 ;
memset ( clt->msg.tx_buf, 0, RMON_MAX_LEN );
sprintf ( clt->msg.tx_buf, "%s %u", ptr->errorMsg, ++clt->tx_sequence ) ;
mlog( "%s sending: %s on socket: %d bytes: %lu\n",
ptr->resource,
clt->msg.tx_buf,
clt->msg.tx_sock,
strlen(clt->msg.tx_buf));
rc = sendto (clt->msg.tx_sock,
clt->msg.tx_buf ,
strlen ( clt->msg.tx_buf), 0,
(struct sockaddr *) &clt->msg.tx_addr,
sizeof(struct sockaddr_in));
if ( rc < 0 )
{
elog ("%s %s sendto error (%d:%s) rc: (%d) (%s) (%s)\n",
ptr->resource,
clt->client_name,
errno , strerror(errno),
rc,
clt->msg.tx_buf,
inet_ntoa(clt->msg.tx_addr.sin_addr));
clt->send_err_cnt++ ;
if (clt->send_err_cnt >= MAX_ERR_CNT) {
/* assume the client process is killed, deregister the client */
ilog("%s client process: %s is not responding, deregistering it \n", ptr->resource, clt->client_name);
total_clients = delete_client(clients, j);
update_total_clients(total_clients);
}
}
else
{
mlog ("%s %s\n", ptr->resource, &clt->msg.tx_buf[0] );
clt->waiting = false;
clt->send_err_cnt = 0;
clt->send_msg_count++ ;
rc = PASS ;
}
}
}
return (rc);
}
/* send rmon interface resource set and clear alarm messages to registered client processes */
int send_interface_msg ( interface_resource_config_type * ptr, int clients)
{
int rc = FAIL ;
int total_clients = clients;
for (int j=0; j<clients; j++) {
registered_clients * clt = get_registered_clients_ptr(j);
clt->waiting = true;
if(( strcmp(clt->registered_not, ptr->resource) == 0) || ( strcmp(clt->registered_not, ALL_USAGE) == 0)) {
/* only send to clients that are registered for the resource type in question */
clt->rx_sequence = 0 ;
memset ( clt->msg.tx_buf, 0, RMON_MAX_LEN );
sprintf ( clt->msg.tx_buf, "%s %u", ptr->errorMsg, ++clt->tx_sequence ) ;
mlog("sending: %s on socket: %d bytes: %lu\n",
clt->msg.tx_buf,
clt->msg.tx_sock,
strlen(clt->msg.tx_buf));
rc = sendto (clt->msg.tx_sock,
clt->msg.tx_buf ,
strlen ( clt->msg.tx_buf), 0,
(struct sockaddr *) &clt->msg.tx_addr,
sizeof(struct sockaddr_in));
if ( 0 >= rc )
{
elog ("%s sendto error (%d:%s) (%s) (%s)\n",
clt->client_name,
errno , strerror(errno),
clt->msg.tx_buf,
inet_ntoa(clt->msg.tx_addr.sin_addr));
clt->send_err_cnt++ ;
if (clt->send_err_cnt >= MAX_ERR_CNT) {
/* assume the client process is killed, deregister the client */
ilog("client process: %s is not responding, deregistering it \n", clt->client_name);
total_clients = delete_client(clients, j);
update_total_clients(total_clients);
}
}
else
{
mlog ("%s\n", &clt->msg.tx_buf[0] );
clt->waiting = false;
clt->send_err_cnt = 0;
clt->send_msg_count++ ;
rc = PASS ;
}
}
}
return (rc);
}

View File

@ -1,33 +0,0 @@
#
# Copyright (c) 2014-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
SRCS = rmon_resource_notify.cpp
OBJS = $(SRCS:.cpp=.o)
LDLIBS = -lstdc++ -lrmonapi -lrt
INCLUDES = -I. -I/usr/include/mtce-daemon -I/usr/include/mtce-common
INCLUDES += -I..
CCFLAGS = -g -O2 -Wall -Wextra -Werror
STATIC_ANALYSIS_TOOL = cppcheck
STATIC_ANALYSIS_TOOL_EXISTS = $(shell [[ -e `which $(STATIC_ANALYSIS_TOOL)` ]] && echo 1 || echo 0)
all: build
.cpp.o:
$(CXX) $(INCLUDES) $(CCFLAGS) $(EXTRACCFLAGS) -c $< -o $@
static_analysis:
ifeq ($(STATIC_ANALYSIS_TOOL_EXISTS), 1)
$(STATIC_ANALYSIS_TOOL) --language=c++ --enable=warning -U__AREA__ -DWANT_FIT_TESTING *.cpp *.h
else
echo "Warning: '$(STATIC_ANALYSIS_TOOL)' static analysis tool not installed ; bypassing ..."
endif
build: clean static_analysis $(OBJS)
$(CXX) $(CCFLAGS) $(OBJS) -L../../common -L../../daemon -L../rmonApi/ $(LDLIBS) $(EXTRALDFLAGS) -o rmon_resource_notify
clean:
@rm -v -f $(OBJ) rmon_resource_notify *.o *.a

View File

@ -1,552 +0,0 @@
/*
* Copyright (c) 2013-2017 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
/**
* @file
* Wind River CGTS Platform Resource Monitor Resource Notify
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netdb.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <list>
#include <vector>
#include <sstream>
#include <time.h>
#include <fcntl.h>
#include <sys/mman.h>
using namespace std;
#include "../rmonApi/rmon_nodeMacro.h" /* for ... CREATE_NONBLOCK_INET_UDP_RX_SOCKET */
#include "rmon_resource_notify.h"
extern "C"
{
#include "../rmonApi/rmon_api.h"
}
#define LOOPBACK_IP "127.0.0.1"
#define RX_PORT (2304)
static char my_hostname [MAX_HOST_NAME_SIZE+1];
static rmon_socket_type rmon_sock ;
static rmon_socket_type * sock_ptr ;
/** Client Config mask */
#define CONFIG_CLIENT_MASK (CONFIG_AGENT_PORT |\
CONFIG_CLIENT_API_PORT |\
CONFIG_CLIENT_PORT)
/****************************/
/* Initialization Utilities */
/****************************/
/* Initialize the unicast api response message */
/* One time thing ; tx same message all the time. */
int rmon_message_init ( void )
{
/* Build the transmit api response message */
memset ( &sock_ptr->tx_message, 0, sizeof (rmon_message_type));
memcpy ( &sock_ptr->tx_message.m[RMON_HEADER_SIZE], my_hostname, strlen(my_hostname));
return (PASS);
}
int rmon_socket_init ( int port, const char * process_name )
{
int on = 1 ;
int rc = PASS ;
CREATE_NONBLOCK_INET_UDP_RX_SOCKET ( LOOPBACK_IP,
port,
rmon_sock.rmon_api_sock,
rmon_sock.rmon_api_addr,
rmon_sock.rmon_api_port,
rmon_sock.rmon_api_len,
"rmon api socket receive",
rc );
if ( rc ) return (rc) ;
/* Open the monitoring socket */
rmon_sock.rmon_socket = resource_monitor_initialize ( process_name, port, RMON_RESOURCE_NOT );
//ilog("Resource Monitor API Socket %d\n", rmon_sock.rmon_socket);
if ( 0 > rmon_sock.rmon_socket )
{
close_syslog();
return (FAIL);
}
/* Make the socket non-blocking */
rc = ioctl(rmon_sock.rmon_socket, FIONBIO, (char *)&on);
if ( 0 > rc )
{
//elog("Failed to set rmon socket non-blocking (%d:%m)\n", errno );
return (FAIL_SOCKET_NOBLOCK);
}
return (PASS);
}
int daemon_init (int port, const char * process_name )
{
int rc = PASS ;
/* Initialize socket construct and pointer to it */
memset ( &rmon_sock, 0, sizeof(rmon_sock));
sock_ptr = &rmon_sock ;
/* Setup the resmon api rx messaging sockets */
if ( (rc = rmon_socket_init (port, process_name)) != PASS )
{
// elog("socket initialization failed (rc:%d)\n", rc);
rc = FAIL_SOCKET_INIT;
}
return (rc);
}
#define RMON_MAX_LEN (100)
int client_service_inbox ()
{
#define MAX_T 100
int bytes = 0 ;
char buf[RMON_MAX_LEN] ;
socklen_t len = sizeof(struct sockaddr_in) ;
char str[RMON_MAX_LEN];
int rc = FAIL;
do
{
memset ( buf,0,RMON_MAX_LEN);
memset ( str,0,RMON_MAX_LEN);
bytes = recvfrom( rmon_sock.rmon_socket, buf, RMON_MAX_LEN, 0, (struct sockaddr *)&rmon_sock.client_sockAddr, &len);
if ( bytes > 0 )
{
sscanf ( buf, "%99s", str);
if ( str[0] != '\0' )
{
if ( strcmp(str, RMON_DONE) == 0)
{
return (PASS);
}
}
return (FAIL);
}
else if (( 0 > bytes ) && ( errno != EINTR ) && ( errno != EAGAIN ))
{
//ilog("problem with test client recv \n");
}
} while ( bytes > 0 ) ;
return rc;
}
/* Maximum length of the dynamic resource list */
#define DYNAMIC_RESOURCE_MAX (1024)
int main ( int argc, char *argv[] )
{
int rc;
int port = RX_PORT;
const char * process_name = PROCESS_NAME;
char res_name[30];
char state[20];
char mount[50];
char type[20];
char device[50];
char volume_group[50];
string delimiter = ",";
unsigned long long timeout = DEFAULT_RESPONSE_TIMEOUT;
char dynamic_res[DYNAMIC_RESOURCE_MAX];
char resource_name [50];
struct stat fileInfo;
struct timespec start, stop;
struct flock fl;
int fd;
bool toNotify = false;
vector<string> dynamic_resources;
size_t pos;
string token;
open_syslog();
memset ((char *)&fileInfo, 0 , sizeof(fileInfo));
memset(&res_name[0], 0, sizeof(res_name));
memset(&state[0], 0, sizeof(state));
memset(&mount[0], 0, sizeof(mount));
memset(&type[0], 0, sizeof(type));
memset(&device[0], 0, sizeof(device));
memset(&volume_group[0], 0, sizeof(volume_group));
memset(&dynamic_res[0], 0, sizeof(dynamic_res));
memset(&resource_name[0], 0, sizeof(resource_name));
fl.l_whence = SEEK_SET;
fl.l_start = 0;
fl.l_len = 0;
fl.l_pid = getpid();
if ((argc > 1) && (strcmp(argv[1],"--help") == 0)) {
printf("usage: rmon_resource_notify "
"--resource-name <entity_name> "
"--resource-state <enabled|disabled> "
"--resource-type <filesystem> "
"--device <device_name> "
"--mount-point <mount_path> "
"--volume_group <volume_name> "
"--timeout <ms> \n");
close_syslog();
return FAIL;
}
for (int i=0; i<argc; ++i)
{
/* parse the dynamic resource monitor request list/table */
if (strcmp(argv[i], "--resource-name") == 0) {
sscanf(argv[i+1], "%29s", res_name);
}
else if (strcmp(argv[i], "--resource-state") == 0) {
sscanf(argv[i+1], "%19s", state);
if (strcmp(state, "disabled") == 0)
{
/* because enabled and disable have the same number of characters */
strcpy(state, "disable");
}
}
else if (strcmp(argv[i], "--resource-type") == 0) {
sscanf(argv[i+1], "%19s", type);
}
else if (strcmp(argv[i], "--device") == 0) {
sscanf(argv[i+1], "%49s", device);
}
else if (strcmp(argv[i], "--mount-point") == 0) {
sscanf(argv[i+1], "%49s", mount);
}
else if (strcmp(argv[i], "--timeout") == 0) {
sscanf(argv[i+1], "%llu", &timeout);
}
else if (strcmp(argv[i], "--volume-group") == 0) {
sscanf(argv[i+1], "%49s", volume_group);
}
}
if (res_name[0] != '\0') {
strcpy( dynamic_res, res_name);
strcat( dynamic_res, " " );
}
if (state[0] != '\0') {
strcat( dynamic_res, state );
strcat( dynamic_res, " " );
}
if (type[0] != '\0') {
strcat( dynamic_res, type );
strcat( dynamic_res, " " );
}
if (device[0] != '\0') {
strcat( dynamic_res, device );
}
else if (volume_group[0] != '\0')
{
strcat( dynamic_res, volume_group );
}
if (mount[0] != '\0') {
strcat( dynamic_res, " " );
strcat( dynamic_res, mount );
}
strcat( dynamic_res, delimiter.c_str() );
// syslog ( LOG_DEBUG, "dynamic_res: %s\n", dynamic_res);
if ( stat(DYNAMIC_FS_FILE, &fileInfo) != -1 )
{
/*******************************************************************************************
* Dynamic Resource Monitor Request - Example
*
* cat /etc/rmonfiles.d/dynamic.conf
* nova-local disable lvg nova-local,
* /etc/nova/instances enabled mount /dev/mapper/nova--local-instances_lv /etc/nova/instances,
* platform-storage disable mount /dev/drbd2 /opt/platform,
* cloud-storage disable mount /dev/drbd3 /opt/cgcs,
* volume-storage disable lvg cinder-volumes,
* database-storage disable mount /dev/drbd0 /var/lib/postgresql,
* messaging-storage disable mount /dev/drbd1 /var/lib/rabbitmq,
* extension-storage disable mount /dev/drbd5 /opt/extension,
*
*********************************************************************************************/
/* file is yet to be read and written */
fd = open(DYNAMIC_FS_FILE, O_RDWR, (mode_t)0600);
if (fd == -1)
{
// elog("Error opening file for read/write");
close_syslog();
return(FAIL);
}
/* lock the file for read and write */
fl.l_type = F_WRLCK;
fcntl(fd, F_SETLKW, &fl);
if (fd == -1)
{
// elog("Error opening file for reading");
close_syslog();
return (FAIL);
}
if (fstat(fd, &fileInfo) == -1)
{
// elog("Error getting the file size");
close_syslog();
return (FAIL);
}
//ilog("File size is %ji\n", (intmax_t)fileInfo.st_size);
char *map = static_cast<char*>(mmap(0, fileInfo.st_size, PROT_READ, MAP_SHARED, fd, 0));
if (map == MAP_FAILED)
{
close(fd);
// elog("Error mmapping the file");
close_syslog();
return (FAIL);
}
string oldFile(map);
/* extract the resource name */
sscanf(dynamic_res, "%49s", resource_name);
string newResource(resource_name);
string updatedResource(dynamic_res);
dynamic_resources.clear();
if ( oldFile.find(updatedResource) == string::npos )
{
if ( oldFile.find(newResource) != string::npos )
{
/* the resource exists, update it in the file */
while ((pos = oldFile.find(delimiter)) != string::npos)
{
/* separate the resources from the file */
token = oldFile.substr(0, pos);
if (token.find(newResource) == string::npos)
{
dynamic_resources.push_back(token);
}
oldFile.erase(0, pos + delimiter.length());
}
oldFile = "";
for (unsigned int i=0; i<dynamic_resources.size(); i++)
{
oldFile.append(dynamic_resources.at(i));
oldFile.append(delimiter);
}
oldFile.append(updatedResource);
}
else
{
/* the resource does not exist, add it to the file */
//ilog("updated_resource: %s", oldFile.c_str());
oldFile.append(updatedResource);
}
snprintf ( dynamic_res, DYNAMIC_RESOURCE_MAX-1, "%s", oldFile.data());
// syslog ( LOG_DEBUG, "%s\n", dynamic_res);
}
else
{
/* resource already exists no need to add it */
memset(dynamic_res, 0, DYNAMIC_RESOURCE_MAX ) ; // sizeof(dynamic_res));
}
/* free the mmapped memory */
if (munmap(map, fileInfo.st_size) == -1)
{
/* unlock the file */
fl.l_type = F_UNLCK;
fcntl(fd, F_SETLK, &fl);
// elog("Error un-mmapping the file");
close_syslog();
return (FAIL);
}
}
/* add or modify the dynamic resource */
else
{
/* file is yet to be written to create a new one */
fd = open(DYNAMIC_FS_FILE, O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600);
if (fd == -1)
{
// elog("Error opening file for writing");
close_syslog();
return(FAIL);
}
/* lock the file for writing */
fl.l_type = F_WRLCK;
fcntl(fd, F_SETLKW, &fl);
}
if (dynamic_res[0] != '\0')
{
toNotify = true;
/* stretch the file size to the size of the (mmapped) array of char */
string text (dynamic_res);
//ilog("dynamicres: %s\n", dynamic_res);
size_t textsize = strlen(text.c_str());
if (lseek(fd, textsize, SEEK_SET) == -1)
{
close(fd);
// elog("Error calling lseek() to 'stretch' the file");
close_syslog();
return (FAIL);
}
if (write(fd, "", 1) == -1)
{
close(fd);
// elog("Error writing last byte of the file");
close_syslog();
return (FAIL);
}
/* memory map the file */
char *map = static_cast<char*>(mmap(0, textsize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0));
if (map == MAP_FAILED)
{
close(fd);
// elog("Error mmapping the file");
close_syslog();
return (FAIL);
}
/* write the resource into memory */
memcpy(map, text.c_str(), textsize);
/* write the updated list to the disk */
if (msync(map, textsize, MS_SYNC) == -1)
{
; // elog("Could not sync the file to disk");
}
/* free the mmapped memory */
if (munmap(map, textsize) == -1)
{
/* unlock the file */
fl.l_type = F_UNLCK;
fcntl(fd, F_SETLK, &fl);
// elog("Error un-mmapping the file");
close_syslog();
return (FAIL);
}
}
close(fd);
/* unlock the file */
fl.l_type = F_UNLCK;
fcntl(fd, F_SETLK, &fl);
if (!toNotify)
{
close_syslog();
return (PASS);
}
/* Check to see if rmond is running */
rc = system("pidof rmond");
if (WEXITSTATUS(rc) != 0)
{
return (PASS);
}
rc = daemon_init(port, process_name);
if (rc == PASS) {
if( clock_gettime( CLOCK_MONOTONIC, &start) == -1 ) {
// elog("clock gettime \n" );
close_syslog();
return (FAIL);
}
rmon_message_init();
rmon_sock.rmon_socket = resource_monitor_get_sel_obj ();
std::list<int> socks;
socks.clear();
socks.push_front ( rmon_sock.rmon_socket );
socks.sort();
// remove the rmon resource notify flag file
// as this will be reset by rmon
remove (RESPONSE_RMON_RESOURCE_NOT);
/* signal to rmon that the dynamic file has been written */
rc = rmon_notification ( RMON_RESOURCE_NOT );
for ( ; ; )
{
/* Initialize the timeval struct */
rmon_sock.waitd.tv_sec = 0;
rmon_sock.waitd.tv_usec = SELECT_TIMEOUT * 100;
/* Initialize the master fd_set */
FD_ZERO(&rmon_sock.readfds);
FD_SET(rmon_sock.rmon_socket, &rmon_sock.readfds);
rc = select( socks.back()+1,
&rmon_sock.readfds, NULL, NULL,
&rmon_sock.waitd);
/* If the select time out expired then */
if (( rc < 0 ) || ( rc == 0 ))
{
/* Check to see if the select call failed. */
/* ... but filter Interrupt signal */
if (( rc < 0 ) && ( errno != EINTR ))
{
//ilog("Socket Select Failed (rc:%d) %s \n", errno, strerror(errno));
}
}
if ( FD_ISSET(rmon_sock.rmon_socket, &rmon_sock.readfds))
{
rc = client_service_inbox();
if (rc == PASS) {
close_syslog();
return PASS;
}
}
if ( clock_gettime( CLOCK_MONOTONIC, &stop) == -1 ) {
// elog("clock gettime\n");
return (FAIL);
}
unsigned long delta = (stop.tv_sec - start.tv_sec) * 1000 + (stop.tv_nsec - start.tv_nsec) / 1000000;
if (delta > timeout)
{
/* we exceeded the timeout.
* It may have happened that rmon
* sent its acknowledgment but that response
* got lost. In that case check for the flag file
* as a last ditch effort
*/
if (access(RESPONSE_RMON_RESOURCE_NOT, F_OK) != -1) {
close_syslog()
return (PASS);
}
close_syslog();
return (FAIL);
}
}
}
close_syslog();
return FAIL;
}

View File

@ -1,106 +0,0 @@
/*
* Copyright (c) 2013-2015 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
/**
* @file
* Wind River CGTS Platform Resource Monitor Resource Notify Header
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <netdb.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include <signal.h>
#include "nodeBase.h"
#include "nodeUtil.h"
/** Maximum service fail count before action */
#define MAX_FAIL_COUNT (1)
#define RMON_HEADER_SIZE (15)
#define RMON_MAX_MSG (50)
#define MAX_COUNT (3)
#define SELECT_TIMEOUT (100)
#define DEFAULT_RESPONSE_TIMEOUT (120 * 1000) // 2mins
/* default process name if none is specified */
#define PROCESS_NAME ((const char *)"rmonResourceNotify")
#define RMON_DONE ((const char *)"done_reading_dynamic_file_systems")
#define DYNAMIC_FS_FILE ((const char *)"/etc/rmonfiles.d/dynamic.conf")
#define RMON_RESOURCE_NOT ((const char *)"read_dynamic_file_system")
#define RESPONSE_RMON_RESOURCE_NOT ((const char *)"/var/run/.dynamicfs_registered")
typedef struct
{
/** Message buffer */
char m [RMON_MAX_MSG];
/** Sequence number */
unsigned int s ;
/* Fast Lookup Clue Info */
unsigned int c ;
/* Status Flags */
unsigned int f ;
/* reserved for future use */
unsigned int r ;
} rmon_message_type ;
/** rmon resource notify socket control structure */
typedef struct
{
struct sockaddr_in client_addr ;
socklen_t client_addr_len ;
/** Unix domain socket used to transmit on-node event messages
* to from other local services such as rmon */
int send_event_socket ;
struct sockaddr_un agent_domain ;
socklen_t agent_domain_len ;
/** rmon api Socket using UDP Inet over 'lo' interface */
int rmon_api_sock ; /**< receive rmon pulses socket */
int rmon_api_port ; /**< the port */
struct sockaddr_in rmon_api_addr ; /**< attributes */
socklen_t rmon_api_len ; /**< length */
int rmon_socket ; /**< Active monitor socket */
/** The addr and port are stored in the shared librmonapi.so library */
struct sockaddr_in client_sockAddr ; /**< Client socket attributes */
socklen_t agentLen ; /**< Agent socket attr struct len */
socklen_t clientLen ; /**< Client socket attr struct len */
int tx_socket ; /**< general transmit socket ID */
int rx_socket ; /**< general receive socket ID */
rmon_message_type tx_message ; /**< transmit message */
rmon_message_type rx_message ; /**< receive message */
int rmon_client_port ;
int fail_count ; /**< Socket retry thresholding */
/* For select dispatch */
struct timeval waitd ;
fd_set readfds;
msgSock_type mtclogd ;
} rmon_socket_type ;

View File

@ -1,27 +0,0 @@
[resource]
resource = Cinder LVM Thinpool Usage
debounce = 20 ; number of seconds to wait before degrade clear
severity = critical ; minor, major, critical
minor_threshold = 70 ; minor Cinder LVM Thinpool utilization threshold percentage
major_threshold = 80 ; major Cinder LVM Thinpool utilization threshold percentage
critical_threshold = 90 ; critical Cinder LVM Thinpool utilization threshold percentage (use 101 if unused)
minor_threshold_abs_node0 = 512 ; absolute minor threshold value MiB processor node 0
major_threshold_abs_node0 = 307 ; absolute major threshold value MiB processor node 0
critical_threshold_abs_node0 = 102 ; absolute critical threshold value MiB processor node 0 (use 0 if unused)
minor_threshold_abs_node1 = 0 ; absolute minor threshold value MiB processor node 1
major_threshold_abs_node1 = 0 ; absolute major threshold value MiB processor node 1
critical_threshold_abs_node1 = 0 ; absolute critical threshold value MiB processor node 1
num_tries = 2 ; number of tries before the alarm is raised
alarm_on = 1 ; 1 for alarm on, 0 for alarm off
percent = 1 ; 1 for percentage used, 0 for absolute value (Cinder LVM Thinpool available in MiB) (default is 1)
[thinpool_metadata]
vg_name = cinder-volumes ; name of parent VG
thinpool_name = cinder-volumes-pool ; name of LV Thin Pool to monitor
critical_threshold = 80 ; critical alarm threshold percentage for metadata utilization
alarm_on = 1 ; 1 to raise critical alarm on threshold, 0 not to raise alarm
autoextend_on = 1 ; 1 to first try extending the metadata on threshold, 0 for autoextend off.
autoexent_by = 20 ; autoextend by a percentage or absolute value in MiB
autoextend_percent = 1 ; percent or MiB
audit_period = 10 ; interval to performa the audit

View File

@ -1,6 +0,0 @@
[resource]
resource = infra
debounce = 20 ; number of seconds to wait before degrade clear
severity = critical ; minor, major, critical
num_tries = 2 ; number of tries before the alarm is raised
alarm_on = 1 ; 1 for alarm on, 0 for alarm off

View File

@ -1,16 +0,0 @@
[resource]
resource = Platform Nova Instances
debounce = 20 ; number of seconds to wait before degrade clear
severity = critical ; minor, major, critical
minor_threshold = 80 ; minor memory utilization threshold percentage
major_threshold = 90 ; major memory utilization threshold percentage
critical_threshold = 95 ; critical memory utilization threshold percentage (use 101 if unsed)
minor_threshold_abs_node0 = 512 ; absolute minor threshold value MiB processor node 0
major_threshold_abs_node0 = 307 ; absolute major threshold value MiB processor node 0
critical_threshold_abs_node0 = 102 ; absolute critical threshold value MiB processor node 0 (use 0 if unused)
minor_threshold_abs_node1 = 0 ; absolute minor threshold value MiB processor node 1
major_threshold_abs_node1 = 0 ; absolute major threshold value MiB processor node 1
critical_threshold_abs_node1 = 0 ; absolute critical threshold value MiB processor node 1
num_tries = 2 ; number of tries before the alarm is raised
alarm_on = 1 ; 1 for alarm on, 0 for alarm off
percent = 1 ; 1 for percentage used, 0 for absolute value (memory available in MiB) (default is 1)

View File

@ -1,6 +0,0 @@
[resource]
resource = mgmt
debounce = 20 ; number of seconds to wait before degrade clear
severity = critical ; minor, major, critical
num_tries = 2 ; number of tries before the alarm is raised
alarm_on = 1 ; 1 for alarm on, 0 for alarm off

View File

@ -1,16 +0,0 @@
[resource]
resource = Nova LVM Thinpool Usage
debounce = 20 ; number of seconds to wait before degrade clear
severity = critical ; minor, major, critical
minor_threshold = 70 ; minor Nova LVM Thinpool threshold percentage
major_threshold = 80 ; major Noval LVM Thinpool utilization threshold percentage
critical_threshold = 90 ; critical Nova LVM Thinpool utilization threshold percentage (use 101 if unused)
minor_threshold_abs_node0 = 512 ; absolute minor threshold value MiB processor node 0
major_threshold_abs_node0 = 307 ; absolute major threshold value MiB processor node 0
critical_threshold_abs_node0 = 102 ; absolute critical threshold value MiB processor node 0 (use 0 if unused)
minor_threshold_abs_node1 = 0 ; absolute minor threshold value MiB processor node 1
major_threshold_abs_node1 = 0 ; absolute major threshold value MiB processor node 1
critical_threshold_abs_node1 = 0 ; absolute critical threshold value MiB processor node 1
num_tries = 2 ; number of tries before the alarm is raised
alarm_on = 1 ; 1 for alarm on, 0 for alarm off
percent = 1 ; 1 for percentage used, 0 for absolute value (Nova LVM Thinpool available in MiB) (default is 1)

View File

@ -1,6 +0,0 @@
[resource]
resource = oam
debounce = 20 ; number of seconds to wait before degrade clear
severity = critical ; minor, major, critical
num_tries = 2 ; number of tries before the alarm is raised
alarm_on = 1 ; 1 for alarm on, 0 for alarm off

View File

@ -1,6 +0,0 @@
[resource]
resource = Remote Logging Connectivity
debounce = 20 ; number of seconds to wait before degrade clear
severity = minor ; minor, major, critical
num_tries = 2 ; number of tries before the alarm is raised
alarm_on = 1 ; 1 for alarm on, 0 for alarm off

View File

@ -1,97 +0,0 @@
#! /bin/sh
#
# Copyright (c) 2013-2014, 2016 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# chkconfig: 2345 95 95
#
### BEGIN INIT INFO
# Provides: rmon
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Resource Monitor daemon
### END INIT INFO
# echo "7:3:respawn:/usr/local/bin/rmond" >> /etc/inittab
. /etc/init.d/functions
DAEMON_NAME="rmond"
DAEMON="/usr/local/bin/${DAEMON_NAME}"
IFACE=""
if [ ! -e "$DAEMON" ] ; then
logger "$DAEMON is missing"
exit 1
fi
RETVAL=0
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
export PATH
case "$1" in
start)
# Prevent multipe starts
if [ -e /var/lock/subsys/${DAEMON_NAME} ] ; then
if [ -n "`pidof ${DAEMON_NAME}`" ] ; then
exit $RETVAL
else
rm -f /var/lock/subsys/${DAEMON_NAME}
fi
fi
echo -n "Starting $DAEMON_NAME: "
start-stop-daemon --start -b -x ${DAEMON} --
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
echo "OK"
touch /var/lock/subsys/${DAEMON_NAME}
else
echo "FAIL"
fi
;;
stop)
echo -n "Stopping ${DAEMON_NAME}: "
if [ -n "`pidof ${DAEMON_NAME}`" ] ; then
killproc ${DAEMON_NAME}
fi
if [ -n "`pidof ${DAEMON_NAME}`" ] ; then
echo "FAIL"
else
echo "OK"
# remove lockfile
rm -f /var/lock/subsys/${DAEMON_NAME}
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
status)
pid=`pidof ${DAEMON_NAME}`
RETVAL=$?
if [ ${RETVAL} -eq 0 ] ; then
echo "${DAEMON_NAME} is running"
else
echo "${DAEMON_NAME} is NOT running"
fi
;;
condrestart)
[ -f /var/lock/subsys/${DAEMON_NAME} ] && $0 restart
;;
*)
echo "usage: $0 { start | stop | status | restart | condrestart | status }"
;;
esac
exit $RETVAL

View File

@ -1,21 +0,0 @@
[process] ; The block label
process = rmond ; The name of the process to be monitored.
service = rmon ; The name of the service known to systemd
pidfile = /var/run/rmond.pid ; The path to process pidfile
script = /etc/init.d/rmon ; The path and restart script file name
style = lsb ; The type of script file. Only lsb is supported
severity = major ; Process failure severity
; critical : host is failed
; major : host is degraded
; minor : log is generated
restarts = 3 ; Number of back to back unsuccessful restarts before severity assertion
interval = 10 ; Number of seconds to wait between back-to-back unsuccessful restarts
debounce = 20 ; Number of seconds the process needs to run before declaring
; it as running O.K. after a restart.
; Time after which back-to-back restart count is cleared.
startuptime = 5 ; Seconds to wait after process start before starting the debounce monitor
mode = passive ; Monitoring mode: passive (default) or active
; passive: process death monitoring (default: always)
; active: heartbeat monitoring, i.e. request / response messaging

View File

@ -1,43 +0,0 @@
#daily
nodateext
/var/log/rmond.log
{
nodateext
size 100M
start 1
missingok
rotate 20
compress
postrotate
sharedscripts
postrotate
systemctl reload syslog-ng > /dev/null 2>&1 || true
endscript
}
/var/log/rmond_notify.log
{
size 10M
start 1
missingok
rotate 10
compress
sharedscripts
postrotate
systemctl reload syslog-ng > /dev/null 2>&1 || true
endscript
}
/var/log/rmond.dump
{
size 10M
start 1
rotate 10
compress
missingok
sharedscripts
postrotate
systemctl reload syslog-ng > /dev/null 2>&1 || true
endscript
}

View File

@ -1,23 +0,0 @@
[Unit]
Description=Titanium Cloud Maintenance Resource Monitor
After=network.target syslog.service config.service
Before=pmon.service
[Service]
Type=forking
ExecStart=/etc/rc.d/init.d/rmon start
ExecStop=/etc/rc.d/init.d/rmon stop
ExecReload=/etc/rc.d/init.d/rmon reload
PIDFile=/var/run/rmond.pid
# Failure handling
TimeoutStartSec=10s
TimeoutStopSec=10s
# Auto recovery by pmond
Restart=no
RestartSec=10
[Install]
WantedBy=multi-user.target

View File

@ -1,47 +0,0 @@
#!/bin/bash
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
source "/etc/init.d/log_functions.sh"
# is it a worker subfunction on a CPE system
isCompute ()
{
[ -f /etc/platform/platform.conf ] || return 0
res=$(grep "subfunction" /etc/platform/platform.conf | grep "controller,worker" | wc -l)
if [ "$res" -eq 0 ] ; then
return 0
else
return 1
fi
}
# only reload rmon if it is a CPE system
isCompute
if [[ "$?" -eq 0 ]]; then
log "Cannot run on a non CPE system."
exit 0
fi
if [ ! -f /var/run/.worker_config_complete ]; then
log "Cannot run prior to worker configuration complete."
exit 0
fi
#################################################################################################
# Temporarily switch this to a process kill instead of reload due to a problem found
# in the rmon config reload handling. A clone Jira was created to track the fix that will migrate
# this back to a reload.
#################################################################################################
# rc=`pkill -hup rmond`
# log "rmond config reload (rc=$rc)"
/usr/local/sbin/pmon-restart rmond
logger "requesting graceful rmon restart in goenabled test on cpe"
exit 0

View File

@ -1,34 +0,0 @@
; CGTS Resource Monitor Configuration File
[config] ; Configuration
audit_period = 30 ; Resource polling period in seconds (1 - 120)
pm_period = 300 ; Period For posting PMs to Ceilometer
ntp_audit_period = 600 ; Resource polling period for querying NTP servers in seconds (10 - 1200)
ntpq_cmd_timeout = 60 ; Max amount of time in seconds to wait for the ntpq command to complete
rmon_tx_port = 2101 ; Transmit Event and Command Reply Port
per_node = 0 ; enable (1) or disable (0) memory checking per processor node
rmon_api_tx_port = 2300 ; Resource Monitor API tx Port
critical_threshold = 1 ; enable (1) or disable (0) critical threshold checking
log_step = 20 ; create resource value logs when readings cross this +/- value threshold
; - this represents highest step for all resources
; - resources can override to smaller step
[timeouts]
start_delay = 10 ; managed range 1 .. 120 seconds
[features]
[debug] ; SIGHUP to reload
debug_timer = 0 ; enable(1) or disable(0) timer logs (tlog)
debug_msg = 0 ; enable(1) or disable(0) message logs (mlog)
debug_state = 0 ; enable(1) or disable(0) state change logs (clog)
debug_level = 0 ; decimal mask 0..15 (8,4,2,1)
debug_all = 0 ;
flush = 1 ; enable(1) or disable(0) force log flush (main loop)
flush_thld = 5 ; if enabled - force flush after this number of loops
debug_event = none ; Not used
debug_filter = none ; Not used
stress_test = 0 ; In-Service Stress test number

View File

@ -1,16 +0,0 @@
[resource]
resource = Cinder LVM Backend Usage
debounce = 20 ; number of seconds to wait before degrade clear
severity = critical ; minor, major, critical
minor_threshold = 70 ; minor Cinder LVM Backend threshold percentage
major_threshold = 80 ; major Cinder LVM Backend utilization threshold percentage
critical_threshold = 90 ; critical Cinder LVM Backend utilization threshold percentage (use 101 if unused)
minor_threshold_abs_node0 = 512 ; absolute minor threshold value MiB processor node 0
major_threshold_abs_node0 = 307 ; absolute major threshold value MiB processor node 0
critical_threshold_abs_node0 = 102 ; absolute critical threshold value MiB processor node 0 (use 0 if unused)
minor_threshold_abs_node1 = 0 ; absolute minor threshold value MiB processor node 1
major_threshold_abs_node1 = 0 ; absolute major threshold value MiB processor node 1
critical_threshold_abs_node1 = 0 ; absolute critical threshold value MiB processor node 1
num_tries = 2 ; number of tries before the alarm is raised
alarm_on = 1 ; 1 for alarm on, 0 for alarm off
percent = 1 ; 1 for percentage used, 0 for absolute value (Cinder LVM Backend available in MiB) (default is 1)

View File

@ -1,396 +0,0 @@
/*
* Copyright (c) 2017 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
/**
* @file
* Wind River Titanium Cloud Platform, LVM Thinpool Metadata Monitor Handler
*/
#include "rmon.h" /* rmon header file */
/* Used to set interface alarms through the FM API */
static SFmAlarmDataT alarmData;
/*******************************************************************************
*
* Name : _build_entity_instance_id
*
* Purpose : Build the entity instance id needed by our alarm
*
* *****************************************************************************/
void thinmeta_init(thinmeta_resource_config_type * res, struct mtc_timer * timers, int count) {
if (count > MAX_RESOURCES) {
elog("Thinpool metadata resource 'count' is: %i, maximum number or resources is: %i, "
"initializing count to max!",
count, MAX_RESOURCES);
count = MAX_RESOURCES;
}
for (int i = 0; i < count; i++) {
/* Mark first execution after reloading the configuration */
res[i].first_run = true;
/* Init timer defaults for this resource */
mtcTimer_init ( timers[i] ) ;
timers[i].hostname = "localhost" ;
timers[i].service = res[i].thinpool_name ;
timers[i].ring = true; // set it to true for the initial run
}
}
/*******************************************************************************
*
* Name : _build_entity_instance_id
*
* Purpose : Build the entity instance id needed by our alarm
*
* *****************************************************************************/
void _build_entity_instance_id(thinmeta_resource_config_type * ptr, char * entity) {
if (!entity) {
elog("%s/%s pool alarm failed to create entity instance id, 'entity' is NULL!",
ptr->vg_name, ptr->thinpool_name);
return;
}
rmon_ctrl_type * _rmon_ctrl_ptr;
_rmon_ctrl_ptr = get_rmon_ctrl_ptr();
snprintf(entity, sizeof(alarmData.entity_instance_id),
"%s.lvmthinpool=%s/%s", _rmon_ctrl_ptr->my_hostname, ptr->vg_name, ptr->thinpool_name);
}
/*******************************************************************************
*
* Name : _set_thinmeta_alarm
*
* Purpose : Set or clears the threshold alarm
*
* *****************************************************************************/
void _set_thinmeta_alarm( thinmeta_resource_config_type * ptr)
{
strcpy(alarmData.uuid, "");
strcpy(alarmData.entity_type_id ,"system.host");
_build_entity_instance_id(ptr, alarmData.entity_instance_id);
alarmData.alarm_state = FM_ALARM_STATE_SET;
alarmData.alarm_type = FM_ALARM_OPERATIONAL;
alarmData.probable_cause = FM_ALARM_STORAGE_PROBLEM;
if ( ptr->autoextend_on ) {
snprintf(alarmData.reason_text , sizeof(alarmData.reason_text),
"Metadata usage for LVM thin pool %s/%s "
"exceeded threshold and automatic extension failed; "
"threshold: %u%%, actual: %.2f%%.",
ptr->vg_name, ptr->thinpool_name,
ptr->critical_threshold, ptr->resource_value);
snprintf(alarmData.proposed_repair_action , sizeof(alarmData.proposed_repair_action),
"Increase Storage Space Allotment for Cinder on the 'lvm' backend. "
"Consult System Administration Manual for more details. "
"If problem persists, contact next level of support.");
}
else {
snprintf(alarmData.reason_text , sizeof(alarmData.reason_text),
"Metadata usage for LVM thin pool %s/%s exceeded threshold; "
"threshold: %u%%, actual: %.2f%%.",
ptr->vg_name, ptr->thinpool_name, ptr->critical_threshold, ptr->resource_value);
snprintf(alarmData.proposed_repair_action , sizeof(alarmData.proposed_repair_action),
"Extend the metadata LV with 'lvextend --poolmetadatasize "
"+<size_to_extend_in_MiB>M %s/%s'. "
"Consult System Administration Manual for more details. "
"If problem persists, contact next level of support.",
ptr->vg_name, ptr->thinpool_name);
}
alarmData.timestamp = 0;
alarmData.service_affecting = FM_FALSE;
alarmData.suppression = FM_TRUE;
alarmData.severity = FM_ALARM_SEVERITY_CRITICAL;
strcpy(alarmData.alarm_id, THINMETA_ALARM_ID);
dlog("%s/%s pool exceeding usage threshold, raising alarm\n", ptr->vg_name, ptr->thinpool_name);
int ret = rmon_fm_set(&alarmData, NULL) == FM_ERR_OK;
if (ret == FM_ERR_OK || ret == FM_ERR_ALARM_EXISTS) {
if (!ptr->alarm_raised) {
// log only once to avoid filling logs
ilog("%s/%s pool exceeding usage threshold, alarm raised", ptr->vg_name, ptr->thinpool_name);
ptr->alarm_raised = true;
}
}
else {
elog("Creation of alarm %s for entity instance id: %s failed. Error: %d \n",
alarmData.alarm_id, alarmData.entity_instance_id, ret);
ptr->alarm_raised = false;
}
}
/*****************************************************************************
*
* Name : _clear_thinmeta_alarm
*
* Purpose : Clear the alarm of the resource passed in
*
*****************************************************************************/
void _clear_thinmeta_alarm ( thinmeta_resource_config_type * ptr )
{
dlog ("%s/%s below threshold, clearing alarm\n", ptr->vg_name, ptr->thinpool_name);
AlarmFilter alarmFilter;
_build_entity_instance_id (ptr, alarmData.entity_instance_id);
snprintf(alarmFilter.alarm_id, FM_MAX_BUFFER_LENGTH, THINMETA_ALARM_ID);
snprintf(alarmFilter.entity_instance_id, FM_MAX_BUFFER_LENGTH, alarmData.entity_instance_id);
int ret = rmon_fm_clear(&alarmFilter);
if (ret == FM_ERR_OK) {
ilog ("Cleared stale alarm %s for entity instance id: %s",
alarmFilter.alarm_id, alarmFilter.entity_instance_id);
ptr->alarm_raised = false;
}
else if (ret == FM_ERR_ENTITY_NOT_FOUND) {
if (!ptr->first_run) {
wlog ("Alarm %s for entity instance id: %s was not found",
alarmFilter.alarm_id, alarmFilter.entity_instance_id);
}
ptr->alarm_raised = false;
}
else {
elog ("Failed to clear stale alarm %s for entity instance id: %s error: %d",
alarmFilter.alarm_id, alarmFilter.entity_instance_id, ret);
ptr->alarm_raised = true;
}
}
/*****************************************************************************
*
* Name : is_pool_ready
*
* Purpose : Check if an LVM Thin Pool is configured
* Return : PASS/FAIL
*
*****************************************************************************/
bool is_pool_ready(thinmeta_resource_config_type * ptr) {
char result[BUFFER_SIZE];
int rc = PASS;
char cmd[BUFFER_SIZE];
snprintf(cmd, sizeof(cmd), "timeout 2 lvs --noheadings -o vg_name,lv_name --separator / %s/%s",
ptr->vg_name, ptr->thinpool_name);
rc = execute_pipe_cmd(cmd, result, sizeof(result));
if (rc == 5 || rc == 1) { // ECMD_FAILED or ECMD_PROCESSED
// pool or VG was not found or not ready
return false;
}
else if (rc) {
// unexpected error
elog("%s/%s pool config query failed", ptr->vg_name, ptr->thinpool_name);
wlog("...cmd: '%s' exit status: %i result: '%s'", cmd, rc, result);
return false;
}
return true;
}
/*****************************************************************************
*
* Name : calculate_metadata_usage
*
* Purpose : Obtain the percentage of used metadata space for a thin pool
* in thin provisioning.
* Return : PASS/FAIL
*
*****************************************************************************/
int calculate_metadata_usage(thinmeta_resource_config_type * ptr) {
char result[BUFFER_SIZE];
int rc = PASS;
char meta_usage_cmd[BUFFER_SIZE];
snprintf(meta_usage_cmd, sizeof(meta_usage_cmd),
"set -o pipefail; timeout 2 lvs -o metadata_percent --noheadings %s/%s | tr -d ' '",
ptr->vg_name, ptr->thinpool_name);
rc = execute_pipe_cmd(meta_usage_cmd, result, sizeof(result));
if (rc == 1) { // ECMD_PROCESSED
// sometimes lvs command fail to process, not critical just retry in this case
dlog("%s/%s pool metadata usage query failed\n", ptr->vg_name, ptr->thinpool_name);
dlog("...cmd: '%s' exit status: %i result: '%s'\n", meta_usage_cmd, rc, result);
rc = execute_pipe_cmd(meta_usage_cmd, result, sizeof(result));
}
if (rc != PASS) {
elog("%s/%s pool metadata usage query failed", ptr->vg_name, ptr->thinpool_name);
wlog("...cmd: '%s' exit status: %i result: '%s'", meta_usage_cmd, rc, result);
return (FAIL);
}
ptr->resource_value = atof(result);
if ( log_value ( ptr->resource_value,
ptr->resource_prev,
DEFAULT_LOG_VALUE_STEP ) )
{
plog("%s/%s pool metadata usage is: %.2f%%\n",
ptr->vg_name, ptr->thinpool_name, ptr->resource_value);
}
return rc;
}
/*****************************************************************************
*
* Name : extend_thinpool_metadata
*
* Purpose : Extend the Logical Volume used by LVM Thin Pool metadata
* Return : PASS/FAIL
*
*****************************************************************************/
int extend_thinpool_metadata(thinmeta_resource_config_type * ptr) {
char result[THINMETA_RESULT_BUFFER_SIZE];
int rc = PASS;
char cmd[BUFFER_SIZE];
dlog(">>> ptr->autoextend_percent: %i", ptr->autoextend_percent);
dlog("%s/%s pool, extending metadata by %i%s\n", ptr->vg_name, ptr->thinpool_name,
ptr->autoextend_by, ptr->autoextend_percent? "%": "MiB");
if (ptr->autoextend_percent) {
char meta_lv_name[BUFFER_SIZE];
/* Get metadata LV name
* 'lvextend --poolmetadatasize' parameter is only allowed in MiB not percents.
* For percent we need to rely on 'lvextend -l...%LV', but we first have to get
* the real name of the metadata LV */
snprintf(cmd, sizeof(cmd),
"set -o pipefail; timeout 2 lvs %s/%s -o metadata_lv --noheadings | "
"tr -d '[] '",
ptr->vg_name, ptr->thinpool_name);
rc = execute_pipe_cmd(cmd, meta_lv_name, sizeof(meta_lv_name));
if (rc != PASS) {
elog("%s/%s pool metadata name query failed. Aborting auto extend.",
ptr->vg_name, ptr->thinpool_name);
return (FAIL);
}
dlog("%s/%s pool metadata LV name is: %s\n",
ptr->vg_name, ptr->thinpool_name, meta_lv_name);
/* Extend metadata cmd*/
snprintf(cmd, sizeof(cmd),
"timeout 10 lvextend -l +%u%%LV %s/%s",
ptr->autoextend_by, ptr->vg_name, meta_lv_name);
}
else {
/* Extend metadata cmd*/
snprintf(cmd, sizeof(cmd),
"timeout 10 lvextend --poolmetadatasize +%uM %s/%s",
ptr->autoextend_by, ptr->vg_name, ptr->thinpool_name);
}
rc = execute_pipe_cmd(cmd, result, sizeof(result));
if (rc != PASS) {
dlog("%s/%s pool metadata size extension failed\n", ptr->vg_name, ptr->thinpool_name);
dlog("...cmd: '%s' exit status: %i result: '%s'\n", cmd, rc, result);
return (FAIL);
}
return rc;
}
/*****************************************************************************
*
* Name : thinmeta_handler
*
* Purpose : Handle the metadata usage and raise alarms through the FM API
*
*****************************************************************************/
int thinmeta_handler( thinmeta_resource_config_type * ptr ) {
if (!ptr) {
elog ("Function called with NULL pointer!");
return (PASS);
}
switch ( ptr->stage ) {
case RMON_STAGE__INIT:
{
/* Check if pool is ready */
dlog("%s/%s pool config query", ptr->vg_name, ptr->thinpool_name);
if (!is_pool_ready(ptr)) {
ilog("%s/%s pool not ready, monitoring will be resumed when ready",
ptr->vg_name, ptr->thinpool_name);
ptr->stage = RMON_STAGE__MONITOR_WAIT;
}
else {
dlog("%s/%s pool ready", ptr->vg_name, ptr->thinpool_name);
ptr->stage = RMON_STAGE__MONITOR;
return (RETRY); // execute next stage immediately
}
break;
}
case RMON_STAGE__MONITOR_WAIT:
{
/* Waiting for pool to be ready*/
if (is_pool_ready(ptr)) {
ilog("%s/%s pool ready, starting monitoring",
ptr->vg_name, ptr->thinpool_name);
ptr->stage = RMON_STAGE__MONITOR;
return (RETRY); // execute next stage immediately
}
break;
}
case RMON_STAGE__MONITOR:
{
dlog("%s/%s pool metadata usage monitoring", ptr->vg_name, ptr->thinpool_name);
/* calculate usage. The first time we calculate thinpool meta
* usage is to get the baseline resource value, if it exceeds
* the critical threshold and if the resource configuration
* allows us to autoextend thinpools then we do an extend
* operation and then check again if our thinpool usage has
* fallen below the critical watermark. */
if(calculate_metadata_usage(ptr) == FAIL) {
ptr->stage = RMON_STAGE__INIT;
return (RETRY); // execute next stage immediately
break;
}
/* act on thresholds */
if((ptr->alarm_raised || ptr->first_run) &&
ptr->resource_value < ptr->critical_threshold) {
// clear alarm
_clear_thinmeta_alarm(ptr);
}
else if(ptr->resource_value >= ptr->critical_threshold) {
if (ptr->autoextend_on) {
// Extend metadata
// Retry at each pass (failures are fast) till successful, in case
// our VG is extended on the fly and we suddenly get enough space.
// Log operation and error only once to avoid filling log file.
if(!ptr->alarm_raised) {
ilog("%s/%s pool metadata will be extended by: %i%s",
ptr->vg_name, ptr->thinpool_name,
ptr->autoextend_by, ptr->autoextend_percent? "%": "MiB");
}
if(extend_thinpool_metadata(ptr) == PASS) {
// after extension recalculate metadata usage
if(calculate_metadata_usage(ptr) == FAIL) {
// this was successful < 1s ago, should not happen!
elog("%s/%s pool second metadata usage calculation failed!",
ptr->vg_name, ptr->thinpool_name);
}
}
else {
if(!ptr->alarm_raised) {
elog("%s/%s pool metadata extension failed ",
ptr->vg_name, ptr->thinpool_name);
}
}
}
if ((ptr->resource_value >= ptr->critical_threshold) && // resource_value may change
ptr->alarm_on) {
// raise alarm (if autoextend is disabled or failed)
_set_thinmeta_alarm(ptr);
}
else if (ptr->alarm_on && (ptr->alarm_raised || ptr->first_run)) {
// condition also needed if alarm existed prior to rmon startup
_clear_thinmeta_alarm(ptr);
}
}
/* Mark first run as complete */
ptr->first_run = false;
break;
}
default:
{
slog ("%s/%s Invalid stage (%d)\n", ptr->vg_name, ptr->thinpool_name, ptr->stage);
/* Default to init for invalid case */
ptr->stage = RMON_STAGE__INIT;
return (RETRY); // execute next stage immediately
}
}
return (PASS);
}

View File

@ -89,8 +89,8 @@ function helpMessage {
echo "" echo ""
echo "sudo memchk -t 60 --C mtcClient mtcAgent ... Check PSS and RSS values of the processes belonging to mtcClient" echo "sudo memchk -t 60 --C mtcClient mtcAgent ... Check PSS and RSS values of the processes belonging to mtcClient"
echo " and mtcAgent every 60 seconds (1 minute)" echo " and mtcAgent every 60 seconds (1 minute)"
echo "sudo memchk -t 3600 --C pmond rmond hwmond ... Check PSS and RSS values of pmond, rmond and hwmond every 3600s (1h)" echo "sudo memchk -t 3600 --C pmond hwmond ... Check PSS and RSS values of pmond, and hwmond every 3600s (1h)"
echo "sudo memchl --C pmond rmond hwmond ... Check PSS and RSS values of commands using default period of 3600s (1h)" echo "sudo memchl --C pmond hwmond ... Check PSS and RSS values of commands using default period of 3600s (1h)"
echo "--------------------------------------------------------------------------------------" echo "--------------------------------------------------------------------------------------"
exit 0 exit 0
} }

View File

@ -74,7 +74,6 @@ hbs_client_mgmnt_port = 2106 ; Management Interface Heartbeat Pulse Request Rx P
hbs_client_infra_port = 2116 ; Infrastructure Interface Heartbeat Pulse Request Rx Port hbs_client_infra_port = 2116 ; Infrastructure Interface Heartbeat Pulse Request Rx Port
hwmon_cmd_port = 2114 ; hwmond Command Rx Port Number hwmon_cmd_port = 2114 ; hwmond Command Rx Port Number
pmon_pulse_port = 2109 ; Process Monitor I'm Alive pulse Port Rx Port pmon_pulse_port = 2109 ; Process Monitor I'm Alive pulse Port Rx Port
rmon_event_port = 2302 ; Resource Monitor Event Port Rx Port
sched_delay_threshold = 300 ; scheduler delay time in msecs that will trigger sched_delay_threshold = 300 ; scheduler delay time in msecs that will trigger
; a scheduler history dump ; a scheduler history dump
daemon_log_port = 2121 ; daemon logger port daemon_log_port = 2121 ; daemon logger port