Bug 236873

Summary: net-mgmt/nagios-check_smartmon: Device-dependent temperature responses cause ValueError
Product: Ports & Packages Reporter: Thomas Eckhardt <freebsd>
Component: Individual Port(s)Assignee: Kubilay Kocak <koobs>
Status: Closed FIXED    
Severity: Affects Some People CC: ports, python
Priority: --- Flags: ports: maintainer-feedback+
koobs: merge-quarterly+
Version: Latest   
Hardware: amd64   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236227
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=237457
Attachments:
Description Flags
change parts-index from -3 to 9 for temperature
none
check-smartmon.patch
ports: maintainer-approval+, ports: maintainer-approval+
check_smartmon python3.6 compatible ports: maintainer-approval+

Description Thomas Eckhardt 2019-03-29 09:52:50 UTC
Created attachment 203237 [details]
change parts-index from -3 to 9 for temperature

After upgrading to version 20100318_4 i get a ValueError for some disks. I think this is caused by the changes base r495215 from bug #236227 because of a slightly different temperature readings, e.g missing values in parantheses:

WDC WD40EFRX-68N32N0 causes the error:
  # /usr/local/libexec/nagios/check_smartmon -d /dev/da1 -v 10
  ..
  parseOutput: we are very keen on this line: '194 Temperature_Celsius     0x0022   121   117   000    Old_age   Always       -       29'
  Traceback (most recent call last):
    File "/usr/local/libexec/nagios/check_smartmon", line 317, in <module>
      (healthStatus, temperature) = parseOutput(healthStatusOutput, temperatureOutput, devtype)
    File "/usr/local/libexec/nagios/check_smartmon", line 218, in parseOutput
      temperature = int(parts[-3])
  ValueError: invalid literal for int() with base r10: 'Always'


While ST4000VN008-2DR166 works:
  # /usr/local/libexec/nagios/check_smartmon -d /dev/da0 -v 10
  ..
  parseOutput: we are very keen on this line: '194 Temperature_Celsius     0x0022   027   040   000    Old_age   Always       -       27 (0 19 0 0 0)'
  parseOutput: Is this the temperature? '0'
  Health status: PASSED
  ..

My temp workaround was to dumb change parts-index on line 218 from -3 to 9 which results in correct temperature-readings and no error.
Comment 1 Krzysztof 2019-03-31 21:34:42 UTC
Hi,

Thanks a lot for reporting problem. I've tested this plugin with ada disks and SCSI one.

With ada0 it works correctly. With /dev/daN I receive 0. Which is not correct value.

So I have to check it with different smartmon results and find out the best solution.

I will come back in a few days
Comment 2 Krzysztof 2019-03-31 21:55:42 UTC
OK, So I've checked different disks. Problem is with WDC disks and with Seagate ones (ST.....) it works or displays 0.

Yes, I think that the best solution is to change line 218 of script to your solution. So I will prepare patch for script.

Thanks a lot for your help and suggestions
Comment 3 Krzysztof 2019-04-09 07:14:37 UTC
Created attachment 203518 [details]
check-smartmon.patch

I've made a patch for a port. I did not tested with poudriere because it is not needed :-)))

Thanks a lot for commiting patch.
Comment 4 Krzysztof 2019-04-16 21:36:09 UTC
Created attachment 203726 [details]
check_smartmon python3.6 compatible

Hello,

I've made a patch which is working correctly with latest deafault python verion (py36). Also I've made changes to Makefile, so no port can be flavorized.

I've tested these changes with poudriere. You can check logfiles at:
http://pkg.bsdserwis.com/pkg/data/11x64-testing/2019-04-16_22h07m20s/logs/nagios-check_smartmon-py36-20100318_4.log

http://pkg.bsdserwis.com/pkg/data/11x64-testing/2019-04-16_22h07m07s/logs/nagios-check_smartmon-py27-20100318_4.log

Changes suggested by Thomas are also included
Comment 5 Krzysztof 2019-04-16 21:37:50 UTC
Comment on attachment 203237 [details]
change parts-index from -3 to 9 for temperature

This patch is not compatible with changes which could be commited to subversion. But as I wrote these changes adre included in my patch
Comment 6 Krzysztof 2019-04-26 12:40:10 UTC
(In reply to Krzysztof from comment #5)

OK, I have to reply to my self, because I'm reading my comment and I cannot understand :-)))

So, original patch (which I'm not able to deprecade/delete) is not compatible to commit to ports.

I've made a new patch, which is ready to commit. Except correcting reading temperature value, my patch covers problems with python3.6 (mix of tabs and spaces). Also I've prepared this port for flavors, so port could be built with as py27 oraz py36.

I hope my patch will be commited soon without problems.

If you (commiter) have any questions I will explain any doubts.
Comment 7 Krzysztof 2019-04-26 12:41:42 UTC
Comment on attachment 203237 [details]
change parts-index from -3 to 9 for temperature

This patch is obsolete
Comment 8 commit-hook freebsd_committer freebsd_triage 2019-05-23 14:27:43 UTC
A commit references this bug:

Author: koobs
Date: Thu May 23 14:27:15 UTC 2019
New revision: 502340
URL: https://svnweb.freebsd.org/changeset/ports/502340

Log:
  net-mgmt/nagios-check_smartmon: Fix ValueError with some drive values

  After upgrading to version 20100318_4, users reported ValueError for
  some disks [1]

  Also fix Python 3.x compatibility [2]

  While I'm here:

    - Pet portlint, NO_* in USE{S} section
    - Make concurrent-safe, installs executables in libexec

  PR:		236873
  Reported by:	Thomas Eckhardt <freebsd eckieck de> [1]
  Submitted by:	Thomas Eckhardt <freebsd eckieck de> [1]
  Submitted by:	Krzysztof <ports bsdserwis com> (maintainer) [2]
  Approved by:	Krzysztof <ports bsdserwis com> (maintainer)
  MFH:		2019Q2 (bugfixes)

Changes:
  head/net-mgmt/nagios-check_smartmon/Makefile
  head/net-mgmt/nagios-check_smartmon/files/patch-check_smartmon
Comment 9 commit-hook freebsd_committer freebsd_triage 2019-05-24 10:23:54 UTC
A commit references this bug:

Author: koobs
Date: Fri May 24 10:23:00 UTC 2019
New revision: 502450
URL: https://svnweb.freebsd.org/changeset/ports/502450

Log:
  MFH: r502340 net-mgmt/nagios-check_smartmon: Fix ValueError with some drive values

  After upgrading to version 20100318_4, users reported ValueError for
  some disks [1]

  Also fix Python 3.x compatibility [2]

  While I'm here:

    - Pet portlint, NO_* in USE{S} section
    - Make concurrent-safe, installs executables in libexec

  PR:		236873
  Reported by:	Thomas Eckhardt <freebsd eckieck de> [1]
  Submitted by:	Thomas Eckhardt <freebsd eckieck de> [1]
  Submitted by:	Krzysztof <ports bsdserwis com> (maintainer) [2]
  Approved by:	Krzysztof <ports bsdserwis com> (maintainer)

  Approved by:	ports-secteam (miwi, blanket: runtime bugfix)

Changes:
_U  branches/2019Q2/
  branches/2019Q2/net-mgmt/nagios-check_smartmon/Makefile
  branches/2019Q2/net-mgmt/nagios-check_smartmon/files/patch-check_smartmon
Comment 10 Kubilay Kocak freebsd_committer freebsd_triage 2019-05-26 11:28:30 UTC
Committed and merged to quarterly. Thanks!