Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor message formatting #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ How to "compile" the check_hpasm script.

1) Run the configure script to initialize variables and create a Makefile, etc.

./configure --prefix=BASEDIRECTORY --with-nagios-user=SOMEUSER --with-nagios-group=SOMEGROUP --with-perl=PATH_TO_PERL --with-noinst-level=LEVEL --with-degrees=UNIT --with-perfdata --with-hpacucli
./configure --prefix=BASEDIRECTORY --with-nagios-user=SOMEUSER --with-nagios-group=SOMEGROUP --with-perl=PATH_TO_PERL --with-noinst-level=LEVEL --with-degrees=UNIT --enable-perfdata --enable-hpacucli

a) Replace BASEDIRECTORY with the path of the directory under which Nagios
is installed (default is '/usr/local/nagios')
Expand Down
55 changes: 29 additions & 26 deletions aclocal.m4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
# generated automatically by aclocal 1.15 -*- Autoconf -*-

# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Copyright (C) 1996-2014 Free Software Foundation, Inc.

# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand All @@ -20,7 +20,7 @@ You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically 'autoreconf'.])])

# Copyright (C) 2002-2013 Free Software Foundation, Inc.
# Copyright (C) 2002-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand All @@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.])
# generated from the m4 files accompanying Automake X.Y.
# (This private macro should not be called outside this file.)
AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.14'
[am__api_version='1.15'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.14.1], [],
m4_if([$1], [1.15], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])

Expand All @@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.14.1])dnl
[AM_AUTOMAKE_VERSION([1.15])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])

# AM_AUX_DIR_EXPAND -*- Autoconf -*-

# Copyright (C) 2001-2013 Free Software Foundation, Inc.
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand Down Expand Up @@ -103,15 +103,14 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# configured tree to be moved without reconfiguration.

AC_DEFUN([AM_AUX_DIR_EXPAND],
[dnl Rely on autoconf to set up CDPATH properly.
AC_PREREQ([2.50])dnl
# expand $ac_aux_dir to an absolute path
am_aux_dir=`cd $ac_aux_dir && pwd`
[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
# Expand $ac_aux_dir to an absolute path.
am_aux_dir=`cd "$ac_aux_dir" && pwd`
])

# Do all the work for Automake. -*- Autoconf -*-

# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand Down Expand Up @@ -201,8 +200,8 @@ AC_REQUIRE([AC_PROG_MKDIR_P])dnl
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
# We need awk for the "check" target. The system "awk" is bad on
# some platforms.
# We need awk for the "check" target (and possibly the TAP driver). The
# system "awk" is bad on some platforms.
AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
Expand Down Expand Up @@ -275,7 +274,11 @@ to "yes", and re-run configure.
END
AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
fi
fi])
fi
dnl The trailing newline in this macro's definition is deliberate, for
dnl backward compatibility and to allow trailing 'dnl'-style comments
dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
])

dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
Expand Down Expand Up @@ -304,7 +307,7 @@ for _am_header in $config_headers :; do
done
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])

# Copyright (C) 2001-2013 Free Software Foundation, Inc.
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand All @@ -315,7 +318,7 @@ echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_co
# Define $install_sh.
AC_DEFUN([AM_PROG_INSTALL_SH],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
if test x"${install_sh}" != xset; then
if test x"${install_sh+set}" != xset; then
case $am_aux_dir in
*\ * | *\ *)
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
Expand All @@ -325,7 +328,7 @@ if test x"${install_sh}" != xset; then
fi
AC_SUBST([install_sh])])

# Copyright (C) 2003-2013 Free Software Foundation, Inc.
# Copyright (C) 2003-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand All @@ -346,7 +349,7 @@ AC_SUBST([am__leading_dot])])

# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-

# Copyright (C) 1997-2013 Free Software Foundation, Inc.
# Copyright (C) 1997-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand Down Expand Up @@ -385,7 +388,7 @@ fi

# Helper functions for option handling. -*- Autoconf -*-

# Copyright (C) 2001-2013 Free Software Foundation, Inc.
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand Down Expand Up @@ -414,7 +417,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])

# Copyright (C) 2001-2013 Free Software Foundation, Inc.
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand All @@ -433,7 +436,7 @@ AC_DEFUN([AM_RUN_LOG],

# Check to make sure that the build environment is sane. -*- Autoconf -*-

# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand Down Expand Up @@ -514,7 +517,7 @@ AC_CONFIG_COMMANDS_PRE(
rm -f conftest.file
])

# Copyright (C) 2009-2013 Free Software Foundation, Inc.
# Copyright (C) 2009-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand Down Expand Up @@ -574,7 +577,7 @@ AC_SUBST([AM_BACKSLASH])dnl
_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
])

# Copyright (C) 2001-2013 Free Software Foundation, Inc.
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand Down Expand Up @@ -602,7 +605,7 @@ fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])

# Copyright (C) 2006-2013 Free Software Foundation, Inc.
# Copyright (C) 2006-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand All @@ -621,7 +624,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])

# Check how to create a tarball. -*- Autoconf -*-

