NewsBlur-viq/archive/munin/path_size
2022-02-01 14:59:05 -05:00

35 lines
885 B
Python
Executable file

#!/srv/newsblur/venv/newsblur3/bin/python
import os
import subprocess
from vendor.munin import MuninPlugin
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()