Check website content
Posted: Mon Jan 30, 2017 9:56 am
I am trying to monitor a website so that if this XML content is not present then I need Nagios to send out a notification. I can get Nagios to return the text withing the <>text</> but not the <item> stuff.
For example if I access the site URL I get a long listing, XML format. I want to monitor to see if <AgentId> is present. If I monitor CL00053167 it works or if I just monitor CL or CINCINNATI any of the data between the values it works. This is all dynamic so I just want to monitor to validate there is data appearing. I figured it would be easier to check for <AgentId> but can't get it to work.
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<ArrayOfAgentLocation xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07 ... MVC.Models">
<AgentLocation>
<AgentId>CL00053167</AgentId>
<City>CINCINNATI</City>
<DistanceInKilometers>14.59196</DistanceInKilometers>
<DistanceInMiles>9.067023</DistanceInMiles>
<Email>[email protected]</Email>
<Latitude>39.0688</Latitude>
<LocationId>239</LocationId>
<Longitude>-84.35329</Longitude>
<Name>AGENCY DEVELOPMENT CORPORATION</Name>
<Phone>5134698999</Phone>
<State>OH</State>
<StreetAddress1>1080 NIMITZVIEW DR STE 301</StreetAddress1>
<StreetAddress2 i:nil="true"/>
<StreetAddress3 i:nil="true"/>
<StreetAddress4 i:nil="true"/>
<Zip>45230</Zip>
Here is the check I am using:
./check_http -H <host> -s "CINCINNATI" -f ok -u "/api/agent/getByZip?zipcode=45102&maximumAgents=10" -S -p 443
HTTP OK: HTTP/1.1 200 OK - 4076 bytes in 0.571 second response time |time=0.571009s;;;0.000000 size=4076B;;;0
./check_http -H <host> -s "<AgentId>" -f ok -u "/api/agent/getByZip?zipcode=45102&maximumAgents=10" -S -p 443
HTTP CRITICAL: HTTP/1.1 200 OK - string '<AgentId>' not found on 'https://columbuslife.com:443/api/agent/ ... mAgents=10' - 4076 bytes in 0.358 second response time |time=0.358072s;;;0.000000 size=4076B;;;0
For example if I access the site URL I get a long listing, XML format. I want to monitor to see if <AgentId> is present. If I monitor CL00053167 it works or if I just monitor CL or CINCINNATI any of the data between the values it works. This is all dynamic so I just want to monitor to validate there is data appearing. I figured it would be easier to check for <AgentId> but can't get it to work.
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<ArrayOfAgentLocation xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07 ... MVC.Models">
<AgentLocation>
<AgentId>CL00053167</AgentId>
<City>CINCINNATI</City>
<DistanceInKilometers>14.59196</DistanceInKilometers>
<DistanceInMiles>9.067023</DistanceInMiles>
<Email>[email protected]</Email>
<Latitude>39.0688</Latitude>
<LocationId>239</LocationId>
<Longitude>-84.35329</Longitude>
<Name>AGENCY DEVELOPMENT CORPORATION</Name>
<Phone>5134698999</Phone>
<State>OH</State>
<StreetAddress1>1080 NIMITZVIEW DR STE 301</StreetAddress1>
<StreetAddress2 i:nil="true"/>
<StreetAddress3 i:nil="true"/>
<StreetAddress4 i:nil="true"/>
<Zip>45230</Zip>
Here is the check I am using:
./check_http -H <host> -s "CINCINNATI" -f ok -u "/api/agent/getByZip?zipcode=45102&maximumAgents=10" -S -p 443
HTTP OK: HTTP/1.1 200 OK - 4076 bytes in 0.571 second response time |time=0.571009s;;;0.000000 size=4076B;;;0
./check_http -H <host> -s "<AgentId>" -f ok -u "/api/agent/getByZip?zipcode=45102&maximumAgents=10" -S -p 443
HTTP CRITICAL: HTTP/1.1 200 OK - string '<AgentId>' not found on 'https://columbuslife.com:443/api/agent/ ... mAgents=10' - 4076 bytes in 0.358 second response time |time=0.358072s;;;0.000000 size=4076B;;;0