diff --git a/utils/monitor_disk_usage.py b/utils/monitor_disk_usage.py index fe931c915..a115d6908 100755 --- a/utils/monitor_disk_usage.py +++ b/utils/monitor_disk_usage.py @@ -13,17 +13,18 @@ def main(): output = df.communicate()[0] device, size, used, available, percent, mountpoint = output.split("\n")[1].split() hostname = socket.gethostname() - - if int(percent) > 95: + percent = int(percent.strip('%')) + + if percent > 95: requests.post( "https://api.mailgun.net/v2/%s/messages" % settings.MAILGUN_SERVER_NAME, auth=("api", settings.MAILGUN_ACCESS_KEY), data={"from": "NewsBlur Monitor: %s " % (hostname, hostname), "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)}) 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__': main()