Nagios plugin for BackupServer
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 Sybase BackupServer is up and connectable.
Create Nagios check script
#!/bin/sh # Plugin for Nagios to check if a BackupServer is up # Author Peter Sap (www.petersap.nl) # All disclamers apply. if [ $# -ne 1 ] then echo "Usage $0: <Backup 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/$$ sp_who 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 MSG="`head -n 1 /tmp/$$`" if [ `echo ${MSG}|grep "No language handler installed"|wc -l` -ne 1 ] then rm -f /tmp/$$ echo "State of backupserver unknown, ${MSG}" exit ${STATE_CRITICAL} fi rm -f /tmp/$$ echo "Server ${SERVER} up" exit ${STATE_OK}
Store this script in the Nagios libexec directory with the name "check_sybase_backup_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:
SYB_BACKUP query tcp ether prd-syb-ase1 4001
The interfaces file must be stored on the machine where Nagios is running.
Edit Nagios files
Define the "check_sybase_backup_up" script in the definition file for commands, e.g. checkcommands.cfg
# 'check_sybase_backup_up' command definition define command{ command_name check_sybase_backup_up command_line $USER1$/check_sybase_backup_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 SYB_BACKUP server.
define service{ use generic-service host_name prd-syb-ase1 service_description SYB_BACKUP 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_backup_up!SYB_BACKUP }
Restart Nagios.