NewsBlur/config/munin/path_size

36 lines
884 B
Text
Raw Permalink Normal View History

2016-11-11 11:09:13 -08:00
#!/srv/newsblur/venv/newsblur/bin/python
2011-12-02 16:22:38 -08:00
import os
import subprocess
2016-11-11 11:06:33 -08:00
from vendor.munin import MuninPlugin
2011-12-02 16:22:38 -08:00
class PathSizePlugin(MuninPlugin):
args = "--base 1024 -l 0"
vlabel = "bytes"
scale = True
category = "other"
fields = (
('size', dict(
label = "size",
info = "Size",
type = "GAUGE",
)),
)
def __init__(self, *args, **kwargs):
super(PathSizePlugin, self).__init__(*args, **kwargs)
self.path = os.environ["PATHSIZE_PATH"]
@property
def title(self):
return "Size of %s" % self.path
def execute(self):
p = subprocess.Popen("du -sk " + self.path, shell=True, stdout=subprocess.PIPE)
du = p.communicate()[0]
size = int(du.split('\t')[0].strip()) * 1024
return dict(size=size)
if __name__ == "__main__":
PathSizePlugin().run()