How to check SQL jobs (particular jobs)
Posted: Wed Oct 16, 2019 11:34 am
Please advise how to monitor MsSQL Jobs with XI standard plugins?
Support for Nagios products and services
https://support.nagios.com/forum/
Code: Select all
/usr/local/nagios/libexec/check_mssql -H <IPAddress> -p <PortNum> -U <username> -P <password> -d <DBname> -q "SELECT sj.name FROM msdb.dbo.sysjobactivity AS sja INNER JOIN msdb.dbo.sysjobs AS sj ON sja.job_id = sj.job_id WHERE sja.start_execution_date IS NOT NULL AND sja.stop_execution_date IS NULL AND sj.name LIKE '<JobName>%'" -W 1 -C 2 --result nameCode: Select all
array(2) {
[0]=>
array(1) {
["name"]=>
string(12) "<JobName>"
}
[1]=>
array(1) {
["name"]=>
string(13) "<JobName2>"
}
}
WARNING: Query result <JobName2> was higher than Query warning threshold 0.|query_duration=0.000576s;; 'name'=<JobName2>;0;mbellerue wrote:You would have to execute a query to find a running job. Here's what I have.
This returns,Code: Select all
/usr/local/nagios/libexec/check_mssql -H <IPAddress> -p <PortNum> -U <username> -P <password> -d <DBname> -q "SELECT sj.name FROM msdb.dbo.sysjobactivity AS sja INNER JOIN msdb.dbo.sysjobs AS sj ON sja.job_id = sj.job_id WHERE sja.start_execution_date IS NOT NULL AND sja.stop_execution_date IS NULL AND sj.name LIKE '<JobName>%'" -W 1 -C 2 --result nameCode: Select all
array(2) { [0]=> array(1) { ["name"]=> string(12) "<JobName>" } [1]=> array(1) { ["name"]=> string(13) "<JobName2>" } } WARNING: Query result <JobName2> was higher than Query warning threshold 0.|query_duration=0.000576s;; 'name'=<JobName2>;0;
Still no luckmbellerue wrote:That looks generally correct. Can you try it without the query being encoded, and drop the --decode?
Still no go: "CRITICAL: Could not execute the Query."mbellerue wrote:I think I've made a mistake in my command to you. I stated that you could specify a database, using the -d <DBName>. I think the master DB specifically is what tracks jobs in SQL Server. Try specifying master, and see if it comes back.
Hi, query works now, but provides a strange result:mbellerue wrote:I'm not sure if it's failing because something is wrong with the query, or if something else is wrong. Let's scale this back and just see if you can run a simple select query. Try just selecting one field from one table with one result, and see if it's able to execute that.