├── .gitignore ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── NEWS ├── README ├── TODO ├── acinclude.m4 ├── aclocal.m4 ├── config.guess ├── config.sub ├── configure.in ├── hpasmd ├── install-sh ├── missing ├── plugins-scripts ├── HP │ ├── BladeSystem.pm │ ├── BladeSystem │ │ ├── Component.pm │ │ └── Component │ │ │ ├── CommonEnclosureSubsystem.pm │ │ │ ├── CommonEnclosureSubsystem │ │ │ ├── FanSubsystem.pm │ │ │ ├── FuseSubsystem.pm │ │ │ ├── ManagerSubsystem.pm │ │ │ └── TempSubsystem.pm │ │ │ ├── NetConnectorSubsystem.pm │ │ │ ├── PowerEnclosureSubsystem.pm │ │ │ ├── PowerSupplySubsystem.pm │ │ │ └── ServerBladeSubsystem.pm │ ├── FCMGMT │ │ ├── Component.pm │ │ └── Component │ │ │ ├── SensorSubsystem.pm │ │ │ └── SensorSubsystem │ │ │ └── SNMP.pm │ ├── HP.pm │ ├── Proliant.pm │ ├── Proliant │ │ ├── Component.pm │ │ └── Component │ │ │ ├── AsrSubsystem.pm │ │ │ ├── AsrSubsystem │ │ │ ├── CLI.pm │ │ │ └── SNMP.pm │ │ │ ├── BatterySubsystem.pm │ │ │ ├── BatterySubsystem │ │ │ ├── CLI.pm │ │ │ └── SNMP.pm │ │ │ ├── CpuSubsystem.pm │ │ │ ├── CpuSubsystem │ │ │ ├── CLI.pm │ │ │ └── SNMP.pm │ │ │ ├── DiskSubsystem.pm │ │ │ ├── DiskSubsystem │ │ │ ├── Da.pm │ │ │ ├── Da │ │ │ │ ├── CLI.pm │ │ │ │ └── SNMP.pm │ │ │ ├── Fca.pm │ │ │ ├── Fca │ │ │ │ ├── CLI.pm │ │ │ │ └── SNMP.pm │ │ │ ├── Ide.pm │ │ │ ├── Ide │ │ │ │ ├── CLI.pm │ │ │ │ └── SNMP.pm │ │ │ ├── Sas.pm │ │ │ ├── Sas │ │ │ │ ├── CLI.pm │ │ │ │ └── SNMP.pm │ │ │ ├── Scsi.pm │ │ │ └── Scsi │ │ │ │ ├── CLI.pm │ │ │ │ └── SNMP.pm │ │ │ ├── EventSubsystem.pm │ │ │ ├── EventSubsystem │ │ │ ├── CLI.pm │ │ │ ├── SNMP.pm │ │ │ └── date.pl │ │ │ ├── FanSubsystem.pm │ │ │ ├── FanSubsystem │ │ │ ├── CLI.pm │ │ │ └── SNMP.pm │ │ │ ├── MemorySubsystem.pm │ │ │ ├── MemorySubsystem │ │ │ ├── CLI.pm │ │ │ └── SNMP.pm │ │ │ ├── NicSubsystem.pm │ │ │ ├── NicSubsystem │ │ │ └── SNMP.pm │ │ │ ├── PowersupplySubsystem.pm │ │ │ ├── PowersupplySubsystem │ │ │ ├── CLI.pm │ │ │ └── SNMP.pm │ │ │ ├── SNMP.pm │ │ │ ├── TemperatureSubsystem.pm │ │ │ └── TemperatureSubsystem │ │ │ ├── CLI.pm │ │ │ └── SNMP.pm │ ├── SNMP │ │ └── Utils.pm │ ├── Server.pm │ ├── Storage.pm │ ├── Storage │ │ ├── Component.pm │ │ └── Component │ │ │ ├── CpuSubsystem.pm │ │ │ ├── CpuSubsystem │ │ │ ├── CLI.pm │ │ │ └── SNMP.pm │ │ │ ├── DiskSubsystem.pm │ │ │ ├── DiskSubsystem │ │ │ ├── Da.pm │ │ │ └── Da │ │ │ │ ├── CLI.pm │ │ │ │ └── SNMP.pm │ │ │ ├── FanSubsystem.pm │ │ │ ├── FanSubsystem │ │ │ ├── CLI.pm │ │ │ └── SNMP.pm │ │ │ ├── MemorySubsystem.pm │ │ │ ├── MemorySubsystem │ │ │ ├── CLI.pm │ │ │ └── SNMP.pm │ │ │ ├── Powersupply.pm │ │ │ ├── PowersupplySubsystem.pm │ │ │ ├── PowersupplySubsystem │ │ │ ├── CLI.pm │ │ │ └── SNMP.pm │ │ │ ├── TemperatureSubsystem.pm │ │ │ └── TemperatureSubsystem │ │ │ ├── CLI.pm │ │ │ └── SNMP.pm │ └── StorageWorks.pm ├── Makefile.am ├── Nagios │ └── MiniPlugin.pm ├── check_hpasm.pl └── subst.in ├── prepare.sh └── t └── TODO /.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | Makefile.in 3 | autom4te.cache/ 4 | config.log 5 | config.status 6 | configure 7 | plugins-scripts/Makefile 8 | plugins-scripts/Makefile.in 9 | plugins-scripts/check_hpasm 10 | plugins-scripts/subst 11 | 12 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Gerhard Lausser 2 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | SUBDIRS = plugins-scripts 4 | 5 | dist-hook: 6 | make 7 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lausser/check_hpasm/1844da14a235b9b0ba89abc4b2f9c21033862b06/NEWS -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | "1.3.6.1.4.1.232.6.2.9.3.1.4.0"; /* PSU Table */ 2 | warning = 3, critical = 4 3 | 4 | "1.3.6.1.4.1.232.6.2.6.4.0"; /* Fan status */ 5 | oder auch .... 7 6 | warning = 3, critical = 4 7 | 3=non-required fan im arsch 8 | 4=required fan im arsch 9 | 10 | 11 | "1.3.6.1.4.1.232.3.2.5.1.1.5"; /* Location Table */ 12 | "1.3.6.1.4.1.232.3.2.5.1.1.6"; /* Drive Table */ 13 | "1.3.6.1.4.1.232.3.2.5.1.1.50"; /* Drive Bus */ 14 | 15 | 16 | "1.3.6.1.4.1.232.6.2.6.8.1.4.1"; /* Temperature table */ 17 | 18 | ml370g4 19 | "Processor zone", 20 | "CPU 1", 21 | "I/O zone", 22 | "CPU 2" 23 | 57.0, 80.0, 53.0, 80.0 24 | 25 | dl385g1 26 | "CPU 1", 27 | "I/O zone", 28 | "CPU 2", 29 | "Processor zone", 30 | "PSU bay" 31 | 100.0, 62.0, 100.0, 60.0, 51.0 32 | 33 | dl380g4 34 | "Processor zone", 35 | "CPU 1", 36 | "I/O zone", 37 | "CPU 2", 38 | "PSU bay" 39 | 62.0, 80.0, 60.0, 80.0, 50.0 40 | 41 | dl380g3 42 | "Processor zone", 43 | "CPU 1", 44 | "I/O zone", 45 | "CPU 2", 46 | "PSU bay" 47 | 62.0, 73.0, 68.0, 73.0, 53.0 48 | 49 | dl360g4 50 | "I/O zone", 51 | "CPU 1", 52 | "CPU 2", 53 | "PSU bay", 54 | "System board" 55 | 63.0, 85.0, 85.0, 48.0, 41.0 56 | 57 | dl360g3 58 | "Processor zone", 59 | "CPU 1", 60 | "I/O zone", 61 | "CPU 2" 62 | 56.0, 67.0, 57.0, 67.0 63 | 64 | dl329g3 65 | "Processor zone", 66 | "CPU 1", 67 | "I/O zone" 68 | 41.0, 85.0, 52.0 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /acinclude.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis ACX_WHICH_GETHOSTBYNAME_R 2 | dnl 3 | dnl Provides a test to determine the correct way to call gethostbyname_r 4 | dnl 5 | dnl defines HAVE_GETHOSTBYNAME_R to the number of arguments required 6 | dnl 7 | dnl e.g. 6 arguments (linux) 8 | dnl e.g. 5 arguments (solaris) 9 | dnl e.g. 3 arguments (osf/1) 10 | dnl 11 | dnl @version $Id: acinclude.m4,v 1.5 2004/02/18 14:56:34 kdebisschop Exp $ 12 | dnl @author Brian Stafford 13 | dnl 14 | dnl based on version by Caolan McNamara 15 | dnl based on David Arnold's autoconf suggestion in the threads faq 16 | dnl 17 | AC_DEFUN([ACX_WHICH_GETHOSTBYNAME_R], 18 | [AC_CACHE_CHECK(number of arguments to gethostbyname_r, 19 | acx_which_gethostbyname_r, [ 20 | AC_TRY_COMPILE([ 21 | # include 22 | ], [ 23 | 24 | char *name; 25 | struct hostent *he; 26 | struct hostent_data data; 27 | (void) gethostbyname_r(name, he, &data); 28 | 29 | ],acx_which_gethostbyname_r=3, 30 | [ 31 | dnl acx_which_gethostbyname_r=0 32 | AC_TRY_COMPILE([ 33 | # include 34 | ], [ 35 | char *name; 36 | struct hostent *he, *res; 37 | char *buffer = NULL; 38 | int buflen = 2048; 39 | int h_errnop; 40 | (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop) 41 | ],acx_which_gethostbyname_r=6, 42 | 43 | [ 44 | dnl acx_which_gethostbyname_r=0 45 | AC_TRY_COMPILE([ 46 | # include 47 | ], [ 48 | char *name; 49 | struct hostent *he; 50 | char *buffer = NULL; 51 | int buflen = 2048; 52 | int h_errnop; 53 | (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop) 54 | ],acx_which_gethostbyname_r=5,acx_which_gethostbyname_r=0) 55 | 56 | ] 57 | 58 | ) 59 | ] 60 | ) 61 | ]) 62 | 63 | if test $acx_which_gethostbyname_r -gt 0 ; then 64 | AC_DEFINE_UNQUOTED([HAVE_GETHOSTBYNAME_R], $acx_which_gethostbyname_r, 65 | [Number of parameters to gethostbyname_r or 0 if not available]) 66 | fi 67 | 68 | ]) 69 | 70 | dnl @synopsis ACX_HELP_STRING(OPTION,DESCRIPTION) 71 | AC_DEFUN([ACX_HELP_STRING], 72 | [ $1 builtin([substr],[ ],len($1))[$2]]) 73 | 74 | 75 | dnl @synopsis ACX_FEATURE(ENABLE_OR_WITH,NAME[,VALUE]) 76 | AC_DEFUN([ACX_FEATURE], 77 | [echo "builtin([substr],[ ],len(--$1-$2))--$1-$2: ifelse($3,,[$]translit($1-$2,-,_),$3)"]) 78 | 79 | -------------------------------------------------------------------------------- /configure.in: -------------------------------------------------------------------------------- 1 | dnl Process this file with autoconf to produce a configure script. 2 | AC_REVISION ($Revision: 1.150 $) 3 | AC_PREREQ(2.58) 4 | AC_INIT(check_hpasm,4.10.1) 5 | AM_INIT_AUTOMAKE([1.9 tar-pax]) 6 | AC_CANONICAL_HOST 7 | 8 | RELEASE=1 9 | AC_SUBST(RELEASE) 10 | 11 | AC_PREFIX_DEFAULT(/usr/local/nagios) 12 | 13 | dnl Figure out how to invoke "install" and what install options to use. 14 | AC_PROG_INSTALL 15 | AC_SUBST(INSTALL) 16 | 17 | AC_PROG_MAKE_SET 18 | AC_PROG_AWK 19 | 20 | WARRANTY="This plugin comes with ABSOLUTELY NO WARRANTY. You may redistribute\ncopies of the plugin under the terms of the GNU General Public License.\nFor more information about these matters, see the file named COPYING.\n" 21 | AC_SUBST(WARRANTY) 22 | 23 | SUPPORT="Send email to gerhard.lausser@consol.de if you have questions\nregarding use of this software.\nPlease include version information with all correspondence (when possible,\nuse output from the --version option of the plugin itself).\n" 24 | AC_SUBST(SUPPORT) 25 | 26 | AC_ARG_WITH(nagios_user, 27 | ACX_HELP_STRING([--with-nagios-user=USER], 28 | [set user name to run nagios]), 29 | with_nagios_user=$withval, 30 | with_nagios_user=nagios) 31 | AC_ARG_WITH(nagios_group, 32 | ACX_HELP_STRING([--with-nagios-group=GROUP], 33 | [set group name to run nagios]), 34 | with_nagios_group=$withval, 35 | with_nagios_group=nagios) 36 | AC_SUBST(with_nagios_user) 37 | AC_SUBST(with_nagios_group) 38 | INSTALL_OPTS="-o $with_nagios_user -g $with_nagios_group" 39 | AC_SUBST(INSTALL_OPTS) 40 | AC_ARG_WITH(noinst_level, 41 | ACX_HELP_STRING([--with-noinst-level=LEVEL], 42 | [error level if hpasm is not installed]), 43 | with_noinst_level=$withval, 44 | with_noinst_level=unknown) 45 | AC_SUBST(NOINSTLEVEL, $with_noinst_level) 46 | AC_ARG_WITH(degrees, 47 | ACX_HELP_STRING([--with-degrees=UNIT], 48 | [which temperature unit to use. (celsius or fahrenheit)]), 49 | with_degrees=$withval, 50 | with_degrees=unknown) 51 | case "$with_degrees" in 52 | fahrenheit) 53 | AC_SUBST(CELSIUS, 0) 54 | ;; 55 | *) 56 | AC_SUBST(CELSIUS, 1) 57 | ;; 58 | esac 59 | AC_ARG_ENABLE([perfdata], 60 | [ --enable-perfdata wether to output perfdata (default=no)], ,enable_perfdata=no) 61 | if test x"$enable_perfdata" = xyes ; then 62 | AC_SUBST(PERFDATA, 1) 63 | else 64 | AC_SUBST(PERFDATA, 0) 65 | fi 66 | AC_ARG_ENABLE([extendedinfo], 67 | [ --enable-extendedinfo wether to output extended info (default=no)], ,enable_extendedinfo=no) 68 | if test x"$enable_extendedinfo" = xyes ; then 69 | AC_SUBST(EXTENDEDINFO, 1) 70 | else 71 | AC_SUBST(EXTENDEDINFO, 0) 72 | fi 73 | AC_ARG_ENABLE([hwinfo], 74 | [ --disable-hwinfo wether to output model desc., serial no., bios version (default=yes)], ,enable_hwinfo=yes) 75 | 76 | if test x"$enable_hwinfo" = xyes ; then 77 | AC_SUBST(HWINFO, 1) 78 | else 79 | AC_SUBST(HWINFO, 0) 80 | fi 81 | AC_ARG_ENABLE([hpacucli], 82 | [ --enable-hpacucli wether to check raid status with hpacucli (default=no)], ,enable_hpacucli=no) 83 | 84 | if test x"$enable_hpacucli" = xyes ; then 85 | AC_SUBST(HPACUCLI, 1) 86 | elif test x"$enable_hpacucli" = xmaybe ; then 87 | AC_SUBST(HPACUCLI, 2) 88 | else 89 | AC_SUBST(HPACUCLI, 0) 90 | fi 91 | 92 | 93 | 94 | 95 | 96 | case "$host_os" in 97 | *hp*) 98 | defaulttrustedpath=/bin:/sbin:/usr/bin:/usr/sbin:/usr/contrib/bin 99 | ;; 100 | *) 101 | defaulttrustedpath=/bin:/sbin:/usr/bin:/usr/sbin 102 | ;; 103 | esac 104 | 105 | EXTRAS= 106 | dnl PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/local/sbin:$PATH 107 | 108 | dnl Checks for programs. 109 | AC_PATH_PROG(SH,sh) 110 | AC_PATH_PROG(PERL,perl) 111 | 112 | dnl allow them to override the path of perl 113 | AC_ARG_WITH(perl, 114 | ACX_HELP_STRING([--with-perl=PATH], 115 | [sets path to perl executable]), 116 | with_perl=$withval,with_perl=$PERL) 117 | AC_SUBST(PERL, $with_perl) 118 | 119 | AC_OUTPUT( 120 | Makefile 121 | plugins-scripts/Makefile 122 | plugins-scripts/subst 123 | ) 124 | 125 | ACX_FEATURE([with],[perl]) 126 | ACX_FEATURE([with],[nagios-user]) 127 | ACX_FEATURE([with],[nagios-group]) 128 | ACX_FEATURE([with],[noinst-level]) 129 | ACX_FEATURE([with],[degrees]) 130 | ACX_FEATURE([enable],[perfdata]) 131 | ACX_FEATURE([enable],[extendedinfo]) 132 | ACX_FEATURE([enable],[hwinfo]) 133 | ACX_FEATURE([enable],[hpacucli]) 134 | -------------------------------------------------------------------------------- /hpasmd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lausser/check_hpasm/1844da14a235b9b0ba89abc4b2f9c21033862b06/hpasmd -------------------------------------------------------------------------------- /plugins-scripts/HP/BladeSystem/Component.pm: -------------------------------------------------------------------------------- 1 | package HP::BladeSystem::Component; 2 | 3 | use strict; 4 | 5 | our @ISA = qw(HP::BladeSystem); 6 | 7 | 1; 8 | -------------------------------------------------------------------------------- /plugins-scripts/HP/BladeSystem/Component/CommonEnclosureSubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::BladeSystem::Component::CommonEnclosureSubsystem; 2 | our @ISA = qw(HP::BladeSystem::Component); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | method => $params{method}, 14 | common_enclosures => [], 15 | common_enclosure_temp_subsys => undef, 16 | common_enclosure_fan_subsys => undef, 17 | common_enclosure_fuse_subsys => undef, 18 | common_enclosure_manager_subsys => undef, 19 | common_enclosure_frus => [], 20 | blacklisted => 0, 21 | info => undef, 22 | extendedinfo => undef, 23 | }; 24 | bless $self, $class; 25 | $self->init(); 26 | return $self; 27 | } 28 | 29 | sub init { 30 | my $self = shift; 31 | # jeweils ein block fuer 32 | # enclosures, temps, fans, fuses 33 | # loop ueber oids und entspr. new 34 | my $oids = { 35 | cpqRackCommonEnclosureEntry => '1.3.6.1.4.1.232.22.2.3.1.1.1', 36 | cpqRackCommonEnclosureRack => '1.3.6.1.4.1.232.22.2.3.1.1.1.1', 37 | cpqRackCommonEnclosureIndex => '1.3.6.1.4.1.232.22.2.3.1.1.1.2', 38 | cpqRackCommonEnclosureModel => '1.3.6.1.4.1.232.22.2.3.1.1.1.3', 39 | cpqRackCommonEnclosureSparePartNumber => '1.3.6.1.4.1.232.22.2.3.1.1.1.6', 40 | cpqRackCommonEnclosureSerialNum => '1.3.6.1.4.1.232.22.2.3.1.1.1.7', 41 | cpqRackCommonEnclosureFWRev => '1.3.6.1.4.1.232.22.2.3.1.1.1.8', 42 | cpqRackCommonEnclosureName => '1.3.6.1.4.1.232.22.2.3.1.1.1.9', 43 | cpqRackCommonEnclosureCondition => '1.3.6.1.4.1.232.22.2.3.1.1.1.16', 44 | cpqRackCommonEnclosureHasServerBlades => '1.3.6.1.4.1.232.22.2.3.1.1.1.17', 45 | cpqRackCommonEnclosureHasPowerBlades => '1.3.6.1.4.1.232.22.2.3.1.1.1.18', 46 | cpqRackCommonEnclosureHasNetConnectors => '1.3.6.1.4.1.232.22.2.3.1.1.1.19', 47 | cpqRackCommonEnclosureHasTempSensors => '1.3.6.1.4.1.232.22.2.3.1.1.1.20', 48 | cpqRackCommonEnclosureHasFans => '1.3.6.1.4.1.232.22.2.3.1.1.1.21', 49 | cpqRackCommonEnclosureHasFuses => '1.3.6.1.4.1.232.22.2.3.1.1.1.22', 50 | cpqRackCommonEnclosureConditionValue => { 51 | 1 => 'other', 52 | 2 => 'ok', 53 | 3 => 'degraded', 54 | 4 => 'failed', 55 | }, 56 | cpqRackCommonEnclosureHasServerBladesValue => { 57 | 1 => 'false', 58 | 2 => 'true', 59 | }, 60 | }; 61 | $oids->{cpqRackCommonEnclosureHasPowerBladesValue} = 62 | $oids->{cpqRackCommonEnclosureHasServerBladesValue}; 63 | $oids->{cpqRackCommonEnclosureHasNetConnectorsValue} = 64 | $oids->{cpqRackCommonEnclosureHasServerBladesValue}; 65 | $oids->{cpqRackCommonEnclosureHasTempSensorsValue} = 66 | $oids->{cpqRackCommonEnclosureHasServerBladesValue}; 67 | $oids->{cpqRackCommonEnclosureHasFansValue} = 68 | $oids->{cpqRackCommonEnclosureHasServerBladesValue}; 69 | $oids->{cpqRackCommonEnclosureHasServerBladesValue} = 70 | $oids->{cpqRackCommonEnclosureHasServerBladesValue}; 71 | # INDEX { cpqRackCommonEnclosureRack cpqRackCommonEnclosureIndex } 72 | foreach ($self->get_entries($oids, 'cpqRackCommonEnclosureEntry')) { 73 | push(@{$self->{common_enclosures}}, 74 | HP::BladeSystem::Component::CommonEnclosureSubsystem::CommonEnclosure->new(%{$_})); 75 | } 76 | 77 | $self->{common_enclosure_fan_subsys} = HP::BladeSystem::Component::CommonEnclosureSubsystem::FanSubsystem->new( 78 | rawdata => $self->{rawdata}, 79 | method => $self->{method}, 80 | runtime => $self->{runtime}, 81 | ); 82 | $self->{common_enclosure_temp_subsys} = HP::BladeSystem::Component::CommonEnclosureSubsystem::TempSubsystem->new( 83 | rawdata => $self->{rawdata}, 84 | method => $self->{method}, 85 | runtime => $self->{runtime}, 86 | ); 87 | $self->{common_enclosure_fuse_subsys} = HP::BladeSystem::Component::CommonEnclosureSubsystem::FuseSubsystem->new( 88 | rawdata => $self->{rawdata}, 89 | method => $self->{method}, 90 | runtime => $self->{runtime}, 91 | ); 92 | $self->{common_enclosure_manager_subsys} = HP::BladeSystem::Component::CommonEnclosureSubsystem::ManagerSubsystem->new( 93 | rawdata => $self->{rawdata}, 94 | method => $self->{method}, 95 | runtime => $self->{runtime}, 96 | ); 97 | } 98 | 99 | sub check { 100 | my $self = shift; 101 | foreach (@{$self->{common_enclosures}}) { 102 | $_->check(); 103 | } 104 | $self->{common_enclosure_fan_subsys}->check(); 105 | $self->{common_enclosure_temp_subsys}->check(); 106 | $self->{common_enclosure_fuse_subsys}->check(); 107 | $self->{common_enclosure_manager_subsys}->check(); 108 | } 109 | 110 | sub dump { 111 | my $self = shift; 112 | foreach (@{$self->{common_enclosures}}) { 113 | $_->dump(); 114 | } 115 | $self->{common_enclosure_fan_subsys}->dump(); 116 | $self->{common_enclosure_temp_subsys}->dump(); 117 | $self->{common_enclosure_fuse_subsys}->dump(); 118 | $self->{common_enclosure_manager_subsys}->dump(); 119 | } 120 | 121 | 122 | package HP::BladeSystem::Component::CommonEnclosureSubsystem::CommonEnclosure; 123 | our @ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem); 124 | 125 | use strict; 126 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 127 | 128 | sub new { 129 | my $class = shift; 130 | my %params = @_; 131 | my $self = { 132 | runtime => $params{runtime}, 133 | rawdata => $params{rawdata}, 134 | blacklisted => 0, 135 | info => undef, 136 | extendedinfo => undef, 137 | }; 138 | map { $self->{$_} = $params{$_} } grep /cpqRackCommonEnclosure/, keys %params; 139 | $self->{name} = $self->{cpqRackCommonEnclosureRack}.':'.$self->{cpqRackCommonEnclosureIndex}; 140 | $self->{serfw} = sprintf "Ser: %s, FW: %s", $self->{cpqRackCommonEnclosureSerialNum}, 141 | $self->{cpqRackCommonEnclosureFWRev}; 142 | bless $self, $class; 143 | return $self; 144 | } 145 | 146 | 147 | sub check { 148 | my $self = shift; 149 | $self->blacklist('ce', $self->{cpqRackCommonEnclosureName}); 150 | my $info = sprintf 'common enclosure %s condition is %s (%s)', 151 | $self->{cpqRackCommonEnclosureName}, $self->{cpqRackCommonEnclosureCondition}, $self->{serfw}; 152 | $self->add_info($info); 153 | if ($self->{cpqRackCommonEnclosureCondition} eq 'failed') { 154 | $info .= sprintf " (SparePartNum %s)", $self->{cpqRackCommonEnclosureSparePartNumber}; 155 | $self->add_message(CRITICAL, $info); 156 | } elsif ($self->{cpqRackCommonEnclosureCondition} eq 'degraded') { 157 | $info .= sprintf " (SparePartNum %s)", $self->{cpqRackCommonEnclosureSparePartNumber}; 158 | $self->add_message(WARNING, $info); 159 | } 160 | } 161 | 162 | sub dump { 163 | my $self = shift; 164 | printf "[COMMON_ENCLOSURE_%s]\n", $self->{cpqRackCommonEnclosureName}; 165 | foreach (qw(cpqRackCommonEnclosureRack cpqRackCommonEnclosureIndex cpqRackCommonEnclosureModel 166 | cpqRackCommonEnclosureSerialNum cpqRackCommonEnclosureFWRev cpqRackCommonEnclosureFWRev 167 | cpqRackCommonEnclosureName 168 | cpqRackCommonEnclosureCondition cpqRackCommonEnclosureHasServerBlades 169 | cpqRackCommonEnclosureHasPowerBlades cpqRackCommonEnclosureHasNetConnectors 170 | cpqRackCommonEnclosureHasTempSensors cpqRackCommonEnclosureHasFans cpqRackCommonEnclosureHasFuses)) { 171 | printf "%s: %s\n", $_, $self->{$_}; 172 | } 173 | printf "\n"; 174 | } 175 | 176 | 1; 177 | -------------------------------------------------------------------------------- /plugins-scripts/HP/BladeSystem/Component/CommonEnclosureSubsystem/FanSubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::BladeSystem::Component::CommonEnclosureSubsystem::FanSubsystem; 2 | our @ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | method => $params{method}, 14 | blacklisted => 0, 15 | fans => [], 16 | info => undef, 17 | extendedinfo => undef, 18 | }; 19 | bless $self, $class; 20 | $self->init(); 21 | return $self; 22 | } 23 | 24 | sub init { 25 | my $self = shift; 26 | my $oids = { 27 | cpqRackCommonEnclosureFanEntry => '1.3.6.1.4.1.232.22.2.3.1.3.1', 28 | cpqRackCommonEnclosureFanRack => '1.3.6.1.4.1.232.22.2.3.1.3.1.1', 29 | cpqRackCommonEnclosureFanChassis => '1.3.6.1.4.1.232.22.2.3.1.3.1.2', 30 | cpqRackCommonEnclosureFanIndex => '1.3.6.1.4.1.232.22.2.3.1.3.1.3', 31 | cpqRackCommonEnclosureFanEnclosureName => '1.3.6.1.4.1.232.22.2.3.1.3.1.4', 32 | cpqRackCommonEnclosureFanLocation => '1.3.6.1.4.1.232.22.2.3.1.3.1.5', 33 | cpqRackCommonEnclosureFanPartNumber => '1.3.6.1.4.1.232.22.2.3.1.3.1.6', 34 | cpqRackCommonEnclosureFanSparePartNumber => '1.3.6.1.4.1.232.22.2.3.1.3.1.7', 35 | cpqRackCommonEnclosureFanPresent => '1.3.6.1.4.1.232.22.2.3.1.3.1.8', 36 | cpqRackCommonEnclosureFanRedundant => '1.3.6.1.4.1.232.22.2.3.1.3.1.9', 37 | cpqRackCommonEnclosureFanRedundantGroupId => '1.3.6.1.4.1.232.22.2.3.1.3.1.10', 38 | cpqRackCommonEnclosureFanCondition => '1.3.6.1.4.1.232.22.2.3.1.3.1.11', 39 | cpqRackCommonEnclosureFanEnclosureSerialNum => '1.3.6.1.4.1.232.22.2.3.1.3.1.12', 40 | cpqRackCommonEnclosureFanPresentValue => { 41 | 1 => 'other', 42 | 2 => 'absent', 43 | 3 => 'present', 44 | }, 45 | cpqRackCommonEnclosureFanRedundantValue => { 46 | 0 => 'other', # meiner phantasie entsprungen, da sich hp nicht aeussert 47 | 1 => 'other', 48 | 2 => 'notRedundant', 49 | 3 => 'redundant', 50 | }, 51 | cpqRackCommonEnclosureFanConditionValue => { 52 | 1 => 'other', 53 | 2 => 'ok', 54 | 3 => 'degraded', 55 | 4 => 'failed', 56 | } 57 | }; 58 | # INDEX { cpqRackCommonEnclosureFanRack, cpqRackCommonEnclosureFanChassis, cpqRackCommonEnclosureFanIndex } 59 | foreach ($self->get_entries($oids, 'cpqRackCommonEnclosureFanEntry')) { 60 | push(@{$self->{fans}}, 61 | HP::BladeSystem::Component::CommonEnclosureSubsystem::FanSubsystem::Fan->new(%{$_})); 62 | } 63 | 64 | } 65 | 66 | sub check { 67 | my $self = shift; 68 | foreach (@{$self->{fans}}) { 69 | $_->check() if $_->{cpqRackCommonEnclosureFanPresent} eq 'present' || 70 | $self->{runtime}->{options}->{verbose} >= 3; # absent nur bei -vvv 71 | } 72 | } 73 | 74 | sub dump { 75 | my $self = shift; 76 | foreach (@{$self->{fans}}) { 77 | $_->dump() if $_->{cpqRackCommonEnclosureFanPresent} eq 'present' || 78 | $self->{runtime}->{options}->{verbose} >= 3; # absent nur bei -vvv 79 | } 80 | } 81 | 82 | 83 | package HP::BladeSystem::Component::CommonEnclosureSubsystem::FanSubsystem::Fan; 84 | 85 | our @ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem::FanSubsystem); 86 | 87 | use strict; 88 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 89 | 90 | sub new { 91 | my $class = shift; 92 | my %params = @_; 93 | my $self = { 94 | runtime => $params{runtime}, 95 | rawdata => $params{rawdata}, 96 | method => $params{method}, 97 | blacklisted => 0, 98 | info => undef, 99 | extendedinfo => undef, 100 | }; 101 | map { $self->{$_} = $params{$_} } grep /cpqRackCommonEnclosureFan/, keys %params; 102 | $self->{name} = $self->{cpqRackCommonEnclosureFanRack}.':'.$self->{cpqRackCommonEnclosureFanChassis}.':'.$self->{cpqRackCommonEnclosureFanIndex}; 103 | bless $self, $class; 104 | return $self; 105 | } 106 | 107 | sub check { 108 | my $self = shift; 109 | $self->blacklist('f', $self->{name}); 110 | $self->add_info(sprintf 'fan %s is %s, location is %s, redundance is %s, condition is %s', 111 | $self->{name}, $self->{cpqRackCommonEnclosureFanPresent}, 112 | $self->{cpqRackCommonEnclosureFanLocation}, 113 | $self->{cpqRackCommonEnclosureFanRedundant}, 114 | $self->{cpqRackCommonEnclosureFanCondition}); 115 | if ($self->{cpqRackCommonEnclosureFanCondition} eq 'degraded') { 116 | $self->{info} .= sprintf ", (SparePartNum: %s)", $self->{cpqRackCommonEnclosureFanSparePartNumber}; 117 | $self->add_message(WARNING, $self->{info}); 118 | } elsif ($self->{cpqRackCommonEnclosureFanCondition} eq 'failed') { 119 | $self->{info} .= sprintf ", (SparePartNum: %s)", $self->{cpqRackCommonEnclosureFanSparePartNumber}; 120 | $self->add_message(CRITICAL, $self->{info}); 121 | } 122 | } 123 | 124 | sub dump { 125 | my $self = shift; 126 | printf "[FAN_%s]\n", $self->{name}; 127 | foreach (qw(cpqRackCommonEnclosureFanRack cpqRackCommonEnclosureFanChassis 128 | cpqRackCommonEnclosureFanIndex cpqRackCommonEnclosureFanEnclosureName 129 | cpqRackCommonEnclosureFanLocation cpqRackCommonEnclosureFanPartNumber 130 | cpqRackCommonEnclosureFanSparePartNumber cpqRackCommonEnclosureFanPresent 131 | cpqRackCommonEnclosureFanRedundant cpqRackCommonEnclosureFanRedundantGroupId 132 | cpqRackCommonEnclosureFanCondition cpqRackCommonEnclosureFanEnclosureSerialNum)) { 133 | printf "%s: %s\n", $_, $self->{$_}; 134 | } 135 | printf "info: %s\n", $self->{info}; 136 | printf "\n"; 137 | } 138 | 139 | 1; 140 | -------------------------------------------------------------------------------- /plugins-scripts/HP/BladeSystem/Component/CommonEnclosureSubsystem/FuseSubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::BladeSystem::Component::CommonEnclosureSubsystem::FuseSubsystem; 2 | our @ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | method => $params{method}, 14 | blacklisted => 0, 15 | fuses => [], 16 | info => undef, 17 | extendedinfo => undef, 18 | }; 19 | bless $self, $class; 20 | $self->init(); 21 | return $self; 22 | } 23 | 24 | sub init { 25 | my $self = shift; 26 | my $oids = { 27 | cpqRackCommonEnclosureFuseEntry => '1.3.6.1.4.1.232.22.2.3.1.4.1', 28 | cpqRackCommonEnclosureFuseRack => '1.3.6.1.4.1.232.22.2.3.1.4.1.1', 29 | cpqRackCommonEnclosureFuseChassis => '1.3.6.1.4.1.232.22.2.3.1.4.1.2', 30 | cpqRackCommonEnclosureFuseIndex => '1.3.6.1.4.1.232.22.2.3.1.4.1.3', 31 | cpqRackCommonEnclosureFuseEnclosureName => '1.3.6.1.4.1.232.22.2.3.1.4.1.4', 32 | cpqRackCommonEnclosureFuseLocation => '1.3.6.1.4.1.232.22.2.3.1.4.1.5', 33 | cpqRackCommonEnclosureFusePresent => '1.3.6.1.4.1.232.22.2.3.1.4.1.8', 34 | cpqRackCommonEnclosureFuseCondition => '1.3.6.1.4.1.232.22.2.3.1.4.1.11', 35 | cpqRackCommonEnclosureFusePresentValue => { 36 | 1 => 'other', 37 | 2 => 'absent', 38 | 3 => 'present', 39 | }, 40 | cpqRackCommonEnclosureFuseConditionValue => { 41 | 1 => 'other', 42 | 2 => 'ok', 43 | 4 => 'failed', 44 | } 45 | }; 46 | # INDEX { cpqRackCommonEnclosureFuseRack, cpqRackCommonEnclosureFuseChassis, cpqRackCommonEnclosureFuseIndex } 47 | foreach ($self->get_entries($oids, 'cpqRackCommonEnclosureFuseEntry')) { 48 | push(@{$self->{fuses}}, 49 | HP::BladeSystem::Component::CommonEnclosureSubsystem::FuseSubsystem::Fuse->new(%{$_})); 50 | } 51 | 52 | } 53 | 54 | sub check { 55 | my $self = shift; 56 | foreach (@{$self->{fuses}}) { 57 | $_->check() if $_->{cpqRackCommonEnclosureFusePresent} eq 'present' || 58 | $self->{runtime}->{options}->{verbose} >= 3; # absent nur bei -vvv 59 | } 60 | } 61 | 62 | sub dump { 63 | my $self = shift; 64 | foreach (@{$self->{fuses}}) { 65 | $_->dump() if $_->{cpqRackCommonEnclosureFusePresent} eq 'present' || 66 | $self->{runtime}->{options}->{verbose} >= 3; # absent nur bei -vvv 67 | } 68 | } 69 | 70 | 71 | package HP::BladeSystem::Component::CommonEnclosureSubsystem::FuseSubsystem::Fuse; 72 | 73 | our @ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem::FuseSubsystem); 74 | 75 | use strict; 76 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 77 | 78 | sub new { 79 | my $class = shift; 80 | my %params = @_; 81 | my $self = { 82 | runtime => $params{runtime}, 83 | rawdata => $params{rawdata}, 84 | method => $params{method}, 85 | blacklisted => 0, 86 | info => undef, 87 | extendedinfo => undef, 88 | }; 89 | map { $self->{$_} = $params{$_} } grep /cpqRackCommonEnclosureFuse/, keys %params; 90 | $self->{name} = $self->{cpqRackCommonEnclosureFuseRack}.':'.$self->{cpqRackCommonEnclosureFuseChassis}.':'.$self->{cpqRackCommonEnclosureFuseIndex}; 91 | bless $self, $class; 92 | return $self; 93 | } 94 | 95 | sub check { 96 | my $self = shift; 97 | $self->blacklist('fu', $self->{name}); 98 | $self->add_info(sprintf 'fuse %s is %s, location is %s, condition is %s', 99 | $self->{name}, $self->{cpqRackCommonEnclosureFusePresent}, 100 | $self->{cpqRackCommonEnclosureFuseLocation}, $self->{cpqRackCommonEnclosureFuseCondition}); 101 | if ($self->{cpqRackCommonEnclosureFuseCondition} eq 'failed') { 102 | $self->add_message(CRITICAL, $self->{info}); 103 | } elsif ($self->{cpqRackCommonEnclosureFuseCondition} ne 'ok') { 104 | $self->add_message(WARNING, $self->{info}); 105 | } 106 | } 107 | 108 | sub dump { 109 | my $self = shift; 110 | printf "[FUSE_%s]\n", $self->{name}; 111 | foreach (qw(cpqRackCommonEnclosureFuseRack cpqRackCommonEnclosureFuseChassis 112 | cpqRackCommonEnclosureFuseIndex cpqRackCommonEnclosureFuseEnclosureName 113 | cpqRackCommonEnclosureFuseLocation cpqRackCommonEnclosureFusePresent 114 | cpqRackCommonEnclosureFuseCondition)) { 115 | printf "%s: %s\n", $_, $self->{$_}; 116 | } 117 | printf "info: %s\n", $self->{info}; 118 | printf "\n"; 119 | } 120 | 121 | 1; 122 | -------------------------------------------------------------------------------- /plugins-scripts/HP/BladeSystem/Component/CommonEnclosureSubsystem/ManagerSubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::BladeSystem::Component::CommonEnclosureSubsystem::ManagerSubsystem; 2 | our @ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | method => $params{method}, 14 | blacklisted => 0, 15 | managers => [], 16 | info => undef, 17 | extendedinfo => undef, 18 | }; 19 | bless $self, $class; 20 | $self->init(); 21 | return $self; 22 | } 23 | 24 | sub init { 25 | my $self = shift; 26 | my $oids = { 27 | cpqRackCommonEnclosureManagerEntry => '1.3.6.1.4.1.232.22.2.3.1.6.1', 28 | cpqRackCommonEnclosureManagerRack => '1.3.6.1.4.1.232.22.2.3.1.6.1.1', 29 | cpqRackCommonEnclosureManagerChassis => '1.3.6.1.4.1.232.22.2.3.1.6.1.2', 30 | cpqRackCommonEnclosureManagerIndex => '1.3.6.1.4.1.232.22.2.3.1.6.1.3', 31 | cpqRackCommonEnclosureManagerEnclosureName => '1.3.6.1.4.1.232.22.2.3.1.6.1.4', 32 | cpqRackCommonEnclosureManagerLocation => '1.3.6.1.4.1.232.22.2.3.1.6.1.5', 33 | cpqRackCommonEnclosureManagerPartNumber => '1.3.6.1.4.1.232.22.2.3.1.6.1.6', 34 | cpqRackCommonEnclosureManagerSparePartNumber => '1.3.6.1.4.1.232.22.2.3.1.6.1.7', 35 | cpqRackCommonEnclosureManagerSerialNum => '1.3.6.1.4.1.232.22.2.3.1.6.1.8', 36 | cpqRackCommonEnclosureManagerRole => '1.3.6.1.4.1.232.22.2.3.1.6.1.9', 37 | cpqRackCommonEnclosureManagerPresent => '1.3.6.1.4.1.232.22.2.3.1.6.1.10', 38 | cpqRackCommonEnclosureManagerRedundant => '1.3.6.1.4.1.232.22.2.3.1.6.1.11', 39 | cpqRackCommonEnclosureManagerCondition => '1.3.6.1.4.1.232.22.2.3.1.6.1.12', 40 | cpqRackCommonEnclosureManagerFWRev => '1.3.6.1.4.1.232.22.2.3.1.6.1.15', 41 | cpqRackCommonEnclosureManagerRoleValue => { 42 | 1 => 'standby', 43 | 2 => 'active', 44 | }, 45 | cpqRackCommonEnclosureManagerPresentValue => { 46 | 1 => 'other', 47 | 2 => 'absent', # mit vorsicht zu geniessen! 48 | 3 => 'present', 49 | }, 50 | cpqRackCommonEnclosureManagerRedundantValue => { 51 | 0 => 'other', # meiner phantasie entsprungen, da sich hp nicht aeussert 52 | 1 => 'other', 53 | 2 => 'notRedundant', 54 | 3 => 'redundant', 55 | }, 56 | cpqRackCommonEnclosureManagerConditionValue => { 57 | 1 => 'other', 58 | 2 => 'ok', 59 | 3 => 'degraded', 60 | 4 => 'failed', 61 | } 62 | }; 63 | # INDEX { cpqRackCommonEnclosureManagerRack, cpqRackCommonEnclosureManagerChassis, cpqRackCommonEnclosureManagerIndex } 64 | foreach ($self->get_entries($oids, 'cpqRackCommonEnclosureManagerEntry')) { 65 | push(@{$self->{managers}}, 66 | HP::BladeSystem::Component::CommonEnclosureSubsystem::ManagerSubsystem::Manager->new(%{$_})); 67 | } 68 | } 69 | 70 | sub check { 71 | my $self = shift; 72 | foreach (@{$self->{managers}}) { 73 | $_->check() if $_->{cpqRackCommonEnclosureManagerPresent} eq 'present' || 74 | $self->{runtime}->{options}->{verbose} >= 3; # absent nur bei -vvv 75 | } 76 | } 77 | 78 | sub dump { 79 | my $self = shift; 80 | foreach (@{$self->{managers}}) { 81 | $_->dump() if $_->{cpqRackCommonEnclosureManagerPresent} eq 'present' || 82 | $self->{runtime}->{options}->{verbose} >= 3; # absent nur bei -vvv 83 | } 84 | } 85 | 86 | 87 | package HP::BladeSystem::Component::CommonEnclosureSubsystem::ManagerSubsystem::Manager; 88 | 89 | our @ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem::ManagerSubsystem); 90 | 91 | use strict; 92 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 93 | 94 | sub new { 95 | my $class = shift; 96 | my %params = @_; 97 | my $self = { 98 | runtime => $params{runtime}, 99 | rawdata => $params{rawdata}, 100 | method => $params{method}, 101 | blacklisted => 0, 102 | info => undef, 103 | extendedinfo => undef, 104 | }; 105 | map { $self->{$_} = $params{$_} } grep /cpqRackCommonEnclosureManager/, keys %params; 106 | $self->{name} = $self->{cpqRackCommonEnclosureManagerRack}. 107 | ':'.$self->{cpqRackCommonEnclosureManagerChassis}. 108 | ':'.$self->{cpqRackCommonEnclosureManagerIndex}; 109 | if ($self->{cpqRackCommonEnclosureManagerPresent} eq "absent" && 110 | defined $self->{cpqRackCommonEnclosureManagerEnclosureName}) { 111 | $self->{cpqRackCommonEnclosureManagerPresent} = "present"; 112 | } 113 | bless $self, $class; 114 | return $self; 115 | } 116 | 117 | sub check { 118 | my $self = shift; 119 | $self->blacklist('em', $self->{name}); 120 | my $info = sprintf 'manager %s is %s, location is %s, redundance is %s, condition is %s, role is %s', 121 | $self->{name}, $self->{cpqRackCommonEnclosureManagerPresent}, 122 | $self->{cpqRackCommonEnclosureManagerLocation}, 123 | $self->{cpqRackCommonEnclosureManagerRedundant}, 124 | $self->{cpqRackCommonEnclosureManagerCondition}, 125 | $self->{cpqRackCommonEnclosureManagerRole}; 126 | $self->add_info($info) if $self->{cpqRackCommonEnclosureManagerPresent} eq 'present' || 127 | $self->{runtime}->{options}->{verbose} >= 3; # absent managers nur bei -vvv 128 | if ($self->{cpqRackCommonEnclosureManagerCondition} eq 'degraded') { 129 | $self->{info} .= sprintf ' (SparePartNum: %s)', 130 | $self->{cpqRackCommonEnclosureManagerSparePartNumber}; 131 | $self->add_message(WARNING, $self->{info}); 132 | } elsif ($self->{cpqRackCommonEnclosureManagerCondition} eq 'failed') { 133 | $self->{info} .= sprintf ' (SparePartNum: %s)', 134 | $self->{cpqRackCommonEnclosureManagerSparePartNumber}; 135 | $self->add_message(CRITICAL, $self->{info}); 136 | } 137 | } 138 | 139 | sub dump { 140 | my $self = shift; 141 | printf "[ENCLOSURE_MANAGER_%s]\n", $self->{name}; 142 | foreach (qw(cpqRackCommonEnclosureManagerRack cpqRackCommonEnclosureManagerChassis 143 | cpqRackCommonEnclosureManagerIndex cpqRackCommonEnclosureManagerEnclosureName 144 | cpqRackCommonEnclosureManagerLocation cpqRackCommonEnclosureManagerPartNumber 145 | cpqRackCommonEnclosureManagerSparePartNumber cpqRackCommonEnclosureManagerPresent 146 | cpqRackCommonEnclosureManagerRedundant 147 | cpqRackCommonEnclosureManagerCondition cpqRackCommonEnclosureManagerFWRev)) { 148 | printf "%s: %s\n", $_, $self->{$_}; 149 | } 150 | printf "info: %s\n", $self->{info}; 151 | printf "\n"; 152 | } 153 | 154 | 1; 155 | -------------------------------------------------------------------------------- /plugins-scripts/HP/BladeSystem/Component/CommonEnclosureSubsystem/TempSubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::BladeSystem::Component::CommonEnclosureSubsystem::TempSubsystem; 2 | our @ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | method => $params{method}, 14 | condition => $params{condition}, 15 | status => $params{status}, 16 | temperatures => [], 17 | blacklisted => 0, 18 | info => undef, 19 | extendedinfo => undef, 20 | }; 21 | bless $self, $class; 22 | if ($params{runtime}->{options}->{customthresholds}) { 23 | if (-f $params{runtime}->{options}->{customthresholds}) { 24 | open CT, $params{runtime}->{options}->{customthresholds}; 25 | $params{runtime}->{options}->{customthresholds} = ; 26 | close CT; 27 | } 28 | foreach my $ct_items 29 | (split(/\//, $params{runtime}->{options}->{customthresholds})) { 30 | if ($ct_items =~ /^(\d+):(\d+)$/) { 31 | my $temp = $2; 32 | $params{runtime}->{options}->{thresholds}->{$1} = $temp; 33 | } else { 34 | die sprintf "invalid threshold %s", $ct_items; 35 | } 36 | } 37 | } 38 | $self->init(); 39 | return $self; 40 | } 41 | 42 | sub init { 43 | my $self = shift; 44 | my %params = @_; 45 | my $snmpwalk = $self->{rawdata}; 46 | my $oids = { 47 | cpqRackCommonEnclosureTempEntry => '1.3.6.1.4.1.232.22.2.3.1.2.1', 48 | cpqRackCommonEnclosureTempRack => '1.3.6.1.4.1.232.22.2.3.1.2.1.1', 49 | cpqRackCommonEnclosureTempChassis => '1.3.6.1.4.1.232.22.2.3.1.2.1.2', 50 | cpqRackCommonEnclosureTempSensorIndex => '1.3.6.1.4.1.232.22.2.3.1.2.1.3', 51 | cpqRackCommonEnclosureTempSensorEnclosureName => '1.3.6.1.4.1.232.22.2.3.1.2.1.4', 52 | cpqRackCommonEnclosureTempLocation => '1.3.6.1.4.1.232.22.2.3.1.2.1.5', 53 | cpqRackCommonEnclosureTempCurrent => '1.3.6.1.4.1.232.22.2.3.1.2.1.6', 54 | cpqRackCommonEnclosureTempThreshold => '1.3.6.1.4.1.232.22.2.3.1.2.1.7', 55 | cpqRackCommonEnclosureTempCondition => '1.3.6.1.4.1.232.22.2.3.1.2.1.8', 56 | cpqRackCommonEnclosureTempType => '1.3.6.1.4.1.232.22.2.3.1.2.1.9', 57 | cpqRackCommonEnclosureTempConditionValue => { 58 | 1 => 'other', 59 | 2 => 'ok', 60 | 3 => 'degraded', 61 | 4 => 'failed', 62 | }, 63 | cpqRackCommonEnclosureTempTypeValue => { 64 | 1 => 'other', 65 | 5 => 'blowout', 66 | 9 => 'caution', 67 | 15 => 'critical', 68 | }, 69 | }; 70 | # INDEX { cpqRackCommonEnclosureTempRack cpqRackCommonEnclosureTempChassis 71 | # cpqRackCommonEnclosureTempSensorIndex } 72 | foreach ($self->get_entries($oids, 'cpqRackCommonEnclosureTempEntry')) { 73 | push(@{$self->{temperatures}}, 74 | HP::BladeSystem::Component::CommonEnclosureSubsystem::TempSubsystem::Temp->new(%{$_})) if (($_->{cpqRackCommonEnclosureTempCurrent} != -1 && $_->{cpqRackCommonEnclosureTempThreshold} != -1) && ($_->{cpqRackCommonEnclosureTempThreshold} != 0)); 75 | } 76 | 77 | } 78 | 79 | 80 | sub check { 81 | my $self = shift; 82 | my $errorfound = 0; 83 | if (scalar (@{$self->{temperatures}}) == 0) { 84 | #$self->overall_check(); 85 | } else { 86 | foreach (@{$self->{temperatures}}) { 87 | $_->check(); 88 | } 89 | } 90 | } 91 | 92 | sub dump { 93 | my $self = shift; 94 | foreach (@{$self->{temperatures}}) { 95 | $_->dump(); 96 | } 97 | } 98 | 99 | 100 | package HP::BladeSystem::Component::CommonEnclosureSubsystem::TempSubsystem::Temp; 101 | our @ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem::TempSubsystem); 102 | 103 | use strict; 104 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 105 | 106 | sub new { 107 | my $class = shift; 108 | my %params = @_; 109 | my $self = { 110 | runtime => $params{runtime}, 111 | rawdata => $params{rawdata}, 112 | method => $params{method}, 113 | blacklisted => 0, 114 | info => undef, 115 | extendedinfo => undef, 116 | }; 117 | map { $self->{$_} = $params{$_} } grep /cpqRackCommonEnclosureTemp/, keys %params; 118 | $self->{name} = $params{cpqRackCommonEnclosureTempRack}.':'. 119 | $params{cpqRackCommonEnclosureTempChassis}.':'. 120 | $params{cpqRackCommonEnclosureTempSensorIndex}; 121 | bless $self, $class; 122 | return $self; 123 | } 124 | 125 | sub check { 126 | my $self = shift; 127 | $self->blacklist('t', $self->{name}); 128 | if ($self->{cpqRackCommonEnclosureTempCurrent} > $self->{cpqRackCommonEnclosureTempThreshold}) { 129 | $self->add_info(sprintf "%s temperature too high (%d%s)", 130 | $self->{cpqRackCommonEnclosureTempLocation}, 131 | $self->{cpqRackCommonEnclosureTempCurrent}, 132 | $self->{runtime}->{options}->{celsius} ? "C" : "F"); 133 | $self->add_message(CRITICAL, $self->{info}); 134 | } else { 135 | $self->add_info(sprintf "%s temperature is %d%s (%d max)", 136 | $self->{cpqRackCommonEnclosureTempLocation}, 137 | $self->{cpqRackCommonEnclosureTempCurrent}, 138 | $self->{runtime}->{options}->{celsius} ? "C" : "F", 139 | $self->{cpqRackCommonEnclosureTempThreshold}); 140 | } 141 | if ($self->{runtime}->{options}->{perfdata} == 2) { 142 | $self->{runtime}->{plugin}->add_perfdata( 143 | label => sprintf('temp_%s', $self->{name}), 144 | value => $self->{cpqRackCommonEnclosureTempCurrent}, 145 | warning => $self->{cpqRackCommonEnclosureTempThreshold}, 146 | critical => $self->{cpqRackCommonEnclosureTempThreshold} 147 | ); 148 | } elsif ($self->{runtime}->{options}->{perfdata} == 1) { 149 | $self->{runtime}->{plugin}->add_perfdata( 150 | label => sprintf('temp_%s_%s', $self->{name}, 151 | $self->{cpqRackCommonEnclosureTempLocation}), 152 | value => $self->{cpqRackCommonEnclosureTempCurrent}, 153 | warning => $self->{cpqRackCommonEnclosureTempThreshold}, 154 | critical => $self->{cpqRackCommonEnclosureTempThreshold} 155 | ); 156 | } 157 | $self->add_extendedinfo(sprintf "temp_%s=%d", 158 | $self->{name}, $self->{cpqRackCommonEnclosureTempCurrent}); 159 | 160 | } 161 | 162 | 163 | sub dump { 164 | my $self = shift; 165 | printf "[TEMP_%s]\n", $self->{name}; 166 | foreach (qw(cpqRackCommonEnclosureTempRack cpqRackCommonEnclosureTempChassis 167 | cpqRackCommonEnclosureTempSensorIndex cpqRackCommonEnclosureTempSensorEnclosureName 168 | cpqRackCommonEnclosureTempLocation 169 | cpqRackCommonEnclosureTempCurrent cpqRackCommonEnclosureTempThreshold 170 | cpqRackCommonEnclosureTempCondition cpqRackCommonEnclosureTempType)) { 171 | printf "%s: %s\n", $_, $self->{$_}; 172 | } 173 | printf "info: %s\n\n", $self->{info}; 174 | } 175 | 176 | 1; 177 | 178 | -------------------------------------------------------------------------------- /plugins-scripts/HP/BladeSystem/Component/NetConnectorSubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::BladeSystem::Component::NetConnectorSubsystem; 2 | our @ISA = qw(HP::BladeSystem::Component); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | method => $params{method}, 14 | net_connectors => [], 15 | blacklisted => 0, 16 | info => undef, 17 | extendedinfo => undef, 18 | }; 19 | bless $self, $class; 20 | $self->init(); 21 | return $self; 22 | } 23 | 24 | sub init { 25 | my $self = shift; 26 | my $oids = { 27 | cpqRackNetConnectorEntry => '1.3.6.1.4.1.232.22.2.6.1.1.1', 28 | cpqRackNetConnectorRack => '1.3.6.1.4.1.232.22.2.6.1.1.1.1', 29 | cpqRackNetConnectorChassis => '1.3.6.1.4.1.232.22.2.6.1.1.1.2', 30 | cpqRackNetConnectorIndex => '1.3.6.1.4.1.232.22.2.6.1.1.1.3', 31 | cpqRackNetConnectorEnclosureName => '1.3.6.1.4.1.232.22.2.6.1.1.1.4', 32 | cpqRackNetConnectorName => '1.3.6.1.4.1.232.22.2.6.1.1.1.5', 33 | cpqRackNetConnectorModel => '1.3.6.1.4.1.232.22.2.6.1.1.1.6', 34 | cpqRackNetConnectorSerialNum => '1.3.6.1.4.1.232.22.2.6.1.1.1.7', 35 | cpqRackNetConnectorPartNumber => '1.3.6.1.4.1.232.22.2.6.1.1.1.8', 36 | cpqRackNetConnectorSparePartNumber => '1.3.6.1.4.1.232.22.2.6.1.1.1.9', 37 | cpqRackNetConnectorFWRev => '1.3.6.1.4.1.232.22.2.6.1.1.1.10', 38 | cpqRackNetConnectorType => '1.3.6.1.4.1.232.22.2.6.1.1.1.11', 39 | cpqRackNetConnectorLocation => '1.3.6.1.4.1.232.22.2.6.1.1.1.12', 40 | cpqRackNetConnectorPresent => '1.3.6.1.4.1.232.22.2.6.1.1.1.13', 41 | cpqRackNetConnectorHasFuses => '1.3.6.1.4.1.232.22.2.6.1.1.1.14', 42 | cpqRackNetConnectorEnclosureSerialNum => '1.3.6.1.4.1.232.22.2.6.1.1.1.15', 43 | cpqRackNetConnectorTypeValue => { 44 | 0 => 'other', # undefined 45 | 1 => 'other', 46 | 2 => 'active', 47 | 3 => 'passive', 48 | }, 49 | cpqRackNetConnectorPresentValue => { 50 | 1 => 'other', 51 | 2 => 'absent', 52 | 3 => 'present', 53 | }, 54 | cpqRackNetConnectorHasFusesValue => { 55 | -1 => 'false', # wird geliefert, also vermute ich false 56 | 1 => 'false', 57 | 2 => 'true', 58 | }, 59 | }; 60 | 61 | 62 | # INDEX { cpqRackNetConnectorRack, cpqRackNetConnectorChassis, cpqRackNetConnectorIndex } 63 | # dreckada dreck, dreckada 64 | foreach ($self->get_entries($oids, 'cpqRackNetConnectorEntry')) { 65 | push(@{$self->{net_connectors}}, 66 | HP::BladeSystem::Component::NetConnectorSubsystem::NetConnector->new(%{$_})); 67 | } 68 | } 69 | 70 | sub check { 71 | my $self = shift; 72 | foreach (@{$self->{net_connectors}}) { 73 | $_->check() if $_->{cpqRackNetConnectorPresent} eq 'present' || 74 | $self->{runtime}->{options}->{verbose} >= 3; # absent nur bei -vvv 75 | } 76 | } 77 | 78 | sub dump { 79 | my $self = shift; 80 | foreach (@{$self->{net_connectors}}) { 81 | $_->dump() if $_->{cpqRackNetConnectorPresent} eq 'present' || 82 | $self->{runtime}->{options}->{verbose} >= 3; # absent nur bei -vvv 83 | } 84 | } 85 | 86 | 87 | package HP::BladeSystem::Component::NetConnectorSubsystem::NetConnector; 88 | our @ISA = qw(HP::BladeSystem::Component::NetConnectorSubsystem); 89 | 90 | use strict; 91 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 92 | 93 | sub new { 94 | my $class = shift; 95 | my %params = @_; 96 | my $self = { 97 | runtime => $params{runtime}, 98 | rawdata => $params{rawdata}, 99 | method => $params{method}, 100 | blacklisted => 0, 101 | info => undef, 102 | extendedinfo => undef, 103 | }; 104 | map { $self->{$_} = $params{$_} } grep /cpqRackNetConnector/, keys %params; 105 | $self->{name} = $params{cpqRackNetConnectorRack}. 106 | ':'.$params{cpqRackNetConnectorChassis}. 107 | ':'.$params{cpqRackNetConnectorIndex}; 108 | $self->{serfw} = sprintf "Ser: %s, FW: %s", $self->{cpqRackNetConnectorSerialNum}, $self->{cpqRackNetConnectorFWRev}; 109 | bless $self, $class; 110 | return $self; 111 | } 112 | 113 | sub check { 114 | my $self = shift; 115 | $self->blacklist('nc', $self->{name}); 116 | my $info = sprintf 'net connector %s is %s, model is %s (%s)', 117 | $self->{name}.($self->{cpqRackNetConnectorName} ? ' \''.$self->{cpqRackNetConnectorName}.'\'' : ''), 118 | $self->{cpqRackNetConnectorPresent}, $self->{cpqRackNetConnectorModel}, $self->{serfw}; 119 | $self->add_info($info); 120 | # hat weder status noch condition, vielleicht spaeter mal 121 | $info .= sprintf " (SparePartNum %s)", $self->{cpqRackNetConnectorSparePartNumber}; 122 | } 123 | 124 | sub dump { 125 | my $self = shift; 126 | printf "[NET_CONNECTOR_%s]\n", $self->{cpqRackNetConnectorName}; 127 | foreach (qw(cpqRackNetConnectorRack cpqRackNetConnectorChassis cpqRackNetConnectorIndex cpqRackNetConnectorEnclosureName cpqRackNetConnectorName cpqRackNetConnectorModel cpqRackNetConnectorSerialNum cpqRackNetConnectorPartNumber cpqRackNetConnectorSparePartNumber cpqRackNetConnectorFWRev cpqRackNetConnectorType cpqRackNetConnectorLocation cpqRackNetConnectorPresent cpqRackNetConnectorHasFuses cpqRackNetConnectorEnclosureSerialNum)) { 128 | printf "%s: %s\n", $_, $self->{$_}; 129 | } 130 | printf "\n"; 131 | } 132 | 133 | 134 | 1; 135 | -------------------------------------------------------------------------------- /plugins-scripts/HP/BladeSystem/Component/PowerEnclosureSubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::BladeSystem::Component::PowerEnclosureSubsystem; 2 | our @ISA = qw(HP::BladeSystem::Component); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | method => $params{method}, 14 | power_enclosures => [], 15 | blacklisted => 0, 16 | info => undef, 17 | extendedinfo => undef, 18 | }; 19 | bless $self, $class; 20 | $self->init(); 21 | return $self; 22 | } 23 | 24 | sub init { 25 | my $self = shift; 26 | 27 | # cpqRackPowerEnclosureTable 28 | my $oids = { 29 | cpqRackPowerEnclosureEntry => '1.3.6.1.4.1.232.22.2.3.3.1.1', 30 | cpqRackPowerEnclosureRack => '1.3.6.1.4.1.232.22.2.3.3.1.1.1', 31 | cpqRackPowerEnclosureIndex => '1.3.6.1.4.1.232.22.2.3.3.1.1.2', 32 | cpqRackPowerEnclosureName => '1.3.6.1.4.1.232.22.2.3.3.1.1.3', 33 | cpqRackPowerEnclosureMgmgtBoardSerialNum => '1.3.6.1.4.1.232.22.2.3.3.1.1.4', 34 | cpqRackPowerEnclosureRedundant => '1.3.6.1.4.1.232.22.2.3.3.1.1.5', 35 | cpqRackPowerEnclosureLoadBalanced => '1.3.6.1.4.1.232.22.2.3.3.1.1.6', 36 | cpqRackPowerEnclosureInputPwrType => '1.3.6.1.4.1.232.22.2.3.3.1.1.7', 37 | cpqRackPowerEnclosurePwrFeedMax => '1.3.6.1.4.1.232.22.2.3.3.1.1.8', 38 | cpqRackPowerEnclosureCondition => '1.3.6.1.4.1.232.22.2.3.3.1.1.9', 39 | cpqRackPowerEnclosureRedundantValue => { 40 | 1 => 'other', 41 | 2 => 'notRedundant', 42 | 3 => 'redundant', 43 | }, 44 | cpqRackPowerEnclosureLoadBalancedValue => { 45 | 0 => 'aechz', 46 | 1 => 'other', 47 | 2 => 'notLoadBalanced', 48 | 3 => 'loadBalanced', 49 | }, 50 | cpqRackPowerEnclosureInputPwrTypeValue => { 51 | 1 => 'other', 52 | 2 => 'singlePhase', 53 | 3 => 'threePhase', 54 | 4 => 'directCurrent', 55 | }, 56 | cpqRackPowerEnclosureConditionValue => { 57 | 1 => 'other', 58 | 2 => 'ok', 59 | 3 => 'degraded', 60 | }, 61 | }; 62 | 63 | 64 | # INDEX { cpqRackPowerEnclosureRack, cpqRackPowerEnclosureIndex } 65 | # dreckada dreck, dreckada 66 | foreach ($self->get_entries($oids, 'cpqRackPowerEnclosureEntry')) { 67 | push(@{$self->{power_enclosures}}, 68 | HP::BladeSystem::Component::PowerEnclosureSubsystem::PowerEnclosure->new(%{$_})); 69 | } 70 | } 71 | 72 | sub check { 73 | my $self = shift; 74 | foreach (@{$self->{power_enclosures}}) { 75 | $_->check(); 76 | } 77 | } 78 | 79 | sub dump { 80 | my $self = shift; 81 | foreach (@{$self->{power_enclosures}}) { 82 | $_->dump(); 83 | } 84 | } 85 | 86 | 87 | package HP::BladeSystem::Component::PowerEnclosureSubsystem::PowerEnclosure; 88 | our @ISA = qw(HP::BladeSystem::Component::PowerEnclosureSubsystem); 89 | 90 | use strict; 91 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 92 | 93 | sub new { 94 | my $class = shift; 95 | my %params = @_; 96 | my $self = { 97 | runtime => $params{runtime}, 98 | rawdata => $params{rawdata}, 99 | method => $params{method}, 100 | blacklisted => 0, 101 | info => undef, 102 | extendedinfo => undef, 103 | }; 104 | map { $self->{$_} = $params{$_} } grep /cpqRackPowerEnclosure/, keys %params; 105 | $self->{name} = $self->{cpqRackPowerEnclosureRack}.':'.$self->{cpqRackPowerEnclosureIndex}; 106 | bless $self, $class; 107 | $self->init(); 108 | return $self; 109 | } 110 | 111 | sub check { 112 | my $self = shift; 113 | $self->blacklist('pe', $self->{name}); 114 | my $info = sprintf 'power enclosure %s \'%s\' condition is %s', 115 | $self->{name}, $self->{cpqRackPowerEnclosureName}, $self->{cpqRackPowerEnclosureCondition}; 116 | $self->add_info($info); 117 | if ($self->{cpqRackPowerEnclosureCondition} eq 'degraded') { 118 | $self->add_message(WARNING, $info); 119 | } 120 | } 121 | 122 | sub dump { 123 | my $self = shift; 124 | printf "[POWER_ENCLOSURE_%s]\n", $self->{cpqRackPowerEnclosureName}; 125 | foreach (qw(cpqRackPowerEnclosureRack cpqRackPowerEnclosureIndex 126 | cpqRackPowerEnclosureName cpqRackPowerEnclosureMgmgtBoardSerialNum 127 | cpqRackPowerEnclosureRedundant cpqRackPowerEnclosureLoadBalanced 128 | cpqRackPowerEnclosureInputPwrType cpqRackPowerEnclosurePwrFeedMax 129 | cpqRackPowerEnclosureCondition)) { 130 | printf "%s: %s\n", $_, $self->{$_}; 131 | } 132 | printf "\n"; 133 | } 134 | 135 | 136 | 1; 137 | -------------------------------------------------------------------------------- /plugins-scripts/HP/BladeSystem/Component/ServerBladeSubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::BladeSystem::Component::ServerBladeSubsystem; 2 | our @ISA = qw(HP::BladeSystem::Component); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | method => $params{method}, 14 | server_blades => [], 15 | blacklisted => 0, 16 | info => undef, 17 | extendedinfo => undef, 18 | }; 19 | bless $self, $class; 20 | $self->init(); 21 | return $self; 22 | } 23 | 24 | sub init { 25 | my $self = shift; 26 | my $oids = { 27 | cpqRackServerBladeEntry => '1.3.6.1.4.1.232.22.2.4.1.1.1', 28 | cpqRackServerBladeRack => '1.3.6.1.4.1.232.22.2.4.1.1.1.1', 29 | cpqRackServerBladeChassis => '1.3.6.1.4.1.232.22.2.4.1.1.1.2', 30 | cpqRackServerBladeIndex => '1.3.6.1.4.1.232.22.2.4.1.1.1.3', 31 | cpqRackServerBladeName => '1.3.6.1.4.1.232.22.2.4.1.1.1.4', 32 | cpqRackServerBladeEnclosureName => '1.3.6.1.4.1.232.22.2.4.1.1.1.5', 33 | cpqRackServerBladePartNumber => '1.3.6.1.4.1.232.22.2.4.1.1.1.6', 34 | cpqRackServerBladeSparePartNumber => '1.3.6.1.4.1.232.22.2.4.1.1.1.7', 35 | cpqRackServerBladePosition => '1.3.6.1.4.1.232.22.2.4.1.1.1.8', 36 | cpqRackServerBladeHeight => '1.3.6.1.4.1.232.22.2.4.1.1.1.9', 37 | cpqRackServerBladeWidth => '1.3.6.1.4.1.232.22.2.4.1.1.1.10', 38 | cpqRackServerBladeDepth => '1.3.6.1.4.1.232.22.2.4.1.1.1.11', 39 | cpqRackServerBladePresent => '1.3.6.1.4.1.232.22.2.4.1.1.1.12', 40 | cpqRackServerBladeHasFuses => '1.3.6.1.4.1.232.22.2.4.1.1.1.13', 41 | cpqRackServerBladeEnclosureSerialNum => '1.3.6.1.4.1.232.22.2.4.1.1.1.14', 42 | cpqRackServerBladeSlotsUsed => '1.3.6.1.4.1.232.22.2.4.1.1.1.15', 43 | cpqRackServerBladeStatus => '1.3.6.1.4.1.232.22.2.4.1.1.1.21', 44 | cpqRackServerBladeDiagnosticString => '1.3.6.1.4.1.232.22.2.4.1.1.1.24', 45 | cpqRackServerBladePowered => '1.3.6.1.4.1.232.22.2.4.1.1.1.25', 46 | cpqRackServerBladePOSTStatus => '1.3.6.1.4.1.232.22.2.4.1.1.1.35', 47 | cpqRackServerBladePresentValue => { 48 | 1 => 'other', 49 | 2 => 'absent', 50 | 3 => 'present', 51 | }, 52 | cpqRackServerBladeStatusValue => { 53 | 1 => 'other', 54 | 2 => 'ok', 55 | 3 => 'degraded', 56 | 4 => 'failed', 57 | }, 58 | cpqRackServerBladePoweredValue => { 59 | 0 => 'aechz', 60 | 1 => 'other', 61 | 2 => 'on', 62 | 3 => 'off', 63 | 4 => 'powerStagedOff', 64 | 5 => 'reboot', 65 | }, 66 | cpqRackServerBladePOSTStatusValue => { 67 | 1 => 'other', 68 | 2 => 'started', 69 | 3 => 'completed', 70 | 4 => 'failed', 71 | }, 72 | }; 73 | 74 | 75 | # INDEX { cpqRackServerBladeRack, cpqRackServerBladeChassis, cpqRackServerBladeIndex } 76 | # dreckada dreck, dreckada 77 | foreach ($self->get_entries($oids, 'cpqRackServerBladeEntry')) { 78 | push(@{$self->{server_blades}}, 79 | HP::BladeSystem::Component::ServerBladeSubsystem::ServerBlade->new(%{$_})); 80 | } 81 | } 82 | 83 | sub check { 84 | my $self = shift; 85 | foreach (@{$self->{server_blades}}) { 86 | $_->check() if $_->{cpqRackServerBladePresent} eq 'present' || 87 | $self->{runtime}->{options}->{verbose} >= 3; # absent blades nur bei -vvv 88 | } 89 | } 90 | 91 | sub dump { 92 | my $self = shift; 93 | foreach (@{$self->{server_blades}}) { 94 | $_->dump() if $_->{cpqRackServerBladePresent} eq 'present' || 95 | $self->{runtime}->{options}->{verbose} >= 3; # absent blades nur bei -vvv 96 | } 97 | } 98 | 99 | 100 | package HP::BladeSystem::Component::ServerBladeSubsystem::ServerBlade; 101 | our @ISA = qw(HP::BladeSystem::Component::ServerBladeSubsystem); 102 | 103 | use strict; 104 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 105 | 106 | sub new { 107 | my $class = shift; 108 | my %params = @_; 109 | my $self = { 110 | runtime => $params{runtime}, 111 | rawdata => $params{rawdata}, 112 | method => $params{method}, 113 | blacklisted => 0, 114 | info => undef, 115 | extendedinfo => undef, 116 | }; 117 | map { $self->{$_} = $params{$_} } grep /cpqRackServerBlade/, keys %params; 118 | $self->{cpqRackServerBladeDiagnosticString} ||= ''; 119 | $self->{name} = $self->{cpqRackServerBladeRack}. 120 | ':'.$self->{cpqRackServerBladeChassis}. 121 | ':'.$self->{cpqRackServerBladeIndex}; 122 | bless $self, $class; 123 | $self->init(); 124 | #printf "%s\n", Data::Dumper::Dumper(\%params); 125 | return $self; 126 | } 127 | 128 | sub check { 129 | my $self = shift; 130 | $self->blacklist('sb', $self->{name}); 131 | my $info = sprintf 'server blade %s \'%s\' is %s, status is %s, powered is %s', 132 | $self->{name}, $self->{cpqRackServerBladeName}, $self->{cpqRackServerBladePresent}, 133 | $self->{cpqRackServerBladeStatus}, $self->{cpqRackServerBladePowered}; 134 | $self->add_info($info); 135 | if ($self->{cpqRackServerBladePowered} eq 'on') { 136 | if ($self->{cpqRackServerBladeStatus} eq 'degraded') { 137 | $self->add_message(WARNING, sprintf 'server blade %s diag is \'%s\', post status is %s', 138 | $self->{cpqRackServerBladeName}, $self->{cpqRackServerBladeDiagnosticString}, 139 | $self->{cpqRackServerBladePOSTStatus}); 140 | } elsif ($self->{cpqRackServerBladeStatus} eq 'failed') { 141 | $self->add_message(CRITICAL, sprintf 'server blade %s diag is \'%s\', post status is %s', 142 | $self->{cpqRackServerBladeName}, $self->{cpqRackServerBladeDiagnosticString}, 143 | $self->{cpqRackServerBladePOSTStatus}); 144 | } 145 | } 146 | } 147 | 148 | sub dump { 149 | my $self = shift; 150 | printf "[SERVER_BLADE_%s]\n", $self->{cpqRackServerBladeName}; 151 | foreach (qw(cpqRackServerBladeRack cpqRackServerBladeChassis cpqRackServerBladeIndex cpqRackServerBladeName cpqRackServerBladeEnclosureName cpqRackServerBladePartNumber cpqRackServerBladeSparePartNumber cpqRackServerBladePosition cpqRackServerBladeHeight cpqRackServerBladeWidth cpqRackServerBladeDepth cpqRackServerBladePresent cpqRackServerBladeHasFuses cpqRackServerBladeEnclosureSerialNum cpqRackServerBladeSlotsUsed cpqRackServerBladeStatus cpqRackServerBladeDiagnosticString cpqRackServerBladePowered cpqRackServerBladePOSTStatus)) { 152 | printf "%s: %s\n", $_, $self->{$_}; 153 | } 154 | printf "\n"; 155 | } 156 | 157 | 158 | 1; 159 | -------------------------------------------------------------------------------- /plugins-scripts/HP/FCMGMT/Component.pm: -------------------------------------------------------------------------------- 1 | package HP::FCMGMT::Component; 2 | our @ISA = qw(HP::FCMGMT); 3 | 4 | 1; 5 | 6 | -------------------------------------------------------------------------------- /plugins-scripts/HP/FCMGMT/Component/SensorSubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::FCMGMT::Component::SensorSubsystem; 2 | our @ISA = qw(HP::FCMGMT::Component); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | sensors => [], 14 | blacklisted => 0, 15 | info => undef, 16 | extendedinfo => undef, 17 | }; 18 | bless $self, $class; 19 | if ($self->{method} eq 'snmp') { 20 | return HP::FCMGMT::SensorSubsystem::SNMP->new(%params); 21 | } else { 22 | die "unknown method"; 23 | } 24 | return $self; 25 | } 26 | 27 | sub check { 28 | my $self = shift; 29 | my $errorfound = 0; 30 | $self->add_info('checking cpus'); 31 | if (scalar (@{$self->{sensors}}) == 0) { 32 | } else { 33 | foreach (@{$self->{sensors}}) { 34 | $_->check(); 35 | } 36 | } 37 | } 38 | 39 | sub dump { 40 | my $self = shift; 41 | foreach (@{$self->{sensors}}) { 42 | $_->dump(); 43 | } 44 | } 45 | 46 | 47 | package HP::FCMGMT::Component::SensorSubsystem::Sensor; 48 | our @ISA = qw(HP::FCMGMT::Component::SensorSubsystem); 49 | 50 | use strict; 51 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 52 | 53 | sub new { 54 | my $class = shift; 55 | my %params = @_; 56 | my $self = { 57 | runtime => $params{runtime}, 58 | cpqSeSensorSlot => $params{cpqSeSensorSlot}, 59 | cpqSeSensorUnitIndex => $params{cpqSeSensorUnitIndex}, 60 | cpqSeSensorName => $params{cpqSeSensorName}, 61 | cpqSeSensorStatus => $params{cpqSeSensorStatus}, 62 | blacklisted => 0, 63 | info => undef, 64 | extendedinfo => undef, 65 | }; 66 | bless $self, $class; 67 | return $self; 68 | } 69 | 70 | sub check { 71 | my $self = shift; 72 | $self->blacklist('c', $self->{cpqSeSensorUnitIndex}); 73 | if ($self->{cpqSeSensorStatus} ne "ok") { 74 | if ($self->{runtime}->{options}{scrapiron} && 75 | ($self->{cpqSeSensorStatus} eq "unknown")) { 76 | $self->add_info(sprintf "cpu %d probably ok (%s)", 77 | $self->{cpqSeSensorUnitIndex}, $self->{cpqSeSensorStatus}); 78 | } else { 79 | $self->add_info(sprintf "cpu %d needs attention (%s)", 80 | $self->{cpqSeSensorUnitIndex}, $self->{cpqSeSensorStatus}); 81 | $self->add_message(CRITICAL, $self->{info}); 82 | } 83 | } else { 84 | $self->add_info(sprintf "cpu %d is %s", 85 | $self->{cpqSeSensorUnitIndex}, $self->{cpqSeSensorStatus}); 86 | } 87 | $self->add_extendedinfo(sprintf "cpu_%s=%s", 88 | $self->{cpqSeSensorUnitIndex}, $self->{cpqSeSensorStatus}); 89 | } 90 | 91 | sub dump { 92 | my $self = shift; 93 | printf "[CPU_%s]\n", $self->{cpqSeSensorUnitIndex}; 94 | foreach (qw(cpqSeSensorSlot cpqSeSensorUnitIndex cpqSeSensorName cpqSeSensorStatus)) { 95 | printf "%s: %s\n", $_, $self->{$_}; 96 | } 97 | printf "info: %s\n", $self->{info}; 98 | printf "\n"; 99 | } 100 | -------------------------------------------------------------------------------- /plugins-scripts/HP/FCMGMT/Component/SensorSubsystem/SNMP.pm: -------------------------------------------------------------------------------- 1 | package HP::FCMGMT::Component::SensorSubsystem::SNMP; 2 | our @ISA = qw(HP::FCMGMT::Component::SensorSubsystem 3 | HP::Proliant::Component::SNMP); 4 | 5 | use strict; 6 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 7 | 8 | sub new { 9 | my $class = shift; 10 | my %params = @_; 11 | my $self = { 12 | runtime => $params{runtime}, 13 | rawdata => $params{rawdata}, 14 | sensors => [], 15 | blacklisted => 0, 16 | info => undef, 17 | extendedinfo => undef, 18 | }; 19 | bless $self, $class; 20 | $self->init(); 21 | return $self; 22 | } 23 | 24 | sub init { 25 | my $self = shift; 26 | my $snmpwalk = $self->{rawdata}; 27 | # FCMGMT-MIB 28 | my $oids = { 29 | connUnitSensorEntry => '1.3.6.1.3.94.1.8.1', 30 | connUnitSensorUnitId => '1.3.6.1.3.94.1.8.1.1', 31 | connUnitSensorIndex => '1.3.6.1.3.94.1.8.1.2', 32 | connUnitSensorName => '1.3.6.1.3.94.1.8.1.3', 33 | connUnitSensorStatus => '1.3.6.1.3.94.1.8.1.4', 34 | connUnitSensorInfo => '1.3.6.1.3.94.1.8.1.5', 35 | connUnitSensorMessage => '1.3.6.1.3.94.1.8.1.6', 36 | connUnitSensorType => '1.3.6.1.3.94.1.8.1.7', 37 | connUnitSensorCharacteristic => '1.3.6.1.3.94.1.8.1.8', 38 | connUnitSensorStatusValue => { 39 | 1 => "unknown", 40 | 2 => "other", 41 | 3 => "ok", 42 | 4 => "warning", 43 | 5 => "failed", 44 | }, 45 | connUnitSensorTypeValue => { 46 | 1 => "unknown", 47 | 2 => "other", 48 | 3 => "battery", 49 | 4 => "fan", 50 | 5 => "power-supply", 51 | 6 => "transmitter", 52 | 7 => "enclosure", 53 | 8 => "board", 54 | 9 => "receiver", 55 | }, 56 | connUnitSensorCharacteristicValue => { 57 | 1 => "unknown", 58 | 2 => "other", 59 | 3 => "temperature", 60 | 4 => "pressure", 61 | 5 => "emf", 62 | 6 => "current", 63 | 7 => "airflow", 64 | 8 => "frequency", 65 | 9 => "power", 66 | 10 => "door", 67 | }, 68 | 69 | }; 70 | 71 | # INDEX { connUnitSensorUnitId, connUnitSensorIndex } 72 | foreach ($self->get_entries($oids, 'connUnitSensorEntry')) { 73 | push(@{$self->{sensors}}, 74 | HP::FCMGMT::Component::SensorSubsystem::Sensor->new(%{$_})); 75 | } 76 | } 77 | 78 | 1; 79 | -------------------------------------------------------------------------------- /plugins-scripts/HP/HP.pm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lausser/check_hpasm/1844da14a235b9b0ba89abc4b2f9c21033862b06/plugins-scripts/HP/HP.pm -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component; 2 | our @ISA = qw(HP::Proliant); 3 | 4 | 1; 5 | 6 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/AsrSubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::AsrSubsystem; 2 | our @ISA = qw(HP::Proliant::Component); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | method => $params{method}, 14 | condition => $params{condition}, 15 | status => $params{status}, 16 | temperatures => [], 17 | blacklisted => 0, 18 | info => undef, 19 | extendedinfo => undef, 20 | }; 21 | bless $self, $class; 22 | if ($self->{method} eq 'snmp') { 23 | return HP::Proliant::Component::AsrSubsystem::SNMP->new(%params); 24 | } elsif ($self->{method} eq 'cli') { 25 | return HP::Proliant::Component::AsrSubsystem::CLI->new(%params); 26 | } else { 27 | die "unknown method"; 28 | } 29 | return $self; 30 | } 31 | 32 | sub check { 33 | my $self = shift; 34 | my $errorfound = 0; 35 | $self->add_info('checking ASR'); 36 | $self->overall_check(); 37 | } 38 | 39 | sub dump { 40 | my $self = shift; 41 | } 42 | 43 | 44 | 1; 45 | 46 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/AsrSubsystem/CLI.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::AsrSubsystem::CLI; 2 | our @ISA = qw(HP::Proliant::Component::AsrSubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | blacklisted => 0, 14 | info => undef, 15 | extendedinfo => undef, 16 | }; 17 | bless $self, $class; 18 | $self->init(%params); 19 | return $self; 20 | } 21 | 22 | sub init { 23 | my $self = shift; 24 | my %params = @_; 25 | } 26 | 27 | sub overall_check { 28 | my $self = shift; 29 | my %params = @_; 30 | } 31 | 32 | 1; 33 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/AsrSubsystem/SNMP.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::AsrSubsystem::SNMP; 2 | our @ISA = qw(HP::Proliant::Component::AsrSubsystem 3 | HP::Proliant::Component::SNMP); 4 | 5 | use strict; 6 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 7 | 8 | sub new { 9 | my $class = shift; 10 | my %params = @_; 11 | my $self = { 12 | runtime => $params{runtime}, 13 | rawdata => $params{rawdata}, 14 | blacklisted => 0, 15 | info => undef, 16 | extendedinfo => undef, 17 | }; 18 | bless $self, $class; 19 | $self->overall_init(%params); 20 | return $self; 21 | } 22 | 23 | sub overall_init { 24 | my $self = shift; 25 | my %params = @_; 26 | my $snmpwalk = $params{rawdata}; 27 | my $cpqHeAsrStatus = "1.3.6.1.4.1.232.6.2.5.1.0"; 28 | my $cpqHeAsrStatusValue = { 29 | 1 => "other", 30 | 2 => "notAvailable", 31 | 3 => "disabled", 32 | 4 => "enabled", 33 | }; 34 | my $cpqHeAsrCondition = "1.3.6.1.4.1.232.6.2.5.17.0"; 35 | my $cpqHeAsrConditionValue = { 36 | 1 => "other", 37 | 2 => "ok", 38 | 3 => "degraded", 39 | 4 => "failed", 40 | }; 41 | $self->{asrcondition} = SNMP::Utils::get_object_value( 42 | $snmpwalk, $cpqHeAsrCondition, 43 | $cpqHeAsrConditionValue); 44 | $self->{asrstatus} = SNMP::Utils::get_object_value( 45 | $snmpwalk, $cpqHeAsrStatus, 46 | $cpqHeAsrStatusValue); 47 | $self->{asrcondition} |= lc $self->{asrcondition}; 48 | $self->{asrstatus} |= lc $self->{asrstatus}; 49 | } 50 | 51 | sub overall_check { 52 | my $self = shift; 53 | my $result = 0; 54 | $self->blacklist('asr', ''); 55 | if ($self->{asrstatus} and $self->{asrstatus} eq "enabled") { 56 | my $info = sprintf 'ASR overall condition is %s', $self->{asrcondition}; 57 | if ($self->{asrcondition} eq "degraded") { 58 | $self->add_message(WARNING, $info); 59 | } elsif ($self->{asrcondition} eq "failed") { 60 | $self->add_message(CRITICAL, $info); 61 | } 62 | $self->add_info($info); 63 | } else { 64 | $self->add_info('This system does not have ASR.'); 65 | } 66 | } 67 | 68 | 1; 69 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/BatterySubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::BatterySubsystem; 2 | our @ISA = qw(HP::Proliant::Component); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | method => $params{method}, 14 | condition => $params{condition}, 15 | status => $params{status}, 16 | sysbatteries => [], 17 | blacklisted => 0, 18 | info => undef, 19 | extendedinfo => undef, 20 | }; 21 | bless $self, $class; 22 | if ($self->{method} eq 'snmp') { 23 | return HP::Proliant::Component::BatterySubsystem::SNMP->new(%params); 24 | } elsif ($self->{method} eq 'cli') { 25 | #return HP::Proliant::Component::BatterySubsystem::CLI->new(%params); 26 | } else { 27 | die "unknown method"; 28 | } 29 | return $self; 30 | } 31 | 32 | sub check { 33 | my $self = shift; 34 | my $errorfound = 0; 35 | $self->add_info('checking sysbatteries'); 36 | if (scalar (@{$self->{sysbatteries}}) == 0) { 37 | #$self->overall_check(); 38 | $self->add_info('no sysbatteries found'); 39 | } else { 40 | foreach (sort { $a->{cpqHeSysBatteryIndex} <=> $b->{cpqHeSysBatteryIndex}} 41 | @{$self->{sysbatteries}}) { 42 | $_->check(); 43 | } 44 | } 45 | } 46 | 47 | sub dump { 48 | my $self = shift; 49 | foreach (@{$self->{sysbatteries}}) { 50 | $_->dump(); 51 | } 52 | } 53 | 54 | 55 | package HP::Proliant::Component::BatterySubsystem::Battery; 56 | our @ISA = qw(HP::Proliant::Component::BatterySubsystem); 57 | 58 | use strict; 59 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 60 | 61 | sub new { 62 | my $class = shift; 63 | my %params = @_; 64 | my $self = { 65 | runtime => $params{runtime}, 66 | cpqHeSysBatteryChassis => $params{cpqHeSysBatteryChassis}, 67 | cpqHeSysBatteryIndex => $params{cpqHeSysBatteryIndex}, 68 | cpqHeSysBatteryPresent => $params{cpqHeSysBatteryPresent}, 69 | cpqHeSysBatteryCondition => $params{cpqHeSysBatteryCondition}, 70 | cpqHeSysBatteryStatus => $params{cpqHeSysBatteryStatus}, 71 | cpqHeSysBatteryCapacityMaximum => $params{cpqHeSysBatteryCapacityMaximum}, 72 | cpqHeSysBatteryProductName => $params{cpqHeSysBatteryProductName}, 73 | cpqHeSysBatteryModel => $params{cpqHeSysBatteryModel}, 74 | cpqHeSysBatterySerialNumber => $params{cpqHeSysBatterySerialNumber}, 75 | cpqHeSysBatteryFirmwareRev => $params{cpqHeSysBatteryFirmwareRev}, 76 | cpqHeSysBatterySparePartNum => $params{cpqHeSysBatterySparePartNum}, 77 | blacklisted => 0, 78 | info => undef, 79 | extendedinfo => undef, 80 | }; 81 | $self->{name} = $params{name} || 82 | $self->{cpqHeSysBatteryChassis}.':'.$self->{cpqHeSysBatteryIndex}; 83 | bless $self, $class; 84 | return $self; 85 | } 86 | 87 | sub check { 88 | my $self = shift; 89 | $self->blacklist('sba', $self->{name}); 90 | my $info = sprintf "battery %s/%s has condition %s and status %s", 91 | $self->{cpqHeSysBatteryChassis}, 92 | $self->{cpqHeSysBatteryIndex}, 93 | $self->{cpqHeSysBatteryCondition}, 94 | $self->{cpqHeSysBatteryStatus}; 95 | if ($self->{cpqHeSysBatteryCondition} eq "ok") { 96 | } elsif ($self->{cpqHeSysBatteryCondition} eq "degraded") { 97 | $self->add_info($info); 98 | $self->add_message(WARNING, $self->{info}); 99 | } elsif ($self->{cpqHeSysBatteryCondition} eq "failed") { 100 | $self->add_info($info); 101 | $self->add_message(CRITICAL, $self->{info}); 102 | } else { 103 | $self->add_info($info); 104 | $self->add_message(UNKNOWN, $self->{info}); 105 | } 106 | } 107 | 108 | sub dump { 109 | my $self = shift; 110 | printf "[SYSBATTERY_%s_%s]\n", $self->{cpqHeSysBatteryChassis}, 111 | $self->{cpqHeSysBatteryIndex}; 112 | foreach (qw(cpqHeSysBatteryChassis cpqHeSysBatteryIndex 113 | cpqHeSysBatteryPresent cpqHeSysBatteryCondition cpqHeSysBatteryStatus 114 | cpqHeSysBatteryCapacityMaximum cpqHeSysBatteryProductName 115 | cpqHeSysBatteryModel cpqHeSysBatterySerialNumber 116 | cpqHeSysBatteryFirmwareRev cpqHeSysBatterySparePartNum)) { 117 | printf "%s: %s\n", $_, $self->{$_}; 118 | } 119 | printf "info: %s\n\n", $self->{info}; 120 | } 121 | 122 | 123 | 1; 124 | 125 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/BatterySubsystem/CLI.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::BatterySubsystem::CLI; 2 | our @ISA = qw(HP::Proliant::Component::BatterySubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | blacklisted => 0, 14 | info => undef, 15 | extendedinfo => undef, 16 | }; 17 | bless $self, $class; 18 | $self->init(%params); 19 | return $self; 20 | } 21 | 22 | sub init { 23 | my $self = shift; 24 | my %params = @_; 25 | } 26 | 27 | 1; 28 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/BatterySubsystem/SNMP.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::BatterySubsystem::SNMP; 2 | our @ISA = qw(HP::Proliant::Component::BatterySubsystem 3 | HP::Proliant::Component::SNMP); 4 | 5 | use strict; 6 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 7 | 8 | sub new { 9 | my $class = shift; 10 | my %params = @_; 11 | my $self = { 12 | runtime => $params{runtime}, 13 | rawdata => $params{rawdata}, 14 | sysbatteries => [], 15 | blacklisted => 0, 16 | info => undef, 17 | extendedinfo => undef, 18 | }; 19 | bless $self, $class; 20 | $self->init(%params); 21 | return $self; 22 | } 23 | 24 | sub init { 25 | my $self = shift; 26 | my %params = @_; 27 | my $snmpwalk = $self->{rawdata}; 28 | my $oids = { 29 | cpqHeSysBatteryTable => '1.3.6.1.4.1.232.6.2.17.2', 30 | cpqHeSysBatteryEntry => '1.3.6.1.4.1.232.6.2.17.2.1', 31 | cpqHeSysBatteryChassis => '1.3.6.1.4.1.232.6.2.17.2.1.1', 32 | cpqHeSysBatteryIndex => '1.3.6.1.4.1.232.6.2.17.2.1.2', 33 | cpqHeSysBatteryPresent => '1.3.6.1.4.1.232.6.2.17.2.1.3', 34 | cpqHeSysBatteryPresentValue => { 35 | '1' => 'other', 36 | '2' => 'absent', 37 | '3' => 'present', 38 | }, 39 | cpqHeSysBatteryCondition => '1.3.6.1.4.1.232.6.2.17.2.1.4', 40 | cpqHeSysBatteryConditionValue => { 41 | '1' => 'other', 42 | '2' => 'ok', 43 | '3' => 'degraded', 44 | '4' => 'failed', 45 | }, 46 | cpqHeSysBatteryStatus => '1.3.6.1.4.1.232.6.2.17.2.1.5', 47 | cpqHeSysBatteryStatusValue => { 48 | '1' => 'noError', 49 | '2' => 'generalFailure', 50 | '3' => 'shutdownHighResistance', 51 | '4' => 'shutdownLowVoltage', 52 | '5' => 'shutdownShortCircuit', 53 | '6' => 'shutdownChargeTimeout', 54 | '7' => 'shutdownOverTemperature', 55 | '8' => 'shutdownDischargeMinVoltage', 56 | '9' => 'shutdownDischargeCurrent', 57 | '10' => 'shutdownLoadCountHigh', 58 | '11' => 'shutdownEnablePin', 59 | '12' => 'shutdownOverCurrent', 60 | '13' => 'shutdownPermanentFailure', 61 | '14' => 'shutdownBackupTimeExceeded', 62 | }, 63 | cpqHeSysBatteryCapacityMaximum => '1.3.6.1.4.1.232.6.2.17.2.1.6', 64 | cpqHeSysBatteryProductName => '1.3.6.1.4.1.232.6.2.17.2.1.7', 65 | cpqHeSysBatteryModel => '1.3.6.1.4.1.232.6.2.17.2.1.8', 66 | cpqHeSysBatterySerialNumber => '1.3.6.1.4.1.232.6.2.17.2.1.9', 67 | cpqHeSysBatteryFirmwareRev => '1.3.6.1.4.1.232.6.2.17.2.1.10', 68 | cpqHeSysBatterySparePartNum => '1.3.6.1.4.1.232.6.2.17.2.1.11', 69 | }; 70 | # INDEX { cpqHeSysBatteryChassis, cpqHeSysBatteryIndex } 71 | foreach ($self->get_entries($oids, 'cpqHeSysBatteryEntry')) { 72 | next if ! $_->{cpqHeSysBatteryPresent} eq "present"; 73 | push(@{$self->{sysbatteries}}, 74 | HP::Proliant::Component::BatterySubsystem::Battery->new(%{$_})); 75 | } 76 | } 77 | 78 | 1; 79 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/CpuSubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::CpuSubsystem; 2 | our @ISA = qw(HP::Proliant::Component); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | ################################## scrapiron ########## 10 | my %params = @_; 11 | my $self = { 12 | runtime => $params{runtime}, 13 | rawdata => $params{rawdata}, 14 | method => $params{method}, 15 | condition => $params{condition}, 16 | status => $params{status}, 17 | cpus => [], 18 | blacklisted => 0, 19 | info => undef, 20 | extendedinfo => undef, 21 | }; 22 | bless $self, $class; 23 | if ($self->{method} eq 'snmp') { 24 | return HP::Proliant::Component::CpuSubsystem::SNMP->new(%params); 25 | } elsif ($self->{method} eq 'cli') { 26 | return HP::Proliant::Component::CpuSubsystem::CLI->new(%params); 27 | } else { 28 | die "unknown method"; 29 | } 30 | return $self; 31 | } 32 | 33 | sub check { 34 | my $self = shift; 35 | my $errorfound = 0; 36 | $self->add_info('checking cpus'); 37 | if (scalar (@{$self->{cpus}}) == 0) { 38 | # sachen gibts..... 39 | # $self->overall_check(); # sowas ist mir nur einmal untergekommen 40 | } else { 41 | foreach (@{$self->{cpus}}) { 42 | $_->check(); 43 | } 44 | } 45 | } 46 | 47 | sub num_cpus { 48 | my $self = shift; 49 | return scalar @{$self->{cpus}}; 50 | } 51 | 52 | sub dump { 53 | my $self = shift; 54 | foreach (@{$self->{cpus}}) { 55 | $_->dump(); 56 | } 57 | } 58 | 59 | 60 | package HP::Proliant::Component::CpuSubsystem::Cpu; 61 | our @ISA = qw(HP::Proliant::Component::CpuSubsystem); 62 | 63 | use strict; 64 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 65 | 66 | sub new { 67 | my $class = shift; 68 | my %params = @_; 69 | my $self = { 70 | runtime => $params{runtime}, 71 | cpqSeCpuSlot => $params{cpqSeCpuSlot}, 72 | cpqSeCpuUnitIndex => $params{cpqSeCpuUnitIndex}, 73 | cpqSeCpuName => $params{cpqSeCpuName}, 74 | cpqSeCpuStatus => $params{cpqSeCpuStatus}, 75 | blacklisted => 0, 76 | info => undef, 77 | extendedinfo => undef, 78 | }; 79 | bless $self, $class; 80 | return $self; 81 | } 82 | 83 | sub check { 84 | my $self = shift; 85 | $self->blacklist('c', $self->{cpqSeCpuUnitIndex}); 86 | if ($self->{cpqSeCpuStatus} ne "ok") { 87 | if ($self->{runtime}->{options}{scrapiron} && 88 | ($self->{cpqSeCpuStatus} eq "unknown")) { 89 | $self->add_info(sprintf "cpu %d probably ok (%s)", 90 | $self->{cpqSeCpuUnitIndex}, $self->{cpqSeCpuStatus}); 91 | } else { 92 | $self->add_info(sprintf "cpu %d needs attention (%s)", 93 | $self->{cpqSeCpuUnitIndex}, $self->{cpqSeCpuStatus}); 94 | $self->add_message(CRITICAL, $self->{info}); 95 | } 96 | } else { 97 | $self->add_info(sprintf "cpu %d is %s", 98 | $self->{cpqSeCpuUnitIndex}, $self->{cpqSeCpuStatus}); 99 | } 100 | $self->add_extendedinfo(sprintf "cpu_%s=%s", 101 | $self->{cpqSeCpuUnitIndex}, $self->{cpqSeCpuStatus}); 102 | } 103 | 104 | sub dump { 105 | my $self = shift; 106 | printf "[CPU_%s]\n", $self->{cpqSeCpuUnitIndex}; 107 | foreach (qw(cpqSeCpuSlot cpqSeCpuUnitIndex cpqSeCpuName cpqSeCpuStatus)) { 108 | printf "%s: %s\n", $_, $self->{$_}; 109 | } 110 | printf "info: %s\n", $self->{info}; 111 | printf "\n"; 112 | } 113 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/CpuSubsystem/CLI.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::CpuSubsystem::CLI; 2 | our @ISA = qw(HP::Proliant::Component::CpuSubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | cpus => [], 14 | blacklisted => 0, 15 | info => undef, 16 | extendedinfo => undef, 17 | }; 18 | bless $self, $class; 19 | $self->init(%params); 20 | return $self; 21 | } 22 | 23 | sub init { 24 | my $self = shift; 25 | my %params = @_; 26 | my %tmpcpu = ( 27 | runtime => $params{runtime}, 28 | ); 29 | my $inblock = 0; 30 | foreach (grep(/^server/, split(/\n/, $self->{rawdata}))) { 31 | if (/Processor:\s+(\d+)/) { 32 | $tmpcpu{cpqSeCpuUnitIndex} = $1; 33 | $inblock = 1; 34 | } elsif (/Name\s*:\s+(.+?)\s*$/) { 35 | $tmpcpu{cpqSeCpuName} = $1; 36 | } elsif (/Status\s*:\s+(.+?)\s*$/) { 37 | $tmpcpu{cpqSeCpuStatus} = lc $1; 38 | } elsif (/Socket\s*:\s+(.+?)\s*$/) { 39 | $tmpcpu{cpqSeCpuSlot} = $1; 40 | } elsif (/^server\s*$/) { 41 | if ($inblock) { 42 | $inblock = 0; 43 | push(@{$self->{cpus}}, 44 | HP::Proliant::Component::CpuSubsystem::Cpu->new(%tmpcpu)); 45 | %tmpcpu = ( 46 | runtime => $params{runtime}, 47 | ); 48 | } 49 | } 50 | } 51 | if ($inblock) { 52 | push(@{$self->{cpus}}, 53 | HP::Proliant::Component::CpuSubsystem::Cpu->new(%tmpcpu)); 54 | } 55 | } 56 | 57 | 1; 58 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/CpuSubsystem/SNMP.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::CpuSubsystem::SNMP; 2 | our @ISA = qw(HP::Proliant::Component::CpuSubsystem 3 | HP::Proliant::Component::SNMP); 4 | 5 | use strict; 6 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 7 | 8 | sub new { 9 | my $class = shift; 10 | my %params = @_; 11 | my $self = { 12 | runtime => $params{runtime}, 13 | rawdata => $params{rawdata}, 14 | cpus => [], 15 | blacklisted => 0, 16 | info => undef, 17 | extendedinfo => undef, 18 | }; 19 | bless $self, $class; 20 | $self->init(); 21 | return $self; 22 | } 23 | 24 | sub init { 25 | my $self = shift; 26 | my $snmpwalk = $self->{rawdata}; 27 | # CPQSTDEQ-MIB 28 | my $oids = { 29 | cpqSeCpuEntry => '1.3.6.1.4.1.232.1.2.2.1.1', 30 | cpqSeCpuUnitIndex => '1.3.6.1.4.1.232.1.2.2.1.1.1', 31 | cpqSeCpuSlot => '1.3.6.1.4.1.232.1.2.2.1.1.2', 32 | cpqSeCpuName => '1.3.6.1.4.1.232.1.2.2.1.1.3', 33 | cpqSeCpuStatus => '1.3.6.1.4.1.232.1.2.2.1.1.6', 34 | cpqSeCpuStatusValue => { 35 | 1 => "unknown", 36 | 2 => "ok", 37 | 3 => "degraded", 38 | 4 => "failed", 39 | 5 => "disabled", 40 | }, 41 | }; 42 | 43 | # INDEX { cpqSeCpuUnitIndex } 44 | foreach ($self->get_entries($oids, 'cpqSeCpuEntry')) { 45 | push(@{$self->{cpus}}, 46 | HP::Proliant::Component::CpuSubsystem::Cpu->new(%{$_})); 47 | } 48 | } 49 | 50 | 1; 51 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/DiskSubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::DiskSubsystem; 2 | our @ISA = qw(HP::Proliant::Component); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | method => $params{method}, 14 | da_subsystem => undef, 15 | sas_da_subsystem => undef, 16 | ide_da_subsystem => undef, 17 | fca_da_subsystem => undef, 18 | scsi_da_subsystem => undef, 19 | condition => $params{condition}, 20 | blacklisted => 0, 21 | }; 22 | bless $self, $class; 23 | $self->init(); 24 | return $self; 25 | } 26 | 27 | sub init { 28 | my $self = shift; 29 | $self->{da_subsystem} = HP::Proliant::Component::DiskSubsystem::Da->new( 30 | runtime => $self->{runtime}, 31 | rawdata => $self->{rawdata}, 32 | method => $self->{method}, 33 | ); 34 | $self->{sas_subsystem} = HP::Proliant::Component::DiskSubsystem::Sas->new( 35 | runtime => $self->{runtime}, 36 | rawdata => $self->{rawdata}, 37 | method => $self->{method}, 38 | ); 39 | $self->{scsi_subsystem} = HP::Proliant::Component::DiskSubsystem::Scsi->new( 40 | runtime => $self->{runtime}, 41 | rawdata => $self->{rawdata}, 42 | method => $self->{method}, 43 | ); 44 | $self->{ide_subsystem} = HP::Proliant::Component::DiskSubsystem::Ide->new( 45 | runtime => $self->{runtime}, 46 | rawdata => $self->{rawdata}, 47 | method => $self->{method}, 48 | ); 49 | $self->{fca_subsystem} = HP::Proliant::Component::DiskSubsystem::Fca->new( 50 | runtime => $self->{runtime}, 51 | rawdata => $self->{rawdata}, 52 | method => $self->{method}, 53 | ); 54 | } 55 | 56 | sub check { 57 | my $self = shift; 58 | $self->add_info('checking disk subsystem'); 59 | $self->{da_subsystem}->check(); 60 | $self->{sas_subsystem}->check(); 61 | $self->{scsi_subsystem}->check(); 62 | $self->{ide_subsystem}->check(); 63 | $self->{fca_subsystem}->check(); 64 | $self->disk_summary(); 65 | } 66 | 67 | sub dump { 68 | my $self = shift; 69 | $self->{da_subsystem}->dump(); 70 | $self->{sas_subsystem}->dump(); 71 | $self->{scsi_subsystem}->dump(); 72 | $self->{ide_subsystem}->dump(); 73 | $self->{fca_subsystem}->dump(); 74 | } 75 | 76 | sub disk_summary { 77 | my $self = shift; 78 | foreach my $subsys (qw(da sas scsi ide fca)) { 79 | if (my $pd = $self->{$subsys.'_subsystem'}->has_physical_drives()) { 80 | my $ld = $self->{$subsys.'_subsystem'}->has_logical_drives(); 81 | $self->add_summary(sprintf '%s: %d logical drives, %d physical drives', 82 | $subsys, $ld, $pd); 83 | } 84 | } 85 | } 86 | 87 | sub assemble { 88 | my $self = shift; 89 | $self->trace(3, sprintf "%s controllers und platten zusammenfuehren", 90 | ref($self)); 91 | $self->trace(3, sprintf "has %d controllers", 92 | scalar(@{$self->{controllers}})); 93 | $self->trace(3, sprintf "has %d accelerators", 94 | scalar(@{$self->{accelerators}})) if exists $self->{accelerators}; 95 | $self->trace(3, sprintf "has %d enclosures", 96 | scalar(@{$self->{enclosures}})); 97 | $self->trace(3, sprintf "has %d physical_drives", 98 | scalar(@{$self->{physical_drives}})); 99 | $self->trace(3, sprintf "has %d logical_drives", 100 | scalar(@{$self->{logical_drives}})); 101 | $self->trace(3, sprintf "has %d spare_drives", 102 | scalar(@{$self->{spare_drives}})); 103 | my $found = { 104 | accelerators => {}, 105 | enclosures => {}, 106 | logical_drives => {}, 107 | physical_drives => {}, 108 | spare_drives => {}, 109 | }; 110 | # found->{komponente}->{controllerindex} ist ein array 111 | # von teilen, die zu einem controller gehoeren 112 | foreach my $item (qw(accelerators enclosures logical_drives physical_drives spare_drives)) { 113 | next if ($item eq "enclosures" && ! exists $self->{$item}); 114 | foreach (@{$self->{$item}}) { 115 | $found->{item}->{$_->{controllerindex}} = [] 116 | unless exists $found->{$item}->{$_->{controllerindex}}; 117 | push(@{$found->{$item}->{$_->{controllerindex}}}, $_); 118 | } 119 | } 120 | foreach my $item (qw(accelerators enclosures logical_drives physical_drives spare_drives)) { 121 | foreach (@{$self->{controllers}}) { 122 | if (exists $found->{$item}->{$_->{controllerindex}}) { 123 | $_->{$item} = $found->{$item}->{$_->{controllerindex}}; 124 | delete $found->{$item}->{$_->{controllerindex}}; 125 | } else { 126 | $_->{$item} = []; # z.b. ein leerer controller: physical_drives = [] 127 | } 128 | } 129 | } 130 | # was jetzt noch in $found uebrig ist, gehoert zu keinem controller 131 | # d.h. komponenten mit ungueltigen cnrtlindex wurden gefunden 132 | } 133 | 134 | sub has_controllers { 135 | my $self = shift; 136 | return scalar(@{$self->{controllers}}); 137 | } 138 | 139 | sub has_accelerators { 140 | my $self = shift; 141 | return exists $self->{accelerators} ? scalar(@{$self->{accelerators}}) : 0; 142 | } 143 | 144 | sub has_physical_drives { 145 | my $self = shift; 146 | return scalar(@{$self->{physical_drives}}); 147 | } 148 | 149 | sub has_logical_drives { 150 | my $self = shift; 151 | return scalar(@{$self->{logical_drives}}); 152 | } 153 | 154 | sub has_enclosures { 155 | my $self = shift; 156 | return scalar(@{$self->{enclosures}}); 157 | } 158 | 159 | 1; 160 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/DiskSubsystem/Fca/CLI.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::DiskSubsystem::Fca::CLI; 2 | our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Fca); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | controllers => [], 12 | accelerators => [], 13 | enclosures => [], 14 | physical_drives => [], 15 | logical_drives => [], 16 | spare_drives => [], 17 | blacklisted => 0, 18 | }; 19 | bless $self, $class; 20 | return $self; 21 | } 22 | 23 | sub init { 24 | my $self = shift; 25 | # ..... 26 | $self->{global_status} = 27 | HP::Proliant::Component::DiskSubsystem::Fca::GlobalStatus->new( 28 | runtime => $self->{runtime}, 29 | cpqFcaMibCondition => 'n/a', 30 | ); 31 | 32 | } 33 | 34 | 1; 35 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/DiskSubsystem/Ide/CLI.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::DiskSubsystem::Ide::CLI; 2 | our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Ide); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | controllers => [], 12 | accelerators => [], 13 | enclosures => [], 14 | physical_drives => [], 15 | logical_drives => [], 16 | spare_drives => [], 17 | blacklisted => 0, 18 | }; 19 | bless $self, $class; 20 | return $self; 21 | } 22 | 23 | sub init { 24 | my $self = shift; 25 | } 26 | 27 | 1; 28 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/DiskSubsystem/Ide/SNMP.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::DiskSubsystem::Ide::SNMP; 2 | our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Ide 3 | HP::Proliant::Component::SNMP); 4 | 5 | use strict; 6 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 7 | 8 | sub new { 9 | my $class = shift; 10 | my %params = @_; 11 | my $self = { 12 | controllers => [], 13 | accelerators => [], 14 | enclosures => [], 15 | physical_drives => [], 16 | logical_drives => [], 17 | spare_drives => [], 18 | blacklisted => 0, 19 | }; 20 | bless $self, $class; 21 | return $self; 22 | } 23 | 24 | sub init { 25 | my $self = shift; 26 | my $snmpwalk = $self->{rawdata}; 27 | 28 | # CPQIDE-MIB 29 | my $oids = { 30 | cpqIdeControllerEntry => '1.3.6.1.4.1.232.14.2.3.1.1', 31 | cpqIdeControllerIndex => '1.3.6.1.4.1.232.14.2.3.1.1.1', 32 | cpqIdeControllerOverallCondition => '1.3.6.1.4.1.232.14.2.3.1.1.2', 33 | cpqIdeControllerModel => '1.3.6.1.4.1.232.14.2.3.1.1.3', 34 | cpqIdeControllerSlot => '1.3.6.1.4.1.232.14.2.3.1.1.5', 35 | cpqIdeControllerOverallConditionValue => { 36 | 1 => "other", 37 | 2 => "ok", 38 | 3 => "degraded", 39 | 4 => "failed", 40 | }, 41 | }; 42 | 43 | # INDEX { cpqIdeControllerIndex } 44 | foreach ($self->get_entries($oids, 'cpqIdeControllerEntry')) { 45 | push(@{$self->{controllers}}, 46 | HP::Proliant::Component::DiskSubsystem::Ide::Controller->new(%{$_})); 47 | } 48 | 49 | $oids = { 50 | cpqIdeLogicalDriveEntry => '1.3.6.1.4.1.232.14.2.6.1.1', 51 | cpqIdeLogicalDriveControllerIndex => '1.3.6.1.4.1.232.14.2.6.1.1.1', 52 | cpqIdeLogicalDriveIndex => '1.3.6.1.4.1.232.14.2.6.1.1.2', 53 | cpqIdeLogicalDriveRaidLevel => '1.3.6.1.4.1.232.14.2.6.1.1.3', 54 | cpqIdeLogicalDriveCapacity => '1.3.6.1.4.1.232.14.2.6.1.1.4', 55 | cpqIdeLogicalDriveStatus => '1.3.6.1.4.1.232.14.2.6.1.1.5', 56 | cpqIdeLogicalDriveCondition => '1.3.6.1.4.1.232.14.2.6.1.1.6', 57 | cpqIdeLogicalDriveDiskIds => '1.3.6.1.4.1.232.14.2.6.1.1.7', 58 | cpqIdeLogicalDriveSpareIds => '1.3.6.1.4.1.232.14.2.6.1.1.9', 59 | cpqIdeLogicalDriveRebuildingDisk => '1.3.6.1.4.1.232.14.2.6.1.1.10', 60 | cpqIdeLogicalDriveRaidLevelValue => { 61 | 1 => "other", 62 | 2 => "raid0", 63 | 3 => "raid1", 64 | 4 => "raid0plus1", 65 | }, 66 | cpqIdeLogicalDriveStatusValue => { 67 | 1 => "other", 68 | 2 => "ok", 69 | 3 => "degraded", 70 | 4 => "rebuilding", 71 | 5 => "failed", 72 | }, 73 | cpqIdeLogicalDriveConditionValue => { 74 | 1 => "other", 75 | 2 => "ok", 76 | 3 => "degraded", 77 | 4 => "failed", 78 | }, 79 | }; 80 | # INDEX { cpqIdeLogicalDriveControllerIndex, cpqIdeLogicalDriveIndex } 81 | foreach ($self->get_entries($oids, 'cpqIdeLogicalDriveEntry')) { 82 | push(@{$self->{logical_drives}}, 83 | HP::Proliant::Component::DiskSubsystem::Ide::LogicalDrive->new(%{$_})); 84 | } 85 | 86 | $oids = { 87 | cpqIdeAtaDiskEntry => '1.3.6.1.4.1.232.14.2.4.1.1', 88 | cpqIdeAtaDiskControllerIndex => '1.3.6.1.4.1.232.14.2.4.1.1.1', 89 | cpqIdeAtaDiskIndex => '1.3.6.1.4.1.232.14.2.4.1.1.2', 90 | cpqIdeAtaDiskModel => '1.3.6.1.4.1.232.14.2.4.1.1.3', 91 | cpqIdeAtaDiskStatus => '1.3.6.1.4.1.232.14.2.4.1.1.6', 92 | cpqIdeAtaDiskCondition => '1.3.6.1.4.1.232.14.2.4.1.1.7', 93 | cpqIdeAtaDiskCapacity => '1.3.6.1.4.1.232.14.2.4.1.1.8', 94 | cpqIdeAtaDiskLogicalDriveMember => '1.3.6.1.4.1.232.14.2.4.1.1.13', 95 | cpqIdeAtaDiskIsSpare => '1.3.6.1.4.1.232.14.2.4.1.1.14', 96 | cpqIdeAtaDiskStatusValue => { 97 | 1 => "other", 98 | 2 => "ok", 99 | 3 => "smartError", 100 | 4 => "failed", 101 | }, 102 | cpqIdeAtaDiskConditionValue => { 103 | 1 => "other", 104 | 2 => "ok", 105 | 3 => "degraded", 106 | 4 => "failed", 107 | }, 108 | }; 109 | # INDEX { cpqIdeAtaDiskControllerIndex, cpqIdeAtaDiskIndex } 110 | foreach ($self->get_entries($oids, 'cpqIdeAtaDiskEntry')) { 111 | push(@{$self->{physical_drives}}, 112 | HP::Proliant::Component::DiskSubsystem::Ide::PhysicalDrive->new(%{$_})); 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/DiskSubsystem/Sas/CLI.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::DiskSubsystem::Sas::CLI; 2 | our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Sas); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | controllers => [], 12 | accelerators => [], 13 | enclosures => [], 14 | physical_drives => [], 15 | logical_drives => [], 16 | spare_drives => [], 17 | blacklisted => 0, 18 | }; 19 | bless $self, $class; 20 | return $self; 21 | } 22 | 23 | sub init { 24 | my $self = shift; 25 | } 26 | 27 | 1; 28 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/DiskSubsystem/Sas/SNMP.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::DiskSubsystem::Sas::SNMP; 2 | our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Sas 3 | HP::Proliant::Component::SNMP); 4 | 5 | use strict; 6 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 7 | 8 | sub new { 9 | my $class = shift; 10 | my %params = @_; 11 | my $self = { 12 | controllers => [], 13 | accelerators => [], 14 | enclosures => [], 15 | physical_drives => [], 16 | logical_drives => [], 17 | spare_drives => [], 18 | blacklisted => 0, 19 | }; 20 | bless $self, $class; 21 | return $self; 22 | } 23 | 24 | sub init { 25 | my $self = shift; 26 | my $snmpwalk = $self->{rawdata}; 27 | 28 | # CPQSCSI-MIB 29 | my $oids = { 30 | cpqSasHbaEntry => "1.3.6.1.4.1.232.5.5.1.1.1", 31 | cpqSasHbaIndex => "1.3.6.1.4.1.232.5.5.1.1.1.1", 32 | cpqSasHbaLocation => "1.3.6.1.4.1.232.5.5.1.1.1.2", 33 | cpqSasHbaSlot => "1.3.6.1.4.1.232.5.5.1.1.1.6", 34 | cpqSasHbaStatus => "1.3.6.1.4.1.232.5.5.1.1.1.4", 35 | cpqSasHbaStatusValue => { 36 | 1 => "other", 37 | 2 => "ok", 38 | 3 => "failed", 39 | }, 40 | cpqSasHbaCondition => "1.3.6.1.4.1.232.5.5.1.1.1.5", 41 | cpqSasHbaConditionValue => { 42 | 1 => "other", 43 | 2 => "ok", 44 | 3 => "degraded", 45 | 4 => "failed", 46 | }, 47 | }; 48 | 49 | # INDEX { cpqSasHbaIndex } 50 | foreach ($self->get_entries($oids, 'cpqSasHbaEntry')) { 51 | push(@{$self->{controllers}}, 52 | HP::Proliant::Component::DiskSubsystem::Sas::Controller->new(%{$_})); 53 | } 54 | 55 | $oids = { 56 | cpqSasLogDrvEntry => "1.3.6.1.4.1.232.5.5.3.1.1", 57 | cpqSasLogDrvHbaIndex => "1.3.6.1.4.1.232.5.5.3.1.1.1", 58 | cpqSasLogDrvIndex => "1.3.6.1.4.1.232.5.5.3.1.1.2", 59 | cpqSasLogDrvStatus => "1.3.6.1.4.1.232.5.5.3.1.1.4", 60 | cpqSasLogDrvCondition => "1.3.6.1.4.1.232.5.5.3.1.1.5", 61 | cpqSasLogDrvRebuildingPercent => "1.3.6.1.4.1.232.5.5.3.1.1.12", 62 | cpqSasLogDrvRaidLevel => "1.3.6.1.4.1.232.5.5.3.1.1.3", 63 | cpqSasLogDrvRaidLevelValue => { 64 | 1 => "other", 65 | 2 => "raid0", 66 | 3 => "raid1", 67 | 4 => "raid0plus1", 68 | 5 => "raid5", 69 | 6 => "raid15", 70 | 7 => "volume", 71 | }, 72 | cpqSasLogDrvConditionValue => { 73 | 1 => "other", 74 | 2 => "ok", 75 | 3 => "degraded", 76 | 4 => "failed", 77 | }, 78 | cpqSasLogDrvStatusValue => { 79 | 1 => "other", 80 | 2 => "ok", 81 | 3 => "degraded", 82 | 4 => "rebuilding", 83 | 5 => "failed", 84 | 6 => "offline", 85 | } 86 | }; 87 | # INDEX { cpqSasLogDrvCntlrIndex, cpqSasLogDrvIndex } 88 | foreach ($self->get_entries($oids, 'cpqSasLogDrvEntry')) { 89 | push(@{$self->{logical_drives}}, 90 | HP::Proliant::Component::DiskSubsystem::Sas::LogicalDrive->new(%{$_})); 91 | } 92 | 93 | $oids = { 94 | cpqSasPhyDrvEntry => "1.3.6.1.4.1.232.5.5.2.1.1", 95 | cpqSasPhyDrvHbaIndex => "1.3.6.1.4.1.232.5.5.2.1.1.1", 96 | cpqSasPhyDrvIndex => "1.3.6.1.4.1.232.5.5.2.1.1.2", 97 | cpqSasPhyDrvLocationString => "1.3.6.1.4.1.232.5.5.2.1.1.3", 98 | cpqSasPhyDrvStatus => "1.3.6.1.4.1.232.5.5.2.1.1.5", 99 | cpqSasPhyDrvSize => "1.3.6.1.4.1.232.5.5.2.1.1.8", 100 | cpqSasPhyDrvCondition => "1.3.6.1.4.1.232.5.5.2.1.1.6", 101 | cpqSasPhyDrvConditionValue => { 102 | 1 => "other", 103 | 2 => "ok", 104 | 3 => "degraded", 105 | 4 => "failed", 106 | }, 107 | cpqSasPhyDrvStatusValue => { 108 | 1 => "other", 109 | 2 => "ok", 110 | 3 => "predictiveFailure", 111 | 4 => "offline", 112 | 5 => "failed", 113 | 6 => "missingWasOk", 114 | 7 => "missingWasPredictiveFailure", 115 | 8 => "missingWasOffline", 116 | 9 => "missingWasFailed", 117 | }, 118 | }; 119 | 120 | # INDEX { cpqPhyLogDrvCntlrIndex, cpqSasPhyDrvIndex } 121 | foreach ($self->get_entries($oids, 'cpqSasPhyDrvEntry')) { 122 | push(@{$self->{physical_drives}}, 123 | HP::Proliant::Component::DiskSubsystem::Sas::PhysicalDrive->new(%{$_})); 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/DiskSubsystem/Scsi.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::DiskSubsystem::Scsi; 2 | our @ISA = qw(HP::Proliant::Component::DiskSubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | method => $params{method}, 14 | controllers => [], 15 | enclosures => [], 16 | physical_drives => [], 17 | logical_drives => [], 18 | spare_drives => [], 19 | condition => undef, 20 | blacklisted => 0, 21 | }; 22 | bless $self, $class; 23 | if ($self->{method} eq 'snmp') { 24 | bless $self, 'HP::Proliant::Component::DiskSubsystem::Scsi::SNMP'; 25 | } else { 26 | bless $self, 'HP::Proliant::Component::DiskSubsystem::Scsi::CLI'; 27 | } 28 | $self->init(); 29 | $self->assemble(); 30 | return $self; 31 | } 32 | 33 | sub check { 34 | my $self = shift; 35 | foreach (@{$self->{controllers}}) { 36 | $_->check(); 37 | } 38 | } 39 | 40 | sub dump { 41 | my $self = shift; 42 | foreach (@{$self->{controllers}}) { 43 | $_->dump(); 44 | } 45 | } 46 | 47 | package HP::Proliant::Component::DiskSubsystem::Scsi::Controller; 48 | our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Scsi); 49 | 50 | use strict; 51 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 52 | 53 | sub new { 54 | my $class = shift; 55 | my %params = @_; 56 | my $self = { 57 | runtime => $params{runtime}, 58 | blacklisted => 0, 59 | info => undef, 60 | extendedinfo => undef, 61 | }; 62 | map { $self->{$_} = $params{$_} } grep /cpqScsiCntlr/, keys %params; 63 | $self->{name} = $params{name} || $params{cpqScsiCntlrIndex}.':'.$params{cpqScsiCntlrBusIndex}; 64 | $self->{controllerindex} = $self->{cpqScsiCntlrIndex}; 65 | bless $self, $class; 66 | return $self; 67 | } 68 | 69 | sub check { 70 | my $self = shift; 71 | $self->blacklist('scco', $self->{name}); 72 | my $info = sprintf 'scsi controller %s in slot %s is %s', 73 | $self->{name}, $self->{cpqScsiCntlrSlot}, $self->{cpqScsiCntlrCondition}; 74 | if ($self->{cpqScsiCntlrCondition} eq 'other') { 75 | if (scalar(@{$self->{physical_drives}})) { 76 | $info .= ' and needs attention'; 77 | $self->add_message(CRITICAL, $info); 78 | $self->add_info($info); 79 | } else { 80 | $info .= ' and unused'; 81 | $self->add_info($info); 82 | $self->{blacklisted} = 1; 83 | } 84 | } elsif ($self->{cpqScsiCntlrCondition} ne 'ok') { 85 | $info .= ' and needs attention'; 86 | $self->add_message(CRITICAL, $info); 87 | $self->add_info($info); 88 | } else { 89 | $self->add_info($info); 90 | } 91 | foreach (@{$self->{logical_drives}}) { 92 | $_->check(); 93 | } 94 | foreach (@{$self->{physical_drives}}) { 95 | $_->check(); 96 | } 97 | foreach (@{$self->{spare_drives}}) { 98 | $_->check(); 99 | } 100 | } 101 | 102 | sub dump { 103 | my $self = shift; 104 | printf "[SCSI_CONTROLLER_%s]\n", $self->{name}; 105 | foreach (qw(cpqScsiCntlrIndex cpqScsiCntlrBusIndex cpqScsiCntlrSlot 106 | cpqScsiCntlrStatus cpqScsiCntlrCondition cpqScsiCntlrHwLocation)) { 107 | printf "%s: %s\n", $_, $self->{$_}; 108 | } 109 | printf "\n"; 110 | foreach (@{$self->{logical_drives}}) { 111 | $_->dump(); 112 | } 113 | foreach (@{$self->{physical_drives}}) { 114 | $_->dump(); 115 | } 116 | foreach (@{$self->{spare_drives}}) { 117 | $_->dump(); 118 | } 119 | } 120 | 121 | 122 | package HP::Proliant::Component::DiskSubsystem::Scsi::LogicalDrive; 123 | our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Scsi); 124 | 125 | use strict; 126 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 127 | 128 | sub new { 129 | my $class = shift; 130 | my %params = @_; 131 | my $self = { 132 | runtime => $params{runtime}, 133 | blacklisted => 0, 134 | info => undef, 135 | extendedinfo => undef, 136 | }; 137 | map { $self->{$_} = $params{$_} } grep /cpqScsiLogDrv/, keys %params; 138 | $self->{name} = $params{name} || $params{cpqScsiLogDrvCntlrIndex}.':'.$params{cpqScsiLogDrvBusIndex}.':'.$params{cpqScsiLogDrvIndex}; 139 | bless $self, $class; 140 | $self->{controllerindex} = $self->{cpqScsiLogDrvCntlrIndex}; 141 | return $self; 142 | } 143 | 144 | sub check { 145 | my $self = shift; 146 | $self->blacklist('scld', $self->{name}); 147 | my $info = sprintf 'logical drive %s is %s', $self->{name}, $self->{cpqScsiLogDrvStatus}; 148 | if ($self->{cpqScsiLogDrvCondition} ne "ok") { 149 | if ($self->{cpqScsiLogDrvStatus} =~ 150 | /rebuild|recovering/) { 151 | $self->add_message(WARNING, $info); 152 | } else { 153 | $self->add_message(CRITICAL, $info); 154 | } 155 | } 156 | $self->add_info($info); 157 | } 158 | 159 | sub dump { 160 | my $self = shift; 161 | printf "[LOGICAL_DRIVE_%s]\n", $self->{name}; 162 | foreach (qw(cpqScsiLogDrvCntlrIndex cpqScsiLogDrvBusIndex cpqScsiLogDrvIndex 163 | cpqScsiLogDrvFaultTol cpqScsiLogDrvStatus cpqScsiLogDrvSize 164 | cpqScsiLogDrvPhyDrvIDs cpqScsiLogDrvCondition)) { 165 | printf "%s: %s\n", $_, $self->{$_}; 166 | } 167 | printf "\n"; 168 | } 169 | 170 | 171 | package HP::Proliant::Component::DiskSubsystem::Scsi::PhysicalDrive; 172 | our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Scsi); 173 | 174 | use strict; 175 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 176 | 177 | sub new { 178 | my $class = shift; 179 | my %params = @_; 180 | my $self = { 181 | runtime => $params{runtime}, 182 | blacklisted => 0, 183 | info => undef, 184 | extendedinfo => undef, 185 | }; 186 | map { $self->{$_} = $params{$_} } grep /cpqScsiPhyDrv/, keys %params; 187 | $self->{name} = $params{name} || 188 | $self->{cpqScsiPhyDrvCntlrIndex}.':'.$self->{cpqScsiPhyDrvBusIndex}.':'.$self->{cpqScsiPhyDrvIndex}; 189 | $self->{controllerindex} = $self->{cpqScsiPhyDrvCntlrIndex}; 190 | bless $self, $class; 191 | return $self; 192 | } 193 | 194 | sub check { 195 | my $self = shift; 196 | $self->blacklist('scpd', $self->{name}); 197 | my $info = sprintf 'physical drive %s is %s', $self->{name}, $self->{cpqScsiPhyDrvCondition}; 198 | if ($self->{cpqScsiPhyDrvCondition} ne 'ok') { 199 | $self->add_message(CRITICAL, $info); 200 | } 201 | $self->add_info($info); 202 | } 203 | 204 | sub dump { 205 | my $self = shift; 206 | printf "[PHYSICAL_DRIVE_%s]\n", $self->{name}; 207 | foreach (qw(cpqScsiPhyDrvCntlrIndex cpqScsiPhyDrvBusIndex cpqScsiPhyDrvIndex 208 | cpqScsiPhyDrvStatus cpqScsiPhyDrvSize cpqScsiPhyDrvCondition)) { 209 | printf "%s: %s\n", $_, $self->{$_}; 210 | } 211 | printf "\n"; 212 | } 213 | 214 | 215 | package HP::Proliant::Component::DiskSubsystem::Scsi::SpareDrive; 216 | our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Scsi); 217 | 218 | use strict; 219 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 220 | 221 | sub dump { 222 | my $self = shift; 223 | printf "[SPARE_DRIVE]\n"; 224 | } 225 | 226 | 227 | 1; 228 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/DiskSubsystem/Scsi/CLI.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::DiskSubsystem::Scsi::CLI; 2 | our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Scsi); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | controllers => [], 12 | accelerators => [], 13 | enclosures => [], 14 | physical_drives => [], 15 | logical_drives => [], 16 | spare_drives => [], 17 | blacklisted => 0, 18 | }; 19 | bless $self, $class; 20 | return $self; 21 | } 22 | 23 | sub init { 24 | my $self = shift; 25 | } 26 | 27 | 1; 28 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/DiskSubsystem/Scsi/SNMP.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::DiskSubsystem::Scsi::SNMP; 2 | our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Scsi 3 | HP::Proliant::Component::SNMP); 4 | 5 | use strict; 6 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 7 | 8 | sub new { 9 | my $class = shift; 10 | my %params = @_; 11 | my $self = { 12 | controllers => [], 13 | accelerators => [], 14 | enclosures => [], 15 | physical_drives => [], 16 | logical_drives => [], 17 | spare_drives => [], 18 | blacklisted => 0, 19 | }; 20 | bless $self, $class; 21 | return $self; 22 | } 23 | 24 | sub init { 25 | my $self = shift; 26 | my $snmpwalk = $self->{rawdata}; 27 | 28 | # CPQSCSI-MIB 29 | my $oids = { 30 | cpqScsiCntlrEntry => '1.3.6.1.4.1.232.5.2.2.1.1', 31 | cpqScsiCntlrIndex => '1.3.6.1.4.1.232.5.2.2.1.1.1', 32 | cpqScsiCntlrBusIndex => '1.3.6.1.4.1.232.5.2.2.1.1.2', 33 | cpqScsiCntlrSlot => '1.3.6.1.4.1.232.5.2.2.1.1.6', 34 | cpqScsiCntlrStatus => '1.3.6.1.4.1.232.5.2.2.1.1.7', 35 | cpqScsiCntlrCondition => '1.3.6.1.4.1.232.5.2.2.1.1.12', 36 | cpqScsiCntlrHwLocation => '1.3.6.1.4.1.232.5.2.2.1.1.16', 37 | cpqScsiCntlrStatusValue => { 38 | 1 => "other", 39 | 2 => "ok", 40 | 3 => "failed", 41 | }, 42 | cpqScsiCntlrConditionValue => { 43 | 1 => "other", 44 | 2 => "ok", 45 | 3 => "degraded", 46 | 4 => "failed", 47 | } 48 | }; 49 | 50 | # INDEX { cpqScsiCntlrIndex, cpqScsiCntlrBusIndex } 51 | foreach ($self->get_entries($oids, 'cpqScsiCntlrEntry')) { 52 | push(@{$self->{controllers}}, 53 | HP::Proliant::Component::DiskSubsystem::Scsi::Controller->new(%{$_})); 54 | } 55 | 56 | $oids = { 57 | cpqScsiLogDrvEntry => '1.3.6.1.4.1.232.5.2.3.1.1', 58 | cpqScsiLogDrvCntlrIndex => '1.3.6.1.4.1.232.5.2.3.1.1.1', 59 | cpqScsiLogDrvBusIndex => '1.3.6.1.4.1.232.5.2.3.1.1.2', 60 | cpqScsiLogDrvIndex => '1.3.6.1.4.1.232.5.2.3.1.1.3', 61 | cpqScsiLogDrvFaultTol => '1.3.6.1.4.1.232.5.2.3.1.1.4', 62 | cpqScsiLogDrvStatus => '1.3.6.1.4.1.232.5.2.3.1.1.5', 63 | cpqScsiLogDrvSize => '1.3.6.1.4.1.232.5.2.3.1.1.6', 64 | cpqScsiLogDrvPhyDrvIDs => '1.3.6.1.4.1.232.5.2.3.1.1.7', 65 | cpqScsiLogDrvCondition => '1.3.6.1.4.1.232.5.2.3.1.1.8', 66 | cpqScsiLogDrvStatusValue => { 67 | 1 => "other", 68 | 2 => "ok", 69 | 3 => "failed", 70 | 4 => "unconfigured", 71 | 5 => "recovering", 72 | 6 => "readyForRebuild", 73 | 7 => "rebuilding", 74 | 8 => "wrongDrive", 75 | 9 => "badConnect", 76 | }, 77 | cpqScsiLogDrvConditionValue => { 78 | 1 => "other", 79 | 2 => "ok", 80 | 3 => "degraded", 81 | 4 => "failed", 82 | }, 83 | cpqScsiLogDrvFaultTolValue => { 84 | 1 => "other", 85 | 2 => "none", 86 | 3 => "mirroring", 87 | 4 => "dataGuard", 88 | 5 => "distribDataGuard", 89 | }, 90 | 91 | }; 92 | # INDEX { cpqScsiLogDrvCntlrIndex, cpqScsiLogDrvBusIndex, cpqScsiLogDrvIndex } 93 | foreach ($self->get_entries($oids, 'cpqScsiLogDrvEntry')) { 94 | push(@{$self->{logical_drives}}, 95 | HP::Proliant::Component::DiskSubsystem::Scsi::LogicalDrive->new(%{$_})); 96 | } 97 | 98 | $oids = { 99 | cpqScsiPhyDrvEntry => '1.3.6.1.4.1.232.5.2.4.1.1', 100 | cpqScsiPhyDrvCntlrIndex => '1.3.6.1.4.1.232.5.2.4.1.1.1', 101 | cpqScsiPhyDrvBusIndex => '1.3.6.1.4.1.232.5.2.4.1.1.2', 102 | cpqScsiPhyDrvIndex => '1.3.6.1.4.1.232.5.2.4.1.1.3', 103 | cpqScsiPhyDrvStatus => '1.3.6.1.4.1.232.5.2.4.1.1.9', 104 | cpqScsiPhyDrvSize => '1.3.6.1.4.1.232.5.2.4.1.1.7', 105 | cpqScsiPhyDrvCondition => '1.3.6.1.4.1.232.5.2.4.1.1.26', 106 | cpqScsiPhyDrvConditionValue => { 107 | 1 => "other", 108 | 2 => "ok", 109 | 3 => "degraded", 110 | 4 => "failed", 111 | }, 112 | cpqScsiPhyDrvStatusValue => { 113 | 1 => "other", 114 | 2 => "ok", 115 | 3 => "failed", 116 | 4 => "notConfigured", 117 | 5 => "badCable", 118 | 6 => "missingWasOk", 119 | 7 => "missingWasFailed", 120 | 8 => "predictiveFailure", 121 | 9 => "missingWasPredictiveFailure", 122 | 10 => "offline", 123 | 11 => "missingWasOffline", 124 | 12 => "hardError", 125 | }, 126 | }; 127 | 128 | # INDEX { cpqScsiPhyDrvCntlrIndex, cpqScsiPhyDrvBusIndex, cpqScsiPhyDrvIndex } 129 | foreach ($self->get_entries($oids, 'cpqScsiPhyDrvEntry')) { 130 | push(@{$self->{physical_drives}}, 131 | HP::Proliant::Component::DiskSubsystem::Scsi::PhysicalDrive->new(%{$_})); 132 | } 133 | 134 | } 135 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/EventSubsystem/CLI.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::EventSubsystem::CLI; 2 | our @ISA = qw(HP::Proliant::Component::EventSubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | use Time::Local; 7 | 8 | sub new { 9 | my $class = shift; 10 | my %params = @_; 11 | my $self = { 12 | runtime => $params{runtime}, 13 | rawdata => $params{rawdata}, 14 | events => [], 15 | blacklisted => 0, 16 | info => undef, 17 | extendedinfo => undef, 18 | }; 19 | bless $self, $class; 20 | $self->init(%params); 21 | return $self; 22 | } 23 | 24 | 25 | sub init { 26 | my $self = shift; 27 | my %params = @_; 28 | my %tmpevent = ( 29 | runtime => $params{runtime}, 30 | ); 31 | my $inblock = 0; 32 | foreach (grep(/^iml/, split(/\n/, $self->{rawdata}))) { 33 | s/^iml\s*//g; 34 | if (/^Event:\s+(\d+)\s+[\w]+:\s+(\d+)\/(\d+)\/(\d+)\s+(\d+):(\d+)/) { 35 | # Event: 31 Added: 09/22/2011 05:11 36 | # 1 2 3 4 5 6 37 | $tmpevent{cpqHeEventLogEntryNumber} = $1; 38 | if ($4 == 0) { 39 | # Event: 29 Added: 00/00/0000 00:00 40 | $tmpevent{cpqHeEventLogUpdateTime} = 0; 41 | } else { 42 | eval { 43 | $tmpevent{cpqHeEventLogUpdateTime} = timelocal(0, $6, $5, $3, $2 - 1, $4); 44 | }; 45 | if ($@) { 46 | # Event: 10 Added: 27/27/2027 27:27 47 | $tmpevent{cpqHeEventLogUpdateTime} = 0; 48 | } 49 | } 50 | $inblock = 1; 51 | } elsif (/^(\w+):\s+(.*?)\s+\-\s+(.*)/) { 52 | $tmpevent{cpqHeEventLogEntrySeverity} = $1; 53 | $tmpevent{cpqHeEventLogEntryClass} = $2; 54 | $tmpevent{cpqHeEventLogErrorDesc} = $3; 55 | if ($tmpevent{cpqHeEventLogErrorDesc} =~ /.*?:\s+(\d+)/) { 56 | $tmpevent{cpqHeEventLogEntryCode} = $1; 57 | } else { 58 | $tmpevent{cpqHeEventLogEntryCode} = 0; 59 | } 60 | } elsif (/^\s*$/) { 61 | if ($inblock) { 62 | $inblock = 0; 63 | push(@{$self->{events}}, 64 | HP::Proliant::Component::EventSubsystem::Event->new(%tmpevent)); 65 | %tmpevent = ( 66 | runtime => $params{runtime}, 67 | ); 68 | } 69 | } 70 | } 71 | if ($inblock) { 72 | push(@{$self->{events}}, 73 | HP::Proliant::Component::EventSubsystem::Event->new(%tmpevent)); 74 | } 75 | } 76 | 77 | 1; 78 | 79 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/EventSubsystem/date.pl: -------------------------------------------------------------------------------- 1 | use Data::Dumper; 2 | use Time::Local; 3 | my $val = "07 D8 0B 1B 13 03"; 4 | my $val2 = $val; 5 | $val2 =~ s/ //; 6 | print $val2; 7 | my ($year, $month, $day, $hour, $min) = map { hex($_) } split(/\s+/, $val2); 8 | my @x = map { hex($_) } split(/\s+/, $val2); 9 | my $now = timelocal(0, $min, $hour, $day, $month - 1, $year); 10 | printf "%s\n", scalar localtime $now; 11 | printf "%s\n", Data::Dumper::Dumper(\@x); 12 | 13 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/FanSubsystem/CLI.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::FanSubsystem::CLI; 2 | our @ISA = qw(HP::Proliant::Component::FanSubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | fans => [], 14 | blacklisted => 0, 15 | info => undef, 16 | extendedinfo => undef, 17 | }; 18 | bless $self, $class; 19 | $self->init(%params); 20 | return $self; 21 | } 22 | 23 | # partner not available = cpqHeFltTolFanRedundantPartner=0 24 | # cpqHeFltTolFanTypeValue = other 25 | sub init { 26 | my $self = shift; 27 | my %params = @_; 28 | my %tmpfan = (); 29 | foreach (grep(/^fans/, split(/\n/, $self->{rawdata}))) { 30 | s/^fans //g; 31 | if (/^#(\d+)\s+([\w#_\/\-]+)\s+(\w+)\s+(\w+)\s+(FAILED|[N\/A\d]+)%*\s+([\w\/]+)\s+(FAILED|[N\/A\d]+)\s+(\w+)/) { 32 | %tmpfan = ( 33 | cpqHeFltTolFanIndex => $1, 34 | cpqHeFltTolFanLocale => lc $2, 35 | cpqHeFltTolFanPresent => lc $3, 36 | cpqHeFltTolFanSpeed => lc $4, 37 | cpqHeFltTolFanPctMax => lc $5, # (FAILED|[N\/A\d]+) 38 | cpqHeFltTolFanRedundant => lc $6, 39 | cpqHeFltTolFanRedundantPartner => lc $7, # (FAILED|[N\/A\d]+) 40 | cpqHeFltTolFanHotPlug => lc $8, 41 | ); 42 | } elsif (/^#(\d+)\s+([\w#_\/\-]+?)(Yes|No|N\/A)\s+(\w+)\s+(FAILED|[N\/A\d]+)%*\s+([\w\/]+)\s+(FAILED|[N\/A\d]+)\s+(\w+)/) { 43 | # #5 SCSI_BACKPLANE_ZONEYes NORMAL N/A .... 44 | %tmpfan = ( 45 | cpqHeFltTolFanIndex => $1, 46 | cpqHeFltTolFanLocale => lc $2, 47 | cpqHeFltTolFanPresent => lc $3, 48 | cpqHeFltTolFanSpeed => lc $4, 49 | cpqHeFltTolFanPctMax => lc $5, 50 | cpqHeFltTolFanRedundant => lc $6, 51 | cpqHeFltTolFanRedundantPartner => lc $7, 52 | cpqHeFltTolFanHotPlug => lc $8, 53 | ); 54 | } elsif (/^#(\d+)\s+([\w#_\/\-]+)\s+[NOno]+\s/) { 55 | # Fan is not installed. #2 CPU#2 No - - No N/A - 56 | } elsif (/^#(\d+)/) { 57 | main::contact_author("FAN", $_); 58 | } 59 | if (%tmpfan) { 60 | $tmpfan{runtime} = $params{runtime}; 61 | $tmpfan{cpqHeFltTolFanChassis} = 1; # geht aus hpasmcli nicht hervor 62 | $tmpfan{cpqHeFltTolFanType} = 'other'; 63 | if ($tmpfan{cpqHeFltTolFanPctMax} !~ /^\d+$/) { 64 | if ($tmpfan{cpqHeFltTolFanSpeed} eq 'normal') { 65 | $tmpfan{cpqHeFltTolFanPctMax} = 50; 66 | } elsif ($tmpfan{cpqHeFltTolFanSpeed} eq 'high') { 67 | $tmpfan{cpqHeFltTolFanPctMax} = 100; 68 | } else { 69 | $tmpfan{cpqHeFltTolFanPctMax} = 0; 70 | } 71 | } 72 | if($tmpfan{cpqHeFltTolFanSpeed} eq 'failed') { 73 | $tmpfan{cpqHeFltTolFanCondition} = 'failed'; 74 | } elsif($tmpfan{cpqHeFltTolFanSpeed} eq 'n/a') { 75 | $tmpfan{cpqHeFltTolFanCondition} = 'other'; 76 | } elsif($tmpfan{cpqHeFltTolFanPresent} eq 'yes' and $tmpfan{cpqHeFltTolFanRedundantPartner} eq 'n/a') { 77 | $tmpfan{cpqHeFltTolFanCondition} = 'degraded'; 78 | } else { 79 | $tmpfan{cpqHeFltTolFanCondition} = 'ok'; 80 | } 81 | $tmpfan{cpqHeFltTolFanRedundant} = 82 | $tmpfan{cpqHeFltTolFanRedundant} eq 'yes' ? 'redundant' : 83 | $tmpfan{cpqHeFltTolFanRedundant} eq 'no' ? 'notRedundant' : 'other'; 84 | $tmpfan{cpqHeFltTolFanPresent} = 85 | $tmpfan{cpqHeFltTolFanPresent} eq 'yes' ? 'present' : 86 | $tmpfan{cpqHeFltTolFanPresent} eq 'failed' ? 'present' : 87 | $tmpfan{cpqHeFltTolFanPresent} eq 'no' ? 'absent' : 'other'; 88 | $tmpfan{cpqHeFltTolFanHotPlug} = 89 | $tmpfan{cpqHeFltTolFanHotPlug} eq 'yes' ? 'hotPluggable' : 90 | $tmpfan{cpqHeFltTolFanHotPlug} eq 'no' ? 'nonHotPluggable' : 'other'; 91 | push(@{$self->{fans}}, 92 | HP::Proliant::Component::FanSubsystem::Fan->new(%tmpfan)); 93 | %tmpfan = (); 94 | } 95 | } 96 | } 97 | 98 | sub overall_check { 99 | my $self = shift; 100 | # nix. nur wegen der gleichheit mit snmp 101 | return 0; 102 | } 103 | 1; 104 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/MemorySubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::MemorySubsystem; 2 | our @ISA = qw(HP::Proliant::Component); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | method => $params{method}, 14 | condition => $params{condition}, 15 | status => $params{status}, 16 | blacklisted => 0, 17 | info => undef, 18 | extendedinfo => undef, 19 | dimms => [], 20 | }; 21 | bless $self, $class; 22 | if ($self->{method} eq 'snmp') { 23 | return HP::Proliant::Component::MemorySubsystem::SNMP->new(%params); 24 | } elsif ($self->{method} eq 'cli') { 25 | return HP::Proliant::Component::MemorySubsystem::CLI->new(%params); 26 | } else { 27 | die "unknown method"; 28 | } 29 | } 30 | 31 | sub check { 32 | my $self = shift; 33 | my $errorfound = 0; 34 | $self->add_info('checking memory'); 35 | foreach (@{$self->{dimms}}) { 36 | $_->check(); # info ausfuellen 37 | } 38 | if ((scalar(grep { 39 | $_->is_present() && 40 | ($_->{condition} ne 'n/a' && $_->{condition} ne 'other' ) 41 | } @{$self->{dimms}})) != 0) { 42 | foreach (@{$self->{dimms}}) { 43 | if (($_->is_present()) && ($_->{condition} ne 'ok')) { 44 | $_->add_message(CRITICAL, $_->{info}); 45 | $errorfound++; 46 | } 47 | } 48 | } else { 49 | if ($self->{runtime}->{options}->{ignore_dimms}) { 50 | $self->add_message(OK, 51 | sprintf "ignoring %d dimms with status 'n/a' ", 52 | scalar(grep { ($_->is_present()) } @{$self->{dimms}})); 53 | } elsif ($self->{runtime}->{options}->{buggy_firmware}) { 54 | $self->add_message(OK, 55 | sprintf "ignoring %d dimms with status 'n/a' because of buggy firmware", 56 | scalar(grep { ($_->is_present()) } @{$self->{dimms}})); 57 | } else { 58 | $self->add_message(WARNING, 59 | sprintf "status of all %d dimms is n/a (please upgrade firmware)", 60 | scalar(grep { $_->is_present() } @{$self->{dimms}})); 61 | $errorfound++; 62 | } 63 | } 64 | foreach (@{$self->{dimms}}) { 65 | printf "%s\n", $_->{info} if $self->{runtime}->{options}->{verbose} >= 2; 66 | } 67 | if (! $errorfound && $self->is_faulty()) { 68 | #if ($self->is_faulty()) { 69 | $self->add_message(WARNING, 70 | sprintf 'overall memory error found'); 71 | } 72 | } 73 | 74 | sub dump { 75 | my $self = shift; 76 | printf "i dump the memory\n"; 77 | foreach (@{$self->{dimms}}) { 78 | $_->dump(); 79 | } 80 | } 81 | 82 | package HP::Proliant::Component::MemorySubsystem::Dimm; 83 | our @ISA = qw(HP::Proliant::Component::MemorySubsystem); 84 | 85 | use strict; 86 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 87 | 88 | sub new { 89 | my $class = shift; 90 | my %params = @_; 91 | my $self = { 92 | runtime => $params{runtime}, 93 | cartridge => $params{cartridge}, 94 | module => $params{module}, 95 | size => $params{size} || 0, 96 | status => $params{status}, 97 | condition => $params{condition}, 98 | type => $params{type}, 99 | blacklisted => 0, 100 | info => undef, 101 | extendedinfo => undef, 102 | }; 103 | bless $self, $class; 104 | $self->{name} = sprintf '%s:%s', 105 | $self->{cartridge}, $self->{module}; 106 | $self->{location} = sprintf 'module %s @ cartridge %s', 107 | $self->{module}, $self->{cartridge}; 108 | return $self; 109 | } 110 | 111 | sub check { 112 | my $self = shift; 113 | # check dient nur dazu, info und extended_info zu fuellen 114 | # die eigentliche bewertung findet eins hoeher statt 115 | $self->blacklist('d', $self->{name}); 116 | if (($self->{status} eq 'present') || ($self->{status} eq 'good')) { 117 | if ($self->{condition} eq 'other') { 118 | $self->add_info(sprintf 'dimm %s (%s) is n/a', 119 | $self->{name}, $self->{location}); 120 | } elsif ($self->{condition} ne 'ok') { 121 | $self->add_info( 122 | sprintf "dimm module %s (%s) needs attention (%s)", 123 | $self->{name}, $self->{location}, $self->{condition}); 124 | } else { 125 | $self->add_info(sprintf 'dimm module %s (%s) is %s', 126 | $self->{name}, $self->{location}, $self->{condition}); 127 | } 128 | } elsif ($self->{status} eq 'notPresent') { 129 | $self->add_info(sprintf 'dimm module %s (%s) is not present', 130 | $self->{name}, $self->{location}); 131 | } else { 132 | $self->add_info( 133 | sprintf "dimm module %s (%s) needs attention (%s)", 134 | $self->{name}, $self->{location}, $self->{condition}); 135 | } 136 | } 137 | 138 | sub is_present { 139 | my $self = shift; 140 | my @signs_of_presence = (qw(present good add upgraded doesnotmatch 141 | notsupported badconfig degraded)); 142 | return scalar(grep { $self->{status} eq $_ } @signs_of_presence); 143 | } 144 | 145 | 146 | sub dump { 147 | my $self = shift; 148 | #printf "[DIMM_%s_%s]\n", $self->{cartridge}, $self->{module}; 149 | #foreach (qw(cartridge module size status condition info)) { 150 | # printf "%s: %s\n", $_, $self->{$_}; 151 | #} 152 | #printf "status: %s\n", $self->{status} if exists $self->{status}; 153 | #printf "\n"; 154 | printf "car %02d mod %02d siz %.0f sta %-12s con %-10s typ %s\n", 155 | $self->{cartridge}, $self->{module}, $self->{size}, 156 | $self->{status}, $self->{condition}, defined $self->{type} ? $self->{type} : ""; 157 | } 158 | 159 | 160 | package HP::Proliant::Component::MemorySubsystem::Cartridge; 161 | our @ISA = qw(HP::Proliant::Component::MemorySubsystem); 162 | 163 | use strict; 164 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 165 | 166 | sub new { 167 | my $class = shift; 168 | my %params = @_; 169 | my $self = { 170 | cpqHeResMemBoardSlotIndex => $params{cpqHeResMemBoardSlotIndex}, 171 | cpqHeResMemBoardOnlineStatus => $params{cpqHeResMemBoardOnlineStatus}, 172 | cpqHeResMemBoardErrorStatus => $params{cpqHeResMemBoardErrorStatus}, 173 | cpqHeResMemBoardNumSockets => $params{cpqHeResMemBoardNumSockets}, 174 | cpqHeResMemBoardOsMemSize => $params{cpqHeResMemBoardOsMemSize}, 175 | cpqHeResMemBoardTotalMemSize => $params{cpqHeResMemBoardTotalMemSize}, 176 | cpqHeResMemBoardCondition => $params{cpqHeResMemBoardCondition}, 177 | blacklisted => 0, 178 | info => undef, 179 | extendedinfo => undef, 180 | }; 181 | bless $self, $class; 182 | return $self; 183 | } 184 | 185 | sub dump { 186 | my $self = shift; 187 | #printf "[CARTRIDGE_%s_%s]\n", $self->{cpqHeResMemBoardSlotIndex}; 188 | #foreach (qw(cpqHeResMemBoardSlotIndex cpqHeResMemBoardOnlineStatus 189 | # cpqHeResMemBoardErrorStatus cpqHeResMemBoardNumSockets 190 | # cpqHeResMemBoardOsMemSize cpqHeResMemBoardTotalMemSize 191 | # cpqHeResMemBoardCondition)) { 192 | # printf "%s: %s\n", $_, $self->{$_}; 193 | #} 194 | #printf "\n"; 195 | } 196 | 197 | 198 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/MemorySubsystem/CLI.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::MemorySubsystem::CLI; 2 | our @ISA = qw(HP::Proliant::Component::MemorySubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | dimms => [], 14 | blacklisted => 0, 15 | info => undef, 16 | extendedinfo => undef, 17 | }; 18 | bless $self, $class; 19 | $self->init(%params); 20 | return $self; 21 | } 22 | 23 | sub init { 24 | my $self = shift; 25 | my %params = @_; 26 | $self->{dimms} = []; 27 | my %tmpdimm = ( 28 | runtime => $params{runtime}, 29 | ); 30 | my $inblock = 0; 31 | foreach (grep(/^dimm/, split(/\n/, $self->{rawdata}))) { 32 | s/^dimm\s*$//g; 33 | if (/Cartridge #:\s+(\d+)/ || /Processor #:\s+(\d+)/) { 34 | # neuerdings (g6) tauchen hier prozessor- statt cartridge-angaben auf 35 | $tmpdimm{cartridge} = $1; 36 | $tmpdimm{board} = $1; 37 | $inblock = 1; 38 | } elsif (/Module #:\s+(\d+)/) { 39 | $tmpdimm{module} = $1; 40 | } elsif (/Present:\s+(\w+)/) { 41 | $tmpdimm{status} = lc $1 eq 'yes' ? 'present' : 42 | lc $1 eq 'no' ? 'notPresent' : 'other'; 43 | } elsif (/Status:\s+(.+?)\s*$/) { 44 | $tmpdimm{condition} = lc $1 =~ /degraded/ ? 'degraded' : 45 | lc $1 eq 'ok' ? 'ok' : lc $1 =~ /n\/a/ ? 'n/a' : 'other'; 46 | } elsif (/Size:\s+(\d+)\s*(.+?)\s*$/) { 47 | $tmpdimm{size} = $1 * (lc $2 eq 'mb' ? 1024*1024 : 48 | lc $2 eq 'gb' ? 1024*1024*1024 : 1); 49 | } elsif (/^\s*$/) { 50 | if ($inblock) { 51 | $inblock = 0; 52 | push(@{$self->{dimms}}, 53 | HP::Proliant::Component::MemorySubsystem::Dimm->new(%tmpdimm)); 54 | %tmpdimm = ( 55 | runtime => $params{runtime}, 56 | ); 57 | } 58 | } elsif (/(\d+)\s+(\d+)\s+(\w+)\s+(0x\w+)\s+(0x\w+)\s+(\d+[MGT]B)\s+(\d+MHz)\s+(\w+)/) { 59 | $tmpdimm{cartridge} = $1; 60 | $tmpdimm{module} = $2; 61 | $tmpdimm{status} = lc $3 eq 'yes' ? 'present' : 62 | lc $3 eq 'no' ? 'notPresent' : 'other'; 63 | my $formfactor = $4; 64 | my $memorytype = $5; 65 | my $memorysize = $6; 66 | my $memoryspeed = $7; 67 | $tmpdimm{condition} = lc $8 =~ /degraded/ ? 'degraded' : 68 | lc $8 eq 'ok' ? 'ok' : lc $8 =~ /n\/a/ ? 'n/a' : 'other'; 69 | $memorysize =~ /(\d+)([MGT]B)/; 70 | $tmpdimm{size} = $1 * (lc $2 eq 'mb' ? 1024*1024 : 71 | lc $2 eq 'gb' ? 1024*1024*1024 : 1); 72 | push(@{$self->{dimms}}, 73 | HP::Proliant::Component::MemorySubsystem::Dimm->new(%tmpdimm)); 74 | } 75 | } 76 | if ($inblock) { 77 | push(@{$self->{dimms}}, 78 | HP::Proliant::Component::MemorySubsystem::Dimm->new(%tmpdimm)); 79 | } 80 | } 81 | 82 | sub is_faulty { 83 | my $self = shift; 84 | return 0; # cli hat so einen globalen status nicht 85 | } 86 | 87 | 1; 88 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/NicSubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::NicSubsystem; 2 | our @ISA = qw(HP::Proliant::Component); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | method => $params{method}, 14 | condition => $params{condition}, 15 | status => $params{status}, 16 | logical_nics => [], 17 | physical_nics => [], 18 | blacklisted => 0, 19 | info => undef, 20 | extendedinfo => undef, 21 | }; 22 | bless $self, $class; 23 | if ($self->{method} eq 'snmp') { 24 | return HP::Proliant::Component::NicSubsystem::SNMP->new(%params); 25 | } elsif ($self->{method} eq 'cli') { 26 | return HP::Proliant::Component::NicSubsystem::CLI->new(%params); 27 | } else { 28 | die "unknown method"; 29 | } 30 | return $self; 31 | } 32 | 33 | sub check { 34 | my $self = shift; 35 | my $errorfound = 0; 36 | $self->add_info('checking nic teams'); 37 | if (scalar (@{$self->{logical_nics}}) == 0) { 38 | $self->add_info('no logical nics found'); 39 | $self->overall_check(); 40 | } else { 41 | foreach (@{$self->{logical_nics}}) { 42 | $_->check(); 43 | } 44 | } 45 | if (scalar (@{$self->{physical_nics}}) == 0) { 46 | $self->add_info('no physical nics found. do you connect with slip?'); 47 | } else { 48 | foreach (@{$self->{physical_nics}}) { 49 | $_->check(); 50 | } 51 | } 52 | } 53 | 54 | sub num_logical_nics { 55 | my $self = shift; 56 | return scalar @{$self->{logical_nics}}; 57 | } 58 | 59 | sub num_physical_nics { 60 | my $self = shift; 61 | return scalar @{$self->{physical_nics}}; 62 | } 63 | 64 | sub dump { 65 | my $self = shift; 66 | foreach (@{$self->{logical_nics}}) { 67 | $_->dump(); 68 | } 69 | foreach (@{$self->{physical_nics}}) { 70 | $_->dump(); 71 | } 72 | } 73 | 74 | sub overall_check { 75 | my $self = shift; 76 | if ($self->{lognicstatus} ne "ok") { 77 | $self->add_info(sprintf 'overall logical nic status is %s', 78 | $self->{lognicstatus}); 79 | } 80 | } 81 | 82 | 83 | package HP::Proliant::Component::NicSubsystem::LogicalNic; 84 | our @ISA = qw(HP::Proliant::Component::NicSubsystem); 85 | 86 | use strict; 87 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 88 | 89 | sub new { 90 | my $class = shift; 91 | my %params = @_; 92 | my $self = { 93 | runtime => $params{runtime}, 94 | blacklisted => 0, 95 | info => undef, 96 | extendedinfo => undef, 97 | }; 98 | foreach (qw(cpqNicIfLogMapIndex cpqNicIfLogMapIfNumber cpqNicIfLogMapDescription cpqNicIfLogMapGroupType cpqNicIfLogMapAdapterCount cpqNicIfLogMapAdapterOKCount cpqNicIfLogMapPhysicalAdapters cpqNicIfLogMapSwitchoverMode cpqNicIfLogMapCondition cpqNicIfLogMapStatus cpqNicIfLogMapNumSwitchovers cpqNicIfLogMapHwLocation cpqNicIfLogMapSpeed cpqNicIfLogMapVlanCount cpqNicIfLogMapVlans)) { 99 | $self->{$_} = $params{$_}; 100 | } 101 | bless $self, $class; 102 | return $self; 103 | } 104 | 105 | sub check { 106 | my $self = shift; 107 | $self->blacklist('lni', $self->{cpqNicIfLogMapIndex}); 108 | if ($self->{cpqNicIfLogMapAdapterCount} > 0) { 109 | if ($self->{cpqNicIfLogMapCondition} eq "other") { 110 | # simply ignore this. if there is a physical nic 111 | # it is usually unknown/other/scheissegal 112 | $self->add_info(sprintf "logical nic %d (%s) is %s", 113 | $self->{cpqNicIfLogMapIndex}, $self->{cpqNicIfLogMapDescription}, 114 | $self->{cpqNicIfLogMapCondition}); 115 | } elsif ($self->{cpqNicIfLogMapCondition} ne "ok") { 116 | $self->add_info(sprintf "logical nic %d (%s) is %s (%s)", 117 | $self->{cpqNicIfLogMapIndex}, $self->{cpqNicIfLogMapDescription}, 118 | $self->{cpqNicIfLogMapCondition}, $self->{cpqNicIfLogMapStatus}); 119 | $self->add_message(CRITICAL, $self->{info}); 120 | } else { 121 | $self->add_info(sprintf "logical nic %d (%s) is %s", 122 | $self->{cpqNicIfLogMapIndex}, $self->{cpqNicIfLogMapDescription}, 123 | $self->{cpqNicIfLogMapCondition}); 124 | } 125 | } else { 126 | $self->add_info(sprintf "logical nic %d (%s) has 0 physical nics", 127 | $self->{cpqNicIfLogMapIndex}, $self->{cpqNicIfLogMapDescription}); 128 | } 129 | } 130 | 131 | sub dump { 132 | my $self = shift; 133 | printf "[LNIC_%s]\n", $self->{cpqNicIfLogMapIndex}; 134 | foreach (qw(cpqNicIfLogMapIndex cpqNicIfLogMapIfNumber cpqNicIfLogMapDescription cpqNicIfLogMapAdapterCount cpqNicIfLogMapGroupType cpqNicIfLogMapSwitchoverMode cpqNicIfLogMapCondition cpqNicIfLogMapStatus cpqNicIfLogMapNumSwitchovers cpqNicIfLogMapHwLocation cpqNicIfLogMapSpeed)) { 135 | printf "%s: %s\n", $_, $self->{$_}; 136 | } 137 | printf "info: %s\n", $self->{info}; 138 | printf "\n"; 139 | } 140 | 141 | 142 | package HP::Proliant::Component::NicSubsystem::PhysicalNic; 143 | our @ISA = qw(HP::Proliant::Component::NicSubsystem); 144 | 145 | use strict; 146 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 147 | 148 | sub new { 149 | my $class = shift; 150 | my %params = @_; 151 | my $self = { 152 | runtime => $params{runtime}, 153 | blacklisted => 0, 154 | info => undef, 155 | extendedinfo => undef, 156 | }; 157 | foreach (qw(cpqNicIfPhysAdapterIndex cpqNicIfPhysAdapterIfNumber cpqNicIfPhysAdapterRole cpqNicIfPhysAdapterDuplexState cpqNicIfPhysAdapterCondition cpqNicIfPhysAdapterState cpqNicIfPhysAdapterStatus cpqNicIfPhysAdapterBadTransmits cpqNicIfPhysAdapterBadReceives)) { 158 | $self->{$_} = $params{$_}; 159 | } 160 | bless $self, $class; 161 | return $self; 162 | } 163 | 164 | sub check { 165 | my $self = shift; 166 | $self->blacklist('pni', $self->{cpqNicIfPhysAdapterIndex}); 167 | if ($self->{cpqNicIfPhysAdapterCondition} eq "other") { 168 | # hp doesnt output a clear status. i am optimistic, unknown/other 169 | # means "dont care" 170 | $self->add_info(sprintf "physical nic %d (%s) is %s", 171 | $self->{cpqNicIfPhysAdapterIndex}, $self->{cpqNicIfPhysAdapterRole}, 172 | $self->{cpqNicIfPhysAdapterCondition}); 173 | } elsif ($self->{cpqNicIfPhysAdapterCondition} ne "ok") { 174 | $self->add_info(sprintf "physical nic %d (%s) is %s (%s,%s)", 175 | $self->{cpqNicIfPhysAdapterIndex}, $self->{cpqNicIfPhysAdapterRole}, 176 | $self->{cpqNicIfPhysAdapterCondition}, 177 | $self->{cpqNicIfPhysAdapterState}, $self->{cpqNicIfPhysAdapterStatus}); 178 | $self->add_message(CRITICAL, $self->{info}); 179 | } else { 180 | if ($self->{cpqNicIfPhysAdapterDuplexState} ne "full") { 181 | $self->add_info(sprintf "physical nic %d (%s) is %s duplex", 182 | $self->{cpqNicIfPhysAdapterIndex}, $self->{cpqNicIfPhysAdapterRole}, 183 | $self->{cpqNicIfPhysAdapterDuplexState}); 184 | } else { 185 | $self->add_info(sprintf "physical nic %d (%s) is %s", 186 | $self->{cpqNicIfPhysAdapterIndex}, $self->{cpqNicIfPhysAdapterRole}, 187 | $self->{cpqNicIfPhysAdapterCondition}); 188 | } 189 | } 190 | } 191 | 192 | sub dump { 193 | my $self = shift; 194 | printf "[PNIC_%s]\n", $self->{cpqNicIfPhysAdapterIndex}; 195 | foreach (qw(cpqNicIfPhysAdapterIndex cpqNicIfPhysAdapterIfNumber cpqNicIfPhysAdapterRole cpqNicIfPhysAdapterDuplexState cpqNicIfPhysAdapterCondition cpqNicIfPhysAdapterState cpqNicIfPhysAdapterStatus cpqNicIfPhysAdapterBadTransmits cpqNicIfPhysAdapterBadReceives)) { 196 | printf "%s: %s\n", $_, $self->{$_}; 197 | } 198 | printf "info: %s\n", $self->{info}; 199 | printf "\n"; 200 | } 201 | 202 | 203 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/PowersupplySubsystem/CLI.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::PowersupplySubsystem::CLI; 2 | our @ISA = qw(HP::Proliant::Component::PowersupplySubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | powersupplies => [], 14 | powerconverters => [], 15 | blacklisted => 0, 16 | info => undef, 17 | extendedinfo => undef, 18 | }; 19 | bless $self, $class; 20 | $self->init(%params); 21 | return $self; 22 | } 23 | 24 | sub init { 25 | my $self = shift; 26 | my %params = @_; 27 | my %tmpps = ( 28 | runtime => $self->{runtime}, 29 | cpqHeFltTolPowerSupplyChassis => 1, 30 | ); 31 | my $inblock = 0; 32 | foreach (grep(/^powersupply/, split(/\n/, $self->{rawdata}))) { 33 | s/^powersupply\s*//g; 34 | if (/^Power supply #(\d+)/) { 35 | if ($inblock) { 36 | $inblock = 0; 37 | push(@{$self->{powersupplies}}, 38 | HP::Proliant::Component::PowersupplySubsystem::Powersupply->new(%tmpps)); 39 | %tmpps = ( 40 | runtime => $self->{runtime}, 41 | cpqHeFltTolPowerSupplyChassis => 1, 42 | ); 43 | } 44 | $tmpps{cpqHeFltTolPowerSupplyBay} = $1; 45 | $inblock = 1; 46 | } elsif (/\s*Present\s+:\s+(\w+)/) { 47 | $tmpps{cpqHeFltTolPowerSupplyPresent} = lc $1 eq 'yes' ? 'present' : 48 | lc $1 eq 'no' ? 'absent': 'other'; 49 | } elsif (/\s*Redundant\s*:\s+(\w+)/) { 50 | $tmpps{cpqHeFltTolPowerSupplyRedundant} = lc $1 eq 'yes' ? 'redundant' : 51 | lc $1 eq 'no' ? 'notRedundant' : 'other'; 52 | } elsif (/\s*Condition\s*:\s+(\w+)/) { 53 | $tmpps{cpqHeFltTolPowerSupplyCondition} = lc $1; 54 | } elsif (/\s*Power\s*:\s+(\d+)/) { 55 | $tmpps{cpqHeFltTolPowerSupplyCapacityUsed} = $1; 56 | } elsif (/\s*Power Supply not present/) { 57 | $tmpps{cpqHeFltTolPowerSupplyPresent} = "absent"; 58 | $tmpps{cpqHeFltTolPowerSupplyCondition} = "other"; 59 | $tmpps{cpqHeFltTolPowerSupplyRedundant} = "notRedundant"; 60 | } elsif (/^\s*$/) { 61 | if ($inblock) { 62 | $inblock = 0; 63 | push(@{$self->{powersupplies}}, 64 | HP::Proliant::Component::PowersupplySubsystem::Powersupply->new(%tmpps)); 65 | %tmpps = ( 66 | runtime => $self->{runtime}, 67 | cpqHeFltTolPowerSupplyChassis => 1, 68 | ); 69 | } 70 | } 71 | } 72 | if ($inblock) { 73 | push(@{$self->{powersupplies}}, 74 | HP::Proliant::Component::PowersupplySubsystem::Powersupply->new(%tmpps)); 75 | %tmpps = ( 76 | runtime => $params{runtime}, 77 | ); 78 | } 79 | } 80 | 81 | 1; 82 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/PowersupplySubsystem/SNMP.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::PowersupplySubsystem::SNMP; 2 | our @ISA = qw(HP::Proliant::Component::PowersupplySubsystem 3 | HP::Proliant::Component::SNMP); 4 | 5 | use strict; 6 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 7 | 8 | sub new { 9 | my $class = shift; 10 | my %params = @_; 11 | my $self = { 12 | runtime => $params{runtime}, 13 | rawdata => $params{rawdata}, 14 | powersupplies => [], 15 | powerconverters => [], 16 | blacklisted => 0, 17 | info => undef, 18 | extendedinfo => undef, 19 | }; 20 | bless $self, $class; 21 | $self->init(%params); 22 | return $self; 23 | } 24 | 25 | sub init { 26 | my $self = shift; 27 | my %params = @_; 28 | my $snmpwalk = $self->{rawdata}; 29 | my $oids = { 30 | cpqHeFltTolPowerSupplyEntry => "1.3.6.1.4.1.232.6.2.9.3.1", 31 | cpqHeFltTolPowerSupplyChassis => "1.3.6.1.4.1.232.6.2.9.3.1.1", 32 | cpqHeFltTolPowerSupplyBay => "1.3.6.1.4.1.232.6.2.9.3.1.2", 33 | cpqHeFltTolPowerSupplyPresent => "1.3.6.1.4.1.232.6.2.9.3.1.3", 34 | cpqHeFltTolPowerSupplyCondition => "1.3.6.1.4.1.232.6.2.9.3.1.4", 35 | cpqHeFltTolPowerSupplyStatus => "1.3.6.1.4.1.232.6.2.9.3.1.5", 36 | cpqHeFltTolPowerSupplyErrorCondition => "1.3.6.1.4.1.232.6.2.9.3.1.18", 37 | cpqHeFltTolPowerSupplyRedundant => "1.3.6.1.4.1.232.6.2.9.3.1.9", 38 | cpqHeFltTolPowerSupplyPresentValue => { 39 | 1 => "other", 40 | 2 => "absent", 41 | 3 => "present", 42 | }, 43 | cpqHeFltTolPowerSupplyConditionValue => { 44 | 1 => "other", 45 | 2 => "ok", 46 | 3 => "degraded", 47 | 4 => "failed", 48 | }, 49 | cpqHeFltTolPowerSupplyStatusValue => { 50 | 1 => "noError", 51 | 2 => "generalFailure", 52 | 3 => "bistFailure", 53 | 4 => "fanFailure", 54 | 5 => "tempFailure", 55 | 6 => "interlockOpen", 56 | 7 => "epromFailed", 57 | 8 => "vrefFailed", 58 | 9 => "dacFailed", 59 | 10 => "ramTestFailed", 60 | 11 => "voltageChannelFailed", 61 | 12 => "orringdiodeFailed", 62 | 13 => "brownOut", 63 | 14 => "giveupOnStartup", 64 | 15 => "nvramInvalid", 65 | 16 => "calibrationTableInvalid", 66 | 17 => "noPowerInput", 67 | }, 68 | cpqHeFltTolPowerSupplyErrorConditionValue => { 69 | 1 => "noError", 70 | 2 => "generalFailure", 71 | 3 => "overvoltage", 72 | 4 => "overcurrent", 73 | 5 => "overtemperature", 74 | 6 => "powerinputloss", 75 | 7 => "fanfailure", 76 | 8 => "vinhighwarning", 77 | 9 => "vinlowwarning", 78 | 10 => "vouthighwarning", 79 | 11 => "voutlowwarning", 80 | 12 => "inlettemphighwarning", 81 | 13 => "iinternaltemphighwarning", 82 | 14 => "vauxhighwarning", 83 | 15 => "vauxlowwarning", 84 | }, 85 | cpqHeFltTolPowerSupplyCapacityUsed => '1.3.6.1.4.1.232.6.2.9.3.1.7', 86 | cpqHeFltTolPowerSupplyCapacityMaximum => '1.3.6.1.4.1.232.6.2.9.3.1.8', 87 | cpqHeFltTolPowerSupplyRedundantValue => { 88 | 1 => "other", 89 | 2 => "notRedundant", 90 | 3 => "redundant", 91 | }, 92 | }; 93 | 94 | # INDEX { cpqHeFltTolPowerSupplyChassis, cpqHeFltTolPowerSupplyBay } 95 | foreach ($self->get_entries($oids, 'cpqHeFltTolPowerSupplyEntry')) { 96 | push(@{$self->{powersupplies}}, 97 | HP::Proliant::Component::PowersupplySubsystem::Powersupply->new(%{$_})); 98 | } 99 | 100 | $oids = { 101 | cpqHePowerConvEntry => "1.3.6.1.4.1.232.6.2.13.3.1", 102 | cpqHePowerConvChassis => "1.3.6.1.4.1.232.6.2.13.3.1.1", 103 | cpqHePowerConvIndex => "1.3.6.1.4.1.232.6.2.13.3.1.2", 104 | cpqHePowerConvPresent => "1.3.6.1.4.1.232.6.2.13.3.1.3", 105 | cpqHePowerConvRedundant => "1.3.6.1.4.1.232.6.2.13.3.1.6", 106 | cpqHePowerConvCondition => "1.3.6.1.4.1.232.6.2.13.3.1.8", 107 | cpqHePowerConvPresentValue => { 108 | 1 => "other", 109 | 2 => "absent", 110 | 3 => "present", 111 | }, 112 | cpqHePowerConvRedundantValue => { 113 | 1 => "other", 114 | 2 => "notRedundant", 115 | 3 => "redundant", 116 | }, 117 | cpqHePowerConvConditionValue => { 118 | 1 => "other", 119 | 2 => "ok", 120 | 3 => "degraded", 121 | 4 => "failed", 122 | }, 123 | cpqHePowerConvHwLocation => "1.3.6.1.4.1.232.6.2.13.3.1.9", 124 | }; 125 | 126 | # INDEX { cpqHePowerConvChassis cpqHePowerConvIndex } 127 | foreach ($self->get_entries($oids, 'cpqHePowerConvEntry')) { 128 | push(@{$self->{powerconverters}}, 129 | HP::Proliant::Component::PowersupplySubsystem::Powerconverter->new(%{$_})); 130 | } 131 | # keine ahnung, was man damit machen kann 132 | 133 | } 134 | 135 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/SNMP.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::SNMP; 2 | 3 | sub get_entries { 4 | my $self = shift; 5 | my $oids = shift; 6 | my $entry = shift; 7 | my $snmpwalk = $self->{rawdata}; 8 | my @params = (); 9 | my @indices = SNMP::Utils::get_indices($snmpwalk, $oids->{$entry}); 10 | foreach (@indices) { 11 | my @idx = @{$_}; 12 | my %params = ( 13 | runtime => $self->{runtime}, 14 | ); 15 | my $maxdimension = scalar(@idx) - 1; 16 | foreach my $idxnr (1..scalar(@idx)) { 17 | $params{'index'.$idxnr} = $_->[$idxnr - 1]; 18 | } 19 | foreach my $oid (keys %{$oids}) { 20 | next if $oid =~ /Entry$/; 21 | next if $oid =~ /Value$/; 22 | if (exists $oids->{$oid.'Value'}) { 23 | $params{$oid} = SNMP::Utils::get_object_value( 24 | $snmpwalk, $oids->{$oid}, $oids->{$oid.'Value'}, @idx); 25 | if (! defined $params{$oid}) { 26 | my $numerical_value = SNMP::Utils::get_object( 27 | $snmpwalk, $oids->{$oid}, @idx); 28 | if (! defined $numerical_value) { 29 | # maschine liefert schrott 30 | $params{$oid} = 'value_unknown'; 31 | } else { 32 | $params{$oid} = 'value_'.SNMP::Utils::get_object( 33 | $snmpwalk, $oids->{$oid}, @idx); 34 | } 35 | } 36 | } else { 37 | $params{$oid} = SNMP::Utils::get_object( 38 | $snmpwalk, $oids->{$oid}, @idx); 39 | } 40 | } 41 | push(@params, \%params); 42 | } 43 | return @params; 44 | } 45 | 46 | sub mib { 47 | my $self = shift; 48 | my $mib = shift; 49 | my $condition = { 50 | 0 => 'other', 51 | 1 => 'ok', 52 | 2 => 'degraded', 53 | 3 => 'failed', 54 | }; 55 | my $MibRevMajor = $mib.'.1.0'; 56 | my $MibRevMinor = $mib.'.2.0'; 57 | my $MibRevCondition = $mib.'.3.0'; 58 | return ( 59 | $self->SNMP::Utils::get_object($self->{rawdata}, 60 | $MibRevMajor), 61 | $self->SNMP::Utils::get_object($self->{rawdata}, 62 | $MibRevMinor), 63 | $self->SNMP::Utils::get_object_value($self->{rawdata}, 64 | $MibRevCondition, $condition)); 65 | }; 66 | 67 | 1; 68 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/TemperatureSubsystem/CLI.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::TemperatureSubsystem::CLI; 2 | our @ISA = qw(HP::Proliant::Component::TemperatureSubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | temperatures => [], 14 | blacklisted => 0, 15 | info => undef, 16 | extendedinfo => undef, 17 | }; 18 | bless $self, $class; 19 | $self->init(%params); 20 | return $self; 21 | } 22 | 23 | sub init { 24 | my $self = shift; 25 | my %params = @_; 26 | my $tempcnt = 1; 27 | foreach (grep(/^temp/, split(/\n/, $params{rawdata}))) { 28 | s/^temp\s*//g; 29 | if (/^#(\d+)\s+([\w_\/\-#]+)\s+(-*\d+)C\/(\d+)F\s+(\d+)C\/(\d+)F/) { 30 | my %params = (); 31 | $params{runtime} = $self->{runtime}; 32 | $params{cpqHeTemperatureChassis} = 1; 33 | $params{cpqHeTemperatureIndex} = $1; 34 | $params{cpqHeTemperatureLocale} = lc $2; 35 | $params{cpqHeTemperatureCelsius} = $3; 36 | $params{cpqHeTemperatureThresholdCelsius} = $5; 37 | $params{cpqHeTemperatureCondition} = 'unknown'; 38 | push(@{$self->{temperatures}}, 39 | HP::Proliant::Component::TemperatureSubsystem::Temperature->new( 40 | %params)); 41 | } elsif (/^#(\d+)\s+([\w_\/\-#]+)\s+\-\s+(\d+)C\/(\d+)F/) { 42 | # #3 CPU#2 - 0C/0F 43 | $self->trace(2, sprintf "skipping temperature %s", $_); 44 | } elsif (/^#(\d+)\s+([\w_\/\-#]+)\s+(\d+)C\/(\d+)F\s+\-/) { 45 | # #3 CPU#2 0C/0F - 46 | $self->trace(2, sprintf "skipping temperature %s", $_); 47 | } elsif (/^#(\d+)\s+([\w_\/\-#]+)\s+\-\s+\-/) { 48 | # #3 CPU#2 - - 49 | $self->trace(2, sprintf "skipping temperature %s", $_); 50 | } elsif (/^#(\d+)/) { 51 | $self->trace(0, sprintf "send this to lausser: %s", $_); 52 | } 53 | } 54 | } 55 | 56 | 1; 57 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Proliant/Component/TemperatureSubsystem/SNMP.pm: -------------------------------------------------------------------------------- 1 | package HP::Proliant::Component::TemperatureSubsystem::SNMP; 2 | our @ISA = qw(HP::Proliant::Component::TemperatureSubsystem 3 | HP::Proliant::Component::SNMP); 4 | 5 | use strict; 6 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 7 | 8 | sub new { 9 | my $class = shift; 10 | my %params = @_; 11 | my $self = { 12 | runtime => $params{runtime}, 13 | rawdata => $params{rawdata}, 14 | temperatures => [], 15 | blacklisted => 0, 16 | info => undef, 17 | extendedinfo => undef, 18 | }; 19 | bless $self, $class; 20 | $self->overall_init(%params); 21 | $self->init(%params); 22 | return $self; 23 | } 24 | 25 | sub overall_init { 26 | my $self = shift; 27 | my %params = @_; 28 | my $snmpwalk = $params{rawdata}; 29 | # overall 30 | my $cpqHeThermalTempStatus = '1.3.6.1.4.1.232.6.2.6.3.0'; 31 | my $cpqHeThermalTempStatusValue = { 32 | 1 => 'other', 33 | 2 => 'ok', 34 | 3 => 'degraded', 35 | 4 => 'failed', 36 | }; 37 | $self->{tempstatus} = lc SNMP::Utils::get_object_value( 38 | $snmpwalk, $cpqHeThermalTempStatus, 39 | $cpqHeThermalTempStatusValue); 40 | $self->{tempstatus} |= lc $self->{tempstatus}; 41 | } 42 | 43 | sub init { 44 | my $self = shift; 45 | my %params = @_; 46 | my $snmpwalk = $self->{rawdata}; 47 | my $oids = { 48 | cpqHeTemperatureEntry => "1.3.6.1.4.1.232.6.2.6.8.1", 49 | cpqHeTemperatureChassis => "1.3.6.1.4.1.232.6.2.6.8.1.1", 50 | cpqHeTemperatureIndex => "1.3.6.1.4.1.232.6.2.6.8.1.2", 51 | cpqHeTemperatureLocale => "1.3.6.1.4.1.232.6.2.6.8.1.3", 52 | cpqHeTemperatureCelsius => "1.3.6.1.4.1.232.6.2.6.8.1.4", 53 | cpqHeTemperatureThresholdCelsius => "1.3.6.1.4.1.232.6.2.6.8.1.5", 54 | cpqHeTemperatureCondition => "1.3.6.1.4.1.232.6.2.6.8.1.6", 55 | cpqHeTemperatureThresholdType => "1.3.6.1.4.1.232.6.2.6.8.1.7", 56 | cpqHeTemperatureLocaleValue => { 57 | 1 => "other", 58 | 2 => "unknown", 59 | 3 => "system", 60 | 4 => "systemBoard", 61 | 5 => "ioBoard", 62 | 6 => "cpu", 63 | 7 => "memory", 64 | 8 => "storage", 65 | 9 => "removableMedia", 66 | 10 => "powerSupply", 67 | 11 => "ambient", 68 | 12 => "chassis", 69 | 13 => "bridgeCard", 70 | }, 71 | cpqHeTemperatureConditionValue => { 72 | 1 => 'other', 73 | 2 => 'ok', 74 | 3 => 'degraded', 75 | 4 => 'failed', 76 | }, 77 | cpqHeTemperatureThresholdTypeValue => { 78 | 1 => 'other', 79 | 5 => 'blowout', 80 | 9 => 'caution', 81 | 15 => 'critical', 82 | }, 83 | }; 84 | # INDEX { cpqHeTemperatureChassis, cpqHeTemperatureIndex } 85 | foreach ($self->get_entries($oids, 'cpqHeTemperatureEntry')) { 86 | # sieht aus, als wurden die gar nicht existieren. 87 | # im ilo4 werden sie als n/a angezeigt 88 | next if $_->{cpqHeTemperatureThresholdType} eq "caution" && $_->{cpqHeTemperatureThresholdCelsius} == 0; 89 | push(@{$self->{temperatures}}, 90 | HP::Proliant::Component::TemperatureSubsystem::Temperature->new(%{$_})); 91 | } 92 | } 93 | 94 | sub overall_check { 95 | my $self = shift; 96 | my $result = 0; 97 | $self->blacklist('ots', ''); 98 | if ($self->{tempstatus}) { 99 | if ($self->{tempstatus} eq "ok") { 100 | $result = 0; 101 | $self->add_info('all temp sensors are within normal operating range'); 102 | } elsif ($self->{tempstatus} eq "degraded") { 103 | $result = 1; 104 | $self->add_info('a temp sensor is outside of normal operating range'); 105 | } elsif ($self->{tempstatus} eq "failed") { 106 | $result = 2; 107 | $self->add_info('a temp sensor detects a condition that could permanently 108 | damage the system'); 109 | } elsif ($self->{tempstatus} eq "other") { 110 | $result = 0; 111 | $self->add_info('temp sensing is not supported by this system or driver'); 112 | } 113 | } else { 114 | $result = 0; 115 | $self->add_info('no global temp status found'); 116 | } 117 | } 118 | 119 | 1; 120 | -------------------------------------------------------------------------------- /plugins-scripts/HP/SNMP/Utils.pm: -------------------------------------------------------------------------------- 1 | package SNMP::Utils; 2 | 3 | use strict; 4 | 5 | { 6 | sub get_indices { 7 | my $oids = shift; 8 | my $entry = shift; 9 | my $numindices = shift; 10 | # find all oids beginning with $entry 11 | # then skip one field for the sequence 12 | # then read the next numindices fields 13 | my $entrypat = $entry; 14 | $entrypat =~ s/\./\\\./g; 15 | my @indices = map { 16 | /^$entrypat\.\d+\.(.*)/ && $1; 17 | } grep { 18 | /^$entrypat/ 19 | } keys %{$oids}; 20 | my %seen = (); 21 | my @o = map {[split /\./]} sort grep !$seen{$_}++, @indices; 22 | return @o; 23 | } 24 | 25 | sub get_size { 26 | my $oids = shift; 27 | my $entry = shift; 28 | my $entrypat = $entry; 29 | $entrypat =~ s/\./\\\./g; 30 | my @entries = grep { 31 | /^$entrypat/ 32 | } keys %{$oids}; 33 | return scalar(@entries); 34 | } 35 | 36 | sub get_object { 37 | my $oids = shift; 38 | my $object = shift; 39 | my @indices = @_; 40 | #my $oid = $object.'.'.join('.', @indices); 41 | my $oid = $object; 42 | $oid .= '.'.join('.', @indices) if (@indices); 43 | return $oids->{$oid}; 44 | } 45 | 46 | sub get_object_value { 47 | my $oids = shift; 48 | my $object = shift; 49 | my $values = shift; 50 | my @indices = @_; 51 | my $key = get_object($oids, $object, @indices); 52 | if (defined $key) { 53 | return $values->{$key}; 54 | } else { 55 | return undef; 56 | } 57 | } 58 | 59 | #SNMP::Utils::counter([$idxs1, $idxs2], $idx1, $idx2), 60 | # this flattens a n-dimensional array and returns the absolute position 61 | # of the element at position idx1,idx2,...,idxn 62 | # element 1,2 in table 0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2 is at pos 6 63 | sub get_number { 64 | my $indexlists = shift; #, zeiger auf array aus [1, 2] 65 | my @element = @_; 66 | my $dimensions = scalar(@{$indexlists->[0]}); 67 | my @sorted = (); 68 | my $number = 0; 69 | if ($dimensions == 1) { 70 | @sorted = 71 | sort { $a->[0] <=> $b->[0] } @{$indexlists}; 72 | } elsif ($dimensions == 2) { 73 | @sorted = 74 | sort { $a->[0] <=> $b->[0] || $a->[1] <=> $b->[1] } @{$indexlists}; 75 | } elsif ($dimensions == 3) { 76 | @sorted = 77 | sort { $a->[0] <=> $b->[0] || 78 | $a->[1] <=> $b->[1] || 79 | $a->[2] <=> $b->[2] } @{$indexlists}; 80 | } 81 | foreach (@sorted) { 82 | if ($dimensions == 1) { 83 | if ($_->[0] == $element[0]) { 84 | last; 85 | } 86 | } elsif ($dimensions == 2) { 87 | if ($_->[0] == $element[0] && $_->[1] == $element[1]) { 88 | last; 89 | } 90 | } elsif ($dimensions == 3) { 91 | if ($_->[0] == $element[0] && 92 | $_->[1] == $element[1] && 93 | $_->[2] == $element[2]) { 94 | last; 95 | } 96 | } 97 | $number++; 98 | } 99 | return ++$number; 100 | } 101 | 102 | } 103 | 104 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Storage/Component.pm: -------------------------------------------------------------------------------- 1 | package HP::Storage::Component; 2 | our @ISA = qw(HP::Storage); 3 | 4 | 1; 5 | 6 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Storage/Component/CpuSubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::Storage::Component::CpuSubsystem; 2 | our @ISA = qw(HP::Storage::Component); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | ################################## scrapiron ########## 10 | my %params = @_; 11 | my $self = { 12 | runtime => $params{runtime}, 13 | rawdata => $params{rawdata}, 14 | method => $params{method}, 15 | condition => $params{condition}, 16 | status => $params{status}, 17 | cpus => [], 18 | blacklisted => 0, 19 | info => undef, 20 | extendedinfo => undef, 21 | }; 22 | bless $self, $class; 23 | if ($self->{method} eq 'snmp') { 24 | return HP::Storage::Component::CpuSubsystem::SNMP->new(%params); 25 | } elsif ($self->{method} eq 'cli') { 26 | return HP::Storage::Component::CpuSubsystem::CLI->new(%params); 27 | } else { 28 | die "unknown method"; 29 | } 30 | return $self; 31 | } 32 | 33 | sub check { 34 | my $self = shift; 35 | my $errorfound = 0; 36 | if (scalar (@{$self->{cpus}}) == 0) { 37 | # sachen gibts..... 38 | # $self->overall_check(); # sowas ist mir nur einmal untergekommen 39 | } else { 40 | foreach (@{$self->{cpus}}) { 41 | $_->check(); 42 | } 43 | } 44 | } 45 | 46 | sub dump { 47 | my $self = shift; 48 | foreach (@{$self->{cpus}}) { 49 | $_->dump(); 50 | } 51 | } 52 | 53 | 54 | package HP::Storage::Component::CpuSubsystem::Cpu; 55 | our @ISA = qw(HP::Storage::Component::CpuSubsystem); 56 | 57 | use strict; 58 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 59 | 60 | sub new { 61 | my $class = shift; 62 | my %params = @_; 63 | my $self = { 64 | runtime => $params{runtime}, 65 | name => $params{name}, 66 | status => $params{status}, 67 | blacklisted => 0, 68 | info => undef, 69 | extendedinfo => undef, 70 | }; 71 | bless $self, $class; 72 | return $self; 73 | } 74 | 75 | sub check { 76 | my $self = shift; 77 | if ($self->{status} ne "ok") { 78 | if ($self->{runtime}->{options}{scrapiron} && 79 | ($self->{status} eq "unknown")) { 80 | $self->add_info(sprintf "cpu #%d probably ok (%s)", 81 | $self->{name}, $self->{status}); 82 | } else { 83 | $self->add_info(sprintf "cpu #%d needs attention (%s)", 84 | $self->{name}, $self->{status}); 85 | $self->add_message(CRITICAL, $self->{info}); 86 | } 87 | } else { 88 | $self->add_info(sprintf "cpu #%d is %s", $self->{name}, $self->{status}); 89 | } 90 | $self->add_extendedinfo(sprintf "cpu_%s=%s", 91 | $self->{name}, $self->{status}); 92 | } 93 | 94 | sub dump { 95 | my $self = shift; 96 | printf "[CPU_%s]\n", $self->{name}; 97 | printf "name: %s\n", $self->{name}; 98 | printf "status: %s\n", $self->{status}; 99 | printf "blacklisted: %s\n", $self->{blacklisted}; 100 | printf "scrapiron: %s\n", $self->{runtime}->{options}->{scrapiron}; 101 | printf "info: %s\n\n", $self->{info}; 102 | } 103 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Storage/Component/CpuSubsystem/CLI.pm: -------------------------------------------------------------------------------- 1 | package HP::Storage::Component::CpuSubsystem::CLI; 2 | our @ISA = qw(HP::Storage::Component::CpuSubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | cpus => [], 14 | blacklisted => 0, 15 | info => undef, 16 | extendedinfo => undef, 17 | }; 18 | bless $self, $class; 19 | $self->init(%params); 20 | return $self; 21 | } 22 | 23 | sub init { 24 | my $self = shift; 25 | my %params = @_; 26 | my %tmpcpu = ( 27 | runtime => $params{runtime}, 28 | ); 29 | my $inblock = 0; 30 | foreach (grep(/^server/, split(/\n/, $self->{rawdata}))) { 31 | if (/Processor:\s+(\d+)/) { 32 | $tmpcpu{name} = $1; 33 | $inblock = 1; 34 | } elsif (/Status\s*:\s+(.+?)\s*$/) { 35 | $tmpcpu{status} = lc $1; 36 | } elsif (/^server\s*$/) { 37 | if ($inblock) { 38 | $inblock = 0; 39 | push(@{$self->{cpus}}, 40 | HP::Storage::Component::CpuSubsystem::Cpu->new(%tmpcpu)); 41 | %tmpcpu = ( 42 | runtime => $params{runtime}, 43 | ); 44 | } 45 | } 46 | } 47 | if ($inblock) { 48 | push(@{$self->{cpus}}, 49 | HP::Storage::Component::CpuSubsystem::Cpu->new(%tmpcpu)); 50 | } 51 | } 52 | 53 | 1; 54 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Storage/Component/CpuSubsystem/SNMP.pm: -------------------------------------------------------------------------------- 1 | package HP::Storage::Component::CpuSubsystem::SNMP; 2 | our @ISA = qw(HP::Storage::Component::CpuSubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | cpus => [], 14 | blacklisted => 0, 15 | info => undef, 16 | extendedinfo => undef, 17 | }; 18 | bless $self, $class; 19 | $self->init(); 20 | return $self; 21 | } 22 | 23 | sub init { 24 | my $self = shift; 25 | my $snmpwalk = $self->{rawdata}; 26 | # CPQSTDEQ-MIB 27 | my $cpqSeCpuEntry = "1.3.6.1.4.1.232.1.2.2.1.1"; 28 | my $cpqSeCpuUnitIndex = "1.3.6.1.4.1.232.1.2.2.1.1.1"; 29 | my $cpqSeCpuName = "1.3.6.1.4.1.232.1.2.2.1.1.3"; 30 | my $cpqSeCpuStatus = "1.3.6.1.4.1.232.1.2.2.1.1.6"; 31 | my $cpqSeCpuStatusValues = { 32 | 1 => "unknown", 33 | 2 => "ok", 34 | 3 => "degraded", 35 | 4 => "failed", 36 | 5 => "disabled", 37 | }; 38 | 39 | # INDEX { cpqSeCpuUnitIndex } 40 | my @indexes = SNMP::Utils::get_indices($snmpwalk, $cpqSeCpuEntry); 41 | foreach (@indexes) { 42 | my $idx1 = $_->[0]; 43 | push(@{$self->{cpus}}, 44 | HP::Storage::Component::CpuSubsystem::Cpu->new( 45 | runtime => $self->{runtime}, 46 | name => 47 | SNMP::Utils::get_object($snmpwalk, $cpqSeCpuUnitIndex, $idx1), 48 | status => 49 | lc SNMP::Utils::get_object_value( 50 | $snmpwalk, $cpqSeCpuStatus, 51 | $cpqSeCpuStatusValues, 52 | $idx1), 53 | )); 54 | } 55 | } 56 | 57 | 1; 58 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Storage/Component/DiskSubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::Storage::Component::DiskSubsystem; 2 | our @ISA = qw(HP::Storage::Component); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | method => $params{method}, 14 | da_subsystem => undef, 15 | sas_da_subsystem => undef, 16 | ide_da_subsystem => undef, 17 | fca_da_subsystem => undef, 18 | ss_da_subsystem => undef, 19 | condition => $params{condition}, 20 | blacklisted => 0, 21 | }; 22 | bless $self, $class; 23 | $self->init(); 24 | return $self; 25 | } 26 | 27 | sub init { 28 | my $self = shift; 29 | $self->{da_subsystem} = HP::Storage::Component::DiskSubsystem::Da->new( 30 | runtime => $self->{runtime}, 31 | rawdata => $self->{rawdata}, 32 | method => $self->{method}, 33 | ); 34 | } 35 | 36 | sub check { 37 | my $self = shift; 38 | $self->{da_subsystem}->check(); 39 | } 40 | 41 | sub dump { 42 | my $self = shift; 43 | $self->{da_subsystem}->dump(); 44 | } 45 | 46 | 47 | 1; 48 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Storage/Component/DiskSubsystem/Da.pm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lausser/check_hpasm/1844da14a235b9b0ba89abc4b2f9c21033862b06/plugins-scripts/HP/Storage/Component/DiskSubsystem/Da.pm -------------------------------------------------------------------------------- /plugins-scripts/HP/Storage/Component/DiskSubsystem/Da/CLI.pm: -------------------------------------------------------------------------------- 1 | package HP::Storage::Component::DiskSubsystem::Da::CLI; 2 | our @ISA = qw(HP::Storage::Component::DiskSubsystem::Da); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | controllers => [], 12 | accelerators => [], 13 | physical_drives => [], 14 | logical_drives => [], 15 | spare_drives => [], 16 | blacklisted => 0, 17 | }; 18 | bless $self, $class; 19 | return $self; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Storage/Component/FanSubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::Storage::Component::FanSubsystem; 2 | our @ISA = qw(HP::Storage::Component); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | ################################## fan_redundancy ########## 10 | my %params = @_; 11 | my $self = { 12 | runtime => $params{runtime}, 13 | rawdata => $params{rawdata}, 14 | method => $params{method}, 15 | condition => $params{condition}, 16 | status => $params{status}, 17 | blacklisted => 0, 18 | info => undef, 19 | extendedinfo => undef, 20 | }; 21 | bless $self, $class; 22 | if ($self->{method} eq 'snmp') { 23 | return HP::Storage::Component::FanSubsystem::SNMP->new(%params); 24 | } elsif ($self->{method} eq 'cli') { 25 | return HP::Storage::Component::FanSubsystem::CLI->new(%params); 26 | } else { 27 | die "unknown method"; 28 | } 29 | return $self; 30 | } 31 | 32 | sub check { 33 | my $self = shift; 34 | my $errorfound = 0; 35 | if (scalar (@{$self->{fans}}) == 0) { 36 | $self->overall_check(); # sowas ist mir nur einmal untergekommen 37 | # die maschine hatte alles in allem nur 2 oids (cpqHeFltTolFanChassis) 38 | # SNMPv2-SMI::enterprises.232.6.2.6.7.1.1.0.1 = INTEGER: 0 39 | # SNMPv2-SMI::enterprises.232.6.2.6.7.1.1.0.2 = INTEGER: 0 40 | } else { 41 | foreach (@{$self->{fans}}) { 42 | $_->check(); 43 | } 44 | } 45 | } 46 | 47 | sub dump { 48 | my $self = shift; 49 | foreach (@{$self->{fans}}) { 50 | $_->dump(); 51 | } 52 | } 53 | 54 | package HP::Storage::Component::FanSubsystem::Fan; 55 | our @ISA = qw(HP::Storage::Component::FanSubsystem); 56 | 57 | use strict; 58 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 59 | 60 | sub new { 61 | my $class = shift; 62 | my %params = @_; 63 | if (exists $params{redundant}) { 64 | return HP::Storage::Component::FanSubsystem::Fan::FTol->new(%params); 65 | } else { 66 | return HP::Storage::Component::FanSubsystem::Fan::Thermal->new(%params); 67 | } 68 | } 69 | 70 | 71 | package HP::Storage::Component::FanSubsystem::Fan::FTol; 72 | our @ISA = qw(HP::Storage::Component::FanSubsystem::Fan); 73 | 74 | 75 | use strict; 76 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 77 | 78 | sub new { 79 | my $class = shift; 80 | my %params = @_; 81 | my $self = { 82 | runtime => $params{runtime}, 83 | name => $params{name}, 84 | location => $params{location}, 85 | present => $params{present}, 86 | speed => $params{speed}, 87 | pctmax => $params{pctmax}, 88 | redundant => $params{redundant}, # n/a koennte other bedeuten 89 | condition => $params{condition}, 90 | partner => $params{partner}, 91 | blacklisted => 0, 92 | info => undef, 93 | extendedinfo => undef, 94 | }; 95 | bless $self, $class; 96 | return $self; 97 | } 98 | 99 | sub check { 100 | my $self = shift; 101 | $self->add_info(sprintf "fan #%d is %s, speed is %s, pctmax is %s%%, ". 102 | "location is %s, redundance is %s, partner is %s", 103 | $self->{name}, $self->{present}, $self->{speed}, $self->{pctmax}, 104 | $self->{location}, $self->{redundant}, $self->{partner}); 105 | $self->add_extendedinfo(sprintf "fan_%s=%d%%", 106 | $self->{name}, $self->{pctmax}); 107 | if ($self->{present} eq "present") { 108 | if ($self->{speed} eq "high") { 109 | $self->add_info(sprintf "fan #%d (%s) runs at high speed", 110 | $self->{name}, $self->{location}); 111 | $self->add_message(CRITICAL, $self->{info}); 112 | } elsif ($self->{speed} ne "normal") { 113 | $self->add_info(sprintf "fan #%d (%s) needs attention", 114 | $self->{name}, $self->{location}); 115 | $self->add_message(CRITICAL, $self->{info}); 116 | } 117 | if ($self->{condition} eq "failed") { 118 | $self->add_info(sprintf "fan #%d (%s) failed", 119 | $self->{name}, $self->{location}); 120 | $self->add_message(CRITICAL, $self->{info}); 121 | } elsif ($self->{condition} eq "degraded") { 122 | $self->add_info(sprintf "fan #%d (%s) degraded", 123 | $self->{name}, $self->{location}); 124 | $self->add_message(WARNING, $self->{info}); 125 | } elsif ($self->{condition} ne "ok") { 126 | $self->add_info(sprintf "fan #%d (%s) is not ok", 127 | $self->{name}, $self->{location}); 128 | $self->add_message(WARNING, $self->{info}); 129 | } 130 | if ($self->{redundant} eq "redundant") { 131 | if ((! defined $self->{partner}) || ($self->{partner} eq "n/a")){ 132 | $self->add_info(sprintf "fan #%d (%s) is not redundant", 133 | $self->{name}, $self->{location}); 134 | $self->add_message(WARNING, $self->{info}); 135 | } 136 | } elsif ($self->{redundant} eq "notredundant") { 137 | if (! $self->{runtime}->{options}->{ignore_fan_redundancy}) { 138 | if (defined $self->{partner} && $self->{partner} ne "n/a") { 139 | $self->add_info(sprintf "fan #%d (%s) is not redundant", 140 | $self->{name}, $self->{location}); 141 | $self->add_message(WARNING, $self->{info}); 142 | } 143 | } 144 | } elsif ($self->{redundant} eq "n/a") { 145 | #seen on a dl320 g5p with bios from 2008. 146 | # maybe redundancy is not supported at all 147 | } 148 | } elsif ($self->{present} eq "failed") { # from cli 149 | $self->add_info(sprintf "fan #%d (%s) failed", 150 | $self->{name}, $self->{location}); 151 | $self->add_message(CRITICAL, $self->{info}); 152 | } elsif ($self->{present} eq "absent") { 153 | $self->add_info(sprintf "fan #%d (%s) needs attention (is absent)", 154 | $self->{name}, $self->{location}); 155 | # weiss nicht, ob absent auch kaputt bedeuten kann 156 | # wenn nicht, dann wuerde man sich hier dumm und daemlich blacklisten 157 | #$self->add_message(CRITICAL, $self->{info}); 158 | $self->add_message(WARNING, $self->{info}); 159 | } 160 | if ($self->{runtime}->{options}->{perfdata}) { 161 | $self->{runtime}->{plugin}->add_perfdata( 162 | label => sprintf('fan_%s', $self->{name}), 163 | value => $self->{pctmax}, 164 | uom => "%", 165 | ); 166 | } 167 | } 168 | 169 | sub dump { 170 | my $self = shift; 171 | printf "[FAN_%s]\n", $self->{name}; 172 | foreach (qw(name location present speed pctmax redundant condition 173 | partner blacklisted info)) { 174 | printf "%s: %s\n", $_, $self->{$_}; 175 | } 176 | printf "\n"; 177 | } 178 | 179 | 180 | package HP::Storage::Component::FanSubsystem::Fan::Thermal; 181 | our @ISA = qw(HP::Storage::Component::FanSubsystem::Fan); 182 | 183 | use strict; 184 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 185 | 186 | sub new { 187 | my $class = shift; 188 | my %params = @_; 189 | my $self = { 190 | runtime => $params{runtime}, 191 | name => $params{name}, 192 | location => $params{location}, 193 | present => $params{present}, 194 | speed => $params{speed}, 195 | pctmax => $params{pctmax}, 196 | redundant => $params{redundant}, # n/a koennte other bedeuten 197 | condition => $params{condition}, 198 | partner => $params{partner}, 199 | blacklisted => 0, 200 | info => undef, 201 | extendedinfo => undef, 202 | }; 203 | bless $self, $class; 204 | return $self; 205 | } 206 | 207 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Storage/Component/FanSubsystem/CLI.pm: -------------------------------------------------------------------------------- 1 | package HP::Storage::Component::FanSubsystem::CLI; 2 | our @ISA = qw(HP::Storage::Component::FanSubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | fans => [], 14 | blacklisted => 0, 15 | info => undef, 16 | extendedinfo => undef, 17 | }; 18 | bless $self, $class; 19 | $self->init(%params); 20 | return $self; 21 | } 22 | 23 | sub init { 24 | my $self = shift; 25 | my %params = @_; 26 | my %tmpfan = (); 27 | foreach (grep(/^fans/, split(/\n/, $self->{rawdata}))) { 28 | s/^fans //g; 29 | if (/^#(\d+)\s+([\w#_\/\-]+)\s+(\w+)\s+(\w+)\s+(FAILED|[N\/A\d]+)%*\s+([\w\/]+)\s+(FAILED|[N\/A\d]+)/) { 30 | %tmpfan = ( 31 | name => $1, 32 | location => lc $2, 33 | present => lc $3, 34 | speed => lc $4, 35 | pctmax => lc $5, # (FAILED|[N\/A\d]+) 36 | redundant => lc $6, 37 | partner => lc $7, # (FAILED|[N\/A\d]+) 38 | runtime => $params{runtime}, 39 | ); 40 | } elsif (/^#(\d+)\s+([\w#_\/\-]+?)(Yes|No|N\/A)\s+(\w+)\s+(FAILED|[N\/A\d]+)%*\s+([\w\/]+)\s+(FAILED|[N\/A\d]+)/) { 41 | # #5 SCSI_BACKPLANE_ZONEYes NORMAL N/A .... 42 | %tmpfan = ( 43 | name => $1, 44 | location => lc $2, 45 | present => lc $3, 46 | speed => lc $4, 47 | pctmax => lc $5, 48 | redundant => lc $6, 49 | partner => lc $7, 50 | runtime => $params{runtime}, 51 | ); 52 | } elsif (/^#(\d+)\s+([\w#_\/\-]+)\s+[NOno]+\s/) { 53 | # Fan is not installed. #2 CPU#2 No - - No N/A - 54 | } elsif (/^#(\d+)/) { 55 | main::contact_author("FAN", $_); 56 | } 57 | if (%tmpfan) { 58 | if ($tmpfan{pctmax} !~ /^\d+$/) { 59 | if ($tmpfan{speed} eq 'normal') { 60 | $tmpfan{pctmax} = 50; 61 | } elsif ($tmpfan{speed} eq 'high') { 62 | $tmpfan{pctmax} = 100; 63 | } else { 64 | $tmpfan{pctmax} = 0; 65 | } 66 | } 67 | if($tmpfan{speed} eq 'failed') { 68 | $tmpfan{condition} = 'failed'; 69 | } elsif($tmpfan{speed} eq 'n/a') { 70 | $tmpfan{condition} = 'other'; 71 | } else { 72 | $tmpfan{condition} = 'ok'; 73 | } 74 | $tmpfan{redundant} = $tmpfan{redundant} eq 'yes' ? 'redundant' : 75 | $tmpfan{redundant} eq 'no' ? 'notredundant' : 'other'; 76 | $tmpfan{present} = $tmpfan{present} eq 'yes' ? 'present' : 77 | $tmpfan{present} eq 'failed' ? 'present' : 78 | $tmpfan{present} eq 'no' ? 'notpresent' : 'other'; 79 | push(@{$self->{fans}}, 80 | HP::Storage::Component::FanSubsystem::Fan->new(%tmpfan)); 81 | %tmpfan = (); 82 | } 83 | } 84 | } 85 | 86 | sub overall_check { 87 | my $self = shift; 88 | # nix. nur wegen der gleichheit mit snmp 89 | } 90 | 1; 91 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Storage/Component/MemorySubsystem.pm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lausser/check_hpasm/1844da14a235b9b0ba89abc4b2f9c21033862b06/plugins-scripts/HP/Storage/Component/MemorySubsystem.pm -------------------------------------------------------------------------------- /plugins-scripts/HP/Storage/Component/MemorySubsystem/CLI.pm: -------------------------------------------------------------------------------- 1 | package HP::Storage::Component::MemorySubsystem::CLI; 2 | our @ISA = qw(HP::Storage::Component::MemorySubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | dimms => [], 14 | blacklisted => 0, 15 | info => undef, 16 | extendedinfo => undef, 17 | }; 18 | bless $self, $class; 19 | $self->init(%params); 20 | return $self; 21 | } 22 | 23 | sub init { 24 | my $self = shift; 25 | my %params = @_; 26 | $self->{dimms} = []; 27 | my %tmpdimm = ( 28 | runtime => $params{runtime}, 29 | ); 30 | my $inblock = 0; 31 | foreach (grep(/^dimm/, split(/\n/, $self->{rawdata}))) { 32 | s/^dimm\s*$//g; 33 | if (/Cartridge #:\s+(\d+)/) { 34 | $tmpdimm{cartridge} = $1; 35 | $tmpdimm{board} = $1; 36 | $inblock = 1; 37 | } elsif (/Module #:\s+(\d+)/) { 38 | $tmpdimm{module} = $1; 39 | } elsif (/Present:\s+(\w+)/) { 40 | $tmpdimm{status} = lc $1 eq 'yes' ? 'present' : 41 | lc $1 eq 'no' ? 'notpresent' : 'other'; 42 | } elsif (/Status:\s+(.+?)\s*$/) { 43 | $tmpdimm{condition} = lc $1 =~ /degraded/ ? 'degraded' : 44 | lc $1 eq 'ok' ? 'ok' : lc $1 =~ /n\/a/ ? 'n/a' : 'other'; 45 | } elsif (/Size:\s+(\d+)\s*(.+?)\s*$/) { 46 | $tmpdimm{size} = $1 * (lc $2 eq 'mb' ? 1024*1024 : 47 | lc $2 eq 'gb' ? 1024*1024*1024 : 1); 48 | } elsif (/^\s*$/) { 49 | if ($inblock) { 50 | $inblock = 0; 51 | push(@{$self->{dimms}}, 52 | HP::Storage::Component::MemorySubsystem::Dimm->new(%tmpdimm)); 53 | %tmpdimm = ( 54 | runtime => $params{runtime}, 55 | ); 56 | } 57 | } 58 | } 59 | if ($inblock) { 60 | push(@{$self->{dimms}}, 61 | HP::Storage::Component::MemorySubsystem::Dimm->new(%tmpdimm)); 62 | } 63 | } 64 | 65 | sub is_faulty { 66 | my $self = shift; 67 | return 0; # cli hat so einen globalen status nicht 68 | } 69 | 70 | 1; 71 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Storage/Component/Powersupply.pm: -------------------------------------------------------------------------------- 1 | package HP::Storage::Component::Powersupply; 2 | our @ISA = qw(HP::Storage::Component); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | { 8 | our @powersupplies = (); 9 | 10 | sub get_components { 11 | return @powersupplies; 12 | } 13 | 14 | sub init { 15 | my %params = @_; 16 | if ($params{method} eq 'snmp') { 17 | HP::Storage::Component::Powersupply::SNMP::init(%params); 18 | } else { 19 | HP::Storage::Component::Powersupply::CLI::init(%params); 20 | } 21 | } 22 | 23 | } 24 | 25 | sub new { 26 | my $class = shift; 27 | my %params = @_; 28 | my $self = { 29 | runtime => $params{runtime}, 30 | name => $params{name}, 31 | present => $params{present}, 32 | redundant => $params{redundant}, 33 | condition => $params{condition}, 34 | blacklisted => 0, 35 | info => undef, 36 | extendexinfo => undef, 37 | }; 38 | bless $self, $class; 39 | return $self; 40 | } 41 | 42 | sub check { 43 | my $self = shift; 44 | if ($self->{present} eq "present") { 45 | if ($self->{condition} ne "ok") { 46 | if ($self->{condition} eq "n/a") { 47 | $self->add_info(sprintf "powersupply #%d is missing", $self->{name}); 48 | } else { 49 | $self->add_info(sprintf "powersupply #%d needs attention (%s)", 50 | $self->{name}, $self->{condition}); 51 | } 52 | $self->add_message(CRITICAL, $self->{info}); 53 | } else { 54 | $self->add_info(sprintf "powersupply #%d is %s", 55 | $self->{name}, $self->{condition}); 56 | } 57 | $self->add_extendedinfo(sprintf "ps_%s=%s", 58 | $self->{name}, $self->{condition}); 59 | } else { 60 | $self->add_info(sprintf "powersupply #%d is %s", 61 | $self->{name}, $self->{present}); 62 | $self->add_extendedinfo(sprintf "ps_%s=%s", 63 | $self->{name}, $self->{present}); 64 | } 65 | } 66 | 67 | 68 | sub dump { 69 | my $self = shift; 70 | printf "[PS_%s]\n", $self->{name}; 71 | printf "name: %s\n", $self->{name}; 72 | printf "present: %s\n", $self->{present}; 73 | printf "redundant: %s\n", $self->{redundant}; 74 | printf "condition: %s\n", $self->{condition}; 75 | printf "blacklisted: %s\n", $self->{blacklisted}; 76 | printf "info: %s\n\n", $self->{info}; 77 | } 78 | 79 | 80 | package HP::Storage::Component::Powersupply::CLI; 81 | our @ISA = qw(HP::Storage::Component::Powersupply); 82 | 83 | use strict; 84 | 85 | { 86 | sub init { 87 | my %params = @_; 88 | my %tmpps = ( 89 | runtime => $params{runtime}, 90 | ); 91 | my $inblock = 0; 92 | foreach (grep(/^powersupply/, split(/\n/, $params{rawdata}))) { 93 | s/^powersupply //g; 94 | if (/^Power supply #(\d+)/) { 95 | $tmpps{name} = $1; 96 | $inblock = 1; 97 | } elsif (/\s*Present\s+:\s+(\w+)/) { 98 | $tmpps{present} = lc $1 eq 'yes' ? 'present' : 99 | lc $1 eq 'no' ? 'absent': 'other'; 100 | } elsif (/\s*Redundant\s*:\s+(\w+)/) { 101 | $tmpps{redundant} = lc $1 eq 'yes' ? 'redundant' : 102 | lc $1 eq 'no' ? 'notredundant' : 'other'; 103 | } elsif (/\s*Condition\s*:\s+(\w+)/) { 104 | $tmpps{condition} = lc $1; 105 | } elsif (/\s*Power Supply not present/) { 106 | $tmpps{present} = "absent"; 107 | $tmpps{condition} = "n/a"; 108 | $tmpps{redundant} = "no"; 109 | } elsif (/^\s*$/) { 110 | if ($inblock) { 111 | $inblock = 0; 112 | push(@HP::Storage::Component::Powersupply::powersupplies, 113 | HP::Storage::Component::Powersupply->new(%tmpps)); 114 | %tmpps = ( 115 | runtime => $params{runtime}, 116 | ); 117 | } 118 | } 119 | } 120 | if ($inblock) { 121 | push(@HP::Storage::Component::Powersupply::powersupplies, 122 | HP::Storage::Component::Powersupply->new(%tmpps)); 123 | %tmpps = ( 124 | runtime => $params{runtime}, 125 | ); 126 | } 127 | } 128 | } 129 | 130 | package HP::Storage::Component::Powersupply::SNMP; 131 | our @ISA = qw(HP::Storage::Component::Powersupply); 132 | 133 | use strict; 134 | 135 | { 136 | sub init { 137 | my %params = @_; 138 | my $snmpwalk = $params{rawdata}; 139 | my $cpqHeFltTolPowerSupplyEntry = "1.3.6.1.4.1.232.6.2.9.3.1"; 140 | my $cpqHeFltTolPowerSupplyChassis = "1.3.6.1.4.1.232.6.2.9.3.1.1"; 141 | my $cpqHeFltTolPowerSupplyBay = "1.3.6.1.4.1.232.6.2.9.3.1.2"; 142 | my $cpqHeFltTolPowerSupplyPresent = "1.3.6.1.4.1.232.6.2.9.3.1.3"; 143 | my $cpqHeFltTolPowerSupplyCondition = "1.3.6.1.4.1.232.6.2.9.3.1.4"; 144 | my $cpqHeFltTolPowerSupplyRedundant = "1.3.6.1.4.1.232.6.2.9.3.1.9"; 145 | my $cpqSeCpuStatus = "1.3.6.1.4.1.232.1.2.2.1.1.6"; 146 | my $cpqHeFltTolPowerSupplyPresentValues = { 147 | 1 => "other", 148 | 2 => "absent", 149 | 3 => "present", 150 | }; 151 | my $cpqHeFltTolPowerSupplyConditionValues = { 152 | 1 => "other", 153 | 2 => "ok", 154 | 3 => "degraded", 155 | 4 => "failed", 156 | }; 157 | my $cpqHeFltTolPowerSupplyRedundantValues = { 158 | 1 => "other", 159 | 2 => "notRedundant", 160 | 3 => "redundant", 161 | }; 162 | 163 | # INDEX { cpqHeFltTolPowerSupplyChassis, cpqHeFltTolPowerSupplyBay } 164 | my @indexes = 165 | SNMP::Utils::get_indices($snmpwalk, $cpqHeFltTolPowerSupplyEntry); 166 | foreach (@indexes) { 167 | my($idx1, $idx2) = ($_->[0], $_->[1]); 168 | push(@HP::Storage::Component::Powersupply::powersupplies, 169 | HP::Storage::Component::Powersupply->new( 170 | runtime => $params{runtime}, 171 | name => 172 | SNMP::Utils::get_number(\@indexes, $idx1, $idx2), 173 | present => 174 | lc SNMP::Utils::get_object_value( 175 | $snmpwalk, $cpqHeFltTolPowerSupplyPresent, 176 | $cpqHeFltTolPowerSupplyPresentValues, 177 | $idx1, $idx2), 178 | condition => 179 | lc SNMP::Utils::get_object_value( 180 | $snmpwalk, $cpqHeFltTolPowerSupplyCondition, 181 | $cpqHeFltTolPowerSupplyConditionValues, 182 | $idx1, $idx2), 183 | redundant => 184 | lc SNMP::Utils::get_object_value( 185 | $snmpwalk, $cpqHeFltTolPowerSupplyRedundant, 186 | $cpqHeFltTolPowerSupplyRedundantValues, 187 | $idx1, $idx2), 188 | )); 189 | } 190 | 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Storage/Component/PowersupplySubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::Storage::Component::PowersupplySubsystem; 2 | our @ISA = qw(HP::Storage::Component); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | ################################## fan_redundancy ########## 10 | my %params = @_; 11 | my $self = { 12 | runtime => $params{runtime}, 13 | rawdata => $params{rawdata}, 14 | method => $params{method}, 15 | condition => $params{condition}, 16 | status => $params{status}, 17 | powersupplies => [], 18 | blacklisted => 0, 19 | info => undef, 20 | extendedinfo => undef, 21 | }; 22 | bless $self, $class; 23 | if ($self->{method} eq 'snmp') { 24 | return HP::Storage::Component::PowersupplySubsystem::SNMP->new(%params); 25 | } elsif ($self->{method} eq 'cli') { 26 | return HP::Storage::Component::PowersupplySubsystem::CLI->new(%params); 27 | } else { 28 | die "unknown method"; 29 | } 30 | return $self; 31 | } 32 | 33 | sub check { 34 | my $self = shift; 35 | my $errorfound = 0; 36 | if (scalar (@{$self->{powersupplies}}) == 0) { 37 | #$self->overall_check(); 38 | } else { 39 | foreach (@{$self->{powersupplies}}) { 40 | $_->check(); 41 | } 42 | } 43 | } 44 | 45 | sub dump { 46 | my $self = shift; 47 | foreach (@{$self->{powersupplies}}) { 48 | $_->dump(); 49 | } 50 | } 51 | 52 | 53 | package HP::Storage::Component::PowersupplySubsystem::Powersupply; 54 | our @ISA = qw(HP::Storage::Component::PowersupplySubsystem); 55 | 56 | use strict; 57 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 58 | 59 | sub new { 60 | my $class = shift; 61 | my %params = @_; 62 | my $self = { 63 | runtime => $params{runtime}, 64 | name => $params{name}, 65 | present => $params{present}, 66 | redundant => $params{redundant}, 67 | condition => $params{condition}, 68 | blacklisted => 0, 69 | info => undef, 70 | extendexinfo => undef, 71 | }; 72 | bless $self, $class; 73 | return $self; 74 | } 75 | 76 | sub check { 77 | my $self = shift; 78 | if ($self->{present} eq "present") { 79 | if ($self->{condition} ne "ok") { 80 | if ($self->{condition} eq "n/a") { 81 | $self->add_info(sprintf "powersupply #%d is missing", $self->{name}); 82 | } else { 83 | $self->add_info(sprintf "powersupply #%d needs attention (%s)", 84 | $self->{name}, $self->{condition}); 85 | } 86 | $self->add_message(CRITICAL, $self->{info}); 87 | } else { 88 | $self->add_info(sprintf "powersupply #%d is %s", 89 | $self->{name}, $self->{condition}); 90 | } 91 | $self->add_extendedinfo(sprintf "ps_%s=%s", 92 | $self->{name}, $self->{condition}); 93 | } else { 94 | $self->add_info(sprintf "powersupply #%d is %s", 95 | $self->{name}, $self->{present}); 96 | $self->add_extendedinfo(sprintf "ps_%s=%s", 97 | $self->{name}, $self->{present}); 98 | } 99 | } 100 | 101 | 102 | sub dump { 103 | my $self = shift; 104 | printf "[PS_%s]\n", $self->{name}; 105 | printf "name: %s\n", $self->{name}; 106 | printf "present: %s\n", $self->{present}; 107 | printf "redundant: %s\n", $self->{redundant}; 108 | printf "condition: %s\n", $self->{condition}; 109 | printf "blacklisted: %s\n", $self->{blacklisted}; 110 | printf "info: %s\n\n", $self->{info}; 111 | } 112 | 113 | 1; 114 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Storage/Component/PowersupplySubsystem/CLI.pm: -------------------------------------------------------------------------------- 1 | package HP::Storage::Component::PowersupplySubsystem::CLI; 2 | our @ISA = qw(HP::Storage::Component::PowersupplySubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | powersupplies => [], 14 | blacklisted => 0, 15 | info => undef, 16 | extendedinfo => undef, 17 | }; 18 | bless $self, $class; 19 | $self->init(%params); 20 | return $self; 21 | } 22 | 23 | sub init { 24 | my $self = shift; 25 | my %params = @_; 26 | my %tmpps = ( 27 | runtime => $self->{runtime}, 28 | ); 29 | my $inblock = 0; 30 | foreach (grep(/^powersupply/, split(/\n/, $self->{rawdata}))) { 31 | s/^powersupply\s*//g; 32 | if (/^Power supply #(\d+)/) { 33 | $tmpps{name} = $1; 34 | $inblock = 1; 35 | } elsif (/\s*Present\s+:\s+(\w+)/) { 36 | $tmpps{present} = lc $1 eq 'yes' ? 'present' : 37 | lc $1 eq 'no' ? 'absent': 'other'; 38 | } elsif (/\s*Redundant\s*:\s+(\w+)/) { 39 | $tmpps{redundant} = lc $1 eq 'yes' ? 'redundant' : 40 | lc $1 eq 'no' ? 'notredundant' : 'other'; 41 | } elsif (/\s*Condition\s*:\s+(\w+)/) { 42 | $tmpps{condition} = lc $1; 43 | } elsif (/\s*Power Supply not present/) { 44 | $tmpps{present} = "absent"; 45 | $tmpps{condition} = "n/a"; 46 | $tmpps{redundant} = "no"; 47 | } elsif (/^\s*$/) { 48 | if ($inblock) { 49 | $inblock = 0; 50 | push(@{$self->{powersupplies}}, 51 | HP::Storage::Component::PowersupplySubsystem::Powersupply->new(%tmpps)); 52 | %tmpps = ( 53 | runtime => $self->{runtime}, 54 | ); 55 | } 56 | } 57 | } 58 | if ($inblock) { 59 | push(@{$self->{powersupplies}}, 60 | HP::Storage::Component::PowersupplySubsystem::Powersupply->new(%tmpps)); 61 | %tmpps = ( 62 | runtime => $params{runtime}, 63 | ); 64 | } 65 | } 66 | 67 | 1; 68 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Storage/Component/PowersupplySubsystem/SNMP.pm: -------------------------------------------------------------------------------- 1 | package HP::Storage::Component::PowersupplySubsystem::SNMP; 2 | our @ISA = qw(HP::Storage::Component::PowersupplySubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | powersupplies => [], 14 | blacklisted => 0, 15 | info => undef, 16 | extendedinfo => undef, 17 | }; 18 | bless $self, $class; 19 | $self->init(%params); 20 | return $self; 21 | } 22 | 23 | sub init { 24 | my $self = shift; 25 | my %params = @_; 26 | my $snmpwalk = $self->{rawdata}; 27 | my $cpqHeFltTolPowerSupplyEntry = "1.3.6.1.4.1.232.6.2.9.3.1"; 28 | my $cpqHeFltTolPowerSupplyChassis = "1.3.6.1.4.1.232.6.2.9.3.1.1"; 29 | my $cpqHeFltTolPowerSupplyBay = "1.3.6.1.4.1.232.6.2.9.3.1.2"; 30 | my $cpqHeFltTolPowerSupplyPresent = "1.3.6.1.4.1.232.6.2.9.3.1.3"; 31 | my $cpqHeFltTolPowerSupplyCondition = "1.3.6.1.4.1.232.6.2.9.3.1.4"; 32 | my $cpqHeFltTolPowerSupplyRedundant = "1.3.6.1.4.1.232.6.2.9.3.1.9"; 33 | my $cpqSeCpuStatus = "1.3.6.1.4.1.232.1.2.2.1.1.6"; 34 | my $cpqHeFltTolPowerSupplyPresentValues = { 35 | 1 => "other", 36 | 2 => "absent", 37 | 3 => "present", 38 | }; 39 | my $cpqHeFltTolPowerSupplyConditionValues = { 40 | 1 => "other", 41 | 2 => "ok", 42 | 3 => "degraded", 43 | 4 => "failed", 44 | }; 45 | my $cpqHeFltTolPowerSupplyRedundantValues = { 46 | 1 => "other", 47 | 2 => "notRedundant", 48 | 3 => "redundant", 49 | }; 50 | 51 | # INDEX { cpqHeFltTolPowerSupplyChassis, cpqHeFltTolPowerSupplyBay } 52 | my @indexes = 53 | SNMP::Utils::get_indices($snmpwalk, $cpqHeFltTolPowerSupplyEntry); 54 | foreach (@indexes) { 55 | my($idx1, $idx2) = ($_->[0], $_->[1]); 56 | push(@{$self->{powersupplies}}, 57 | HP::Storage::Component::PowersupplySubsystem::Powersupply->new( 58 | runtime => $params{runtime}, 59 | name => 60 | SNMP::Utils::get_number(\@indexes, $idx1, $idx2), 61 | present => 62 | lc SNMP::Utils::get_object_value( 63 | $snmpwalk, $cpqHeFltTolPowerSupplyPresent, 64 | $cpqHeFltTolPowerSupplyPresentValues, 65 | $idx1, $idx2), 66 | condition => 67 | lc SNMP::Utils::get_object_value( 68 | $snmpwalk, $cpqHeFltTolPowerSupplyCondition, 69 | $cpqHeFltTolPowerSupplyConditionValues, 70 | $idx1, $idx2), 71 | redundant => 72 | lc SNMP::Utils::get_object_value( 73 | $snmpwalk, $cpqHeFltTolPowerSupplyRedundant, 74 | $cpqHeFltTolPowerSupplyRedundantValues, 75 | $idx1, $idx2), 76 | )); 77 | } 78 | } 79 | 80 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Storage/Component/TemperatureSubsystem.pm: -------------------------------------------------------------------------------- 1 | package HP::Storage::Component::TemperatureSubsystem; 2 | our @ISA = qw(HP::Storage::Component); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | ################################## custom_thresholds 10 | my %params = @_; 11 | my $self = { 12 | runtime => $params{runtime}, 13 | rawdata => $params{rawdata}, 14 | method => $params{method}, 15 | condition => $params{condition}, 16 | status => $params{status}, 17 | temperatures => [], 18 | blacklisted => 0, 19 | info => undef, 20 | extendedinfo => undef, 21 | }; 22 | bless $self, $class; 23 | if ($params{runtime}->{options}->{customthresholds}) { 24 | if (-f $params{runtime}->{options}->{customthresholds}) { 25 | open CT, $params{runtime}->{options}->{customthresholds}; 26 | $params{runtime}->{options}->{customthresholds} = ; 27 | close CT; 28 | } 29 | foreach my $ct_items 30 | (split(/\//, $params{runtime}->{options}->{customthresholds})) { 31 | if ($ct_items =~ /^(\d+):(\d+)$/) { 32 | my $temp = $2; 33 | $params{runtime}->{options}->{thresholds}->{$1} = $temp; 34 | } else { 35 | die sprintf "invalid threshold %s", $ct_items; 36 | } 37 | } 38 | } 39 | if ($self->{method} eq 'snmp') { 40 | return HP::Storage::Component::TemperatureSubsystem::SNMP->new(%params); 41 | } elsif ($self->{method} eq 'cli') { 42 | return HP::Storage::Component::TemperatureSubsystem::CLI->new(%params); 43 | } else { 44 | die "unknown method"; 45 | } 46 | return $self; 47 | } 48 | 49 | sub check { 50 | my $self = shift; 51 | my $errorfound = 0; 52 | if (scalar (@{$self->{temperatures}}) == 0) { 53 | #$self->overall_check(); 54 | } else { 55 | foreach (@{$self->{temperatures}}) { 56 | $_->check(); 57 | } 58 | } 59 | } 60 | 61 | sub dump { 62 | my $self = shift; 63 | foreach (@{$self->{temperatures}}) { 64 | $_->dump(); 65 | } 66 | } 67 | 68 | 69 | package HP::Storage::Component::TemperatureSubsystem::Temperature; 70 | our @ISA = qw(HP::Storage::Component::TemperatureSubsystem); 71 | 72 | use strict; 73 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 74 | 75 | sub new { 76 | my $class = shift; 77 | my %params = @_; 78 | my $self = { 79 | runtime => $params{runtime}, 80 | name => $params{name}, 81 | location => $params{location}, 82 | degrees => $params{degrees}, 83 | threshold => $params{threshold}, 84 | blacklisted => 0, 85 | info => undef, 86 | extendedinfo => undef, 87 | }; 88 | bless $self, $class; 89 | return $self; 90 | } 91 | 92 | sub check { 93 | my $self = shift; 94 | if ($self->{degrees} > $self->{threshold}) { 95 | $self->add_info(sprintf "%s temperature too high (%d%s)", 96 | $self->{location}, $self->{degrees}, 97 | $self->{runtime}->{options}->{celsius} ? "C" : "F"); 98 | $self->add_message(CRITICAL, $self->{info}); 99 | } else { 100 | $self->add_info(sprintf "%d %s temperature is %d (%d max)", 101 | $self->{name}, $self->{location}, 102 | $self->{degrees}, $self->{threshold}); 103 | } 104 | if ($self->{runtime}->{options}->{perfdata} == 2) { 105 | $self->{runtime}->{plugin}->add_perfdata( 106 | label => sprintf('temp_%s', $self->{name}), 107 | value => $self->{degrees}, 108 | warning => $self->{threshold}, 109 | critical => $self->{threshold} 110 | ); 111 | } elsif ($self->{runtime}->{options}->{perfdata} == 1) { 112 | $self->{runtime}->{plugin}->add_perfdata( 113 | label => sprintf('temp_%s_%s', $self->{name}, $self->{location}), 114 | value => $self->{degrees}, 115 | warning => $self->{threshold}, 116 | critical => $self->{threshold} 117 | ); 118 | } 119 | $self->add_extendedinfo(sprintf "temp_%s=%d", 120 | $self->{name}, 121 | $self->{degrees}); 122 | } 123 | 124 | sub dump { 125 | my $self = shift; 126 | printf "[TEMP_%s]\n", $self->{name}; 127 | printf "name: %s\n", $self->{name}; 128 | printf "location: %s\n", $self->{location}; 129 | printf "degrees: %s%s\n", $self->{degrees}, 130 | $self->{runtime}->{options}->{celsius} ? 'C' : 'F'; 131 | printf "threshold: %s\n", $self->{threshold}; 132 | printf "blacklisted: %s\n", $self->{blacklisted}; 133 | printf "info: %s\n\n", $self->{info}; 134 | } 135 | 136 | 1; 137 | 138 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Storage/Component/TemperatureSubsystem/CLI.pm: -------------------------------------------------------------------------------- 1 | package HP::Storage::Component::TemperatureSubsystem::CLI; 2 | our @ISA = qw(HP::Storage::Component::TemperatureSubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | temperatures => [], 14 | blacklisted => 0, 15 | info => undef, 16 | extendedinfo => undef, 17 | }; 18 | bless $self, $class; 19 | $self->init(%params); 20 | return $self; 21 | } 22 | 23 | sub init { 24 | my $self = shift; 25 | my %params = @_; 26 | my $tempcnt = 1; 27 | foreach (grep(/^temp/, split(/\n/, $params{rawdata}))) { 28 | s/^temp\s*//g; 29 | if (/^#(\d+)\s+([\w_\/\-#]+)\s+(\d+)C\/(\d+)F\s+(\d+)C\/(\d+)F/) { 30 | push(@{$self->{temperatures}}, 31 | HP::Storage::Component::TemperatureSubsystem::Temperature->new( 32 | runtime => $params{runtime}, 33 | name => $1, 34 | location => lc $2, 35 | degrees => $self->{runtime}->{options}->{celsius} ? $3 : $4, 36 | threshold => 37 | exists $self->{runtime}->{options}->{thresholds}->{$1} 38 | ? $self->{runtime}->{options}->{thresholds}->{$1} 39 | : $self->{runtime}->{options}->{celsius} ? $5 : $6, 40 | counter => $tempcnt++ )); 41 | } elsif (/^#(\d+)\s+([\w_\/\-#]+)\s+\-\s+(\d+)C\/(\d+)F/) { 42 | # #3 CPU#2 - 0C/0F 43 | $self->trace(2, sprintf "skipping temperature %s", $_); 44 | } elsif (/^#(\d+)\s+([\w_\/\-#]+)\s+(\d+)C\/(\d+)F\s+\-/) { 45 | # #3 CPU#2 0C/0F - 46 | $self->trace(2, sprintf "skipping temperature %s", $_); 47 | } elsif (/^#(\d+)\s+([\w_\/\-#]+)\s+\-\s+\-/) { 48 | # #3 CPU#2 - - 49 | $self->trace(2, sprintf "skipping temperature %s", $_); 50 | } elsif (/^#(\d+)/) { 51 | $self->trace(0, sprintf "send this to lausser: %s", $_); 52 | } 53 | } 54 | } 55 | 56 | 1; 57 | -------------------------------------------------------------------------------- /plugins-scripts/HP/Storage/Component/TemperatureSubsystem/SNMP.pm: -------------------------------------------------------------------------------- 1 | package HP::Storage::Component::TemperatureSubsystem::SNMP; 2 | our @ISA = qw(HP::Storage::Component::TemperatureSubsystem); 3 | 4 | use strict; 5 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 6 | 7 | sub new { 8 | my $class = shift; 9 | my %params = @_; 10 | my $self = { 11 | runtime => $params{runtime}, 12 | rawdata => $params{rawdata}, 13 | temperatures => [], 14 | blacklisted => 0, 15 | info => undef, 16 | extendedinfo => undef, 17 | }; 18 | bless $self, $class; 19 | $self->init(%params); 20 | return $self; 21 | } 22 | 23 | sub init { 24 | my $self = shift; 25 | my %params = @_; 26 | my $snmpwalk = $self->{rawdata}; 27 | my $cpqHeTemperatureEntry = "1.3.6.1.4.1.232.6.2.6.8.1"; 28 | my $cpqHeTemperatureChassis = "1.3.6.1.4.1.232.6.2.6.8.1.1"; 29 | my $cpqHeTemperatureIndex = "1.3.6.1.4.1.232.6.2.6.8.1.2"; 30 | my $cpqHeTemperatureLocale = "1.3.6.1.4.1.232.6.2.6.8.1.3"; 31 | my $cpqHeTemperatureCelsius = "1.3.6.1.4.1.232.6.2.6.8.1.4"; 32 | my $cpqHeTemperatureThreshold = "1.3.6.1.4.1.232.6.2.6.8.1.5"; 33 | my $cpqHeTemperatureCondition = "1.3.6.1.4.1.232.6.2.6.8.1.6"; 34 | my $cpqHeTemperatureLocaleValue = { 35 | 1 => "other", 36 | 2 => "unknown", 37 | 3 => "system", 38 | 4 => "systemBoard", 39 | 5 => "ioBoard", 40 | 6 => "cpu", 41 | 7 => "memory", 42 | 8 => "storage", 43 | 9 => "removableMedia", 44 | 10 => "powerSupply", 45 | 11 => "ambient", 46 | 12 => "chassis", 47 | 13 => "bridgeCard", 48 | }; 49 | # INDEX { cpqHeTemperatureChassis, cpqHeTemperatureIndex } 50 | my @indexes = 51 | SNMP::Utils::get_indices($snmpwalk, $cpqHeTemperatureEntry); 52 | foreach (@indexes) { 53 | my($idx1, $idx2) = ($_->[0], $_->[1]); 54 | my $name = SNMP::Utils::get_number(\@indexes, $idx1, $idx2); 55 | my $degrees = SNMP::Utils::get_object( 56 | $snmpwalk, $cpqHeTemperatureCelsius, $idx1, $idx2); 57 | $degrees = ((($degrees * 9) / 5) + 32) 58 | unless $params{runtime}->{options}->{celsius}; 59 | my $threshold = (exists $self->{runtime}->{options}->{thresholds}->{$name}) ? 60 | $self->{runtime}->{options}->{thresholds}->{$name} : 61 | $params{runtime}->{options}->{celsius} ? 62 | SNMP::Utils::get_object( 63 | $snmpwalk, $cpqHeTemperatureThreshold, $idx1, $idx2) : 64 | ((SNMP::Utils::get_object( 65 | $snmpwalk, $cpqHeTemperatureThreshold, $idx1, $idx2) 66 | * 9) / 5) + 32; 67 | push(@{$self->{temperatures}}, 68 | HP::Storage::Component::TemperatureSubsystem::Temperature->new( 69 | runtime => $params{runtime}, 70 | name => $name, 71 | location => 72 | lc SNMP::Utils::get_object_value( 73 | $snmpwalk, $cpqHeTemperatureLocale, 74 | $cpqHeTemperatureLocaleValue, 75 | $idx1, $idx2), 76 | degrees => $degrees, 77 | threshold => $threshold, 78 | )); 79 | } 80 | } 81 | 82 | 1; 83 | -------------------------------------------------------------------------------- /plugins-scripts/HP/StorageWorks.pm: -------------------------------------------------------------------------------- 1 | package HP::StorageWorks; 2 | 3 | use strict; 4 | use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; 5 | use Data::Dumper; 6 | 7 | our @ISA = qw(HP::Server); 8 | 9 | sub init { 10 | my $self = shift; 11 | $self->{serial} = 'unknown'; 12 | $self->{product} = 'unknown'; 13 | $self->{romversion} = 'unknown'; 14 | $self->collect(); 15 | if (! $self->{runtime}->{plugin}->check_messages()) { 16 | $self->set_serial(); 17 | $self->overall_init(); 18 | $self->overall_check(); 19 | } 20 | } 21 | 22 | sub overall_init { 23 | my $self = shift; 24 | my %params = @_; 25 | my $snmpwalk = $self->{rawdata}; 26 | my $cpqHoMibStatusArray = '1.3.6.1.4.1.232.11.2.10.1.0'; 27 | $self->{cpqHoMibStatusArray} = SNMP::Utils::get_object( 28 | $snmpwalk, $cpqHoMibStatusArray); 29 | if ($self->{cpqHoMibStatusArray} =~ /^(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/) { 30 | $self->{cpqHoMibStatusArray} = 1 * $2; 31 | } elsif ($self->{cpqHoMibStatusArray} =~ /^0x.*(\d\d)(\d\d)(\d\d)(\d\d)$/) { 32 | $self->{cpqHoMibStatusArray} = 1 * $2; 33 | } 34 | } 35 | 36 | sub overall_check { 37 | my $self = shift; 38 | if ($self->{cpqHoMibStatusArray} == 4) { 39 | $self->add_info('overall status is failed'); 40 | $self->add_message(CRITICAL, 'overall status is failed'); 41 | } elsif ($self->{cpqHoMibStatusArray} == 3) { 42 | $self->add_info('overall status is degraded'); 43 | $self->add_message(WARNING, 'overall status is degraded'); 44 | } elsif ($self->{cpqHoMibStatusArray} == 2) { 45 | $self->add_info('overall status is ok'); 46 | $self->add_message(OK, 'overall status is ok'); 47 | } elsif ($self->{cpqHoMibStatusArray} == 1) { 48 | $self->add_info('overall status is other'); 49 | $self->add_message(UNKNOWN, 'overall status is other'); 50 | } 51 | } 52 | 53 | sub identify { 54 | my $self = shift; 55 | return $self->{productname}; 56 | } 57 | 58 | sub dump { 59 | my $self = shift; 60 | printf STDERR "serial %s\n", $self->{serial}; 61 | printf STDERR "product %s\n", $self->{product}; 62 | printf STDERR "romversion %s\n", $self->{romversion}; 63 | printf STDERR "%s\n", Data::Dumper::Dumper($self->{components}); 64 | } 65 | 66 | sub collect { 67 | my $self = shift; 68 | if ($self->{runtime}->{plugin}->opts->snmpwalk) { 69 | my $cpqHoMibStatusArray = '1.3.6.1.4.1.232.11.2.10.1.0'; 70 | if (! exists $self->{rawdata}->{$cpqHoMibStatusArray}) { 71 | $self->add_message(CRITICAL, 72 | 'snmpwalk returns no health data (cpqhost-mib)'); 73 | } 74 | } else { 75 | my $net_snmp_version = Net::SNMP->VERSION(); # 5.002000 or 6.000000 76 | #$params{'-translate'} = [ 77 | # -all => 0x0 78 | #]; 79 | my ($session, $error) = 80 | Net::SNMP->session(%{$self->{runtime}->{snmpparams}}); 81 | if (! defined $session) { 82 | $self->{plugin}->add_message(CRITICAL, 'cannot create session object'); 83 | $self->trace(1, Data::Dumper::Dumper($self->{runtime}->{snmpparams})); 84 | } 85 | if (! $self->{runtime}->{plugin}->check_messages()) { 86 | # snmp peer is alive 87 | $self->trace(2, sprintf "Protocol is %s", 88 | $self->{runtime}->{snmpparams}->{'-version'}); 89 | my $cpqHoMibStatusArray = '1.3.6.1.4.1.232.11.2.10.1.0'; 90 | $session->translate; 91 | my $tic = time; 92 | my $response = $session->get_request( 93 | -varbindlist => [$cpqHoMibStatusArray] 94 | ); 95 | my $tac = time; 96 | $self->trace(2, sprintf "%03d seconds for walk cpqHoMibStatusArray (%d oids)", 97 | $tac - $tic, scalar(keys %{$response})); 98 | $session->close; 99 | map { $response->{$_} =~ s/^\s+//; $response->{$_} =~ s/\s+$//; } 100 | keys %$response; 101 | $self->{rawdata} = $response; 102 | } 103 | } 104 | return $self->{runtime}->{plugin}->check_messages(); 105 | } 106 | 107 | sub set_serial { 108 | my $self = shift; 109 | my $snmpwalk = $self->{rawdata}; 110 | my @serials = (); 111 | my @models = (); 112 | my @fws = (); 113 | my $cpqSsBackplaneEntry = '1.3.6.1.4.1.232.8.2.2.6.1'; 114 | my $cpqSsBackplaneFWRev = '1.3.6.1.4.1.232.8.2.2.6.1.3'; 115 | my $cpqSsBackplaneModel = '1.3.6.1.4.1.232.8.2.2.6.1.9'; 116 | my $cpqSsBackplaneSerialNumber = '1.3.6.1.4.1.232.8.2.2.6.1.13'; 117 | # INDEX { cpqSsBackplaneChassisIndex, cpqSsBackplaneIndex } 118 | my @indexes = SNMP::Utils::get_indices($snmpwalk, 119 | $cpqSsBackplaneEntry); 120 | foreach (@indexes) { 121 | my($idx1, $idx2) = ($_->[0], $_->[1]); 122 | my $fw = SNMP::Utils::get_object($snmpwalk, 123 | $cpqSsBackplaneFWRev, $idx1, $idx2); 124 | my $model = SNMP::Utils::get_object($snmpwalk, 125 | $cpqSsBackplaneModel, $idx1, $idx2); 126 | my $serial = SNMP::Utils::get_object($snmpwalk, 127 | $cpqSsBackplaneSerialNumber, $idx1, $idx2); 128 | push(@serials, $serial); 129 | push(@models, $model); 130 | push(@fws, $fw); 131 | } 132 | 133 | $self->{serial} = join('/', @serials); 134 | $self->{product} = join('/', @models); 135 | $self->{romversion} = join('/', @fws); 136 | $self->{runtime}->{product} = $self->{product}; 137 | } 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 1; 158 | -------------------------------------------------------------------------------- /plugins-scripts/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | SED=/bin/sed 4 | GREP=/bin/grep 5 | CAT=/bin/cat 6 | ECHO=/bin/echo 7 | 8 | SUFFIXES = .pl .pm .sh 9 | 10 | VPATH=$(top_srcdir) $(top_srcdir)/plugins-scripts $(top_srcdir)/plugins-scripts/t 11 | 12 | libexec_SCRIPTS=check_hpasm 13 | MY_MODULES= 14 | EXTRA_MODULES=\ 15 | Nagios/MiniPlugin.pm \ 16 | HP/SNMP/Utils.pm \ 17 | HP/Proliant/Component/EventSubsystem.pm \ 18 | HP/Proliant/Component/EventSubsystem/CLI.pm \ 19 | HP/Proliant/Component/EventSubsystem/SNMP.pm \ 20 | HP/Proliant/Component/PowersupplySubsystem.pm \ 21 | HP/Proliant/Component/PowersupplySubsystem/CLI.pm \ 22 | HP/Proliant/Component/PowersupplySubsystem/SNMP.pm \ 23 | HP/Proliant/Component/TemperatureSubsystem.pm \ 24 | HP/Proliant/Component/TemperatureSubsystem/CLI.pm \ 25 | HP/Proliant/Component/TemperatureSubsystem/SNMP.pm \ 26 | HP/Proliant/Component/CpuSubsystem.pm \ 27 | HP/Proliant/Component/CpuSubsystem/CLI.pm \ 28 | HP/Proliant/Component/CpuSubsystem/SNMP.pm \ 29 | HP/Proliant/Component/FanSubsystem.pm \ 30 | HP/Proliant/Component/FanSubsystem/CLI.pm \ 31 | HP/Proliant/Component/FanSubsystem/SNMP.pm \ 32 | HP/Proliant/Component/MemorySubsystem/CLI.pm \ 33 | HP/Proliant/Component/MemorySubsystem/SNMP.pm \ 34 | HP/Proliant/Component/MemorySubsystem.pm \ 35 | HP/Proliant/Component/NicSubsystem/SNMP.pm \ 36 | HP/Proliant/Component/NicSubsystem.pm \ 37 | HP/Proliant/Component/AsrSubsystem/CLI.pm \ 38 | HP/Proliant/Component/AsrSubsystem/SNMP.pm \ 39 | HP/Proliant/Component/AsrSubsystem.pm \ 40 | HP/Proliant/Component/SNMP.pm \ 41 | HP/Proliant/Component/DiskSubsystem/Da/CLI.pm \ 42 | HP/Proliant/Component/DiskSubsystem/Da/SNMP.pm \ 43 | HP/Proliant/Component/DiskSubsystem/Da.pm \ 44 | HP/Proliant/Component/DiskSubsystem/Sas/CLI.pm \ 45 | HP/Proliant/Component/DiskSubsystem/Sas/SNMP.pm \ 46 | HP/Proliant/Component/DiskSubsystem/Sas.pm \ 47 | HP/Proliant/Component/DiskSubsystem/Scsi/CLI.pm \ 48 | HP/Proliant/Component/DiskSubsystem/Scsi/SNMP.pm \ 49 | HP/Proliant/Component/DiskSubsystem/Scsi.pm \ 50 | HP/Proliant/Component/DiskSubsystem/Ide/CLI.pm \ 51 | HP/Proliant/Component/DiskSubsystem/Ide/SNMP.pm \ 52 | HP/Proliant/Component/DiskSubsystem/Ide.pm \ 53 | HP/Proliant/Component/DiskSubsystem/Fca/CLI.pm \ 54 | HP/Proliant/Component/DiskSubsystem/Fca/SNMP.pm \ 55 | HP/Proliant/Component/DiskSubsystem/Fca.pm \ 56 | HP/Proliant/Component/DiskSubsystem.pm \ 57 | HP/Proliant/Component/BatterySubsystem/CLI.pm \ 58 | HP/Proliant/Component/BatterySubsystem/SNMP.pm \ 59 | HP/Proliant/Component/BatterySubsystem.pm \ 60 | HP/Proliant/Component.pm \ 61 | HP/Proliant.pm \ 62 | HP/BladeSystem/Component/CommonEnclosureSubsystem.pm \ 63 | HP/BladeSystem/Component/CommonEnclosureSubsystem/FanSubsystem.pm \ 64 | HP/BladeSystem/Component/CommonEnclosureSubsystem/TempSubsystem.pm \ 65 | HP/BladeSystem/Component/CommonEnclosureSubsystem/FuseSubsystem.pm \ 66 | HP/BladeSystem/Component/CommonEnclosureSubsystem/ManagerSubsystem.pm \ 67 | HP/BladeSystem/Component/PowerEnclosureSubsystem.pm \ 68 | HP/BladeSystem/Component/PowerSupplySubsystem.pm \ 69 | HP/BladeSystem/Component/NetConnectorSubsystem.pm \ 70 | HP/BladeSystem/Component/ServerBladeSubsystem.pm \ 71 | HP/BladeSystem/Component.pm \ 72 | HP/BladeSystem.pm \ 73 | HP/Storage.pm \ 74 | HP/StorageWorks.pm \ 75 | HP/Server.pm 76 | EXTRA_DIST=check_hpasm.pl $(EXTRA_MODULES) 77 | 78 | CLEANFILES=$(libexec_SCRIPTS) 79 | 80 | AM_INSTALL_PROGRAM_FLAGS=@INSTALL_OPTS@ 81 | 82 | .pm : 83 | $(AWK) -f ./subst $< > $@ 84 | chmod +x $@ 85 | 86 | .pl : 87 | $(AWK) -f ./subst $< > $@ 88 | chmod +x $@ 89 | 90 | .sh : 91 | $(AWK) -f ./subst $< > $@ 92 | chmod +x $@ 93 | 94 | $(libexec_SCRIPTS) : $(EXTRA_DIST) 95 | $(ECHO) "#! #PERL# -w" | $(AWK) -f ./subst > $@ 96 | $(ECHO) >> $@ 97 | for m in ${EXTRA_MODULES}; do \ 98 | $(SED) -e 's/^1;//g' < $$m | $(AWK) -f ./subst | $(GREP) -v "use Nagios::Plugin" >> $@; \ 99 | done 100 | $(ECHO) "package main;" >> $@ 101 | $(CAT) check_hpasm.pl | $(AWK) -f ./subst >> $@ 102 | chmod +x $@ 103 | #| $(GREP) -v "use Nagios" >> $@; 104 | 105 | -------------------------------------------------------------------------------- /plugins-scripts/check_hpasm.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | 3 | use strict; 4 | 5 | my $CELSIUS = 1; 6 | my $PERFDATA = 1; 7 | my $EXTENDEDINFO = 1; 8 | my $HWINFO = 1; 9 | my $HPACUCLI = 1; 10 | my $NOINSTLEVEL = 'unknown'; 11 | 12 | use constant OK => 0; 13 | use constant WARNING => 1; 14 | use constant CRITICAL => 2; 15 | use constant UNKNOWN => 3; 16 | use constant DEPENDENT => 4; 17 | 18 | my $plugin = Nagios::MiniPlugin->new( 19 | shortname => '', 20 | usage => 'Usage: %s [ -v|--verbose ] [ -t ] '. 21 | '--hostname --community '. 22 | ' ...]', 23 | version => '4.0', 24 | blurb => 'This plugin checks the hardware of hp/compaq proliant servers', 25 | url => 'http://labs.consol.de/nagios/check_hpasm', 26 | timeout => 60, 27 | shortname => '', 28 | ); 29 | $plugin->add_arg( 30 | spec => 'blacklist|b=s', 31 | help => '--blacklist 32 | Blacklist some (missing/failed) components', 33 | required => 0, 34 | default => '', 35 | ); 36 | $plugin->add_arg( 37 | spec => 'ignore-dimms|i', 38 | help => '--ignore-dimms 39 | Ignore "N/A"-DIMM status on misc. servers (e.g. older DL320)', 40 | required => 0, 41 | ); 42 | $plugin->add_arg( 43 | spec => 'ignore-fan-redundancy', 44 | help => '--ignore-fan-redundancy 45 | Ignore missing redundancy partners', 46 | required => 0, 47 | ); 48 | $plugin->add_arg( 49 | spec => 'customthresholds|c=s', 50 | help => '--customthresholds 51 | Use custom thresholds for certain temperatures', 52 | required => 0, 53 | ); 54 | $plugin->add_arg( 55 | spec => 'eventrange=s', 56 | help => '--eventrange=/ 57 | Period of time before critical IML events respecively become warnings or vanish 58 | A range is descibed as a number and a unit (s, m, h, d), e.g. --eventrange 1h/20m', 59 | required => 0, 60 | ); 61 | $plugin->add_arg( 62 | spec => 'perfdata=s', 63 | help => '--perfdata=[short] 64 | Output performance data. If your performance data string becomes 65 | too long and is truncated by Nagios, then you can use --perfdata=short 66 | instead. This will output temperature tags without location information', 67 | required => 0, 68 | ); 69 | $plugin->add_arg( 70 | spec => 'hostname|H=s', 71 | help => '--hostname 72 | Hostname or IP-address of the server (SNMP mode only)', 73 | required => 0, 74 | ); 75 | $plugin->add_arg( 76 | spec => 'port=i', 77 | help => '--port 78 | The SNMP port to use (default: 161)', 79 | required => 0, 80 | default => 161, 81 | ); 82 | $plugin->add_arg( 83 | spec => 'protocol|P=s', 84 | help => '--protocol 85 | The SNMP protocol to use (default: 2c, other possibilities: 1,3)', 86 | required => 0, 87 | default => '2c', 88 | ); 89 | $plugin->add_arg( 90 | spec => 'domain|d=s', 91 | help => '--domain 92 | The transport protocol to use (default: udp, other possibilities: tcp)', 93 | required => 0, 94 | default => 'udp', 95 | ); 96 | $plugin->add_arg( 97 | spec => 'community|C=s', 98 | help => '--community 99 | SNMP community of the server (SNMP v1/2 only)', 100 | required => 0, 101 | default => 'public', 102 | ); 103 | $plugin->add_arg( 104 | spec => 'username=s', 105 | help => '--username 106 | The securityName for the USM security model (SNMPv3 only)', 107 | required => 0, 108 | ); 109 | $plugin->add_arg( 110 | spec => 'authpassword=s', 111 | help => '--authpassword 112 | The authentication password for SNMPv3', 113 | required => 0, 114 | ); 115 | $plugin->add_arg( 116 | spec => 'authprotocol=s', 117 | help => '--authprotocol 118 | The authentication protocol for SNMPv3 (md5|sha)', 119 | required => 0, 120 | ); 121 | $plugin->add_arg( 122 | spec => 'privpassword=s', 123 | help => '--privpassword 124 | The password for authPriv security level', 125 | required => 0, 126 | ); 127 | $plugin->add_arg( 128 | spec => 'privprotocol=s', 129 | help => '--privprotocol 130 | The private protocol for SNMPv3 (des|aes|aes128|3des|3desde)', 131 | required => 0, 132 | ); 133 | $plugin->add_arg( 134 | spec => 'snmpwalk=s', 135 | help => '--snmpwalk 136 | A file with the output of snmpwalk 1.3.6.1.4.1.232', 137 | required => 0, 138 | ); 139 | $plugin->add_arg( 140 | spec => 'hpasmcli=s', 141 | help => '--hpasmcli 142 | A file with the output of hpasmcli', 143 | required => 0, 144 | ); 145 | $plugin->add_arg( 146 | spec => 'servertype=s', 147 | help => '--servertype 148 | The type of the server: proliant (default) or bladesystem', 149 | required => 0, 150 | ); 151 | $plugin->add_arg( 152 | spec => 'eval-nics', 153 | help => '--eval-nics 154 | Check network interfaces (and groups). Try it and report me whyt you think about it. I need to build up some know how on this subject. If get an error and you think, it is not justified for your configuration, please tell me about it. (alwasy send the output of "snmpwalk -On .... 1.3.6.1.4.1.232" and a description how you setup your nics and why it is correct opposed to the plugins error message', 155 | required => 0, 156 | ); 157 | 158 | $plugin->getopts(); 159 | if (! $PERFDATA && $plugin->opts->get('perfdata')) { 160 | $PERFDATA = 1; 161 | } 162 | if ($PERFDATA && $plugin->opts->get('perfdata') && 163 | ($plugin->opts->get('perfdata') eq 'short')) { 164 | $PERFDATA = 2; 165 | } 166 | $plugin->{messages}->{unknown} = []; # wg. add_message(UNKNOWN,...) 167 | 168 | $plugin->{info} = []; # gefrickel 169 | 170 | $SIG{'ALRM'} = sub { 171 | printf "UNKNOWN - check_hpasm timed out after %d seconds\n", 172 | $plugin->opts->get('timeout'); 173 | exit $ERRORS{UNKNOWN}; 174 | }; 175 | alarm($plugin->opts->get('timeout')); 176 | 177 | my $server = HP::Server->new( runtime => { 178 | plugin => $plugin, 179 | options => { 180 | servertype => $plugin->opts->get('servertype'), 181 | verbose => $plugin->opts->get('verbose'), 182 | scrapiron => 0, 183 | ignore_fan_redundancy => $plugin->opts->get('ignore-fan-redundancy'), 184 | ignore_dimms => $plugin->opts->get('ignore-dimms'), 185 | customthresholds => $plugin->opts->get('customthresholds'), 186 | eventrange => $plugin->opts->get('eventrange'), 187 | blacklist => $plugin->opts->get('blacklist'), 188 | celsius => $CELSIUS, 189 | perfdata => $PERFDATA, 190 | extendedinfo => $EXTENDEDINFO, 191 | hwinfo => $HWINFO, 192 | hpacucli => $HPACUCLI, 193 | noinstlevel => $NOINSTLEVEL, 194 | }, 195 | },); 196 | if (! $plugin->check_messages()) { 197 | $server->init(); 198 | $plugin->add_message(OK, $server->identify()) if $HWINFO; 199 | if (! $plugin->check_messages()) { 200 | $plugin->add_message(OK, 'hardware working fine'); 201 | $plugin->add_message(OK, $server->get_summary()) 202 | if $server->get_summary(); 203 | $plugin->add_message(OK, $server->get_extendedinfo()) 204 | if $server->get_extendedinfo(); 205 | } 206 | } else { 207 | $plugin->add_message(CRITICAL, 'wrong device'); 208 | } 209 | 210 | my ($code, $message) = $plugin->check_messages(join => ', ', join_all => ', '); 211 | $message .= sprintf "\n%s\n", join("\n", @{$plugin->{info}}) 212 | if $plugin->opts->get('verbose') >= 1; 213 | #printf "%s\n", Data::Dumper::Dumper($plugin->{info}); 214 | $plugin->nagios_exit($code, $message); 215 | 216 | -------------------------------------------------------------------------------- /plugins-scripts/subst.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/awk 2 | 3 | function which(c,path) { 4 | cmd = "test -x " c; 5 | 6 | if (system(cmd)==0) { 7 | return c; 8 | } 9 | 10 | sub(/\/.*\//,"",c); 11 | for (dir in path) { 12 | cmd = "test -x " path[dir] "/" c; 13 | if (system(cmd)==0) { 14 | return path[dir] "/" c; 15 | } 16 | } 17 | 18 | 19 | return c; 20 | } 21 | 22 | # used to replace "use lib utils.pm" with "use lib @libexecdir" 23 | # 24 | function led() { 25 | led1 = "@libexecdir@"; 26 | led2 = "@exec_prefix@"; 27 | led3 = "@prefix@"; 28 | if ( match(led1, /^\$\{exec_prefix\}/ ) != 0 ) { 29 | return "\"" led3 "/libexec\" " ; 30 | 31 | } 32 | return "\"" led1 "\"" ; 33 | } 34 | 35 | BEGIN { 36 | split(ENVIRON["PATH"] ":/sbin:/usr/sbin",path,/:/); 37 | 38 | } 39 | 40 | # scripting language (first line) 41 | 42 | /^#! ?\/.*\/python/ {sub(/^#! ?\/.*\/python/,"#! @PYTHON@");} 43 | /^#! ?\/.*\/perl/ {sub(/^#! ?\/.*\/perl/,"#! @PERL@");} 44 | /^#! ?\/.*\/[a-z]{0,2}awk/ {sub(/^#! ?\/.*\/[a-z]{0,2}awk/,"#! @AWK@");} 45 | /^#! ?\/.*\/sh/ {sub(/^#! ?\/.*\/sh/,"#! @SHELL@");} 46 | 47 | # add to libexecdir to INC for perl utils.pm 48 | /^use/ { if (/lib/) { if (/utils.pm|"."/ ) {sub(/utils.pm|"."/,led() )} } } 49 | 50 | 51 | # Replace the placeholders with the values from configure 52 | /#PERL#/ {sub(/#PERL#/,"@PERL@");} 53 | /my \$NOINSTLEVEL = 'unknown'/ {sub(/unknown/,"@NOINSTLEVEL@");} 54 | /my \$CELSIUS = 1;/ {sub(/1/,"@CELSIUS@");} 55 | /my \$PERFDATA = 1;/ {sub(/1/,"@PERFDATA@");} 56 | /my \$EXTENDEDINFO = 1;/ {sub(/1/,"@EXTENDEDINFO@");} 57 | /my \$HWINFO = 1;/ {sub(/1/,"@HWINFO@");} 58 | /my \$HPACUCLI = 1;/ {sub(/1/,"@HPACUCLI@");} 59 | /version => '.*',/ {sub(/'.*'/,"'@PACKAGE_VERSION@'");} 60 | 61 | { 62 | print; 63 | } 64 | 65 | -------------------------------------------------------------------------------- /prepare.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | aclocal 3 | autoheader 4 | automake --add-missing --copy 5 | autoconf 6 | ./configure 7 | -------------------------------------------------------------------------------- /t/TODO: -------------------------------------------------------------------------------- 1 | - simple snmp scan & compare device list with output 2 | - custom thresholds 3 | --------------------------------------------------------------------------------