# Copyright (C) 2004-2013 Free Software Foundation, Inc.
# Copyright (C) 2004-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand Down
6 changes: 2 additions & 4 deletions plugins-scripts/HP/BladeSystem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ sub collect {
my $cpqRackMibCondition = '1.3.6.1.4.1.232.22.1.3.0';
$self->trace(3, 'getting cpqRackMibCondition');
if (! exists $self->{rawdata}->{$cpqRackMibCondition}) {
$self->add_message(CRITICAL,
'snmpwalk returns no health data (cpqrack-mib)');
$self->add_message(CRITICAL, 'snmpwalk returns no health data (cpqrack-mib)');
}
} else {
my $net_snmp_version = Net::SNMP->VERSION(); # 5.002000 or 6.000000
Expand All @@ -166,8 +165,7 @@ sub collect {
$result->{$cpqRackMibCondition} eq 'noSuchInstance' ||
$result->{$cpqRackMibCondition} eq 'noSuchObject' ||
$result->{$cpqRackMibCondition} eq 'endOfMibView') {
$self->add_message(CRITICAL,
'snmpwalk returns no health data (cpqrack-mib)');
$self->add_message(CRITICAL, 'snmpwalk returns no health data (cpqrack-mib)');
$session->close;
} else {
$self->trace(3, 'getting cpqRackMibCondition done');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ sub new {
sub check {
my $self = shift;
$self->blacklist('f', $self->{name});
$self->add_info(sprintf 'fan %s is %s, location is %s, redundance is %s, condition is %s',
$self->{name}, $self->{cpqRackCommonEnclosureFanPresent},
$self->{cpqRackCommonEnclosureFanLocation},
$self->{cpqRackCommonEnclosureFanRedundant},
$self->{cpqRackCommonEnclosureFanCondition});
$self->add_info('fan %s is %s, location is %s, redundance is %s, condition is %s',
\'name', \'cpqRackCommonEnclosureFanPresent',
\'cpqRackCommonEnclosureFanLocation',
\'cpqRackCommonEnclosureFanRedundant',
\'cpqRackCommonEnclosureFanCondition');
if ($self->{cpqRackCommonEnclosureFanCondition} eq 'degraded') {
$self->{info} .= sprintf ", (SparePartNum: %s)", $self->{cpqRackCommonEnclosureFanSparePartNumber};
$self->add_message(WARNING, $self->{info});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ sub new {
sub check {
my $self = shift;
$self->blacklist('fu', $self->{name});
$self->add_info(sprintf 'fuse %s is %s, location is %s, condition is %s',
$self->{name}, $self->{cpqRackCommonEnclosureFusePresent},
$self->{cpqRackCommonEnclosureFuseLocation}, $self->{cpqRackCommonEnclosureFuseCondition});
$self->add_info('fuse %s is %s, location is %s, condition is %s',
\'name', \'cpqRackCommonEnclosureFusePresent',
\'cpqRackCommonEnclosureFuseLocation', \'cpqRackCommonEnclosureFuseCondition');
if ($self->{cpqRackCommonEnclosureFuseCondition} eq 'failed') {
$self->add_message(CRITICAL, $self->{info});
} elsif ($self->{cpqRackCommonEnclosureFuseCondition} ne 'ok') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,17 @@ sub check {
my $self = shift;
$self->blacklist('t', $self->{name});
if ($self->{cpqRackCommonEnclosureTempCurrent} > $self->{cpqRackCommonEnclosureTempThreshold}) {
$self->add_info(sprintf "%s temperature too high (%d%s)",
$self->{cpqRackCommonEnclosureTempLocation},
$self->{cpqRackCommonEnclosureTempCurrent},
$self->{runtime}->{options}->{celsius} ? "C" : "F");
$self->add_info("%s temperature too high (%d%s)",
\'cpqRackCommonEnclosureTempLocation',
\'cpqRackCommonEnclosureTempCurrent',
$self->{runtime}{options}{celsius} ? "C" : "F");
$self->add_message(CRITICAL, $self->{info});
} else {
$self->add_info(sprintf "%s temperature is %d%s (%d max)",
$self->{cpqRackCommonEnclosureTempLocation},
$self->{cpqRackCommonEnclosureTempCurrent},
$self->add_info("%s temperature is %d%s (%d max)",
\'cpqRackCommonEnclosureTempLocation',
\'cpqRackCommonEnclosureTempCurrent',
$self->{runtime}->{options}->{celsius} ? "C" : "F",
$self->{cpqRackCommonEnclosureTempThreshold});
\'cpqRackCommonEnclosureTempThreshold');
}
if ($self->{runtime}->{options}->{perfdata} == 2) {
$self->{runtime}->{plugin}->add_perfdata(
Expand All @@ -154,8 +154,7 @@ sub check {
critical => $self->{cpqRackCommonEnclosureTempThreshold}
);
}
$self->add_extendedinfo(sprintf "temp_%s=%d",
$self->{name}, $self->{cpqRackCommonEnclosureTempCurrent});
$self->add_extendedinfo("temp_%s=%d", \'name', \'cpqRackCommonEnclosureTempCurrent');

}

Expand Down
12 changes: 6 additions & 6 deletions plugins-scripts/HP/BladeSystem/Component/PowerSupplySubsystem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ sub check {
if ($self->{cpqRackPowerSupplyCondition} eq 'degraded') {
$info .= sprintf " (SparePartNum %s)", $self->{cpqRackPowerSupplySparePartNumber};
$self->add_message(WARNING, $info);
$self->add_info(sprintf 'power supply %s status is %s, inp.line status is %s',
$self->{name}, $self->{cpqRackPowerSupplyStatus},
$self->{cpqRackPowerSupplySupplyInputLineStatus});
$self->add_info('power supply %s status is %s, inp.line status is %s',
\'name', \'cpqRackPowerSupplyStatus',
\'cpqRackPowerSupplySupplyInputLineStatus');
} elsif ($self->{cpqRackPowerSupplyCondition} eq 'failed') {
$info .= sprintf " (SparePartNum %s)", $self->{cpqRackPowerSupplySparePartNumber};
$self->add_message(CRITICAL, $info);
$self->add_info(sprintf 'power supply %s status is %s, inp.line status is %s',
$self->{name}, $self->{cpqRackPowerSupplyStatus},
$self->{cpqRackPowerSupplySupplyInputLineStatus});
$self->add_info('power supply %s status is %s, inp.line status is %s',
\'name', \'cpqRackPowerSupplyStatus',
\'cpqRackPowerSupplySupplyInputLineStatus');
}
if ($self->{runtime}->{options}->{perfdata} != 2) {
$self->{runtime}->{plugin}->add_perfdata(
Expand Down
19 changes: 9 additions & 10 deletions plugins-scripts/HP/BladeSystem/Component/ServerBladeSubsystem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,18 @@ sub new {
sub check {
my $self = shift;
$self->blacklist('sb', $self->{name});
my $info = sprintf 'server blade %s \'%s\' is %s, status is %s, powered is %s',
$self->{name}, $self->{cpqRackServerBladeName}, $self->{cpqRackServerBladePresent},
$self->{cpqRackServerBladeStatus}, $self->{cpqRackServerBladePowered};
$self->add_info($info);
$self->add_info('server blade %s \'%s\' is %s, status is %s, powered is %s',
\'name', \'cpqRackServerBladeName', \'cpqRackServerBladePresent',
\'cpqRackServerBladeStatus', \'cpqRackServerBladePowered');
if ($self->{cpqRackServerBladePowered} eq 'on') {
if ($self->{cpqRackServerBladeStatus} eq 'degraded') {
$self->add_message(WARNING, sprintf 'server blade %s diag is \'%s\', post status is %s',
$self->{cpqRackServerBladeName}, $self->{cpqRackServerBladeDiagnosticString},
$self->{cpqRackServerBladePOSTStatus});
$self->add_message(WARNING, 'server blade %s diag is \'%s\', post status is %s',
\'cpqRackServerBladeName', \'cpqRackServerBladeDiagnosticString',
\'cpqRackServerBladePOSTStatus');
} elsif ($self->{cpqRackServerBladeStatus} eq 'failed') {
$self->add_message(CRITICAL, sprintf 'server blade %s diag is \'%s\', post status is %s',
$self->{cpqRackServerBladeName}, $self->{cpqRackServerBladeDiagnosticString},
$self->{cpqRackServerBladePOSTStatus});
$self->add_message(CRITICAL, 'server blade %s diag is \'%s\', post status is %s',
\'cpqRackServerBladeName', \'cpqRackServerBladeDiagnosticString',
\'cpqRackServerBladePOSTStatus');
}
}
}
Expand Down
12 changes: 4 additions & 8 deletions plugins-scripts/HP/FCMGMT/Component/SensorSubsystem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,15 @@ sub check {
if ($self->{cpqSeSensorStatus} ne "ok") {
if ($self->{runtime}->{options}{scrapiron} &&
($self->{cpqSeSensorStatus} eq "unknown")) {
$self->add_info(sprintf "cpu %d probably ok (%s)",
$self->{cpqSeSensorUnitIndex}, $self->{cpqSeSensorStatus});
$self->add_info("cpu %d probably ok (%s)", \'cpqSeSensorUnitIndex', \'cpqSeSensorStatus');
} else {
$self->add_info(sprintf "cpu %d needs attention (%s)",
$self->{cpqSeSensorUnitIndex}, $self->{cpqSeSensorStatus});
$self->add_info("cpu %d needs attention (%s)", \'cpqSeSensorUnitIndex', \'cpqSeSensorStatus');
$self->add_message(CRITICAL, $self->{info});
}
} else {
$self->add_info(sprintf "cpu %d is %s",
$self->{cpqSeSensorUnitIndex}, $self->{cpqSeSensorStatus});
$self->add_info("cpu %d is %s", \'cpqSeSensorUnitIndex', \'cpqSeSensorStatus');
}
$self->add_extendedinfo(sprintf "cpu_%s=%s",
$self->{cpqSeSensorUnitIndex}, $self->{cpqSeSensorStatus});
$self->add_extendedinfo("cpu_%s=%s", \'cpqSeSensorUnitIndex', \'cpqSeSensorStatus');
}

sub dump {
Expand Down
Loading