Console Server & Router User Manual
267
-
For a connection alert (when a user connects or disconnects from a port or network host):
/etc/scripts/portmanager-
user-alert
(for port connections) or
/etc/scripts/sdt-user-alert
(for host connections)
-
For a signal alert (when a signal on a port changes state):
/etc/scripts/portmanager-signal-alert
-
For a pattern match alert (when a specific regular expression is found in the serial ports character stream):
/etc/scripts/portmanager-pattern-alert
-
For a UPS status alert (when the UPS power status changes between on line, on battery, and low battery):
/etc/scripts/ups-status-alert
-
For a environmental, power and alarm sensor alerts(temperature, humidity, power load and battery charge alerts):
/etc/scripts/environmental-alert
-
For an interface failover alert:
/etc/scripts/interface-failover-alert
All of these scripts do a check to see whether you have created a custom script to run instead. The code that does this
check is shown below (an extract from the file /etc/scripts/portmanager-pattern-alert):
# If there's a user-configured script, run it instead
scripts[0]="/etc/config/scripts/pattern-alert.${ALERT_PORTNAME}"
scripts[1]="/etc/config/scripts/portmanager-pattern-alert"
for (( i=0 ; i < ${#scripts[@]} ; i++ )); do
if [ -f "${scripts[$i]}" ]; then
exec /bin/sh "${scripts[$i]}"
fi
done
This code shows that there are two alternative scripts that can be run instead of the default one. This code first checks
whether a file "
/etc/config/scripts/pattern-alert.${ALERT_PORTNAME}"
exists. The variable ${ALERT_PORTNAME} must
be replaced with "port01" or "port13" or whichever port the alert should run for. If this file cannot be found, the script
checks whether the file "
/etc/config/scripts/portmanager-pattern-alert"
exists. If either of these files exists the script calls
the
exec
command on the first file that it finds and runs that custom file/script instead.
As an example, you can copy the
/etc/scripts/portmanager-pattern-alert
script file to
/etc/config/scripts/portmanager-
pattern-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
The next step will be to edit the new script file. Firstly, open the file
/etc/config/scripts/portmanager-pattern-alert
using vi
(or any other editor), and remove the lines that check for a custom script (the code from above) - this will prevent the new
custom script from repeatedly calling itself. After these lines have been removed, edit the file, or add any additional
scripting to the file.
15.1.3 Example script - Power cycling on pattern match
If for example we had an RPC (PDU) connected to port 1 on a
console server
and also have some telecommunications
device connected to port 2 and 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:
Summary of Contents for ACM5000
Page 3: ......
Page 10: ...Table of Contents 10 Console Server RIM Gateway User Manual...
Page 11: ......
Page 94: ...Chapter 5 Firewall Failover and Out of Band 94 Console Server RIM Gateway User Manual...
Page 119: ......
Page 149: ......
Page 191: ......
Page 205: ......
Page 225: ......
Page 303: ......
Page 313: ......
Page 323: ......