EasyManua.ls Logo

Black Box LES1608A - Example Script: Power Cycling on Pattern Match; Example Script: Mulitple Email Notifications on each Alert

Black Box LES1608A
348 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
285
1. 8 7 7. 8 7 7. 2 26 9 BLACKBOX.COM
NEED HELP?
LEAVE THE TECH TO US
LIVE 24/7
TECHNICAL
SUPPORT
1.877.87 7.2269
CHAPTER 16: ADVANCED CONFIGURATION
The next step is to edit the new script file.
Open the file /etc/config/scripts/portmanager-pattern-alert using vi (or other text editor).
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.
16.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 that 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, 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.
16.1.4 EXAMPLE SCRIPT: MULTIPLE E-MAIL NOTIFICATIONS ON EACH ALERT
If you desire 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 is responsible for sending the email. The line which invokes the email script looks as
follows:
/bin/sh /etc/scripts/alert-email $suffix &
If you wish 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. 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="emailaddress@domain.com"
/bin/sh /etc/scripts/alert-email $suffix &

Table of Contents