Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

No Format
cat << 'EOL' >/usr/share/xymon-client/ext/asterisk.sh
#!/bin/sh

COLUMN=asterisk                             
COLOR=green                             
MSG='sudo asterisk -rx "core show hints" | grep "SIP/201&Custom:DND20  State:{Idle|InUse}'

#In this test, if var = empty = RED
var="$(sudo asterisk -rx "core show hints" | grep "SIP/201&Custom:DND20  State:Idle")"
var1="$(sudo asterisk -rx "core show hints" | grep "SIP/201&Custom:DND20  State:InUse")"
cmd="$(sudo asterisk -rx "core show hints")"


if [ -z "$var" ] && [ -z "$var1" ]

then

COLOR=red
MSG="${MSG}
FAILED
"${cmd}"
"
else

MSG="${MSG}
SUCCESS
"${cmd}"
"
fi

# Leave the rest of script alone
# Tell Xymon about it
$XYMON $XYMSRV "status $MACHINE.$COLUMN $COLOR `date`

${MSG}
"

exit 0
EOL


chown xymon:xymon /usr/share/xymon-client/ext/asterisk.sh
chmod 777 /usr/share/xymon-client/ext/asterisk.sh
 

cat << 'EOL' >/etc/xymon-client/client.d/asterisk.cfg
[asterisk]
 ENVFILE $XYMONCLIENTHOME/etc/xymonclient.cfg
 CMD $XYMONCLIENTHOME/ext/asterisk.sh
 LOGFILE $XYMONCLIENTHOME/logs/asterisk.log
 INTERVAL 15m
EOL
 
chown xymon:xymon /etc/xymon-client/client.d/asterisk.cfg
chmod 777 /etc/xymon-client/client.d/asterisk.cfg

/usr/share/xymon-client/bin/xymoncmd /usr/share/xymon-client/ext/asterisk.sh

/etc/init.d/xymon-client restart

...

No Format
cat << 'EOL' >/usr/share/xymon-client/ext/asterisk.sh
#!/bin/sh

COLUMN=asterisk                             
COLOR=green                             
MSG='asterisk -rx "sip show peers" | grep "{SIP|DEVICE}OK"'

#In this test, if var = empty = RED
var="$(sudo asterisk -rx "sip show peers" | grep "SIP.*OK")"
var1="$(sudo asterisk -rx "sip show peers" | grep "DEVICE.*OK")"
cmd="$(sudo asterisk -rx "sip show peers")"

if [ -z "$var" ] && [ -z "$var1" ]

then

COLOR=red
MSG="${MSG}
FAILED
""
"${cmd}"
"
else

MSG="${MSG}
SUCCESS
""
"${cmd}"
"
fi

# Leave the rest of script alone
# Tell Xymon about it
$XYMON $XYMSRV "status $MACHINE.$COLUMN $COLOR `date`

${MSG}
"

exit 0
EOL


chown xymon:xymon /usr/share/xymon-client/ext/asterisk.sh
chmod 777 /usr/share/xymon-client/ext/asterisk.sh
 

cat << 'EOL' >/etc/xymon-client/client.d/asterisk.cfg
[asterisk]
 ENVFILE $XYMONCLIENTHOME/etc/xymonclient.cfg
 CMD $XYMONCLIENTHOME/ext/asterisk.sh
 LOGFILE $XYMONCLIENTHOME/logs/asterisk.log
 INTERVAL 15m
EOL
 
chown xymon:xymon /etc/xymon-client/client.d/asterisk.cfg
chmod 777 /etc/xymon-client/client.d/asterisk.cfg

/usr/share/xymon-client/bin/xymoncmd /usr/share/xymon-client/ext/asterisk.sh

/etc/init.d/xymon-client restart

...