ePN /usr/lib/nagios/plugins/check_winhd.pl

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
SecplusHelpDesk
Posts: 5
Joined: Thu Dec 08, 2016 1:58 pm

ePN /usr/lib/nagios/plugins/check_winhd.pl

Post by SecplusHelpDesk »

I am getting the below errors for two of our hosts:

For one of our branch Windows nt servers for checking C Drive Usage:
**ePN /usr/lib/nagios/plugins/check_winhd.pl: "Use of uninitialized value $resultat3 in pattern match (m//) at (eval 1) line 51,".

-AND-

For one of our OPS Windows servers for checking C Drive Usage:
**ePN /usr/lib/nagios/plugins/check_winhd.pl: "Use of uninitialized value $resultat2 in pattern match (m//) at (eval 1) line 45,".

I am lost and have no idea how to fix this.
Last edited by dwhitfield on Fri Dec 09, 2016 2:50 pm, edited 1 time in total.
Reason: marking with green check mark
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: ePN /usr/lib/nagios/plugins/check_winhd.pl

Post by dwhitfield »

What version of Core are you using? Did you compile from source or install from distro repos? On what OS/version are you running Nagios? Can you post a link to that script or the test of the script?

I ask these questions primarily because I have no /usr/lib/nagios/plugins on my system, and those questions will help us understand your file paths and the exact commands to give you.
SecplusHelpDesk
Posts: 5
Joined: Thu Dec 08, 2016 1:58 pm

Re: ePN /usr/lib/nagios/plugins/check_winhd.pl

Post by SecplusHelpDesk »

[1] Version: Nagios® Core™ 3.5.1
[2] I have no idea about your "compile from source" question. I was not here yet when Nagios was first introduced to our environment
[3] Nagios is running on Linux (Debian GNU/Linux)

/usr/lib/nagios/plugins:

check_winhd.pl Script:
-----------------------------------------------------

Code: Select all

#!/usr/bin/perl -w

use strict;

# Dont use the embedded apache perl....
# Author : Peter
# Date : Apr 11 2006
# check_hd IP COMMUNITY warnlevel criticallevel disc

my $PROGNAME = "check_winhd";
my $RESOK=0;
my $RESWARN=1;
my $RESCRIT=2;
my $RESUNK=3;


sub print_usage {
	print "$PROGNAME IP COMMUNITY warnlevel criticallevel disc\n";
}

if  ( !defined($ARGV[0]) || !defined($ARGV[1]) || !defined($ARGV[2]) ||
      !defined($ARGV[3]) || !defined($ARGV[4])) {
    print_usage();
    exit $RESOK;
}

my $IP=$ARGV[0];
my $COMMUNITY=$ARGV[1];
my $warning=$ARGV[2];
my $critical=$ARGV[3];
my $LW=$ARGV[4]; # Drive letter.

my $resultat =`snmpwalk -v 1 -c $COMMUNITY $IP  hrStorageDescr | grep $LW:`;

my $fullsize1=0;
my $usedsize1=0;
my $freespace=0;

