Build precise queries to find exactly what you need
Press ESC to close
You can actually easily modify the script in order to retrieve values from the query. I modified mine to retrieve only one value:
in process_results, i changed $perfdata=…. to $perfdata = “value={$query_duration};0;”; There is no need for me to actually show static lines for warning and critical.
i initially did the change for query, but due to the complexity of the query, just better to go through a stored proc to dodge nagios / centreon cleanup string functions.
before the call to process_results i did the following changes that will allow you to retrieve a value for a procedure:
//Custom modification by ######### if ($querytype == “stored procedure”) { $stmt = mssql_init($oldstoredproc);
$query_data = mssql_execute($stmt); $query_result=”no result returned”;
if (mssql_num_rows($query_data) > 0 ) { $row = mssql_fetch_row($query_data); $query_result = $row[0]; // cheating on process_results $query_duration = $query_result; $output_msg = “Value=$query_result.”; } mssql_free_statement($stmt); $exit_code = 0; } // end of custom
and at the beginning of the file, I changed to the following because mssql_execute does not need the exec part: // Add “exec” to the beginning of the stored proc if it doesnt exist. if (isset($storedproc)) { $oldstoredproc = $storedproc; if (substr($storedproc, 0, 5) != “exec “) { $storedproc = “exec $storedproc”; } }
We’ve completely redesigned the world’s largest repository of Nagios plugins and monitoring tools. Join thousands of users sharing monitoring solutions for servers, applications, and everything in between.
Due to our redesign, all existing accounts require a password reset to access your account again.
Ready to explore 6,100+ projects and contribute to the community?
Reset Password Create Account
Happy Monitoring!