summaryrefslogtreecommitdiff
path: root/plugins/disk.py
blob: e705f4e324c03e481842b604d166d10b3c31af53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import plugins
import psutil


DISK_DEFAULTS = {'partition': '/', 'problem': 80, 'freq': 15}


class PluginThread(plugins.PluginThreadCommon):
    def __init__(self, config):
        super(PluginThread, self).__init__(config, DISK_DEFAULTS)

    def main(self):
        du_stat = psutil.disk_usage(self.conf['partition'])
        if du_stat.percent >= self.conf['problem']:
            self.hide = False
            self.status['urgent'] = True
        else:
            self.hide = True
            self.status['urgent'] = False
        du_free = str(round(du_stat.free / 2**30, 2))
        disk_usage = self.conf['partition'] + ': ' + du_free + 'G'
        self.status['full_text'] = disk_usage