From nobody@FreeBSD.org  Sun Jan 24 20:24:55 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 979BE106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 24 Jan 2010 20:24:55 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 6D2608FC19
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 24 Jan 2010 20:24:55 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o0OKOskx043282
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 24 Jan 2010 20:24:54 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o0OKOsJs043280;
	Sun, 24 Jan 2010 20:24:54 GMT
	(envelope-from nobody)
Message-Id: <201001242024.o0OKOsJs043280@www.freebsd.org>
Date: Sun, 24 Jan 2010 20:24:54 GMT
From: Thomas Rasmussen <thomas@gibfest.dk>
To: freebsd-gnats-submit@FreeBSD.org
Subject: net-mgmt/nagios-check_smartmon produces warnings
X-Send-Pr-Version: www-3.1
X-GNATS-Notify: steinex@nognu.de

>Number:         143185
>Category:       ports
>Synopsis:       net-mgmt/nagios-check_smartmon produces warnings
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 24 20:30:06 UTC 2010
>Closed-Date:    Mon Jan 25 02:59:32 UTC 2010
>Last-Modified:  Thu Mar 11 09:50:02 UTC 2010
>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@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@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:
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Sun Jan 24 20:30:43 UTC 2010 
State-Changed-Why:  
Awaiting maintainers feedback (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=143185 

From: Edwin Groothuis <edwin@FreeBSD.org>
To: steinex@nognu.de
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/143185: net-mgmt/nagios-check_smartmon produces warnings
Date: Sun, 24 Jan 2010 20:30:39 UT

 Maintainer of net-mgmt/nagios-check_smartmon,
 
 Please note that PR ports/143185 has just been submitted.
 
 If it contains a patch for an upgrade, an enhancement or a bug fix
 you agree on, reply to this email stating that you approve the patch
 and a committer will take care of it.
 
 The full text of the PR can be found at:
     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/143185
 
 -- 
 Edwin Groothuis via the GNATS Auto Assign Tool
 edwin@FreeBSD.org

From: Frank Steinborn <steinex@nognu.de>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/143185: net-mgmt/nagios-check_smartmon produces warnings
Date: Mon, 25 Jan 2010 02:00:05 +0100

 Thank you very much for fixing this! I was already aware of the issue
 but didn't have the time yet for looking at it.
 
 I will have a new distfile ready tommorow and you can watch out for an
 update to this port in the next couple of days.
 
 PR can be closed.
 
 Thanks,
 Frank
State-Changed-From-To: feedback->closed 
State-Changed-By: linimon 
State-Changed-When: Mon Jan 25 02:59:01 UTC 2010 
State-Changed-Why:  
Maintainer will have new distfile available that incorporates this 
patch soon. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=143185 

From: Dan Langille <dan@langille.org>
To: bug-followup@FreeBSD.org, thomas@gibfest.dk, 
 Frank Steinborn <steinex@nognu.de>
Cc:  
Subject: Re: ports/143185: net-mgmt/nagios-check_smartmon produces warnings
Date: Wed, 10 Mar 2010 20:22:44 -0500

 Any new distfile yet?  I'm now encountering the same problem.
 
 Failing that, do you mind if we patch the port so we can get a fix out 
 to the FreeBSD community?
 -- 
 Dan Langille - http://langille.org/

From: Frank Steinborn <steinex@nognu.de>
To: Dan Langille <dan@langille.org>
Cc: bug-followup@FreeBSD.org, thomas@gibfest.dk
Subject: Re: ports/143185: net-mgmt/nagios-check_smartmon produces warnings
Date: Thu, 11 Mar 2010 10:48:08 +0100

 Dan Langille wrote:
 > Any new distfile yet?  I'm now encountering the same problem.
 > 
 > Failing that, do you mind if we patch the port so we can get a fix out 
 > to the FreeBSD community?
 
 Hi,
 
 sorry - the new distfile and the port were ready for weeks, the commit
 simply was forgotten. miwi@ just committed it, thanks for the
 reminder!
 
 Frank
>Unformatted:
