_____________________________________________________________________
724-746-5500 | blackbox.com
Page 240
15.1.3 Example script -‐ Power Cycling on Pattern Match
For example, we have an RPC (PDU) connected to port 1 on a
console server
and also have some telecommunications
device connected to port 2 (which is powered by the RPC outlet 3). Now assume the telecom device transmits a
character stream "EMERGENCY" out on its serial console port every time that it encounters some specific error, and the
only way to fix this error is to power cycle the telecom device.
The first step is to setup a pattern-‐match alert on port 2 to check for the pattern "EMERGENCY".
Next we need to create a custom script to deal with this alert:
# cd /
# mkdir /etc/config/scripts
(if the directory does not already exist)
# cp /etc/scripts/portmanager-‐pattern-‐alert /etc/config/scripts/portmanager-‐pattern-‐alert
Note: Make sure to remove the
if
statement (which checks for a custom script) from the new script, in order to prevent
an infinite loop.
The
pmpower
utility is used to send power commands to RPC device in order to power cycle our telecom device:
# pmpower -‐l port01 -‐o 3 cycle
(The RPC is on serial port 1. The telecom device is powered by RPC outlet 3)
We can now append this command to our custom script. This will guarantee that our telecom device will be power
cycled every time the console reads the "EMERGENCY" character stream on port 2.
15.1.4 Example script -‐ Multiple email notifications on each alert
If you want to send more than one email when an alert triggers, you have to create a replacement script using the
method described above and add the appropriate lines to your new script.
Currently, there is a script
/etc/scripts/alert-‐email
that runs from within all the alert scripts (for example,
portmanager-‐
user-‐alert or environmental-‐alert
). The alert-‐email script sends the email. The line that invokes the email script is as
follows:
/bin/sh /etc/scripts/alert-‐email $suffix &
If you want to send another email to a single address or the same email to many recipients, edit the custom script
appropriately. You can follow the examples in any of the seven alert scripts listed above. In particular, consider the
portmanager-‐user-‐alert
script. If you need to send the same alert email to more than one email address, find the lines in
the script responsible for invoking the alert-‐email script, then add the following lines below the existing lines:
export TOADDR="[email protected]"
/bin/sh /etc/scripts/alert-‐email $suffix &
These two lines assign a new email address to TOADDR and invoke the alert-‐email script in the background.
15.1.5 Deleting Configuration Values from the CLI
The
delete-‐node
script is provided to help with deleting nodes from the command line. The
"delete-‐node"
script takes
one argument, the node name you want to delete (for example,
"config.users.user1"
or
"config.sdt.hosts.host1"
).
delete-‐node
is a general script for deleting any node you desire (users, groups, hosts, UPSes, etc.) from the command
line. The script deletes the specified node and shuffles the remainder of the node values.
For example, if we have five users configured and we use the script to delete user 3, then user 4 will become user 3, and
user 5 will become user 4.