Skip to content

Commit

Permalink
Plugin for monitoring directory size
Browse files Browse the repository at this point in the history
  • Loading branch information
vfuse committed Sep 5, 2019
1 parent 0599823 commit 5d474ce
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nixstatsagent/nixstatsagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import urllib
import urllib2

__version__ = '1.1.54'
__version__ = '1.1.55'

__FILEABSDIRNAME__ = os.path.dirname(os.path.abspath(__file__))

Expand Down
26 changes: 26 additions & 0 deletions nixstatsagent/plugins/dirsize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import subprocess
import plugins
import json

class Plugin(plugins.BasePlugin):
__name__ = 'dirsize'

def run(self, config):
'''
Monitor total directory sizes, specify the directories you want to monitor in /etc/nixstats.ini
'''

data = {}
my_dirs = config.get('dirsize', 'dirs').split(',')

for dir in my_dirs:
data[dir] = {'bytes': os.popen('du -c {} | grep total'.format(dir)).read().replace('total', '').rstrip()}

return data


if __name__ == '__main__':
Plugin().execute()

0 comments on commit 5d474ce

Please sign in to comment.