From lupe@lupe-christoph.de  Wed May  6 13:33:55 2009
Return-Path: <lupe@lupe-christoph.de>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A59F11065670
	for <freebsd-gnats-submit@freebsd.org>; Wed,  6 May 2009 13:33:55 +0000 (UTC)
	(envelope-from lupe@lupe-christoph.de)
Received: from buexe.b-5.de (buexe.b-5.de [84.19.0.30])
	by mx1.freebsd.org (Postfix) with ESMTP id 1FA508FC19
	for <freebsd-gnats-submit@freebsd.org>; Wed,  6 May 2009 13:33:54 +0000 (UTC)
	(envelope-from lupe@lupe-christoph.de)
Received: from alanya.lupe-christoph.de (alanya.lupe-christoph.de [172.17.0.19])
	by buexe.b-5.de (8.13.8/8.13.8/b-5/buexe-3.6.3) with ESMTP id n46DXmq5022980;
	Wed, 6 May 2009 15:33:48 +0200
Received: from localhost (localhost [127.0.0.1])
	by alanya.lupe-christoph.de (Postfix) with ESMTP id 6BDF92C0AE;
	Wed,  6 May 2009 15:32:42 +0200 (CEST)
Received: from alanya.lupe-christoph.de ([127.0.0.1])
	by localhost (alanya.lupe-christoph.de [127.0.0.1]) (amavisd-new, port 10024)
	with LMTP id 6PDfBY-qf6UL; Wed,  6 May 2009 15:32:35 +0200 (CEST)
Received: by alanya.lupe-christoph.de (Postfix, from userid 1000)
	id E86A52C2BD; Wed,  6 May 2009 15:32:35 +0200 (CEST)
Message-Id: <20090506133235.GI10207@lupe-christoph.de>
Date: Wed, 6 May 2009 15:32:35 +0200
From: Lupe Christoph <lupe@lupe-christoph.de>
To: Takefu Kenji <takefu@airport.fm>, freebsd-gnats-submit@freebsd.org,
        munin-users@lists.sourceforge.net
In-Reply-To: <20090506092501.GB24549@lupe-christoph.de>
Subject: Re: [munin-users] ports/134263: munin-node failure in some
References: <200905060856.n468u96f058746@www.freebsd.org> <20090506092501.GB24549@lupe-christoph.de>

