File: //usr/lib/python3.6/site-packages/glances/plugins/__pycache__/glances_smart.cpython-36.opt-1.pyc
3
Eo�c � @ s� d Z ddlmZ ddlmZ ddlmZ ddlmZ yddl m
Z
W n6 ek
rz Z zda
ejdje�� W Y d d Z[X nX d
a
dd� Zd
d� ZG dd� de�Zd S )a�
Hard disk SMART attributes plugin.
Depends on pySMART and smartmontools
Must execute as root
"usermod -a -G disk USERNAME" is not sufficient unfortunately
SmartCTL (/usr/sbin/smartctl) must be in system path for python2.
Regular PySMART is a python2 library.
We are using the pySMART.smartx updated library to support both python 2 and 3.
If we only have disk group access (no root):
$ smartctl -i /dev/sda
smartctl 6.6 2016-05-31 r4324 [x86_64-linux-4.15.0-30-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
Probable ATA device behind a SAT layer
Try an additional '-d ata' or '-d sat' argument.
This is not very hopeful: https://medium.com/opsops/why-smartctl-could-not-be-run-without-root-7ea0583b1323
So, here is what we are going to do:
Check for admin access. If no admin access, disable SMART plugin.
If smartmontools is not installed, we should catch the error upstream in plugin initialization.
� )�
GlancesPlugin)�logger)�disable)�is_admin)�
DeviceListTz5Missing Python Lib ({}), HDD Smart plugin is disabledNFc C s. | j | j| j| j| j| j| j| j| j| j d�
S )N)
�name�num�flags�raw�value�worstZ threshold�type�updated�when_failed)
r r r r
r r Zthreshr
r r )�attr� r �#/usr/lib/python3.6/glances_smart.py�convert_attribute_to_dict4 s r c ! C s� g } y
t � }W n4 tk
rB } ztjdj|�� da| S d}~X nX x�|jD ]�}| jddj|j|j �i� xt|j
D ]j}|dkr�qrt|�}|jdd�}yW n6 t
k
r� } ztjdj||�� wrW Y dd}~X nX || d |<