Menu

Enabling smart?

Help
2009-09-14
2012-12-12
  • Dave Anonymouse

    Dave Anonymouse - 2009-09-14

    phpsysinfo - 3.0-RC9 under openSUSE 11.1 32bit. 

    I'm trying to get the temperature readout from smartctl, but can't seem to get any data returned.  All I get is - ***No matching records found***.  I think it's something to do with not being able to run the smartctl as a normal user.

    from SMART.config.php -

        define('PSI_PLUGIN_SMART_ACCESS', 'command');
        define('PSI_PLUGIN_SMART_DEVICES', '/dev/sda');
        define('PSI_PLUGIN_SMART_DEVICE', false);
        define('PSI_PLUGIN_SMART_IDS', '194-RAW_VALUE');

    from smartctl as normal user -

        smartctl -all /dev/sda
        smartctl 5.39 2008-10-24 22:33  (openSUSE RPM)
        Copyright (C) 2002-8 by Bruce Allen, http://smartmontools.sourceforge.net
       
        Smartctl open device: /dev/sda failed: Permission denied

    from smartctl as root -

        smartctl -all /dev/sda
        smartctl 5.39 2008-10-24 22:33  (openSUSE RPM)         
        Copyright (C) 2002-8 by Bruce Allen, http://smartmontools.sourceforge.net   
       
        === START OF INFORMATION SECTION ===
        Model Family:     Hitachi Travelstar 80GN family
        Device Model:     IC25N040ATMR04-0             
        Serial Number:    MRG254KBDT7V7P               
        Firmware Version: MO2OAD4A                     
        User Capacity:    40,007,761,920 bytes         
        Device is:        In smartctl database
        ATA Version is:   6                                             
        ATA Standard is:  ATA/ATAPI-6 T13 1410D revision 3a             
        Local Time is:    Mon Sep 14 13:10:18 2009 CEST                 
        SMART support is: Available - device has SMART capability.      
        SMART support is: Enabled                                       
       
        === START OF READ SMART DATA SECTION ===
        SMART overall-health self-assessment test result: PASSED
       
        General SMART Values:
        Offline data collection status:  (0x00) Offline data collection activity
                                                was never started.             
                                                Auto Offline Data Collection: Disabled.
        Self-test execution status:      (   0) The previous self-test routine completed
                                                without error or no self-test has ever 
                                                been run.                              
        Total time to complete Offline                                                 
        data collection:                 ( 645) seconds.                               
        Offline data collection                                                        
        capabilities:                    (0x5b) SMART execute Offline immediate.       
                                                Auto Offline data collection on/off support.
                                                Suspend Offline collection upon new        
                                                command.                                   
                                                Offline surface scan supported.            
                                                Self-test supported.                       
                                                No Conveyance Self-test supported.         
                                                Selective Self-test supported.             
        SMART capabilities:            (0x0003) Saves SMART data before entering           
                                                power-saving mode.                         
                                                Supports SMART auto save timer.            
        Error logging capability:        (0x01) Error logging supported.                   
                                                General Purpose Logging supported.         
        Short self-test routine                                                            
        recommended polling time:        (   2) minutes.                                   
        Extended self-test routine                                                         
        recommended polling time:        (  37) minutes.                                   
       
        SMART Attributes Data Structure revision number: 16
        Vendor Specific SMART Attributes with Thresholds: 
        ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
          1 Raw_Read_Error_Rate     0x000b   100   100   062    Pre-fail  Always       -       0       
          2 Throughput_Performance  0x0005   100   100   040    Pre-fail  Offline      -       0       
          3 Spin_Up_Time            0x0007   162   162   033    Pre-fail  Always       -       1       
          4 Start_Stop_Count        0x0012   100   100   000    Old_age   Always       -       880     
          5 Reallocated_Sector_Ct   0x0033   100   100   005    Pre-fail  Always       -       0       
          7 Seek_Error_Rate         0x000b   100   100   067    Pre-fail  Always       -       0       
          8 Seek_Time_Performance   0x0005   100   100   040    Pre-fail  Offline      -       0       
          9 Power_On_Hours          0x0012   094   094   000    Old_age   Always       -       2691    
         10 Spin_Retry_Count        0x0013   100   100   060    Pre-fail  Always       -       0
         12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       864
        191 G-Sense_Error_Rate      0x000a   100   100   000    Old_age   Always       -       0
        192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       36
        193 Load_Cycle_Count        0x0012   092   092   000    Old_age   Always       -       80728
        194 Temperature_Celsius     0x0002   152   152   000    Old_age   Always       -       36 (Lifetime Min/Max 4/48)
        196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0
        197 Current_Pending_Sector  0x0022   100   100   000    Old_age   Always       -       0
        198 Offline_Uncorrectable   0x0008   100   100   000    Old_age   Offline      -       0
        199 UDMA_CRC_Error_Count    0x000a   200   200   000    Old_age   Always       -       0
       
        SMART Error Log Version: 1
        No Errors Logged
       
        SMART Self-test log structure revision number 1
        No self-tests have been logged. 
       
       
        Warning! SMART Selective Self-Test Log Structure error: invalid SMART checksum.
        SMART Selective self-test log data structure revision number 1
         SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
            1        0        0  Not_testing
            2        0        0  Not_testing
            3        0        0  Not_testing
            4        0        0  Not_testing
            5        0        0  Not_testing
        Selective self-test flags (0x0):
          After scanning selected spans, do NOT read-scan remainder of disk.
        If Selective self-test is pending on power-up, resume after 0 minute delay.

    Any ideas as to how I can get this working?  Thanks :)

     
  • Anonymous

    Anonymous - 2009-09-14

    you are right, when the command is not able to complete successfull as a normal user, then the webserver also is not able in standard installtions. a quick and dirty way is to set the (user/group) execution bit (have a look at the chmod command) of the smartctl executable. so that when the smartctl executable belongs to root and the user execution bit is set then it should work, because root is normally able to read the device files. but be warned: THIS MIGHT BE A SECURITY RISK

     
  • Dave Anonymouse

    Dave Anonymouse - 2009-09-14

    Thanks for the reply.

    Sadly chmod 755 did nothing.

    I tried adding several lines to /etc/sudoers, such as -

        ALL ALL=NOPASSWD:/usr/sbin/smartctl -all /dev/sda
        ALL ALL=NOPASSWD:/usr/sbin/smartctl
        %www  ALL=/usr/sbin/smartctl

    ….nothing worked.

    and even tried allowing ALL users to run ALL commands on the entire system without a password!  It still didn't work :(.

    Has anyone had this working?  I'm wondering if it's a plugin bug.

    I also added a space to the command syntax in class.SMART.inc.php, I thought maybe there was a space missing between the command and the -all switch -

    original -

        if (CommonFunctions::executeProgram('smartctl', '-all '.((PSI_PLUGIN_SMART_DEVICE) ? ' -device '.PSI_PLUGIN_SMART_DEVICE : '').

    modified -
      

         if (CommonFunctions::executeProgram('smartctl', ' -all '.((PSI_PLUGIN_SMART_DEVICE) ? ' -device '.PSI_PLUGIN_SMART_DEVICE : '').

    But still nothing.

     
  • Anonymous

    Anonymous - 2009-09-14

    entries in sudoers are not used because command is not called with sudo from phpsysinfo, so forget that
    the space is not relevant, because it is added automatically, so no need to change the source
    simply chmodding 755 will not solve the problem because you didn't set the execution bit, please read the chmod manual page and see there is a fourth number to add to achive that what described earlier. so chmod 4755  is that what you need or simply chmod u+s

     
  • Jørgen Thomsen

    Jørgen Thomsen - 2009-09-27

    chmod 4755 does not work on Linux.

    I had to change class.SMART.inc.php line line 60 to

    if (CommonFunctions::executeProgram('sudo', '/usr/sbin/smartctl -all '.((PSI_PLUGIN_SMART_DEVICE) ? ' -device '.PSI_PLUGIN_SMART_DEVICE : '').' '.$disk, $buffer, PSI_DEBUG)) {

    and add appropriate lines to /etc/sudoers with visudo:

    apache  ALL=NOPASSWD: /usr/sbin/smartctl -all -device sat /dev/sda

    In the process of finding this out I had large difficulties in finding out why there were no error messages from the plugins until I realized, that plugins are called by javascript (Ajax) and errors from these are never displayed anywhere!

    You have to use an URL like this to display the data and errors from plugins:

    http://domain.tld/phpsysinfo/xml.php?plugin=SMART

    I would suggest explaining this in a simple way in the README_PLUGIN file.

     
  • Jørgen Thomsen

    Jørgen Thomsen - 2009-09-27

    I have to modify my reply.
    chmod 4755 smartctl actually does work, but the other method does it as well and the documentation suggestion is still highly appropriate.

     
  • Anonymous

    Anonymous - 2009-09-28

    i opened a feature request to display plugin errors as well

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.