Semintelligent

Updated Nagios::Plugin::SNMP and Nenm::Utils on Githhub (on CPAN this week) · 26 August 2009, 19:19

I have released version 1.2 of Nagios::Plugin::SNMP to Github:

http://github.com/perldork/nagios—plugin—snmp/tree/master

This release includes:

Additionally I have released an updated version of the Nenm::Utils module that I initially created for the Syngress Nagios book project I lead. This version includes:

This module is also available on the book site

http://www.nagios3book.com/

My team at work uses both of these modules extensively to query several thousand SNMP-based agents every 5 minutes.

Special thanks to:

My teammates Ryan Richins and Shaofeng Yang for their extensive contributions to both of these modules.

My managers at Comcast, Mike Fischer and Jason Livingood, for allowing us to contribute code we have done at work back to the open source community.

Comcast is hiring! Our team is looking for a talented developer with systems administration experience to join our team. Let me know if you are in the northern Virginia area of the US and are looking for a fun and challenging place to work :).

— Max Schubert

Comment

---

Why do I get an 'unitialized value' error message from Getopt/Long.pm when Nagios runs my perl-based plugin under ePN? · 25 July 2009, 10:48

Had this message while debugging an ePN-based script today:

**ePN /data/nagios/etc/customers/tean/project/plugins/check_plugin_name.pl: "Use of uninitialized value in pattern match (m//) at /usr/lib/perl5/5.8.8/Getopt/Long.pm line 848,".

Was very puzzled by this as i had never seen that error before, we run 20-30 or more ePN-based scripts, and obviously I don’t maintain that code so how could I have introduced a bug into it?

Answer: I didn’t. What i did do was define a custom attribute for a service but not put any spaces after the attribute in my service definition. E.g.

define command {
    command_name check_plugin_name
    command_line $USER10$/team/project/plugins/check_plugin_name.pl \
    --check-interval $_SERVICE_PROJECT_CHECK_INTERVAL$ \
    --hostname $HOSTADDRESS$ \
    $_SERVICE_PROJECT_ALT_HOSTS$ \
    -p '$_HOST_SNMP_PORT$' \
    --snmp-version 2c \
    --rocommunity $_HOST_SNMP_COMMUNITY$ \
    --timeout $_HOST_PLUGIN_TIMEOUT$ \
    -c '$_SERVICE_PROJECT_CRIT$' \
    $_SERVICE_PROJECT_WARN$
}

Notice that at the end of the command line I reference $_SERVICE_PROJECT_WARN$. This style of custom attribute calling lets the user set a warning threshold definition the service definition if they want to, like so

define service {
    ...
    __project_warn -w my_threshold_specification
    ...
}

But if they don’t, no changes are needed to the command definition to let it work as the command does not require a warning threshold.

However I then defined the attribute like so in my service definition:

define service {
    ...
    __project_warn<-- end of line, no spaces!
    ...
}

This caused Nagios to substitute a null or some other non-printable character as the value of the attribute in the command line before executing it, which in turn got passed through to Getopt/Long.pm as an undefined option name.

The fix .. just add spaces and an empty string to the attribute in the service definition :)

define service {
    ...
    __snmp_port           161
    __project_warn        ''
    ...
}

Voila, no undefined option.

Could be a candidate for either a Nagios custom attribute value fix or a Getopt/Long.pm fix, I am thinking Getopt::Long should set an undefined option name to the empty string so that developers do not have to guard for this condition.

— Max Schubert

Comment

---

New perl module: Sys::Syslog::OO · 15 March 2009, 19:19

I just uploaded Sys::Syslog::OO to my Github account and CPAN.
Sys::Syslog::OO is a thin object-oriented wrapper around Sys::Syslog designed to make it easy to integrate Sys::Syslog in object-oriented projects.

Special thanks to my managers Mike Fischer and Jason Livingood at Comcast for allowing me to release my work to the OSS community.

— Max Schubert

Comment

---

New perl module: Schedule::Week · 13 March 2009, 16:07

I just uploaded Schedule::Week to my Github account and CPAN. Schedule::Week lets a developer easily create, manipulate, serialize, and deserialize a weekly hour-by-hour schedule.

Special thanks to my managers Mike Fischer and Jason Livingood at Comcast for allowing me to release my work to the OSS community.

— Max Schubert

Comment

---

Sending email from Perl: Mail::Sendmail · 19 December 2008, 19:33

I always forget which mail-related modules on CPAN are the easiest and most flexible for sending mail from a perl program. Several times now I have gone to CPAN, re-found Mail::Mailer, been enticed by it’s features, downloaded/installed it, and then had troubles getting it to work in ‘smtp’ mode.

I then download Mail::Sendmail and am up and running in minutes. The only feature Mail::Sendmail does not support that would make it the best (in my opinion) of the perl mail modules is SMTP AUTH.

— Max Schubert

Comment

---

Using SSL proxies with WWW::Mechanize - why doesn't my HTTPS proxy setting work? · 16 January 2008, 11:34

WWW::Mechanize is a sub-class of the tried and true LWP package. The problem is that LWP does not properly support SSL proxying for any web server other than Apache; it issues an GET request to the proxy with the full URL to be requested as opposed to doing a CONNECT through the proxy in question. While most of us do work with Apache, there are certainly times when we will be using other types of proxies; in this case I was coding a test that goes through a Bluecoat hardware proxy.

To have SSL proxies work properly with WWW::Mechanize on non-Apache platforms , just install Crypt::SSLeay (which also installs Net::SSL) and then set the proxy URL into the environment in a variable named HTTPS_PROXY. Example:

$ENV{'HTTPS_PROXY'} = 'http://www.example.com:80/'

If you forget the port part Crypt::SSLeay will not accept the proxy setting, error will look like this:

500 no port given for proxy server NN.NN.NN.NN

To enable debugging output at the Crypt::SSLeay level, just set the environment variable HTTPS_DEBUG to 1

$ENV{'HTTPS_DEBUG'} = 1;

Finally, to turn on debugging output for LWP in a script at run time (i.e. via command line option) just call LWP::Debug::level(’+’), this will turn on all debug levels for LWP, very useful for troubleshooting LWP scripts.

LWP::Debug::level('+');

— Max Schubert

Comment

---