Mar 14

Monitoring HP Windows Servers with Nagios

I want to love Nagios, I really do. The learning curve has been a bit steep but I think it’s finally paying off.

One problem that I continued to have no luck with was monitoring HP servers. Obviously I was interested in monitoring things like temperature, RAID status, failures, etc.

For reference, I am currently running the following on my Nagios server:

CentOS 6.4
Nagios Core 3.5.1
Adagios 1.40

I’m assuming that you’ve added hosts, understand how to install NSClient++, and have a basic understanding of what’s under the hood with Nagios, including installing plugins.

The test server I am trying to pull SNMP data from is a DL380 G7 running Server 2008 R2. I have all HP System Management tools installed and am using the check_hpasm plugin.

Adding hosts with Adagios is really easy thanks to OKConfig. After adding the host I went ahead and installed NSClient++ and restarted Nagios. I checked the host in the Status pane and I can confirm that the basic Windows checks are working.

Basic checks working...one in the red

But the one that’s not is super important to me, which is the HP plugin. Drilling down to the alert for the specific service on this host, I see this:

SNMP error, wrong device???

SNMP error, wrong device???

CRITICAL – could not contact snmp agent, wrong device is the error I see.

Just for fun (and because rechecks from the web GUI are sometimes slow) I ran the command from the CLI:

/usr/lib64/nagios/plugins/check_hpasm -H -C public --perfdata=long -v

This gave me the same error, but at least it’s consistent.

Googling that didn’t give me too much. Lots of recommendations of what needed to be running on the client side, but most of these posts were referencing *nix running on HP, not Windows. Other recommendations were to install/update the Perl SNMP modules from CPAN, but that all looked good.

Instead, I started digging into how SNMP was running on the Windows side. First of all, I confirmed that the HP Management Agent was running, as well as the SNMP service in Windows.

Next, I poked around the System Management Homepage. I browsed to Settings » SNMP Webagent » SNMP & Agent Settings. Under Security I found what I was looking for.

HP's SNMP settings

HP’s SNMP settings

So two options, accept from ANY host or from a defined host list. By default only localhost is allowed; by separating each host with a semicolon, then applying and restarting agents, polling began to work as expected.


It works!

All green in the status pane

And that’s it. One quick check in the Status Pane to confirm it’s looking pretty and I’m done.

I expect to continue playing with Nagios and working towards a write-up that will describe some of the nuances I hit.


Sep 13

Have Raspberry Pi Email Your IP

Hi all.

I was scrolling through reddit when I noticed a post in the /r/raspberry_pi section.

In the post, the user is showing how he plugs in his Pi to the school network but then has to IP scan the network to find his Pi since he’s running it headless.

I guess that works, especially with using native shell commands to form a ping sweep.

But that might be against the network’s terms, he might have trouble finding it if he doesn’t know the subnet, who knows.

So I whipped up a script to kick off a cron job after boot to run a script which will give us the Pi’s IP if your’e running headless.

First off, we need some packages installed and configured. My example uses Gmail as the SMTP server.

You’d do the following:

sudo apt-get install mailutils
sudo apt-get install ssmtp
sudo vi /etc/ssmtp/ssmtp.conf

Add the following:


Now to make the script:

#! /bin/bash
#Wait to ensure system is up with an IP
sleep 60
#Set variable to get interface's IP assuming interface is eth0
IP=$(/sbin/ifconfig eth0 | grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')
#Send mail to admin with IP address in body
#Set subject
SUBJECT="Pi's Current IP"
# Email To ?
# Email text/message
echo "Your IP is:"> $EMAILMESSAGE
# send an email using /bin/mail
/usr/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE

So what we’re doing here is waiting to ensure the system is up, parsing ifconfig’s output with grep for the relevant string we’d like, and then forming a quick email message to deliver via the previously installed packages.

Now all that’s left to do is to configure it as a cron job.

crontab -e

And add

@reboot /path/to/script

And that should be it. Anytime your Pi boots or reboots, it’ll kick out an email after a minute with it’s IP.