[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#990558: unblock: etbemon/1.3.5-6



Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock

Please unblock package etbemon

(Please provide enough (but not too much) information to help
the release team to judge the request efficiently. E.g. by
filling in the sections below.)

[ Reason ]
Improvements to imapnew.monitor, added hp-temp.monitor for HP server
temperature monitoring, and added support for MegaRAID and NVMe to
smartctl.monitor

[ Impact ]
Less functionality for users with MegaRAID (Dell servers among others) and
people using HP servers.

[ Risks ]
No risks regarding hp-temp.monitor as people can use linux-temp.monitor if
hp-temp.monitor doesn't work for them.

smartctl.monitor has been tested and found to work OK on the SATA scenarios
that the previous version supported.

imapnew.monitor has been extensively tested, and also has better quality code.

[ Checklist ]
  [x] all changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in testing

unblock etbemon/1.3.5-6


diff -u etbemon-1.3.5/debian/changelog etbemon-1.3.5/debian/changelog
--- etbemon-1.3.5/debian/changelog
+++ etbemon-1.3.5/debian/changelog
@@ -1,3 +1,13 @@
+etbemon (1.3.5-6) unstable; urgency=medium
+
+  * Better fix for headers in imapnew.monitor that doesn't need
+    libhash-case-perl.
+  * Added hp-temp.monitor to use /sbin/hplog to monitor HP server temperature
+  * Added -M option to smartctl.monitor for MegaRAID AKA PERC support and
+    added support for NVMe devices
+
+ -- Russell Coker <russell@coker.com.au>  Mon, 07 Jun 2021 16:34:01 +1000
+
 etbemon (1.3.5-5) unstable; urgency=medium
 
   * Make the deleted-mapped check avoid perl privsep processes, don't want
reverted:
--- etbemon-1.3.5/debian/control
+++ etbemon-1.3.5.orig/debian/control
@@ -13,7 +13,7 @@
 Package: mon
 Architecture: any
 Depends: mon-client (>= 1.2.0), libtime-period-perl, adduser, ${shlibs:Depends}, ${misc:Depends}
+Recommends: fping, libauthen-pam-perl, libfilesys-df-perl, libnet-perl, libnet-dns-perl, libnet-ldap-perl, libnet-telnet-perl, libsnmp-perl, libstatistics-descriptive-perl, libtime-parsedate-perl, libcrypt-ssleay-perl, libmail-imapclient-perl, libtimedate-perl, swaks, libcgi-pm-perl, bc, libproc-processtable-perl, libsys-filesystem-perl
-Recommends: fping, libauthen-pam-perl, libfilesys-df-perl, libnet-perl, libnet-dns-perl, libnet-ldap-perl, libnet-telnet-perl, libsnmp-perl, libstatistics-descriptive-perl, libtime-parsedate-perl, libcrypt-ssleay-perl, libmail-imapclient-perl, libtimedate-perl, swaks, libcgi-pm-perl, bc, libproc-processtable-perl, libsys-filesystem-perl, libhash-case-perl
 Suggests: mon-contrib
 Conflicts: mon-contrib (<= 1.0+dfsg-3+nmu1)
 Description: monitor hosts/services/whatever and alert about problems
diff -u etbemon-1.3.5/mon-local.d/smartctl.monitor etbemon-1.3.5/mon-local.d/smartctl.monitor
--- etbemon-1.3.5/mon-local.d/smartctl.monitor
+++ etbemon-1.3.5/mon-local.d/smartctl.monitor
@@ -5,38 +5,67 @@
 # copyright 2020 Russell Coker, Licensed under GPLv3 or higher.
 #
 # Monitor script to run smartctl and parse output.  By default checks
-# /dev/sd[a-z] and /dev/sd[a-z][a-z] but you can give a list of devices on the
-# command line
+# /dev/sd[a-z] /dev/sd[a-z][a-z] /dev/nvme[0-9] /dev/nvme[0-9][0-9] but
+# you can give a list of devices on the command line
 #
-# -f to treat marginal as failed
+# -f to treat all marginal conditions as failed
 # -m ATTRIBUTE_NAME to treat attribute as marginal
+#
+# -M for MegaRAID support, takes parameters of a device node on the MegaRAID
+# and a list of disk IDs separated by commas, eg "-M /dev/sda,0,1,7" for
+# disks 0, 1, and 7 on the MegaRAID controller that runs /dev/sda.
 
 my $summary;
 my $margsummary;
 my $detail;
 my $margdetail;
+my $megadev;
+my @ids;
 
 our $opt_f;
 our $opt_m;
-getopts("fm:") or die;
+our $opt_M;
+getopts("fm:M:") or die;
 
-if(-1 == $#ARGV)
+if($opt_M)
+{
+  @ids = split(/,/, $opt_M);
+  $megadev = $ids[0];
+  shift @ids;
+}
+else
 {
-  @ARGV = glob( "/dev/sd[a-z] /dev/sd[a-z][a-z]" );
   if(-1 == $#ARGV)
   {
-    print "No devices found\n";
-    exit(1);
+    @ids = glob( "/dev/sd[a-z] /dev/sd[a-z][a-z] /dev/nvme[0-9] /dev/nvme[0-9][0-9]" );
+    if(-1 == $#ids)
+    {
+      print "No devices found\n";
+      exit(1);
+    }
+  }
+  else
+  {
+    @ids = @ARGV;
   }
 }
 
-foreach my $dev (@ARGV)
+foreach my $dev (@ids)
 {
-  open(SMART, "/usr/lib/mon/bin/smartctl.helper $dev|") or die "Can't run smartctl.helper";
+  my $cmd;
+  if($opt_M)
+  {
+    $cmd = "/usr/lib/mon/bin/smartctl.helper M$megadev,$dev"
+  }
+  else
+  {
+    $cmd = "/usr/lib/mon/bin/smartctl.helper $dev";
+  }
+  open(SMART, "$cmd|") or die "Can't run smartctl.helper";
   my $header = 0;
   while(<SMART>)
   {
-    if($_ =~ /^=== START OF READ/)
+    if($_ =~ /^=== START OF .*SMART DATA SECTION/)
     {
       $header = 1;
       last;
@@ -44,7 +73,7 @@
   }
   if(not $header)
   {
-    die "Error running smartctl on $dev";
+    die "Error running \"$cmd\", does device exist?";
   }
   my $line = <SMART>;
   my $name = $dev;
@@ -108,4 +137,18 @@
 
-print "$margsummary\n";
-print $margdetail;
+if($margsummary)
+{
+  print "$margsummary\n";
+  print $margdetail;
+}
+else
+{
+  if($opt_M)
+  {
+    print("MegaRAID $opt_M OK\n");
+  }
+  else
+  {
+    print("@ids OK\n");
+  }
+}
 exit(0);
diff -u etbemon-1.3.5/mon.d/imapnew.monitor etbemon-1.3.5/mon.d/imapnew.monitor
--- etbemon-1.3.5/mon.d/imapnew.monitor
+++ etbemon-1.3.5/mon.d/imapnew.monitor
@@ -1,6 +1,5 @@
 #!/usr/bin/perl
 use strict;
-use Hash::Case::Preserve;
 
 # needs package libmail-imapclient-perl on Debian
 
@@ -133,10 +132,7 @@
     $newcount++;
   }
 
-  my %headers;
-  tie my(%headers), 'Hash::Case::Preserve';
-  %headers = %{ $imap->parse_headers( $msg, "ALL" ) };
-  my @received = @{ $headers{Received} };
+  my @received = $imap->parse_headers( $msg, "Received" );;
   my @rec_date;
   my @rec_host;
   push(@rec_date, $delivery_secs);
@@ -151,18 +147,17 @@
     push(@rec_date, str2time($rdate));
     push(@rec_host, $host);
   }
-  my @header_date = @{ $headers{Date} };
-  push(@rec_date, str2time($header_date[0]));
+  my $header_date = $imap->get_header($msg, "Date" );
+  push(@rec_date, str2time($header_date));
   push(@rec_host, "Sender");
 
-  my @subject = @{ $headers{Subject} };
-  if(not $headers{'Message-Id'})
+  my $subject = $imap->get_header($msg, "Subject");
+  my $msgid = $imap->get_header($msg, "Message-ID");
+  if(not $msgid)
   {
-    print "message without Message-Id header (subject @subject)\n";
+    print "message without Message-Id header (subject $subject)\n";
     exit(1);
   }
-  my @msgid = @{ $headers{'Message-Id'} };
-
 
   for(my $i = 0; $rec_date[$i+1]; $i++)
   {
@@ -171,7 +166,7 @@
     if($skew > $max_skew)
     {
       print "Clock skewed\n";
-      print "$rec_host[$i] received message $skew seconds before $rec_host[$i+1] sent it\nSubject: $subject[0]\nMessage-ID: $msgid[0]\n";
+      print "$rec_host[$i] received message $skew seconds before $rec_host[$i+1] sent it\nSubject: $subject\nMessage-ID: $msgid\n";
       if($delcount)
       {
         $imap->expunge();
@@ -186,7 +181,7 @@
     elsif($delay > $max_delay)
     {
       print "Message delayed $delay seconds\n";
-      print "$rec_host[$i] received message $delay seconds after $rec_host[$i+1] sent it\nSubject: $subject[0]\nMessage-ID: $msgid[0]\n";
+      print "$rec_host[$i] received message $delay seconds after $rec_host[$i+1] sent it\nSubject: $subject\nMessage-ID: $msgid\n";
       if($delcount)
       {
         $imap->expunge();
only in patch2:
unchanged:
--- etbemon-1.3.5.orig/bin/smartctl.helper.cpp
+++ etbemon-1.3.5/bin/smartctl.helper.cpp
@@ -3,7 +3,28 @@
 #include <unistd.h>
 #include <sys/wait.h>
 #include <string.h>
+#include <stdlib.h>
 
+void check_device(const char * const dev)
+{
+  const char * const errmsg = "ERROR: Device \"%s\" didn't match /dev/sd[a-z] /dev/sd[a-z][a-z] /dev/nvme[0-9] /dev/nvme[0-9][0-9]\n";
+  if(!strncmp(dev, "/dev/sd", 7))
+  {
+    if(dev[7] < 'a' || dev[7] > 'z' || (dev[8] && (dev[8] < 'a' || dev[8] > 'z' || dev[9])))
+    {
+      fprintf(stderr, errmsg, dev);
+      exit(1);
+    }
+  }
+  else if(!strncmp(dev, "/dev/nvme", 9))
+  {
+    if(dev[9] < '0' || dev[9] > '9' || (dev[10] && (dev[10] < '0' || dev[10] > '9' || dev[11])))
+    {
+      fprintf(stderr, errmsg, dev);
+      exit(1);
+    }
+  }
+}
 int main(int argc, char **argv)
 {
   if(argc != 2)
@@ -11,18 +32,40 @@
     fprintf(stderr, "ERROR: Must specify device for smartctl\n");
     return 1;
   }
-  if(strncmp(argv[1], "/dev/sd", 7))
+  char *child_args[5];
+  child_args[0] = strdup("/usr/sbin/smartctl");
+  if(argv[1][0] == 'M')
   {
-    fprintf(stderr, "ERROR: First parameter must specify a /dev/sd device\n");
-    return 1;
+    char *buf = strdup(argv[1] + 1);
+    char *device = strtok(buf, ",");
+    char *id;
+    if(!device || strncmp(device, "/dev/sd", 7) || !(id = strtok(NULL, ",")) )
+    {
+      fprintf(stderr, "ERROR: parameter for MegaRAID must be \"M/dev/sdX,X\"\n");
+      return 1;
+    }
+    check_device(device);
+    char *megaraid = (char *)malloc(12 + strlen(id));
+    strcpy(megaraid, "-dmegaraid,");
+    strcpy(megaraid + 11, id);
+    child_args[1] = megaraid;
+    child_args[2] = strdup("-H");
+    child_args[3] = device;
+    child_args[4] = NULL;
   }
-  if(argv[1][7] < 'a' || argv[1][7] > 'z' || (argv[1][8] && (argv[1][8] < 'a' || argv[1][8] > 'z' || argv[1][9])))
+  else
   {
-    fprintf(stderr, "ERROR: Device didn't match /dev/sd[a-z] or /dev/sd[a-z][a-z]\n");
-    return 1;
+    if(strncmp(argv[1], "/dev/sd", 7) && strncmp(argv[1], "/dev/nvme", 9))
+    {
+      fprintf(stderr, "ERROR: First parameter must specify a /dev/sd or /dev/nvme device\n");
+      return 1;
+    }
+    check_device(argv[1]);
+    child_args[1] = strdup("-H");
+    child_args[2] = argv[1];
+    child_args[3] = NULL;
   }
-  char * const child_args[] = { "/usr/sbin/smartctl", "-H", argv[1], NULL };
-  execv(child_args[0], child_args);
+  execv(child_args[0], (char* const*)child_args);
   fprintf(stderr, "ERROR: Can't execute %s\n", child_args[0]);
   return 1;
 }
only in patch2:
unchanged:
--- etbemon-1.3.5.orig/mon-local.d/hp-temp.monitor
+++ etbemon-1.3.5/mon-local.d/hp-temp.monitor
@@ -0,0 +1,100 @@
+#!/usr/bin/perl
+use strict;
+use Getopt::Std;
+
+# Mon script to check HP server temperature via the "hplog" program.
+#
+# Takes any line containing "Normal" to be good, anything else is bad.
+# Copyright Russell Coker GPLv3
+#
+# Use -i to specify a comma separated list of ID numbers to ignore, EG
+# -i2,4
+# Use -f for Fahrenheit
+
+open(SENSORS, "/sbin/hplog -t 2> /dev/null|") or die "Can't run hplog";
+
+my $line_id = "";
+my $input = 0;
+my $summary = "";
+my $failed = "";
+my @ignore_list;
+my $temp_ignore = "[- 1-9][- 0-9][-0-9]F.";
+
+our $opt_f;
+our $opt_i;
+getopts("i:f");
+
+if($opt_f)
+{
+  $temp_ignore = ".[- 1-9][- 0-9][-0-9]C";
+}
+
+if(length($opt_i) > 0)
+{
+  foreach my $item (split(/,/, $opt_i))
+  {
+    $ignore_list[$item] = 1;
+  }
+}
+
+# this is written for a hplog output line having 2 characters for the ID num, a
+# space, then 28 characters for the description, 8 characters for the status,
+# and then temperatures.
+while(<SENSORS>)
+{
+  chomp;
+  next if(not $_ =~ /^[ 1-9][0-9] /);
+#  next if($_ =~ /Normal/);
+
+  $line_id = substr($_, 0, 2);
+  next if($ignore_list[$line_id] == 1);
+
+  my $name = substr($_, 4, 28);
+  $name =~ s/ *$//;
+  $name =~ s/Basic Sensor/Bas:/;
+  $summary .= ", " if(length($summary) > 0);
+  $summary .= $name;
+  $_ =~ s/$temp_ignore//g;
+  $failed .= "$_\n";
+}
+if(length($failed) == 0)
+{
+  exit(0);
+}
+print "$summary\n";
+print $failed;
+
+my $format = "%8s %5s %4s %8s %s\n";
+my $ccount = 0;
+my $output = "";
+
+use Proc::ProcessTable;
+my $process_table = new Proc::ProcessTable('cache_ttys' => 0 );
+
+foreach my $p ( sort { $b->pctcpu <=> $a->pctcpu } @{$process_table->table} )
+{
+  if($ccount > 9 || $p->pctcpu < 5.0)
+  {
+    last;
+  }
+  $ccount++;
+  my $name;
+  $name  = getpwuid($p->uid) or $name = $p->uid;
+  my $cmd = $p->cmndline, 0, 60;
+  if(length($cmd) == 0)
+  {
+    $cmd = "[" . $p->fname . "]";
+  }
+  $cmd = substr($cmd, 0, 60);
+  my $devname = $p->ttydev;
+  $devname =~ s/\/dev\///;
+  $output .= sprintf($format, $name, sprintf("%5d", $p->pid), sprintf("%4.1f", $p->pctcpu), $devname, $cmd);
+}
+if($ccount > 0)
+{
+  print "\nHere are processes with the top CPU percentages:\n";
+  printf($format, "USER", "PID", "CPU", "TTY", "COMMAND");
+  print "$output\n";
+}
+
+exit(1);


Reply to: