Skip to navigation

Monitoring Actions

View as Markdown

This chapter covers how to manage monitoring-driven actions with cmsh.

3.1 Actions And Triggers

A monitoring action is a script that is executed by CMDaemon. It runs when triggered by the monitored data.

An action by itself does nothing—it needs a trigger (section 10.4.5 of the Administrator Manual) to be defined to execute the action.

By default, several actions (section 10.4.4 of the Administrator Manual) are predefined:

  • Drain: Drain node (node refuses new WLM jobs)

  • Event: Send an event to users with connected client

  • ImageUpdate: Update the image on the node

  • PowerOff: Power off a device

  • PowerOn: Power on a device:

  • PowerReset: Power reset a device

  • Reboot: Reboot a node

  • Send e-mail to administrators: Send e-mail

  • Shutdown: Shutdown a node

  • Undrain: Undrain node (node accepts new WLM jobs)

  • killprocess: /cm/local/apps/cmd/scripts/actions/killprocess.pl

  • remount: /cm/local/apps/cmd/scripts/actions/remount

  • testaction: /cm/local/apps/cmd/scripts/actions/testaction

A new action script can be created as follows:

Example

[basecm11]% monitoring action
[basecm11->monitoring->action]% add script MyScript
[...MyScript*]% set script /path/to/MyScript
[...MyScript*]% commit

3.2 Time Restrictions

It is possible to allow actions to only be executed at certain times, with the allowedtime setting.

Example

[basecm11]% monitoring action
[basecm11->monitoring->action]% add script MyScript
[...MyScript*]% set script /path/to/MyScript
[...MyScript*]% set allowedtime "9:00-17:00"
[...MyScript*]% commit

More complex timing restrictions are possible:

Example

monday-friday{9:00-17:00}
monday-friday{00:00-09:00;17:00-00:00};saturday-sunday
november-march{monday-saturday{13:00-17:00}}
may-september{monday-friday{09:00-18:00};saturday-sunday{13:00-17:00}}

Further examples can be seen in section 10.4.4 of the Administrator Manual, here.

3.2.1 Time Restriction Syntax In EBNF Notation

The allowed values can be written as a not-very-rigorous EBNF grammar:

Example

<start> ::= <time_intervals> | ""
<time_intervals> ::= <time_interval> (";" <time_interval>)*
<time_interval> = <inner_time_interval> "{" <time_intervals> "}"
<inner_time_interval> ::=
| <day_of_week_interval>
| <time_of_day_interval>
| <day_of_month_interval>
| <month_interval>
<day_of_week_interval> ::=
| (<day_of_week> "-" <day_of_week>)
| (<day_of_week> ("," day_of_week)*)
<day_of_week> ::=
| "sunday" | "monday" | "tuesday" | "wednesday" | "thursday"
| "friday" | "saturday"
<time_of_day_interval> ::= <time_of_day> "-" <time_of_day>
<time_of_day> ::= { <digit> } <digit> ":" <digit> <digit>
<digit> ::= "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "0"
<month_interval> ::= (<month> "-" <month>) | (<month> ("," <month>)*)
<month> ::=
| "january" | "february" | "march" | "april" | "may" | "june" | "july"
| "august" | "september"
| "october" | "november" | "december"
<day_of_month_interval> ::= (<day_of_month> "-" <day_of_month>)
| (<day_of_month> ("," <day_of_month>)*)
<day_of_month> ::= { <digit> } <digit>

The shortcomings in the rigor can be fixed, but then the description would be much longer.

For example, the <time_interval> definition should have the time that is specified in the curly brackets be lesser than the one specified by the time outside the curly brackets. So the form

month_interval{day_of_month_interval} (okay)

would be correct, but not:

day_of_month_interval{month_interval} (not okay)

Keeping the description non-rigorous provides a useful enough guide for developers.

3.3 CMDaemon Environment Variables

3.3.1 Standard Environment Variables Available In Action Scripts

