mirror of
https://github.com/viq/NewsBlur.git
synced 2025-08-05 16:49:45 +00:00
Cleaning up disk usage monitor.
This commit is contained in:
parent
7264b6a91d
commit
f534b2bd2a
1 changed files with 5 additions and 4 deletions
|
@ -13,17 +13,18 @@ def main():
|
||||||
output = df.communicate()[0]
|
output = df.communicate()[0]
|
||||||
device, size, used, available, percent, mountpoint = output.split("\n")[1].split()
|
device, size, used, available, percent, mountpoint = output.split("\n")[1].split()
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
|
percent = int(percent.strip('%'))
|
||||||
if int(percent) > 95:
|
|
||||||
|
if percent > 95:
|
||||||
requests.post(
|
requests.post(
|
||||||
"https://api.mailgun.net/v2/%s/messages" % settings.MAILGUN_SERVER_NAME,
|
"https://api.mailgun.net/v2/%s/messages" % settings.MAILGUN_SERVER_NAME,
|
||||||
auth=("api", settings.MAILGUN_ACCESS_KEY),
|
auth=("api", settings.MAILGUN_ACCESS_KEY),
|
||||||
data={"from": "NewsBlur Monitor: %s <admin@%s.newsblur.com>" % (hostname, hostname),
|
data={"from": "NewsBlur Monitor: %s <admin@%s.newsblur.com>" % (hostname, hostname),
|
||||||
"to": [settings.ADMINS[0][1]],
|
"to": [settings.ADMINS[0][1]],
|
||||||
"subject": "%s hit %s%% disk usage!" % (hostname, int(percent)),
|
"subject": "%s hit %s%% disk usage!" % (hostname, percent),
|
||||||
"text": "Usage on %s: %s" % (hostname, output)})
|
"text": "Usage on %s: %s" % (hostname, output)})
|
||||||
else:
|
else:
|
||||||
print " ---> Disk usage is fine: %s / %s%% used" % (hostname, int(percent))
|
print " ---> Disk usage is fine: %s / %s%% used" % (hostname, percent)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue