I wrote a simple plugin (dstat_externalBackup.py
) for dstat
to monitor the filesystem free space and placed it in /usr/share/dstat
and it works as intended.
€ dstat --externalBackup 3600
extern
free
226G
226G
The code is below. As you may notice, the filesystem being monitored is hard coded in the plugin which is suboptimal. Has anyone figured out how to pass a parameter to the plugin so I can enter the filesystem to monitor on the command line?
### Author: J. Hendrix / Dag Wieers
class dstat_plugin(dstat):
'''
Provides a test playground to test syntax and structure.
'''
def __init__(self):
self.name = 'externalBackup'
self.nick = ( 'free' , )
self.vars = ( 'text' , )
self.type = 's'
self.width = 6
self.scale = 0
def extract(self):
import subprocess
import re
temp1 = subprocess.check_output( ["/bin/df" , "-h" , "--output=avail", "/media/jhendrix/externalBackup" ] )
temp2 = re.search( 'n([^n]+)n' , temp1 )
self.val['text'] = temp2.group( 1 )