Check_mssql and linked server queries
Posted: Tue Sep 03, 2019 3:14 pm
Hello everyone. Last week, we came up with a few queries that we wanted to use to monitor if replication is starting to go bad, but when we tried to use a linked server query or a view with check_mssql, the error that came back was:
string(144) "select count(*) from farad_production..control_systems s1 left join srvdbdwp01.scwdw.dbo.control_systems s2 on s1.id = s2.id where s2.id is null"
CRITICAL: Could not execute the Query.
I started to then poke around the check_mssql code and see if I could figure out what PDO was having an issue with:
// Attempt to execute the query/stored procedure $time_start = microtime(true); $pdo_query = $connection->prepare($query); if (!$pdo_query->execute()) { var_dump($query); $exit_code = 2; $output_msg = "CRITICAL: Could not execute the $querytype.\n"; display_output($exit_code, $output_msg); } else { $time_end = microtime(true); $query_duration = round(($time_end - $time_start), 6); $output_msg = "$querytype duration=$query_duration seconds."; }
That's as far I was able to get, PHP and I do not get along together and I broke our server because of it (I reverted the bad code to unbreak). Thoughts?
string(144) "select count(*) from farad_production..control_systems s1 left join srvdbdwp01.scwdw.dbo.control_systems s2 on s1.id = s2.id where s2.id is null"
CRITICAL: Could not execute the Query.
I started to then poke around the check_mssql code and see if I could figure out what PDO was having an issue with:
// Attempt to execute the query/stored procedure $time_start = microtime(true); $pdo_query = $connection->prepare($query); if (!$pdo_query->execute()) { var_dump($query); $exit_code = 2; $output_msg = "CRITICAL: Could not execute the $querytype.\n"; display_output($exit_code, $output_msg); } else { $time_end = microtime(true); $query_duration = round(($time_end - $time_start), 6); $output_msg = "$querytype duration=$query_duration seconds."; }
That's as far I was able to get, PHP and I do not get along together and I broke our server because of it (I reverted the bad code to unbreak). Thoughts?