Hi KFluffie
i’ve been using scripts from this page : http://www.sqlservercentral.com/articles/Administering/sevenmonitoringscripts/1024/
and wrapping small shell scripts around them that i call from nagios.
here’s an example of one i use for checking for failed jobs;
[code]#!/bin/bash
check_mssql_jobs.sh
version date
1.0 18 Sep 2007 k release
if ! $1 ]
then
echo "Usage: $0 server [jobname]"
exit 3
fi
SERVER=echo $1 | awk 'BEGIN{FS="."}{print $1}'
SP="msdb.dbo.sp_help_job"
if $2 ]
then
jobname=echo $2 | awk 'BEGIN{FS="."}{print $1}'
SP="msdb.dbo.sp_help_job @job_name = ‘$jobname’"
fi
SQL=“select name, run_status, substring(cast(run_date as varchar(8)),7,2) + ‘/’ + substring(cast(run_date as varchar(8)),5,2) + ‘/’ +
substring(cast(run_date as varchar(8)),1,4) + ’ ’ + case len(cast(run_time as varchar(6))) when 6 then left(cast(run_time as
varchar(6)),2) + ‘:’ + substring(cast(run_time as varchar(6)),3,2) when 5 then left(cast(run_time as varchar(6)),1) + ‘:’ +
substring(cast(run_time as varchar(6)),2,2) else ‘00:00’ end as ‘RunTime’ from msdb.dbo.sysjobhistory sjh join msdb.dbo.sysjobs sjv
on sjh.job_id = sjv.job_id where instance_id in (select top 1 instance_id from msdb.dbo.sysjobhistory sjh2 where step_name = ‘(Job
outcome)’ and sjh.job_id = sjh2.job_id order by instance_id desc) and run_status = 1 order by run_status, instance_id DESC”
export USER=xxxxxx
export PASS=xxxxxx
export OUTFILE="/tmp/check_mssql_jobs_$1.tmp"
/usr/local/bin/tsql -H $SERVER -p 1433 -U $USER -P $PASS > $OUTFILE << EOF
set nocount on
go
$SQL
go
exit
EOF
grep “Login failed” $OUTFILE >> /dev/null
if $? -eq 0 ]
then
echo "CRITICAL - LOGIN FAILED!! $SERVER DOWN??"
rm -f $OUTFILE
exit 2
fi
JOB=awk '{FS="\t"}{print $1}' $OUTFILE | sed -n '4p'
mv -f $OUTFILE $OUTFILE.bak
if $JOB ]
then
echo "$SERVER Sql Job(s) Failed - $JOB"
exit 2
else
echo "$SERVER Sql Jobs all OK"
exit 0
fi[/code]
not the most elegant solution i admit, but it does the job