3 `@sPddlZddlZddlZddlZddlZGdddejZedkrLejdS)Nc@seZdZdZddZdS)PluginZ diskstatusc Csi}y.tjdtjtjddjdjj}d}Wn$tk rV}zd}dSd}~XnX|dkrx(|D]}y|jddjd d }tj d j |jddj j}d} |d jd ddkrd} i||<d} xv|D]n} | dddkrd} q| dkrqt j dd| j} | jd} t| dkr| d||| djjdd<qW| ||d<Wqjtk r}zt|WYdd}~XqjXqjW|S)a Monitor nvme or smart disk status. For NVME drives use the diskstatus-nvme plugin for smart status install smartmontools (apt-get/yum install smartmontools) This plugin requires the agent to be run under the root user. zsmartctl --scanT)stdoutstderrshellrFz+Could not fetch smartctl status informationN /zsmartctl -A -H {}z: ZPASSEDzID#z + Z_celsiusstatus) subprocessPopenPIPE communicatedecode splitlines Exceptionsplitospopenformatreadresubstriplenlowerreplaceprint) selfconfigresultsZdevlistZsmartctlerowZdisk_idZ disk_statsZ smart_statusstartZstatsr(J/usr/local/lib/python3.6/site-packages/nixstatsagent/plugins/diskstatus.pyrun s>& "    $z Plugin.runN)__name__ __module__ __qualname__r*r(r(r(r)r sr__main__) rrZpluginsjsonrZ BasePluginrr+executer(r(r(r)s-