It is currently May 1st, 2024, 11:04 am

WebParser problems, not sure where I'm going wrong

Get help with creating, editing & fixing problems with skins
mistawac
Posts: 14
Joined: August 19th, 2012, 8:05 pm

WebParser problems, not sure where I'm going wrong

Post by mistawac »

I'm trying to use the WebParser tutorial from the manual (http://rainmeter.net/cms/Tips-WebParserPrimer) to learn how to use WebParser for my needs. Allow me to describe what I'm doing:

I'm a system admin and work from home. Our monitoring software is Icinga and I generally have the browser open to our intranet Icinga site regardless of if I'm working or not so I can monitor if something goes wrong somewhere. What I'd like to do is bring that information to my desktop for our crucial checks so I don't really need to keep Chrome open all the time.

What I have right now is this (pertinent information edited out for security):

Code: Select all

[Variables]
URL="http://xxx.xxx.xxx.xxx/icinga/cgi-bin/extinfo.cgi?type=2&host=HOSTNAME&service=AV+Client"
FontColor=255, 255, 255, 255
FontFace=rockwell
Substitute="&":"&",""":"","&Quot;":"","<br>":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE>":"","PRE>":"","<":""

[MeasureWebsite]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1800
Url=#URL#
RegExp="(?siU)<TR><TD CLASS='dataVar'>Current Status:</TD><TD CLASS='dataVal'><DIV CLASS='(.*)'>.*"
Debug=1

[MeasureIPAddress]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWebsite]
StringIndex=1
The line I'm looking for in the website code is:

Code: Select all

<TR><TD CLASS='dataVar'>Current Status:</TD><TD CLASS='dataVal'><DIV CLASS='serviceCRITICAL'>&nbsp;&nbsp;CRITICAL&nbsp;&nbsp;</DIV>&nbsp;(for  0d  0h  0m 20s)</TD></TR>
It's not bringing up any information. I checked the log file and it's telling me it can fetch the website, but cannot find a match for that line of code. Anyone have any ideas?
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WebParser problems, not sure where I'm going wrong

Post by jsmorley »

You sure that you are getting:

Code: Select all

<TR><TD CLASS='dataVar'>Current Status:</TD><TD CLASS='dataVal'><DIV CLASS='serviceCRITICAL'>&nbsp;&nbsp;CRITICAL&nbsp;&nbsp;</DIV>&nbsp;(for  0d  0h  0m 20s)</TD></TR>
In your browser when you hit the site? It's not important what is in the source code for the page, but what you get when you display the HTML with "view source" in your browser.
mistawac
Posts: 14
Joined: August 19th, 2012, 8:05 pm

Re: WebParser problems, not sure where I'm going wrong

Post by mistawac »

Yeah. Once I navigate to the correct service I want to monitor and view the source that's in there. That value can be 1 of 3 different states (serviceOK, serviceWARNING, serviceCRITICAL).

I think its worth mentioning that the website uses frames. The address bar always shows http://xxx.xxx.xxx.xxx/icinga regardless of what I click. I had to drill down into the service I wanted then view the source for that site and used the URL it pulled up. I know that works alright.

Its definitely there.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WebParser problems, not sure where I'm going wrong

Post by jsmorley »

mistawac wrote:Yeah. Once I navigate to the correct service I want to monitor and view the source that's in there. That value can be 1 of 3 different states (serviceOK, serviceWARNING, serviceCRITICAL).

I think its worth mentioning that the website uses frames. The address bar always shows http://xxx.xxx.xxx.xxx/icinga regardless of what I click. I had to drill down into the service I wanted then view the source for that site and used the URL it pulled up. I know that works alright.

Its definitely there.
What I would do is put Debug=1 on the main Webparser measure. That will download what is being returned by the site into a text file in the root folder of your hard drive, called C:\WebParserDump.txt. I would check that to be sure WebParser is getting what you think it is. It can be tricky with frames.

The reason I say that is because when I parse that text you posted using the RegExp= that you are using, it works just fine and returns "serviceCRITICAL" in StringIndex 1.

Edit: I see that you already have Debug=1 on the measure. Is what is in WebParserDump.txt correct?
mistawac
Posts: 14
Joined: August 19th, 2012, 8:05 pm

Re: WebParser problems, not sure where I'm going wrong

Post by mistawac »

...seriously? That's just annoying! I've been messing with this since 2 and the damn thing doesn't want to work.

I'll let you know what the webparser log says.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WebParser problems, not sure where I'm going wrong

Post by jsmorley »

mistawac wrote:...seriously? That's just annoying! I've been messing with this since 2 and the damn thing doesn't want to work.

I'll let you know what the webparser log says.
It's not really a log in WebParserDump.txt, but rather the entire HTML that was sent to WebParser by the site. Very useful in cases like this to be sure WebParser is getting what you think it is.
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: WebParser problems, not sure where I'm going wrong

Post by Seahorse »

Also worth using RainRegExp tool. which makes for quicker testing.
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WebParser problems, not sure where I'm going wrong

Post by jsmorley »

One thing that concerns me is that I can't imagine that your work site is open to the public, and that you are logging in either in your browser and thus setting a cookie of some kind, or through some kind of VPN that requires some kind of token to be passed back and forth.

Be aware that WebParser will not do any of this. It just hits the URL as a complete "stranger", and cannot use cookies or other authentication.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WebParser problems, not sure where I'm going wrong

Post by jsmorley »

Seahorse wrote:Also worth using RainRegExp tool. which makes for quicker testing.
Yes, but that is kinda beside the point really. His RegExp is fine.
mistawac
Posts: 14
Joined: August 19th, 2012, 8:05 pm

Re: WebParser problems, not sure where I'm going wrong

Post by mistawac »

jsmorley wrote:One thing that concerns me is that I can't imagine that your work site is open to the public, and that you are logging in either in your browser and thus setting a cookie of some kind, or through some kind of VPN that requires some kind of token to be pasted back and forth.

Be aware that WebParser will not do any of this. It just hits the URL as a complete "stranger", and cannot use cookies or other authentication.
It's only open to the subnet that administrators get when they log into the VPN and it's completely internal. A username/password is required to login though, I'm now guessing that may be an issue? Judging by the rainmeter log it's hitting the site, just not finding the information.

In any case, there's no webparserdump.txt in my C:. I have Debug=1 in the [MeasureWebsite] measure, logging on, and debug enabled in Rainmeter. However, whenever I check the log file from the systray icon it shows this information:

Code: Select all

NOTE (05:23:43.372) Refreshing skin "IPLookup\IP.ini"
DBUG (05:23:43.372) Reading file: C:\Users\mistawac\AppData\Roaming\Rainmeter\Rainmeter.ini
DBUG (05:23:43.372) Reading file: C:\Users\mistawac\Documents\Rainmeter\Skins\IPLookup\IP.ini
DBUG (05:23:43.372) WebParser.dll: Fetching: http://xxx.xxx.xxx.xxxxicinga/cgi-bin/extinfo.cgi?type=2&host=HOSTNAME&service=AV+Client
ERRO (05:23:43.481) WebParser.dll: [MeasureWebsite] Matching error! (-1)
That's probably not useful, thought I'd post it though. In any case, no WebParserDump.txt in the C:\