Quantcast
Channel: THWACK: Message List
Viewing all articles
Browse latest Browse all 20396

Re: Need help with the "Define SQL variable" feature please

$
0
0

So far, I use it for two different things.  The first is to give me a status of all of my power supplies in our nexus switches.  Note, this query has a union so I can supply a response of NOT PRESENT if the PS is missing.

 

Power Supply 1: ${SQL:SELECT CustomPollerStatus.Status, CustomPollerAssignment.CustomPollerID FROM CustomPollerStatus INNER JOIN CustomPollerAssignment ON (CustomPollerStatus.CustomPollerAssignmentID = CustomPollerAssignment.CustomPollerAssignmentID) INNER JOIN CustomPollers ON (CustomPollers.CustomPollerID = CustomPollerAssignment.CustomPollerID) WHERE CustomPollerAssignment.NodeID = ${NodeID} AND CustomPollers.UniqueName = 'N7KPSPS1' UNION SELECT 'N/A',NULL WHERE NOT EXISTS ( SELECT 1 FROM CustomPollerStatus INNER JOIN CustomPollerAssignment ON (CustomPollerStatus.CustomPollerAssignmentID = CustomPollerAssignment.CustomPollerAssignmentID) INNER JOIN CustomPollers ON (CustomPollers.CustomPollerID = CustomPollerAssignment.CustomPollerID) WHERE CustomPollerAssignment.NodeID = ${NodeID} AND CustomPollers.UniqueName = 'N7KPSPS1' )}

Power Supply 2: ${SQL:SELECT CustomPollerStatus.Status, CustomPollerAssignment.CustomPollerID FROM CustomPollerStatus INNER JOIN CustomPollerAssignment ON (CustomPollerStatus.CustomPollerAssignmentID = CustomPollerAssignment.CustomPollerAssignmentID) INNER JOIN CustomPollers ON (CustomPollers.CustomPollerID = CustomPollerAssignment.CustomPollerID) WHERE CustomPollerAssignment.NodeID = ${NodeID} AND CustomPollers.UniqueName = 'N7KPSPS2’ UNION SELECT 'N/A',NULL WHERE NOT EXISTS ( SELECT 1 FROM CustomPollerStatus INNER JOIN CustomPollerAssignment ON (CustomPollerStatus.CustomPollerAssignmentID = CustomPollerAssignment.CustomPollerAssignmentID) INNER JOIN CustomPollers ON (CustomPollers.CustomPollerID = CustomPollerAssignment.CustomPollerID) WHERE CustomPollerAssignment.NodeID = ${NodeID} AND CustomPollers.UniqueName = 'N7KPSPS2’ )}

 

I also use it to determine the battery status of the UPS for a location whenever a device goes down.

 

A couple of things to note:  Carriage returns break this functionality. Also, if you use this on a custom poller that is not assigned, and you don't do a union like I'm doing above, you will receive the entire sql in your email alert.


Viewing all articles
Browse latest Browse all 20396

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>