EasyManua.ls Logo

Tripp Lite B092-016 - Running Custom Scripts When Alerts Are Triggered

Tripp Lite B092-016
257 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...
202
Chapter 15: Advanced Configuration
15.1.2 Running custom scripts when alerts are triggered
Wheneveranalertgetstriggered,specicscriptsgetcalled.Thesescriptsallresidein /etc/scripts/. Below is a list of the default
scripts that get run for each applicable alert:
• 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specic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le/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]}"
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le"/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lecannotbefound,thescriptchecks
whetherthele"/etc/config/scripts/portmanager-pattern-alert"exists.Ifeitheroftheseles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le.Firstly,openthele/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le,oraddanyadditionalscriptingtothe
file.

Table of Contents

Other manuals for Tripp Lite B092-016

Related product manuals