NameDescription
CMD_ENTITY_UUIDThe UUID of the entity that triggered the action.
CMD_ENTITY_NAMEThe name of the entity that triggered the action.
CMD_ENTITY_TYPEThe type of entity that triggered the action.
CMD_MEASURABLE_NAMEThe name of the measurable that triggered the action.
CMD_MEASURABLE_PARAMETERThe parameter of the measurable that triggered the action.
CMD_MEASURABLE_TYPEThe type of the measurable.
CMD_VALUEThe value that triggered the action.
CMD_RAW_VALUEThe raw value.
CMD_VALUE_TIMEThe time on which the value was measured, in ms elapsed since Unix epoch.
CMD_INFO_MESSAGEExtra information sampled along with the value.
CMD_PRODUCER_NAMEThe name of the monitoring data producer that samples the measurable.
CMD_ACTION_NAMEThe name of the action that was triggered.
CMD_TRIGGER_NAMEThe name of the trigger.
CMD_TRIGGER_EXPRESSIONThe expression that was evaluated.
CMD_VALUE_EVALThe result of the evaluated expression.
CMD_VALUE_COUNTThe number of times the expression evaluated to the same value.
CMD_SEVERITYThe assigned severity of the trigger.
CMD_STATE_FLAPPINGIs the measurable flapping?
CMD_JSON_DATAIf set to yes, then a JSON blob is passed on STDIN. The blob contains the information normally in env. CMD_JSON_DATA is used by the Send e-mail action
CMD_MEASURABLE_UUIDThe UUID of the measurable used
CMD_MULTI_ACTIONData values from measurables or triggers are dealt with together in some way if the action is yes
Example If the value of the parameter mergedmeasurables is set to yes, and if more than one data value is gathered within a period that is specified by the value of mergedelay, then the data values for a measurable are dealt with together in some way by the action. Merge delay, Merge triggers, and Merge measurables are parameters that are available within some monitoring actions.
[basecm11->monitoring->action]% list -f name:0,mergedelay,mergemeasurables
name (key) mergedelay mergemeasurables
-------------------- -------------- --------------
...
Send e-mail to administrators 2s yes
...
% [basecm11->monitoring->action]% use send e-mail to administrators
% [...->action[Send e-mail to administrators]]% get mergedelay
% 2s
% [...->action[Send e-mail to administrators]]% get mergemeasurables
% yes
The Send e-mail action in this supports CMD_MULTI_ACTION=yes by sending one email with multiple values, instead of one e-mail per measured or triggered value:
CMD_TRIGGER_UUIDUUID of the trigger
CMD_SCRIPTTIMEOUTscript timeout, in seconds, when CMDaemon runs an action script

All action scripts have the preceding standard environment variables set.

In cmsh, if the action object has its node environment parameter set to the value yes, then scripts running on a node are enabled with an extended environment that provides many more CMD_* environment variables. Otherwise they run in the standard environment. There are more environment variables besides the standard and node environment ones.

A list of the standard or extended environment variables can be dumped by running the system command env > /tmp/dumpfile within an action script, such as the test example script, and triggering the script to run.

Many of the environment variables are similar to the ones used by initialize and finalize scripts (section E.3 of the Administrator Manual) in the node-installer environment.

3.3.2 Extended Environment Variables Available To Action Scripts

If the action object has its node environment parameter set to the value yes, then scripts run in an extended environment that provides many more CMD_* environment variables. Otherwise they run in the standard environment of section 3.3.1.

The following table shows the extended as well as the standard environment variables, with some example values:

