[pkg-nagios-changes] [Git][nagios-team/pkg-nagios-plugins-contrib][master] check_ipmi_sensor: Update to 3.13
Jan Wagner
gitlab at salsa.debian.org
Tue Jan 29 15:17:09 GMT 2019
Jan Wagner pushed to branch master at Debian Nagios Maintainer Group / pkg-nagios-plugins-contrib
Commits:
c3aa205e by Jan Wagner at 2019-01-29T14:25:05Z
check_ipmi_sensor: Update to 3.13
- - - - -
5 changed files:
- − check_ipmi_sensor/README
- + check_ipmi_sensor/README.md
- check_ipmi_sensor/changelog.txt → check_ipmi_sensor/changelog
- check_ipmi_sensor/check_ipmi_sensor
- check_ipmi_sensor/control
Changes:
=====================================
check_ipmi_sensor/README deleted
=====================================
@@ -1,45 +0,0 @@
-
- check_ipmi_sensor
- =================
-
- check_ipmi_sensor: Nagios/Icinga plugin to check IPMI sensors
-
- Copyright (C) 2009-2016 Thomas-Krenn.AG,
- additional contributors see changelog.txt
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, see <http://www.gnu.org/licenses/>.
-
-
- Requirements:
- -------------
- o Nagios or Icinga
- o FreeIPMI version 0.5.1 or newer
- o Perl
- o Perl IPC::Run
-
-
- Installation hints:
- -------------------
- On Debian/Ubuntu use 'apt-get install libipc-run-perl' to install IPC::Run.
- If you are running the plugin locally and not via network, the user 'nagios'
- needs root privileges for calling:
- o ipmimonitoring/ipmi-sensors/ipmi-sel/[ipmi-fru]
- You can achieve that by adding a sudoers config (e.g. for ipmi-sensors)
- o nagios ALL=(root) NOPASSWD: /usr/sbin/ipmi-sensors, /usr/sbin/ipmi-sel
- Please check with '-vvv' which commands are run by the plugin!
-
- Notes on ipmi-sel:
- ------------------
- If you want to clear the ipmi system event log, pleas use:
- o /usr/sbin/ipmi-sel -h $IP -u ADMIN -p $PW -l ADMIN --clear
=====================================
check_ipmi_sensor/README.md
=====================================
@@ -0,0 +1,67 @@
+# check_ipmi_sensor - Nagios/Icinga plugin to check IPMI sensors [![License: GPL v3+](https://img.shields.io/badge/License-GPL%20v3%2B-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
+
+## Description
+With this plugin the hardware status of a server can be monitored with Nagios, Icinga or Icinga 2. Specifically, fan speeds, temperatures, voltages, power consumption, power supply performance, etc. can be monitored.
+
+## Requirements
+* Nagios, Icinga or Icinga 2
+* FreeIPMI version 0.5.1 or newer
+* Perl
+* Perl IPC::Run
+
+## Installation hints
+For detailed information, installation instructions and definition examples, please go to:
+
+* [IPMI Sensor Monitoring Plugin](https://www.thomas-krenn.com/en/wiki/IPMI_Sensor_Monitoring_Plugin)
+
+### Destination folder
+Copy this plugin to the following folder:
+
+ /usr/lib/nagios/plugins/check_ipmi_sensor
+
+### Debian/Ubuntu
+Install missing lib:
+
+ apt-get install libipc-run-perl
+
+### CentOS
+Install missing lib:
+
+ yum install perl-IPC-Run freeipmi
+
+### Additional
+If you are running the plugin locally and not via network, the user 'nagios'
+needs root privileges for calling:
+* ipmimonitoring/ipmi-sensors/ipmi-sel/[ipmi-fru]/[ipmi-dcmi]
+
+You can achieve that by adding a sudoers config (e.g. for ipmi-sensors)
+
+ nagios ALL=(root) NOPASSWD: /usr/sbin/ipmi-sensors, /usr/sbin/ipmi-sel, /usr/sbin/ipmi-fru, /usr/sbin/ipmi-dcmi
+
+Please check with '-vvv' which commands are run by the plugin!
+
+## Notes on ipmi-sel
+If you want to clear the ipmi system event log, please use ipmi-sel.
+
+### Remote machine
+ /usr/sbin/ipmi-sel -h $IP -u ADMIN -p $PW -l ADMIN --clear
+
+### Local machine
+ /usr/sbin/ipmi-sel --clear
+
+## License
+Copyright (C) 2009-2019 [Thomas-Krenn.AG](https://www.thomas-krenn.com/en/index.html),
+additional contributors see changelog.txt
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 3 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, see <http://www.gnu.org/licenses/>.
=====================================
check_ipmi_sensor/changelog.txt → check_ipmi_sensor/changelog
=====================================
@@ -2,6 +2,20 @@
Changelog for check_ipmi_sensor, a Nagios/Icinga plugin to check IPMI sensors
################################################################################
+Version 3.13 20190123
+ * Option --unify-sensors to unify sensor names across platforms
+ (closes issue #8)
+ * Options --xx and -sx now support regular expressions (closes issue #25)
+ * Added --selonly option to check only System Event Log (closes issue #12)
+ * Added --seltail to limit SEL output to specified count of last messages
+ * Added ipmi-dcmi command to fetch current power (closes issue #26)
+ * Added spec file for creating a rpm file under RHEL (closes issue #24)
+ * Added check sensor event and reading for absent sensors
+ * Added installation hints for CentOS
+ * Bug fixes and minor improvements
+ * Updated help texts and usage information
+ * Updated copyright information
+
Version 3.12 20161005
* New Options added (closes issue #6)
Option -xT to exclude monitored sensor types
=====================================
check_ipmi_sensor/check_ipmi_sensor
=====================================
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# check_ipmi_sensor: Nagios/Icinga plugin to check IPMI sensors
#
-# Copyright (C) 2009-2016 Thomas-Krenn.AG,
+# Copyright (C) 2009-2019 Thomas-Krenn.AG,
# additional contributors see changelog.txt
#
# This program is free software; you can redistribute it and/or modify it under
@@ -35,12 +35,12 @@ use Getopt::Long qw(:config no_ignore_case);
use IPC::Run qw( run ); #interact with processes
################################################################################
# set text variables
-our $check_ipmi_sensor_version = "3.12";
+our $check_ipmi_sensor_version = "3.13";
sub get_version{
return <<EOT;
check_ipmi_sensor version $check_ipmi_sensor_version
-Copyright (C) 2009-2016 Thomas-Krenn.AG
+Copyright (C) 2009-2019 Thomas-Krenn.AG
Current updates at https://github.com/thomas-krenn/check_ipmi_sensor_v3.git
EOT
}
@@ -50,10 +50,13 @@ sub get_usage{
Usage:
check_ipmi_sensor -H <hostname>
[-f <FreeIPMI config file> | -U <username> -P <password> -L <privilege level>]
- [-O <FreeIPMI options>] [-b] [-T <sensor type(s)>] [-x <sensor id>]
- [-xT <sensor type(s)>] [-xST <SEL sensor type(s)]
+ [-O <FreeIPMI options>] [-b] [-T <sensor type(s)>] [-ST <SEL sensor type(s)>]
+ [-x <sensor id>] [-xT <sensor type(s)>] [-xST <SEL sensor type(s)]
[-i <sensor id>] [-o zenoss] [-D <protocol LAN version>] [-h] [-V]
- [-fc <num_fans>] [--fru] [--nosel] [--nothresholds] [--nosudo]
+ [-fc <num_fans>] [--fru] [--nosel] [--selonly] [--seltail <count>]
+ [-sx|--selexclude <sel exclude file>] [-xx|--sexclude <exclude file>]
+ [-us|--unify-sensors <unify file>] [--nosudo [--nothresholds]
+ [--noentityabsent] [-s <ipmi-sensor output file>] [-h] [-V]
[-v|-vv|-vvv]
EOT
}
@@ -96,8 +99,10 @@ sub get_help{
Examples for IPMI sensor types are 'Fan', 'Temperature', 'Voltage', ...
See the output of the FreeIPMI command 'ipmi-sensors -L' and chapter
'42.2 Sensor Type Codes and Data' of the IPMI 2.0 spec for a full list
- of possible sensor types. The available types depend on your particular
- server and the available sensors there.
+ of possible sensor types. You can also find the full list of possible
+ sensor types at https://www.thomas-krenn.com/en/wiki/IPMI_Sensor_Types
+ The available types depend on your particular server and the available
+ sensors there.
Multiple sensor types can be specified as a comma-separated list.
[-ST <SEL sensor type(s)>]
limit SEL entries to specific types, run 'ipmi-sel -L' for a list of
@@ -137,9 +142,10 @@ sub get_help{
version if not overwritten with this option. Use 'default' here if you
don't want to use LAN_2_0.
[-fc <num fans>]
- number of fans that should be active. If the number of current active
- fans reported by IPMI is smaller than <num fans> then a Warning state
- is returned.
+ number of installed fans. If the number of current installed
+ fans reported by IPMI is not equal than <num fans> then a Warning state
+ is returned. Please use this option carefully as number of fans and
+ number of fan sensors can differ!
[--fru]
print the product serial number if it is available in the IPMI FRU data.
For this purpose the tool 'ipmi-fru' is used. E.g.:
@@ -148,6 +154,12 @@ sub get_help{
turn off system event log checking via ipmi-sel. If there are
unintentional entries in SEL, use 'ipmi-sel --clear' or the -sx or -xST
option.
+ [--selonly]
+ check only system event log checking via ipmi-sel. If there are
+ unintentional entries in SEL, use 'ipmi-sel --clear' or the -sx or -xST
+ option.
+ [--seltail <count>]
+ limit SEL output to specified count of last messages
[-sx|--selexclude <sel exclude file>]
use a sel exclude file to exclude entries from the system event log.
Specify name and type pipe delimitered in this file to exclude an entry,
@@ -155,10 +167,24 @@ sub get_help{
To get valid names and types use the -vvv option and take a look at:
debug output for sel (-vvv is set). Don't use name and type from the
web interface as sensor descriptions are not complete there.
+ As with the '-xx' option if the first character of a line is '~' the
+ name is treated as a regular expression.
[-xx|--sexclude <exclude file>]
- use an exclude file to exclude sensors.
+ use an exclude file to exclude sensors, each line specifies an exclude.
Specify name and type pipe delimitered in this file to exclude a sensor,
+ for example: System Chassis Chassis Intru|Physical Security
+ If the first character of a line is '~' the name is treated as a regular
+ expression. E.g. to exclude all sensor names from CPU0 to CPU9:
+ ~CPU[0-9] Temp|Temperature
To get valid names and types use the -vvv option.
+ [-us|--unify-sensors <unify file>]
+ use an unify file to unify sensor names. This is an easy way to rename
+ sensors with given patterns in the file. Once might use this option
+ to get the same sensor names accross different platforms, e.g. to only
+ have 'Mainboard Temperature' as sensor name and not 'MB1 Temperature' or 'System Temp'.
+ Rules in the file follow simple regex patterns e.g.:
+ ^(MB1 Temperature|System Temp)\$/Mainboard Temperature
+ Temp\$/TEMP
[--nosudo]
turn off sudo usage on localhost or if ipmi host is ommited.
[--nothresholds]
@@ -189,10 +215,10 @@ Further information about this plugin can be found at
http://www.thomas-krenn.com/en/wiki/IPMI_Sensor_Monitoring_Plugin
Use the github repo at https://github.com/thomas-krenn/check_ipmi_sensor_v3.git
-to submit patches, or suggest improvements.
+to submit patches, suggest improvements or if you have questions regarding
+use of this plugin.
-Send email to the IPMI-plugin-user mailing list if you have questions regarding
-use of this software. The mailing list is available at
+Attention: the mailing list is no longer in use but an archive can be found at
http://lists.thomas-krenn.com/
EOT
}
@@ -364,6 +390,62 @@ sub parse_sel{
return \@sel_rows;
}
+sub get_dcmi{
+ my @dcmicmd = @{(shift)};
+ my $verbosity = shift;
+ my $dcmi;
+ if(-e '/usr/sbin/ipmi-dcmi'){
+ $dcmi = '/usr/sbin/ipmi-dcmi';
+ }
+ else{
+ chomp($dcmi = `which ipmi-dcmi`);
+ }
+ #if sudo is used the command is the second element
+ if($dcmicmd[0] eq 'sudo'){
+ $dcmicmd[1] = $dcmi;
+ }
+ else{
+ $dcmicmd[0] = $dcmi;
+ }
+ push @dcmicmd, '--get-system-power-statistics';
+
+ my $dcmioutput;
+ my $returncode;
+ run \@dcmicmd, '>&', \$dcmioutput;
+ $returncode = $? >> 8;
+ if ( $returncode == 0 ){
+ return split('\n', $dcmioutput);
+ }
+}
+
+sub parse_dcmi{
+ my $dcmicmd = shift;
+ my $verbosity = shift;
+ my @dcmioutput = get_dcmi($dcmicmd, $verbosity);
+ if(@dcmioutput){
+ @dcmioutput = map { [ map { s/^\s*//; s/\s*$//; $_; } split(m/\:/, $_) ] } @dcmioutput;
+ my %current_power;
+ my $power_available = 0;
+ foreach my $power (@dcmioutput){
+ if(defined($power) && defined($power->[0]) && $power->[0] ne ''){
+ if($power->[0] eq 'Current Power'){
+ $power->[1] =~ m/^(\d+)/;
+ my $watts = $1;
+ $current_power{'Current Power'} = $watts;
+ }
+ if($power->[0] eq 'Power Measurement'){
+ if($power->[1] eq 'Active'){
+ $power_available = 1;
+ }
+ }
+ }
+ }
+ if($power_available == 1){
+ return \%current_power;
+ }
+ }
+}
+
# Excludes a name and type pair if it is present in the given file, pipe
# delimitered.
# @return 1 if name should be skipped, 0 if not
@@ -382,15 +464,49 @@ sub exclude_with_file{
}
foreach my $exclude (@xlist){
my @curr_exclude = map { s/^\s*//; s/\s*$//; $_; } split(/\|/,$exclude);
- if($curr_exclude[0] eq $name &&
- $curr_exclude[1] eq $type){
- $skip = 1;
+ if(@curr_exclude && $curr_exclude[0] ne '' && $curr_exclude[1] ne ''){
+ #if the first char of the name in the exclude file is a '~' treat it as regex
+ if(substr($curr_exclude[0], 0, 1 ) eq '~'){
+ my $regex_curr_exclude = substr $curr_exclude[0], 1;
+ if($name =~ m/$regex_curr_exclude/ && $curr_exclude[1] eq $type){
+ $skip = 1;
+ }
+ }
+ elsif($curr_exclude[0] eq $name && $curr_exclude[1] eq $type){
+ $skip = 1;
+ }
}
}
close FH;
return $skip;
}
+# Reads regular expressions from a file and applies the rules to sensor names.
+# This unifies sensor names across different platforms.
+# @return The sensor name with specified unify rules applied
+sub unify_with_file{
+ my $file_name = shift;
+ my $name = shift;# given sensor name
+ my @ulist;# list of rules to apply
+ if($file_name){
+ if(!(open (FH, "< $file_name"))){
+ print "-> Reading unify file $file_name failed with: $!.\n";
+ exit(3);
+ };
+ @ulist = <FH>;
+ }
+ foreach my $unify_rule (@ulist){
+ #split at the only / that is not masked with a \,
+ #this is the separator in s/x/y/g to get x and y
+ my @curr_rule = map { s/^\s*//; s/\s*$//; $_; } split(/(?<!\\)\//,$unify_rule);
+ if(@curr_rule && $curr_rule[0] ne '' && $curr_rule[1] ne ''){
+ $name =~ s/$curr_rule[0]/$curr_rule[1]/g;
+ }
+ }
+ close FH;
+ return $name;
+}
+
#define entire hashes
our %hdrmap = (
'Record_ID' => 'id', # FreeIPMI ...,0.7.x
@@ -434,7 +550,7 @@ MAIN: {
my @exclude_sel_sensor_types;
my $sel_issues_present = 0;
my $simulate = '';
- my ($use_fru, $no_sel, $no_sudo, $use_thresholds, $no_thresholds, $sel_xfile, $s_xfile, $no_entity_absent);
+ my ($use_fru, $no_sel, $sel_only, $sel_tail, $no_sudo, $use_thresholds, $no_thresholds, $sel_xfile, $s_xfile, $s_ufile, $no_entity_absent);
#read in command line arguments and init hash variables with the given values from argv
if ( !( GetOptions(
@@ -451,6 +567,8 @@ MAIN: {
'xST|exclude-sel-sensor-types=s' => \@exclude_sel_sensor_types,
'fru' => \$use_fru,
'nosel' => \$no_sel,
+ 'selonly' => \$sel_only,
+ 'seltail=s' => \$sel_tail,
'nosudo' => \$no_sudo,
'nothresholds' => \$no_thresholds,
'noentityabsent' => \$no_entity_absent,
@@ -460,6 +578,7 @@ MAIN: {
'x|exclude=s' => \@ipmi_xlist,
'sx|selexclude=s' => \$sel_xfile,
'xx|sexclude=s' => \$s_xfile,
+ 'us|unify-sensors=s'=> \$s_ufile,
'i|include=s' => \@ipmi_ilist,
'o|outformat=s' => \$ipmi_outformat,
'fc|fancount=i' => \$fan_count,
@@ -575,6 +694,7 @@ MAIN: {
@frucmd = @basecmd
}
my @selcmd = @basecmd;
+ my @dcmicmd = @basecmd;
if(@ipmi_sensor_types){
# , is the seperator in the new string
@@ -629,12 +749,18 @@ MAIN: {
if($use_thresholds && !$no_thresholds){
push @getstatus, '--output-sensor-thresholds';
}
+ if(defined($sel_tail)){
+ push @selcmd, "--tail=$sel_tail";
+ }
################################################################################
#execute status command and redirect stdout and stderr to ipmioutput
my $ipmioutput;
my $returncode;
- if(!$simulate){
+ if ($sel_only){
+ $returncode = 0;
+ }
+ elsif(!$simulate){
run \@getstatus, '>&', \$ipmioutput;
#the upper eight bits contain the error condition (exit code)
#see http://perldoc.perl.org/perlvar.html#Error-Variables
@@ -653,9 +779,11 @@ MAIN: {
if(!$no_sel){
$seloutput = parse_sel(\@selcmd, $verbosity, $sel_xfile, \@sel_sensor_types, \@exclude_sel_sensor_types);
}
+ my $dcmioutput;
+ $dcmioutput = parse_dcmi(\@dcmicmd, $verbosity);
################################################################################
# print debug output when verbosity is set to 3 (-vvv)
- if ( $verbosity == 3 ){
+ if ( $verbosity == 3 && !$sel_only ){
my $ipmicommandversion;
run [$IPMICOMMAND, '-V'], '2>&1', '|', ['head', '-n', 1], '&>', \$ipmicommandversion;
#remove trailing newline with chomp
@@ -689,7 +817,7 @@ MAIN: {
if(defined($ipmioutput)){
@outputRows = split('\n', $ipmioutput);
}
- if(!defined($ipmioutput) || scalar(@outputRows) == 1){
+ if(!$sel_only && (!defined($ipmioutput) || scalar(@outputRows) == 1)){
print "-> Your server seems to be powered off.";
print " (Execution of FreeIPMI returned an empty output or only 1 header row!)\n";
print "-> $IPMICOMMAND was executed with the following parameters:\n";
@@ -700,129 +828,147 @@ MAIN: {
if ( @ipmi_sensor_types ){
print "Sensor Type(s) ", join(', ', @ipmi_sensor_types), " Status: ";
}
+ elsif ($sel_only){
+ print "SEL Status: ";
+ }
else{
print "IPMI Status: ";
}
- #split at newlines, fetch array with lines of output
- my @ipmioutput = split('\n', $ipmioutput);
-
- #remove sudo errors and warnings like they appear on dns resolving issues
- @ipmioutput = map { /^sudo:/ ? () : $_ } @ipmioutput;
-
- #remove leading and trailing whitespace characters, split at the pipe delimiter
- @ipmioutput = map { [ map { s/^\s*//; s/\s*$//; $_; } split(m/\|/, $_) ] } @ipmioutput;
-
- #shift out the header as it is the first line
- my $header = shift @ipmioutput;
- if(!defined($header)){
- print "$ipmioutput\n";
- print " FreeIPMI returned an empty header map (first line)";
- if(@ipmi_sensor_types){
- print " FreeIPMI could not find any sensors for the given sensor type (option '-T').\n";
- }
- exit(3);
- }
- my %header;
- for(my $i = 0; $i < @$header; $i++)
- {
- #assigning %header with (key from hdrmap) => $i
- #checking at which position in the header is which key
- $header{$hdrmap{$header->[$i]}} = $i;
- }
- my @ipmioutput2;
- foreach my $row ( @ipmioutput ){
- my %row;
- #fetch keys from header and assign existent values to row
- #this maps the values from row(ipmioutput) to the header values
- while ( my ($key, $index) = each %header ){
- $row{$key} = $row->[$index];
- }
- if(!(exclude_with_file($s_xfile, $row{'name'}, $row{'type'}))){
- push @ipmioutput2, \%row;
- }
- }
- #create hash with sensor name an 1
- my %ipmi_xlist = map { ($_, 1) } @ipmi_xlist;
- #filter out the desired sensor values
- @ipmioutput2 = grep(!exists $ipmi_xlist{$_->{'id'}}, @ipmioutput2);
- #check for an include list
- if(@ipmi_ilist){
- my %ipmi_ilist = map { ($_, 1) } @ipmi_ilist;
- #only include sensors from include list
- @ipmioutput2 = grep(exists $ipmi_ilist{$_->{'id'}}, @ipmioutput2);
- }
#start with main output
my $exit = 0;
my $w_sensors = '';#sensors with warnings
my $sel_w_sensors = '';#verbose output for sel entries with warnings
my $perf = '';#performance sensor
my $curr_fans = 0;
- foreach my $row ( @ipmioutput2 ){
- if( $zenoss ){
- $row->{'name'} =~ s/ /_/g;
+ my @ipmioutput2;#filtered original ipmi output
+
+ #skip ipmi output, if only SEL queried
+ if (!$sel_only){
+ #split at newlines, fetch array with lines of output
+ my @ipmioutput = split('\n', $ipmioutput);
+
+ #remove sudo errors and warnings like they appear on dns resolving issues
+ @ipmioutput = map { /^sudo:/ ? () : $_ } @ipmioutput;
+
+ #remove leading and trailing whitespace characters, split at the pipe delimiter
+ @ipmioutput = map { [ map { s/^\s*//; s/\s*$//; $_; } split(m/\|/, $_) ] } @ipmioutput;
+
+ #shift out the header as it is the first line
+ my $header = shift @ipmioutput;
+ if(!defined($header)){
+ print "$ipmioutput\n";
+ print " FreeIPMI returned an empty header map (first line)";
+ if(@ipmi_sensor_types){
+ print " FreeIPMI could not find any sensors for the given sensor type (option '-T').\n";
+ }
+ exit(3);
}
- my $check_sensor_state = 1;
- if($no_entity_absent && ($row->{'event'} eq '\'Entity Absent\'')){
- $check_sensor_state = 0;
+ my %header;
+ for(my $i = 0; $i < @$header; $i++)
+ {
+ #assigning %header with (key from hdrmap) => $i
+ #checking at which position in the header is which key
+ $header{$hdrmap{$header->[$i]}} = $i;
}
- #check for warning sensors
- if($check_sensor_state && ($row->{'state'} ne 'Nominal' && $row->{'state'} ne 'N/A')){
- $exit = 1 if $exit < 1;
- $exit = 2 if $exit < 2 && $row->{'state'} ne 'Warning';
- #don't insert a , the first time
- $w_sensors .= ", " unless $w_sensors eq '';
- $w_sensors .= "$row->{'name'} = $row->{'state'}";
- if( $verbosity ){
- if( $row->{'reading'} ne 'N/A'){
- $w_sensors .= " ($row->{'reading'})" ;
+ foreach my $row ( @ipmioutput ){
+ my %row;
+ #fetch keys from header and assign existent values to row
+ #this maps the values from row(ipmioutput) to the header values
+ while ( my ($key, $index) = each %header ){
+ #check if the option to unify sensor names is active
+ if($key eq 'name' && $s_ufile && $s_ufile ne ''){
+ $row{$key} = unify_with_file($s_ufile, $row->[$index]);
}
else{
- $w_sensors .= " ($row->{'event'})";
+ $row{$key} = $row->[$index];
}
}
- }
- if($check_sensor_state && ($row->{'units'} ne 'N/A')){
- my $val = $row->{'reading'};
- my $perf_data;
- my $perf_thresholds;
- if($zenoss){
- $perf_data = $row->{'name'}."=".$val;
+ if(!(exclude_with_file($s_xfile, $row{'name'}, $row{'type'}))){
+ push @ipmioutput2, \%row;
}
- else{
- $perf_data = "'".$row->{'name'}."'=".$val;
+ }
+ #create hash with sensor name an 1
+ my %ipmi_xlist = map { ($_, 1) } @ipmi_xlist;
+ #filter out the desired sensor values
+ @ipmioutput2 = grep(!exists $ipmi_xlist{$_->{'id'}}, @ipmioutput2);
+ #check for an include list
+ if(@ipmi_ilist){
+ my %ipmi_ilist = map { ($_, 1) } @ipmi_ilist;
+ #only include sensors from include list
+ @ipmioutput2 = grep(exists $ipmi_ilist{$_->{'id'}}, @ipmioutput2);
+ }
+ foreach my $row ( @ipmioutput2 ){
+ if( $zenoss ){
+ $row->{'name'} =~ s/ /_/g;
}
- if($use_thresholds && !$no_thresholds){
- if(($row->{'lowerNC'} ne 'N/A') && ($row->{'upperNC'} ne 'N/A')){
- $perf_thresholds = $row->{'lowerNC'}.":".$row->{'upperNC'}.";";
- }
- elsif(($row->{'lowerNC'} ne 'N/A') && ($row->{'upperNC'} eq 'N/A')){
- $perf_thresholds = $row->{'lowerNC'}.":;";
+ my $check_sensor_state = 1;
+ if($no_entity_absent){
+ if(exists $row->{'event'} && ($row->{'event'} =~ /\'.*((Device|Entity) (Absent|Removed)).*\'/)){
+ $check_sensor_state = 0;
}
- elsif(($row->{'lowerNC'} eq 'N/A') && ($row->{'upperNC'} ne 'N/A')){
- $perf_thresholds = "~:".$row->{'upperNC'}.";";
+ if(exists $row->{'reading'} && ($row->{'reading'} =~ /\'.*((Device|Entity) (Absent|Removed)).*\'/)){
+ $check_sensor_state = 0;
}
- elsif(($row->{'lowerNC'} eq 'N/A') && ($row->{'upperNC'} eq 'N/A')){
- $perf_thresholds = ";";
- }
- if(($row->{'lowerC'} ne 'N/A') && ($row->{'upperC'} ne 'N/A')){
- $perf_thresholds .= $row->{'lowerC'}.":".$row->{'upperC'};
+ }
+ #check for warning sensors
+ if($check_sensor_state && ($row->{'state'} ne 'Nominal' && $row->{'state'} ne 'N/A')){
+ $exit = 1 if $exit < 1;
+ $exit = 2 if $exit < 2 && $row->{'state'} ne 'Warning';
+ #don't insert a , the first time
+ $w_sensors .= ", " unless $w_sensors eq '';
+ $w_sensors .= "$row->{'name'} = $row->{'state'}";
+ if( $verbosity ){
+ if( $row->{'reading'} ne 'N/A'){
+ $w_sensors .= " ($row->{'reading'})" ;
+ }
+ else{
+ $w_sensors .= " ($row->{'event'})";
+ }
}
- elsif(($row->{'lowerC'} ne 'N/A') && ($row->{'upperC'} eq 'N/A')){
- $perf_thresholds .= $row->{'lowerC'}.":";
+ }
+ if($check_sensor_state && ($row->{'units'} ne 'N/A')){
+ my $val = $row->{'reading'};
+ my $perf_data;
+ my $perf_thresholds;
+ if($zenoss){
+ $perf_data = $row->{'name'}."=".$val;
}
- elsif(($row->{'lowerC'} eq 'N/A') && ($row->{'upperC'} ne 'N/A')){
- $perf_thresholds .= "~:".$row->{'upperC'};
+ else{
+ $perf_data = "'".$row->{'name'}."'=".$val;
}
- # Add thresholds to performance data
- if(($row->{'lowerNC'} ne 'N/A') || ($row->{'upperNC'} ne 'N/A') ||
- ($row->{'lowerC'} ne 'N/A') || ($row->{'upperC'} ne 'N/A')){
- $perf_data .= ";".$perf_thresholds;
+ if($use_thresholds && !$no_thresholds){
+ if(($row->{'lowerNC'} ne 'N/A') && ($row->{'upperNC'} ne 'N/A')){
+ $perf_thresholds = $row->{'lowerNC'}.":".$row->{'upperNC'}.";";
+ }
+ elsif(($row->{'lowerNC'} ne 'N/A') && ($row->{'upperNC'} eq 'N/A')){
+ $perf_thresholds = $row->{'lowerNC'}.":;";
+ }
+ elsif(($row->{'lowerNC'} eq 'N/A') && ($row->{'upperNC'} ne 'N/A')){
+ $perf_thresholds = "~:".$row->{'upperNC'}.";";
+ }
+ elsif(($row->{'lowerNC'} eq 'N/A') && ($row->{'upperNC'} eq 'N/A')){
+ $perf_thresholds = ";";
+ }
+ if(($row->{'lowerC'} ne 'N/A') && ($row->{'upperC'} ne 'N/A')){
+ $perf_thresholds .= $row->{'lowerC'}.":".$row->{'upperC'};
+ }
+ elsif(($row->{'lowerC'} ne 'N/A') && ($row->{'upperC'} eq 'N/A')){
+ $perf_thresholds .= $row->{'lowerC'}.":";
+ }
+ elsif(($row->{'lowerC'} eq 'N/A') && ($row->{'upperC'} ne 'N/A')){
+ $perf_thresholds .= "~:".$row->{'upperC'};
+ }
+ # Add thresholds to performance data
+ if(($row->{'lowerNC'} ne 'N/A') || ($row->{'upperNC'} ne 'N/A') ||
+ ($row->{'lowerC'} ne 'N/A') || ($row->{'upperC'} ne 'N/A')){
+ $perf_data .= ";".$perf_thresholds;
+ }
}
+ $perf .= $perf_data." ";
+ }
+ if( $row->{'type'} eq 'Fan' && $row->{'reading'} ne 'N/A' ){
+ $curr_fans++;
}
- $perf .= $perf_data." ";
- }
- if( $row->{'type'} eq 'Fan' && $row->{'reading'} ne 'N/A' ){
- $curr_fans++;
}
}
foreach my $row (@{$seloutput}){
@@ -876,6 +1022,20 @@ MAIN: {
$serial_number = $1;
}
}
+ if(defined($dcmioutput) && $dcmioutput ne ''){
+ my $power_perf = '';
+ if(exists $dcmioutput->{'Current Power'}){
+ my $power_key = 'Current Power';
+ if($s_ufile && $s_ufile ne ''){
+ $power_key = unify_with_file($s_ufile, $power_key);
+ }
+ if( $zenoss ){
+ $power_key =~ s/ /_/g;
+ }
+ $power_perf = "\'$power_key\'=" . $dcmioutput->{'Current Power'};
+ }
+ $perf = $power_perf . ' ' . $perf;
+ }
$perf = substr($perf, 0, -1);#cut off the last chars
if ( $exit == 0 ){
print "OK";
=====================================
check_ipmi_sensor/control
=====================================
@@ -1,5 +1,5 @@
Recommends: freeipmi-tools, libipc-run-perl
-Version: 3.12
+Version: 3.13
Uploaders: Bernd Zeimetz <bzed at debian.org>
Homepage: http://www.thomas-krenn.com/en/oss/ipmi-plugin.html
Description: IPMI Sensor Monitoring Plugin
View it on GitLab: https://salsa.debian.org/nagios-team/pkg-nagios-plugins-contrib/commit/c3aa205e3eb321fd0922d1b306ea12833181c2c1
--
View it on GitLab: https://salsa.debian.org/nagios-team/pkg-nagios-plugins-contrib/commit/c3aa205e3eb321fd0922d1b306ea12833181c2c1
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-nagios-changes/attachments/20190129/ccdee9f7/attachment-0001.html>
More information about the pkg-nagios-changes
mailing list