Difference between revisions of "Nagios plugin for ASE"
m |
|||
Line 58: | Line 58: | ||
==Setup Sybase environment== | ==Setup Sybase environment== | ||
− | + | Before you go further, check if you have Sybase OpenClient software installed on the server where Nagios is running. | |
+ | |||
+ | Add the servers you want to monitor to the $SYBASE/interfaces file. Sample: | ||
ASE1 | ASE1 | ||
query tcp ether prd-syb-ase1 4000 | query tcp ether prd-syb-ase1 4000 | ||
Line 64: | Line 66: | ||
− | Log on to the ASE server and add a login that will be used by Nagios to connect to | + | Log on to the ASE server and add a login that will be used by Nagios to connect to ASE. |
isql -Usa -SASE1 | isql -Usa -SASE1 | ||
1> sp_addlogin nagios,nagios | 1> sp_addlogin nagios,nagios |
Latest revision as of 23:02, 18 December 2007
When you are using Nagios (http://www.nagios.org) as a monitoring tool, it's real easy to implement your own checks for Sybase servers. Here's a sample check to see if your ASE server is up and connectable.
Create Nagios check script
#!/bin/sh # Plugin for Nagios to check if an ASE is up # Author Peter Sap (www.petersap.nl) # All disclamers apply. if [ $# -ne 1 ] then echo "Usage $0: <ASE server>" exit 1 fi SERVER=$1 STATE_OK=0 STATE_WARNING=1 STATE_CRITICAL=2 STATE_UNKNOWN=3 STATE_DEPENDENT=4 export SYBASE=<location of OpenClient software> export SYBASE_OCS=OCS-15_0 $SYBASE/$SYBASE_OCS/bin/isql -Unagios -Pnagios -S${SERVER} -b<<EOF > /tmp/$$ set nocount on go select count(*) from master..sysprocesses where suid != 0 go EOF if [ `head -n 1 /tmp/$$|grep "CT-LIBRARY"|wc -l` -gt 0 ] then rm -f /tmp/$$ echo "Could not connect to ${SERVER}." exit ${STATE_CRITICAL} fi if [ `head -n 1 /tmp/$$|grep "^Msg "|wc -l` -gt 0 ] then MSG=`head -n 3 /tmp/$$|tail -n 1` rm -f /tmp/$$ echo "Could not connect to ${SERVER}, ${MSG}" exit ${STATE_CRITICAL} fi COUNT=`cat /tmp/$$` rm -f /tmp/$$ echo "Server ${SERVER} up," ${COUNT} "active sessions (including workers)" exit ${STATE_OK}
Store this script in the Nagios libexec directory with the name "check_sybase_ase_up" . Do a "chmod +x" to make it executable.
Setup Sybase environment
Before you go further, check if you have Sybase OpenClient software installed on the server where Nagios is running.
Add the servers you want to monitor to the $SYBASE/interfaces file. Sample:
ASE1 query tcp ether prd-syb-ase1 4000
The interfaces file must be stored on the machine where Nagios is running.
Log on to the ASE server and add a login that will be used by Nagios to connect to ASE.
isql -Usa -SASE1 1> sp_addlogin nagios,nagios 2> go Password correctly set. Account unlocked. New login created. (return status = 0) 1>
Edit Nagios files
Define the "check_sybase_ase_up" script in the definition file for commands, e.g. checkcommands.cfg
# 'check_sybase_ase_up' command definition define command{ command_name check_sybase_ase_up command_line $USER1$/check_sybase_ase_up $ARG1$ }
Now you can use the command as a service check. Add this sample to the definition file for your checks, to check the ASE1 server.
define service{ use generic-service host_name prd-syb-ase1 service_description ASE1 is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_sybase_ase_up!ASE1 }
Restart Nagios.