Table 3.3.2: Environment Variables For Nodes In The Extended Environment
VariableExample Value
CMD_ACTION_NAMEmyaction
CMD_ACTIVE_HEAD_NODE_IP10.141.255.254
CMD_CLUSTERNAMEbasecm11
CMD_DEVICE_TYPEHeadNode
CMD_ENTITY_NAMEbasecm11
CMD_ENTITY_TYPEHeadNode
CMD_ENTITY_UUID78d29ab5-b415-486f-ad6a-04c5a983110f
CMD_ENVIRONMENT_CACHE_EPOCH_MILLISECONDS1733150703765
CMD_ENVIRONMENT_CACHE_UPDATES15
CMD_EXPORTS/cm/node-installer@internalnet /cm/node-installer/certificates@internalnet /var/spool/burn@internalnet /home@internalnet /cm/shared@internalnet
CMD_FSEXPORT__SLASH_cm_SLASH_node_DASH_
installer<node-installer values>
where <node-installer values> takes these substitutions:
<node-installer values>example value
_installer_AT_internalnet_ALLOWWRITEfalse
_AT_internalnet_HOSTS10.141.0.0/16
_AT_internalnet_PATH/cm/node-installer
_SLASH_certificates_AT_internalnet_ALLOWWRITEtrue
_SLASH_certificates_AT_internalnet_HOSTS10.141.0.0/16
_SLASH_certificates_AT_internalnet_PATH/cm/node-installer/certificates
CMD_FSEXPORT__SLASH_<path values>
where <path values> takes these substitutions:
<path values>example value
cm_SLASH_shared_AT_internalnet_ALLOWWRITEtrue
cm_SLASH_shared_AT_internalnet_HOSTS10.141.0.0/16
cm_SLASH_shared_AT_internalnet_PATH/cm/shared
home_AT_internalnet_ALLOWWRITEtrue
home_AT_internalnet_HOSTS10.141.0.0/16
home_AT_internalnet_PATH/home
var_SLASH_spool_SLASH_burn_AT_internalnet_ALLOWWRITEtrue
var_SLASH_spool_SLASH_burn_AT_internalnet_HOSTS10.141.0.0/16
var_SLASH_spool_SLASH_burn_AT_internalnet_PATH/var/spool/burn
CMD_HOSTNAMEbasecm11
CMD_HTTP_PORT8080
CMD_INFO_MESSAGE
The interfaces eth0 and eth1 that make up the environment variable names listed next are for a Type 1 network with ethernet interfaces. The environment variable names change if the interface names change. For example, with InfiniBand interfaces, the eth0, eth1 strings become ib0, ib1.
CMD_INTERFACE_eth0_IP10.141.255.254
CMD_INTERFACE_eth0_MAC00:00:00:00:00:00
CMD_INTERFACE_eth0_MASK_BITS16
CMD_INTERFACE_eth0_MTU1500
CMD_INTERFACE_eth0_SPEED
CMD_INTERFACE_eth0_STARTIFALWAYS
CMD_INTERFACE_eth0_TYPENetworkPhysicalInterface
CMD_INTERFACE_eth1_GATEWAY192.168.255.254
CMD_INTERFACE_eth1_IP192.168.244.169
CMD_INTERFACE_eth1_MAC00:00:00:00:00:00
CMD_INTERFACE_eth1_MASK_BITS20
CMD_INTERFACE_eth1_MTU1500
CMD_INTERFACE_eth1_SPEED
CMD_INTERFACE_eth1_STARTIFALWAYS
CMD_INTERFACE_eth1_TYPENetworkPhysicalInterface
CMD_INTERFACESeth0 eth1
CMD_IP10.141.255.254
CMD_JSON_DATAno
CMD_MACFA:16:3E:33:8E:10
CMD_MANAGEMENT_IP10.141.255.254
CMD_MEASURABLE_NAMEPageOut
CMD_MEASURABLE_PARAMETER
CMD_MEASURABLE_TYPEMonitoringMeasurableMetric
CMD_MEASURABLE_UUID24321ec1-275c-4fd2-92eb-2ad7494216a8
CMD_MULTI_ACTIONno
CMD_MYSQL_SOCKET/var/run/mysqld/mysqld.sock
CMD_NODEGROUPS
CMD_NODE_INSTALLER_PATH/cm/node-installer
CMD_PARTITIONbase
CMD_PASSIVE_HEAD_NODE_IP
CMD_PORT8081
CMD_PRIMARY_HEAD_NODEbasecm11
CMD_PRODUCER_NAMEProcVMStat
CMD_PROTOCOLhttps
CMD_RAW_VALUE103603.200000
CMD_ROLESSlurmServer Storage Backup Boot Provisioning Monitoring SlurmAccounting Firewall HeadNode SlurmSubmit
CMD_SCRIPTTIMEOUT5
CMD_SEVERITY10
CMD_SHARED_HEAD_NODE_IP
CMD_STATE_FLAPPINGno
CMD_STATUS_BURNINGNO
CMD_STATUS_CLOSEDNO
CMD_STATUS_HEALTHCHECK_FAILEDYES
CMD_STATUS_HEALTHCHECK_UNKNOWNNO
CMD_STATUS_MESSAGE
CMD_STATUS_MUTEDNO
CMD_STATUS_RESTART_REQUIREDNO
CMD_STATUS_STATEFLAPPINGNO
CMD_STATUS_TERMINATEDNO
CMD_STATUS_TOOLMESSAGE
CMD_STATUSUP
CMD_STATUS_UPDATE_INDEX4
CMD_STATUS_USERMESSAGE
CMD_SYSINFO_SYSTEM_MANUFACTUREROpenStack Foundation
CMD_SYSINFO_SYSTEM_NAMEOpenStack Nova
CMD_TRIGGER_EXPRESSION(basecm11, , ) > 50
CMD_TRIGGER_NAMEkillallyestrigger
CMD_TRIGGER_UUID1b784150-3f4f-4cb2-af37-993bbbe3dea4
CMD_UPDATE_EPOCH_MILLISECONDS1733150703765
CMD_USERDEFINED1
CMD_USERDEFINED2
CMD_UUID78d29ab5-b415-486f-ad6a-04c5a983110f
CMD_VALUE101 KiB/s
CMD_VALUE_COUNT1
CMD_VALUE_EVALtrue
CMD_VALUE_TIME1733151851527

3.3.3 Environment Variables Useful For Debugging

The following environmental variables can be handy for debugging:

Table 3.3.3: Environment Variables Useful For Debugging
VariableDescription
CMD_INFO_FDSet file descriptor used by CMDaemon for collecting information (default value: 3)
CMD_DEBUGSetting this to a value of 1 often gives more debug output (default value: 0)

Examples of their use are given in sections 2.3, 2.4, and 2.13.