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?
Check_mssql and linked server queries
Re: Check_mssql and linked server queries
I'm digging into this on my side, but I just wanted to throw out a quick question.
Should that be farad_production..control_systems? I'm not used to seeing two .'s next to each other. Does this query work if you copy/paste it into Management Studio?farad_production..control_systems
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
dietdrpepper
- Posts: 12
- Joined: Mon Jul 01, 2019 4:13 pm
Re: Check_mssql and linked server queries
Correct, it's an older version of sql syntax. It also does run. I wonder if that is why PDO isn't liking it? There's a few here that also use the older join syntax which kills me and wants to rewrite queries, lol.
join on table 1.id = table 2.id,
table 3,
table 4
Ugh.
join on table 1.id = table 2.id,
table 3,
table 4
Ugh.
Re: Check_mssql and linked server queries
It could be that PDO doesn't like the older syntax. Is it possible to re-build that query and try it out?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!