if ( defined($resultat) and $resultat =~ m/hrStorageDescr\./) {
    my $resstring= $resultat;
    my $tsid = substr($resstring,35,1);		
    my $resultat2 =`snmpget -v 1 -c $COMMUNITY $IP hrStorageAllocationUnits.$tsid`;
    my $resstring2 = $resultat2;
    if ($resultat2 =~ /hrStorageAllocationUnits\.$tsid/) {
	my @unit=split(/:/,$resstring2);
	my @unit1=split(/\ /,$unit[3]);
	my $unit1=$unit1[1];
	my $resultat3 =`snmpget -v 1 -c $COMMUNITY $IP hrStorageSize.$tsid`;
	my $resstring3 = $resultat3;
	if ($resultat3 =~ /hrStorageSize\.$tsid/) {
	    my @ta=split(/INTEGER/,$resstring3);
	    chomp($ta[1]);
	    my $size1=substr($ta[1],1);
	    $fullsize1 = $fullsize1 + $size1;
	    $fullsize1 = $fullsize1 * $unit1;
	}
	my $resultat4 =`snmpget -v 1 -c $COMMUNITY $IP hrStorageUsed.$tsid`;
	my $resstring4 = $resultat4;
	if ($resultat4 =~ /hrStorageUsed\.$tsid/) {
	    my @tb=split(/INTEGER/,$resstring4);
	    chomp($tb[1]);
	    my $size1=substr($tb[1],1);
	    $usedsize1 = $usedsize1 + $size1;
	    $usedsize1 = $usedsize1 * $unit1;
	}
	if ($usedsize1 > 0 && $fullsize1 > 0) {
	    $freespace=$fullsize1 - $usedsize1;
	    $freespace=$freespace / 1024 / 1024 / 1024;
	    my $percfilled=$usedsize1 * 100 / $fullsize1;
	    if ($percfilled > $critical) {
		printf "CRITICAL: hd $LW: in use %.2f%% and %.1f GB free\n",$percfilled,$freespace;
		exit $RESCRIT;
	    }
	    if ($percfilled > $ARGV[2]) {
		printf "WARNING: hd $LW: in use %.2f%% and %.1f GB free\n",$percfilled,$freespace;
		exit $RESWARN;
	    }
	    printf "OK: hd $LW: in use %.2f%% and %.1f GB free\n",$percfilled,$freespace;
	    exit $RESOK;
	}
    }
} else {
    print "UNKNOWNN: Response unknown\n";
    print $RESUNK;
}
Last edited by tmcdonald on Thu Dec 08, 2016 2:31 pm, edited 1 time in total.
Reason: Please use [code][/code] tags around long output
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: ePN /usr/lib/nagios/plugins/check_winhd.pl

Post by rkennedy »

Can you show us the command definition, and also the service definition that is using this? It'll make it easy to see how things are lining up.

One thing to note, there seem to be mixed reviews for this specific plugin, so we may be held on the support we can provide, since they are from the Exchange.
https://exchange.nagios.org/directory/P ... hd/details
https://exchange.nagios.org/directory/P ... hd/details

On the flip side, it looks like it's using SNMP -
my $resultat =`snmpwalk -v 1 -c $COMMUNITY $IP hrStorageDescr | grep $LW\:\\`;

Could you also run a full snmpwalk against the machine, from the Nagios machine, and show us the full output? You can do so by running snmpwalk -v 1 -c communitystring ip.of.windows.machine
(replace communitystring and ip.of.windows.machine accordingly)
Former Nagios Employee
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: ePN /usr/lib/nagios/plugins/check_winhd.pl

Post by dwhitfield »

In addition to what @rkennedy mentioned...

What's the output of dpkg-query -l | grep nagios? What version of Debian cat /etc/*-release? The main reason for wanting the version # is to determine if we need to start processes with systemd or the old init. I double-checked a Debian 8 system, and no /usr/lib/nagios/plugins there either.
SecplusHelpDesk
Posts: 5
Joined: Thu Dec 08, 2016 1:58 pm

Re: ePN /usr/lib/nagios/plugins/check_winhd.pl

Post by SecplusHelpDesk »

Our nagios host needed an apt-upgrade and a reboot. She is up again and the odd ePN /usr/lib/nagios/plugins/check_winhd.pl errors went away. Thank you for your help.
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: ePN /usr/lib/nagios/plugins/check_winhd.pl

Post by dwhitfield »

It would be helpful for others if you could post the output of dpkg-query -l | grep nagios. Either way, thanks for using the forums!
SecplusHelpDesk
Posts: 5
Joined: Thu Dec 08, 2016 1:58 pm

Re: ePN /usr/lib/nagios/plugins/check_winhd.pl

Post by SecplusHelpDesk »

Ok, not a problem. See attached.
Attachments
grep_nagios.JPG
cat.JPG
cat.JPG (13.55 KiB) Viewed 2975 times
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: ePN /usr/lib/nagios/plugins/check_winhd.pl

Post by dwhitfield »

Thanks so much for posting that info. That will really help if people have this issue in the future.

Are we ready to lock this up?
SecplusHelpDesk
Posts: 5
Joined: Thu Dec 08, 2016 1:58 pm

Re: ePN /usr/lib/nagios/plugins/check_winhd.pl

Post by SecplusHelpDesk »

Yes, sure. I think we are good for now. I appreciate the response!
Locked