Created
November 24, 2018 19:25
-
-
Save darxtrix/d53541760eed96f8c18e56aacf2a7430 to your computer and use it in GitHub Desktop.
Ptop disk sensor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Disk Sensor Plugin | |
''' | |
from ptop.core import Plugin | |
import psutil | |
class DiskSensor(Plugin): | |
def __init__(self,**kwargs): | |
super(DiskSensor,self).__init__(**kwargs) | |
# there can be many text (key,value) pairs to display corresponding to each key | |
self.currentValue['text'] = {'/' : {}} | |
# overriding the update method | |
def update(self): | |
# no graph part will be there | |
disk_usage = psutil.disk_usage('/') | |
self.currentValue['text']['/']['total'] = int(float(disk_usage.total)/(1024*1024)) | |
self.currentValue['text']['/']['used'] = int(float(disk_usage.used)/(1024*1024)) | |
self.currentValue['text']['/']['percentage'] = int(disk_usage.percent) | |
disk_sensor = DiskSensor(name='Disk',sensorType='text',interval=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment