ports/143185: net-mgmt/nagios-check_smartmon produces warnings

Thomas Rasmussen thomas at gibfest.dk
Sun Jan 24 20:30:07 UTC 2010


>Number:         143185
>Category:       ports
>Synopsis:       net-mgmt/nagios-check_smartmon produces warnings
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 24 20:30:06 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Thomas Rasmussen
>Release:        8.0-RELEASE-p2 amd64
>Organization:
Tykling Inc.
>Environment:
FreeBSD server.local 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 #0: Tue Jan  5 21:11:58 UTC 2010     root at amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
As evidenced by the output below, the port for the Nagios plugin check_smartmon outputs a couple of warnings when you run it, it works fine though:

[tykling at server ~]$ sudo /usr/local/libexec/nagios/check_smartmon -d /dev/ad4
/usr/local/libexec/nagios/check_smartmon:114: DeprecationWarning: os.popen3 is deprecated.  Use the subprocess module.
  (child_stdin, child_stdout, child_stderr) = os.popen3(cmd)
/usr/local/libexec/nagios/check_smartmon:127: DeprecationWarning: os.popen3 is deprecated.  Use the subprocess module.
  (child_stdin, child_stdout, child_stderr) = os.popen3(cmd)
OK: device is functional and stable (temperature: 43)


>How-To-Repeat:
sudo /usr/local/libexec/nagios/check_smartmon -d /dev/ad4

.replacing ad4 for any SMART enabled device in the system.
>Fix:
The fix to stop these warnings is to change the way smartctl is called from the python script from the old os.popen3 to the new subprocess.Popen way. See http://docs.python.org/library/subprocess.html#replacing-older-functions-with-the-subprocess-module for more. 

The attached patch changes this and appears to stop the warnings. I am new with Python so perhaps someone should check that it looks correct.

Patch attached with submission follows:

--- check_smartmon	2010-01-24 18:11:23.000000000 +0100
+++ check_smartmon_patch	2010-01-24 21:11:18.000000000 +0100
@@ -29,6 +29,7 @@
 import os.path
 import sys
 
+from subprocess import Popen,PIPE
 from optparse import OptionParser
 
 
@@ -111,7 +112,8 @@
         # get health status
         cmd = "%s -H %s" % (path, device)
         vprint(3, "Get device health status: %s" % cmd)
-        (child_stdin, child_stdout, child_stderr) = os.popen3(cmd)
+        p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
+        (child_stdout, child_stderr) = (p.stdout, p.stderr)
         line = child_stderr.readline()
         if len(line):
                 return (3, "UNKNOWN: call exits unexpectedly (%s)" % line, "",
@@ -124,7 +126,8 @@
         # get temperature
         cmd = "%s -A %s" % (path, device)
         vprint(3, "Get device temperature: %s" % cmd)
-        (child_stdin, child_stdout, child_stderr) = os.popen3(cmd)
+        p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
+        (child_stdout, child_stderr) = (p.stdout, p.stderr)
         line = child_stderr.readline()
         if len(line):
                 return (3, "UNKNOWN: call exits unexpectedly (%s)" % line, "",


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list