HARD DISK MONITORING

How to: integrate Hard Disk Sentinel by automatic XML report export

In this tutorial, it is described how to configure Hard Disk Sentinel to create and automatically update an XML file which contains all detected status information, including but not limited to

The created XML file can be read, processed by any third party application, script - and this allows integrators, developers to display, store, process any detected information and make custom actions, logging based on that.

Generally the information in the XML file is similar which saved in a text / HTML report (saved by using the Report menu in Hard Disk Sentinel), just in different XML format.

Requirements

Registered (complete) Hard Disk Sentinel version required to be installed.

Configuration

Enable Configuration -> Advanced Options -> Generate and update XML file. By default, this saves HDSentinel.xml file in the folder where the software installed. By the button next to the option, it is possible to select the target location of the XML file. The XML file updated automatically based on the configured detection frequency (which can be adjusted by the slider on the top of the Advanced Options page, by default once per every 5 minutes).

Configuration -> Advanced options

Alternatively, the complete status in XML reports can be read over the network (internet) via HTTP, from any web browser or tool downloading web traffic (for example wget). For this, please enable Configuration -> Integration -> Enable WebStatus option - and then it is possible to read the complete report by entering http://computer-name:61220/xml in any web browser, where computer-name is the name (or IP address) of the actual computer.

Processing

The created XML report can be read, processed differently based on the actual requirements. There are Add-ons available, using this technique, for example the Remote PC status gadget and the Nagios integration.

Example 1: read by VBS script

Just open notepad, copy/paste the following code and save the file as hdsentinel-xml-demo.vbs in the folder where Hard Disk Sentinel saves the XML file. Then double-clicking on the hdsentinel-xml-demo.vbs file (or by starting cscript hdsentinel-xml-demo.vbs) gives the details from the XML file.


Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = "False"
xmlDoc.Load("HDSentinel.xml")

For count=0 to 255

 Set colNodes = xmlDoc.selectNodes _
 ("/Hard_Disk_Sentinel/Physical_Disk_Information_Disk_"&count&"/Hard_Disk_Summary/Hard_Disk_Model_ID")
 For Each objNode in colNodes
    Wscript.Echo "Disk "&count&" Model ID     : "&objNode.Text
 Next

 Set colNodes = xmlDoc.selectNodes _
 ("/Hard_Disk_Sentinel/Physical_Disk_Information_Disk_"&count&"/Hard_Disk_Summary/Hard_Disk_Serial_Number")
 For Each objNode in colNodes
    Wscript.Echo "Disk "&count&" Serial Number: "&objNode.Text
 Next

 Set colNodes = xmlDoc.selectNodes _
 ("/Hard_Disk_Sentinel/Physical_Disk_Information_Disk_"&count&"/Hard_Disk_Summary/Interface")
 For Each objNode in colNodes
    Wscript.Echo "Disk "&count&" Interface    : "&objNode.Text
 Next

 Set colNodes = xmlDoc.selectNodes _
 ("/Hard_Disk_Sentinel/Physical_Disk_Information_Disk_"&count&"/Hard_Disk_Summary/Current_Temperature")
 For Each objNode in colNodes
    Wscript.Echo "Disk "&count&" Temperature  : "&objNode.Text
 Next

 Set colNodes = xmlDoc.selectNodes _
 ("/Hard_Disk_Sentinel/Physical_Disk_Information_Disk_"&count&"/Hard_Disk_Summary/Health")
 For Each objNode in colNodes
    Wscript.Echo "Disk "&count&" Health       : "&objNode.Text
 Next

 Set colNodes = xmlDoc.selectNodes _
 ("/Hard_Disk_Sentinel/Physical_Disk_Information_Disk_"&count&"/Hard_Disk_Summary/Performance")
 For Each objNode in colNodes
    Wscript.Echo "Disk "&count&" Performance  : "&objNode.Text
 Next

Next

Sample output:

XML output

Example 2: integration with PRTG

Quote from Ken Wallewein (Thanks for his hard work and sharing the information): "PRTG offers direct XML reading functionality. Here's some example PowerShell code that shows the XML need. "

Reads from URL, writes to SYS$OUTPUT
Requires Powershell 3 or 4 (?)


$result = Invoke-WebRequest -Uri "http://kmbdr1:61220/xml" -ErrorAction SilentlyContinue -UseBasicParsing

if ($result.StatusCode -ne 200){
    write-host ""
    write-host "1"
    write-host "HTTP Request Failed"
    write-host ""
    Exit
}

[xml] $xdoc = $result.Content

## Write-Output $result.Content 
## Write-Output $xdoc 

Write-Output ""

foreach ($xmlnode in $xdoc.Hard_Disk_Sentinel.Childnodes.Hard_Disk_Summary) {
    Write-Output ""
    Write-Output "$($xmlnode.Hard_Disk_Serial_Number)"
    Write-Output "$($xmlnode.Health)"
    Write-Output "1"
    Write-Output ""
  }

Write-Host ""

Tips

It may be good idea to combine XML output with other functions, for example the WMI function, when status information can be read by WMI queries, from local or remote computer.

Also it is good solution to use Hard Disk Sentinel in service mode. This way the software runs in the background "silently" as NT Service and without affecting the current user, it is possible to use these functions to detect and read/parse/process the collected status information (in addition to possible other options, for example alerts), making ideal solution to monitor status of computers where users have limited user rights only - or even computers (servers) where there is no active user at all.

Feedback

Feel free to submit questions, suggestions or possible other requirements to info (at) hdsentinel (dot) com e-mail address. If you create and want to share 3rd party add-on(s) based on this function, feel free to contact and it can be added to the Add-ons page to help other users too.

 

Navigation

Hard Disk Sentinel Home

News

Products

Store

Support

Partners

Useful links

Download Hard Disk Sentinel

Frequently asked questions

Knowledge base

Discussion forum

Contact us

Privacy policy

Resources

Q&A Knowledge Base

Testimonials

Use Case

HDSentinel on Facebook

HDD Monitoring Blog

About

Newsletter

Enter your e-mail address to receive news, tips, updates and special offers about Hard Disk Sentinel software. More ...

Your e-mail address is kept securely (see our privacy policy).


© 2024 H.D.S. Hungary. All Rights Reserved.

Software for hard disk monitoring and data protection