Wednesday, September 15, 2010

Web Scraping Nagios

I have not been web scape for quite a while. Recently I need to rearrange and summarise Nagios data so as to present the monitoring info into some form of management dashboard.

With Tcl and it's tdom extension, I am able to web scrape with ease. However, one of the challenges is that I need to summarise all the disk partitions utilisation criticality as a single service. My initial XPath is to go through all 26 partitions (Disks A to Z)

$branch selectNodes {td/a[@class='statusCRITICAL'][
    text()='WINDISK-A' or text()='WINDISK-B' or text()='WINDISK-C' or
    text()='WINDISK-D' or text()='WINDISK-E' or text()='WINDISK-F' or
    text()='WINDISK-G' or text()='WINDISK-H' or text()='WINDISK-I' or
    text()='WINDISK-J' or text()='WINDISK-K' or text()='WINDISK-L' or
    text()='WINDISK-M' or text()='WINDISK-N' or text()='WINDISK-O' or
    text()='WINDISK-P' or text()='WINDISK-Q' or text()='WINDISK-R' or
    text()='WINDISK-S' or text()='WINDISK-T' or text()='WINDISK-U' or
    text()='WINDISK-V' or text()='WINDISK-W' or text()='WINDISK-X' or
    text()='WINDISK-Y' or text()='WINDISK-Z'
]}

If you read the XPath specification, you will find the starts-with() function can be used in this scenario. With a single function, I can avoid all the above messy syntax.

$branch selectNodes {td/a[@class='statusCRITICAL'][starts-with(.,'WINDISK-')]}

Labels: , ,

Thursday, September 09, 2010

What's New in SQLite3

The latest version of SQLite is 3.7.2. Prior to 3.7, SQLite uses atomic commit and rollback. From 3.7.0 onwards, the default method is write-ahead logging.

A recent article from O'Reilly talked about the latest features in 3.7. Also a new book - Using SQLite is already out in the local bookstore.

If you are i-whatever (iPhone, iPad, ...) user, you are already a SQLite user. See this 94 page PDF presentation, The World's Most Popular TCL Extension, presented by the author in last year Tcl 2009 conference to find out more

Whether you are a web developer, system programmer or administrator, SQLite is definitely a tool that you should learn and know about.

Labels: