What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Parse data from html

Votes:

0

I have a device that provides data via an html page. I'm trying to setup the HTML Content sensor to grab the value data and report. However it's only provided in a table format, see below, this format cannot be changed. Also this page is refreshed on a 1-2 minute interval.

<tr>
  <td width="200" class="tblL">Downlink RF Power (dBm)</td>
  <td width="400" class="tblR">-37.1</td>
</tr>

Any ideas how I can make this work in PRTG, without too much coding if possible?

Thanks

html prtg sensor

Created on Oct 18, 2015 4:15:21 PM

Last change on Oct 30, 2015 3:35:14 PM by  Luciano Lingnau [Paessler]



3 Replies

Votes:

0

Hi there,

I'm afraid that the native HTML sensors will not be capable of extracting values from HTML tables, so this will need to be done with a custom script. As a kickoff, I found this article which describes a Powershell script. Please do also have a look at the API documentation Setup > PRTG API > Custom Sensors for the correct syntax.

Best regards, Felix

Created on Oct 21, 2015 5:56:21 AM by  Felix Saure [Paessler Support]



Votes:

0

Hi,

I'm still having issue with getting the custom sensor to work. I have a batch file that opens the target page to grab the data from, then writes this data to a file. I assume this data now needs to be converted into the prtg xml format so I can pull the data. Is this correct? If so is there an easier way than writing a custom exe file to accomplish this task? Setting up custom sensors could really be much easier than it is right now.

Thanks,

Stuart

Created on Oct 30, 2015 3:30:14 PM



Votes:

0

Hi,
I'm afraid there is no other way than using a script to parse the HTML. However, there is no need to save a file, you should be able to work with the HTML directly (e.g. in Powershell). Below you will find example code which reads the html and accesses a value:

ry{
    $page = Invoke-WebRequest -Uri ("{0}" -f $url)
}
Catch{
    Write-Host "0:An Error occured"
    Exit(2)
}
$data = $($page.ParsedHtml.getElementsByTagName("td"))
# Uncomment to see all elements
#foreach ($element in $data){
#    Write-Host $element.innerHTML
#}
#Write-Host $data[11].innerText.ToString()
# Some debugging and adjusting has to be done here
Write-Host ("{0}:{1}" -f $data[12].innerText.ToString(), $data[11].innerText.ToString())
Exit(0)

This snippet has an output which already can handled by PRTG's EXE/Script Sensor but you will have to adjust the parsing logic to suit your needs.

Created on Nov 5, 2015 7:28:15 AM by  Konstantin Wolff [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.