Remoting an old APC PDU using SNMP and remOcular

Posted by: admin  :  Category: Hardware, Perl, Programming, Utilities

Garage sale at the office: Good chance to grab on some (very) old hardware, like an APC 9221 PDU. Yes, it’s old (some 15 years or so), so surely not state of the art. But yet good enough to use in my home lab. Who could tell that there were some unforeseen issues waiting for me …
Read more…

Nagios/Icinga Plugin to check for DokuWiki Updates (v2,2015-09-05)

Posted by: gdelmatto  :  Category: HowTo's, Perl, Programming, Scripting

Nagios/Icinga can also serve to send you friendly reminders, like for example that you need to perform software updates.

Here’s my little contribution, a simple plugin to monitor a given DokuWiki site and check against the release server for any upgrades.

Just fetch the  check_dokuwiki-0.1 check_dokuwiki-0.2 tarball and extract the check_dokuwiki script to your Nagios/Icinga plugin directory.

The latest plugin update (0.2, 2015-09-06) catches up with latest updates on Dokuwikis web page, and now incorporates upstream checks using the same mechanism that Dokuwiki uses internally. Also it adds some (although not yet well tested) support for http authentication.

Please check out the cli help for more details on specific arguments:

check_dokuwiki v (nagios-plugins 1.4.15)
The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute
copies of the plugins under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
Copyright (c) 2012 Gianpaolo Del Matto

  check_dokuwiki -H 
  check_dokuwiki [-h | --help]
  check_dokuwiki [-V | --version]

more arguments
  -a | --use-auth              enable http authentication mode
  -r name | --realm=name       use given realm with http auth
  -u user | --username=user    use given username for http auth
  -p pass | --password=pass    use given password for http auth
  -s | --use-ssl               enable SSL mode (uses TCP:443 as default, see --tcp-port
  -p num | --tcp-port num      use non-standard port
                               if not given, defaults to TCP:80 (or TCP:443 if --use-ssl is used)

   	give any valid DokuWiki hostname to fetch the 'VERSION' file from.
                         Note: HTTP AUTH is currently not supported.

Send email to if you have questions
regarding use of this software. To submit patches or suggest improvements,
send email to
Please include version information with all correspondence (when possible,
use output from the --version option of the plugin itself).

Register the plugin with a command definition like this:

# 'check_dokuwiki' command definition
define command{
        command_name	check_dokuwiki
        command_line	/usr/local/libexec/nagios/check_dokuwiki -H $HOSTNAME

Then simply add a service to one or more of your DokuWiki hosts (or hostgroups, whatever you prefer).

define service{
        use                     generic-service
        host_name               your_wiki_host_objects_list_here
        service_description     dokuwiki_version
        check_command           check_dokuwiki
        max_check_attempts      5
        check_interval          5
        retry_interval          3
        check_period            24x7
        notification_interval   0
        notification_period     24x7
        notification_options    w,c,r

Restart Nagios/Icinga and you’re done.

Happy monitoring 🙂

Perl/SOAP::Lite: Rewrite response XML for ASP.NET compatibility

Posted by: gdelmatto  :  Category: Hacks, Perl, Programming

So you finally hacked up your nifty SOAP::Lite web service only to find that it works fine with SOAP::Lite or PHP clients, but ASP.NET terribily fails?
Yes, I should mention, that you must of course write up a WSDL first, especially for .NET, I’ll cover that topic in a follow-up.

This post however refers to a hack that I have done to SOAP::Lite to allow for dynamic response rewriting for different SOAP client implementations.
Read more…

Convert a Perl Hash of Hashes into XML with XML::Dumper

Posted by: gdelmatto  :  Category: Perl, Programming

For a project of mine, I wanted to convert a Perl data structure, a so called Hash of Hashes, into an XML.

The simple solution to this is to use the XML::Dumper module.
Read more…

Extract and Unify Cisco Device-Types with SNMP and Perl

Posted by: gdelmatto  :  Category: Cisco, Networking, Perl, Programming

Here’s a short script which I use to extract Cisco device-types from SNMP.
Bad enough, most of these devices return their device type ID differently, e.g. sometimes prefixed with an uppercase ‘C’, sometimes without any prefix, then again sometimes we find a suffix.

So here’s a snippet, that makes them look neat, so I can work with simple and unified looking device IDs.
Read more…

Print File Contents in Reverse Order (“reverse cat”)

Posted by: gdelmatto  :  Category: Perl, Programming, Scripting

The ‘cat’ utility serves it’s purpose print the content of a file at once. So do ‘more’ and other tools as well. But they all do in ‘forward’ mode only.
To print a file in reverse order, at least some linux distros come with the ‘tac’ command, which will do a ‘reverse cat’.
But what to do, if ‘tac’ is missing?
Read more…

Shell Scripting: How to easily convert UNIX timestamp into date format

Posted by: admin  :  Category: Perl, Programming, Scripting

When writing shell scripts (bash, sh, etc) maybe you had to work with POSIX/UNIX timestamps from time to time.
While the serialized nature of the timestamp is great to work with for scripting, it’s easier for human beings to have them printed in date format.

Before you start digging around using some fancy conversion in Perl, check out the ‘date’ command first.
Read more…

Recognize invalid/unexpected characters with Perl

Posted by: admin  :  Category: Perl

Today a colleague of mine faced a very weird problem.
While parsing XML output from an HP ILO into Perl, his code constantly broke with the message:

FILE.XML:123 parser error : PCDATA invalid Char value 1

While the message itself states clearly that there is an unexpected character value (Char value 1, ASCII SOH) on one hand, it doesn’t tell the character position on the other.
Read more…

Your Makefile has been rebuilt…

Posted by: admin  :  Category: Perl

One might asume building a port from source should be fast and straight forward.
Not in this case, however…
Read more…

Prototype Mismatch in APR::XSLoader::BOOTSTRAP

Posted by: admin  :  Category: Perl

Well, today I just did not believe my eyes.

I was just bringing up a new webmail host when I noticed Apache throwing an 500 internal server error at me.
Read more…