
Here's the scenario; my team runs a program (on linux) that sometimes floods the network. Instead of waiting for someone to come tell us "Hey, you've crippled the network again.", we would like to have the program shutdown automatically if "Packet Loss" on more than 2 of our switches reach 85%.
Here's how I think it could work; a script, (python/perl/bash) using SOAP can poll the "Packet Loss" stat from Orion NPM. If the stat reaches a point where people normally start complaining, it executes the shutdown script.
I originally wrote a script in python that logged into the linux box over ssh, then ran the shutdown script, all from my test Orion NPM box. I then created an alert condition which executed the script when the packet loss threshold was met. It worked great in my tests, however the guys who run our Production Orion NPM won't allow us to install python or anything else on it. So now we must use SWIS.
I'm using soapUI to figure out the messages we need to send and what we'll be getting back, and so far all I can do through SOAP is read: swis://solarwinds/Orion/Orion.Nodes/NodeID=n/Stats
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inf="http://schemas.solarwinds.com/2007/08/informationservice">
<soapenv:Header/>
<soapenv:Body>
<inf:Read>
<inf:uri>swis://solarwinds/Orion/Orion.Nodes/NodeID=1/Stats</inf:uri>
</inf:Read>
</soapenv:Body>
</soapenv:Envelope>
Using SWIS Studio, I use this query to see how many nodes are "down" though packet loss:
select count(NodeID) AS NodesCount from Orion.NodesStats where PercentLoss = '100'
Now for my real question:
How do I send my query "select count(NodeID) AS NodesCount from Orion.NodesStats where PercentLoss = '100'" though SOAP?
I know I should use the Query message type:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inf="http://schemas.solarwinds.com/2007/08/informationservice" xmlns:quer="http://schemas.solarwinds.com/2007/08/informationservice/queryoptions">
<soapenv:Header/>
<soapenv:Body>
<inf:Query>
<!--Optional:-->
<inf:query>?</inf:query>
<!--Optional:-->
<inf:queryOptions>
<quer:outputFormat>?</quer:outputFormat>
</inf:queryOptions>
</inf:Query>
</soapenv:Body>
</soapenv:Envelope>
But I'm not sure how to format it inside the SOAP request.
Are there any other tools we could use from a linux machine, kind of like the PoweShell Snapin?
Thanks!
-dan-
The "Query" message is not really recommended because the output is hard to parse. You should use the "QueryXml" message instead. Here's an example request (whitespace added):
POST https://tdanner-dev:17778/SolarWinds/InformationService/OrionBasic HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://schemas.solarwinds.com/2007/08/informationservice/InformationService/QueryXml"
Authorization: Basic YWRtaW46
Host: tdanner-dev:17778
Content-Length: 306
Expect: 100-continue
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<QueryXml xmlns="http://schemas.solarwinds.com/2007/08/informationservice">
<query>select count(NodeID) AS NodesCount from Orion.NodesStats where PercentLoss = '100'" RETURN XML RAW</query>
<parameters/>
</QueryXml>
</s:Body>
</s:Envelope>
And the response will look like this (whitespace added):
HTTP/1.1 200 OK
Content-Length: 532
Content-Type: text/xml; charset=utf-8
Server: Microsoft-HTTPAPI/2.0
Date: Fri, 20 Jan 2012 17:23:38 GMT
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header><log xmlns="http://schemas.solarwinds.com/2007/08/informationservice"/></s:Header>
<s:Body>
<QueryXmlResponse xmlns="http://schemas.solarwinds.com/2007/08/informationservice">
<QueryXmlResult>
<queryResult xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<template>
<resultset>
<column name="NodesCount" type="Int32" ordinal="0"/>
</resultset>
</template>
<data>
<row>
<c0>0</c0>
</row>
</data>
</queryResult>
</QueryXmlResult>
</QueryXmlResponse>
</s:Body>
</s:Envelope>
From a Linux box we don't have anything as convenient as the PowerShell snapin. The Java sample in the SDK should work on Linux (though I haven't tried it). You could also try the Perl approach from this thread: Problem consuming wsdl
Thank you!
The query works and I'm getting the information I'm looking for.
Thanks again!
-dan-