>Number:         134268
>Category:       ports
>Synopsis:       Re: [munin-users] ports/134263: munin-node failure in some
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 06 13:40:00 UTC 2009
>Closed-Date:    Fri May 08 03:42:57 UTC 2009
>Last-Modified:  Fri May 08 03:42:57 UTC 2009
>Originator:     
>Release:        
>Organization:
>Environment:
>Description:
 --tKW2IUtsqtDRztdT
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 On Wednesday, 2009-05-06 at 11:25:02 +0200, Lupe Christoph wrote:
 > On Wednesday, 2009-05-06 at 08:56:09 +0000, Takefu Kenji wrote:
 
 > > munin-node, the following error logs.
 > > > hdparm: not found
 > > > hdparm: not found
 
 The attached version of hddtemp_smartctl should fix this. Please test
 and report back.
 
 Lupe Christoph
 -- 
 | There is no substitute for bad design except worse design.                   |
 | /me                                                                          |
 
 --tKW2IUtsqtDRztdT
 Content-Type: text/plain; charset=iso-8859-15
 Content-Disposition: attachment; filename=hddtemp_smartctl
 Content-Transfer-Encoding: 8bit
 
 #!/usr/bin/perl -w
 # -*- perl -*-
 #
 # Plugin to monitor harddrive temperatures through SMART.
 #
 # client-conf.d/-options:
 #
 #	smartctl	-- path to smartctl executable
 #	drives		-- List drives to monitor. E.g. "env.drives hda hdc".
 #	type_$dev	-- device type for one drive, e.g. "env.type_sda 3ware,0"
 #	args_$dev	-- additional arguments to smartctl for one drive,
 #			   e.g. "env.args_hda -v 194,10xCelsius"
 #                          Use this to make the plugin use the --all or -a option
 #                          if your disk will not return it's temperature when
 #                          only the -A option is used.
 #	dev_$dev	-- monitoring device for one drive, e.g. twe0
 #
 # Note for users of RAID controllers: you can specify the drives attached to
 # your RAID controller(s) as raiddev_num (e.g. sda_0). Then you must specify
 # the type like this: type_sda_0 3ware,0.
 #
 # For a cciss RAID controller use e.g.:
 #   env.drives cciss6
 #   env.type_cciss6 cciss,6
 #   env.dev_cciss6 cciss/c0d0
 #
 # Recent versions of the kernel driver use a separate major device number
 # for monitoring purposes, like /dev/twe<n> or /dev/twa<n>. This can be
 # put in the e.g. dev_sda environment variable, to allow the user to keep
 # sda as the name of the disk.
 #
 # To avoid spinning up sleeping disks, you need the hdparm command in your PATH
 #
 #%# family=auto
 #%# capabilities=autoconf
 #
 # Copyright (c) 2005, Lutz Peter Christoph
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
 # are met:
 #
 #   * Redistributions of source code must retain the above copyright
 #     notice, this list of conditions and the following disclaimer.
 #
 #   * Redistributions in binary form must reproduce the above copyright
 #     notice, this list of conditions and the following disclaimer in
 #     the documentation and/or other materials provided with the
 #     distribution.
 #
 #   * The name and aliases of Lutz Peter Christoph ("Lupe Christoph",
 #     "Lutz Christoph") may not be used to endorse or promote products
 #     derived from this software without specific prior written
 #     permission.
 #
 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 # $Id: hddtemp_smartctl.in 1629 2008-06-05 07:56:13Z matthias $
 
 use strict;
 
 my $smartctl = exists $ENV{smartctl} ? $ENV{smartctl} : undef;
 
 # If the envvar is not set, look for smartctl
 # first, try $PATH
 $smartctl = `which smartctl` unless $smartctl;
 chomp $smartctl;
 $smartctl = undef unless -x $smartctl;
 
 # Still not found? Check obvious places
 my @dirs = qw(/usr/bin /usr/sbin /usr/local/bin /usr/local/sbin);
 until ($smartctl or @dirs == 0) {
   my $dir = shift @dirs;
   my $path = $dir.'/smartctl';
   $smartctl = $path if -x $path;
 }
 
 $ENV{LANG} = 'C';
 $ENV{LC_ALL} = 'C';
 my @drives;
 
 # Try to get a default set of drives
 if ($^O eq 'linux') {
   # On Linux, we know how to enumerate ide drives. SCSI is not as easy
   if (-d '/proc/ide') {
     opendir(IDE, '/proc/ide');
     @drives = grep /hd[a-z]/, readdir IDE;
     closedir(IDE);
   }
   # "SCSI disks" could be both SCSI or SATA - we can't know which
   # without probing them.
 } elsif ($^O eq 'freebsd') {
   opendir(DEV, '/dev');
   @drives = grep /^ad[0-9]+$/, readdir DEV;
   closedir(DEV);
 } elsif ($^O eq 'solaris') {
   @drives = map { s@.*/@@ ; $_ } glob '/dev/rdsk/c*t*d*s2';
 }
 
 @drives = split ' ', $ENV{drives} if exists $ENV{drives};
 
 # Sort list of drives
 @drives = sort @drives;
 
 if (defined $ARGV[0]) {
   if ($ARGV[0] eq 'autoconf') {
     if ($smartctl and -x $smartctl) {
       if (@drives) {
         print "yes\n";
         exit 0;
       } else {
         print "no (no drives known)\n";
         exit 1;
       }
     } else {
       print "no (smartctl not found)\n";
       exit 1;
     }
   } elsif ($ARGV[0] eq 'config') {
     print "graph_title HDD temperature\n";
     print "graph_args --base 1000 -l 0\n";
     print "graph_vlabel temp in C\n";
     print "graph_category sensors\n";
     print "graph_info This graph shows the temperature in degrees Celsius of the hard drives in the machine.\n";
     print "$_.label $_\n" foreach @drives;
     exit 0;
   }
 }
 
 foreach (@drives) {
   my $dev;
   $dev = $_ =~ /(.*)(?:_\d+)/ ? $1 : $_;
 
   my $fulldev = '/dev/';
   $fulldev .= 'rdsk/' if $^O eq 'solaris';
   $fulldev .= exists $ENV{'dev_'.$_} ? $ENV{'dev_'.$_} : $dev;
 
   my $cmd = $smartctl.' -A ';
   # Avoid spinning up sleeping disks
   $cmd .= '-n standby ';
   $cmd .= $ENV{'args_'.$_}.' ' if exists $ENV{'args_'.$_};
   $cmd .= '-d '.$ENV{'type_'.$_}.' ' if exists $ENV{'type_'.$_};
   $cmd .= $fulldev;
 
   my $output = `$cmd`;
   if ($output =~ /Current Drive Temperature:\s*(\d+)/) {
     print "$_.value $1\n";
   } elsif ($output =~ /^(194 Temperature_Celsius.*)/m) {
     my @F = split ' ', $1;
     print "$_.value $F[9]\n";
   } elsif ($output =~ /^(231 Temperature_Celsius.*)/m) {
     my @F = split ' ', $1;
     print "$_.value $F[9]\n";
   }
 }
 
 --tKW2IUtsqtDRztdT--
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Fri May 8 03:42:06 UTC 2009 
State-Changed-Why:  
Misfiled followup to ports/134263; content migrated. 


Responsible-Changed-From-To: gnats-admin->freebsd-ports-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Fri May 8 03:42:06 UTC 2009 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=134268 
>Unformatted:
