I’m trying to put together a very simple script to monitor and alert users their disk usage percentage if it goes below a certain amount. I don’t want to use the disk condition that’s already on the site as I need to add more text to the message. I’m not very good with python so any help would be grateful.
The script run’s fine on my own local machine, but when I try to use within Itarian, I get AttributeError: ‘module’ object has no attribute ‘disk_usage’ I am using ‘import shutil’
Sure here’s the script, it’s very basic in terms of the calculating of the disk space, but it’s fine for our own needs. I’ve had to replace some hardcoded values of machine and user names with x’s but I think you should get an idea of what we are trying to achieve
Best Regards
import sys
import os
import re
import socket
import shutil
import math
if c3 <= 34:
alert(1)
print()
if mn == ‘xxxxx_Laptop’:
print(“Trello Handle @xxxxx13”)
if mn == ‘xxxxx_Desktop’:
print(“Trello Handle @xxxxx7”)
if mn == ‘xxxxxx_Laptop’:
print(“Trello Handle @xxxxx2”)
if mn == ‘xxxx_Laptop’:
print(“Trello Handle @xxxxx4”)
if mn == ‘xxxx_Desktop’:
print(“Trello Handle @xxxxx4”)
if mn == ‘xxxxx_Laptop’:
print(“Trello Handle @xxxxx3”)
else:
pass
print()
print(“CRITICAL: Ransomware protection disabled on " + mn + " due to low disk space”)
print()
print(“CRITICAL: Windows Updates will not be Installed **”)
print()
print(“CRITICAL: Your SSD lifespan will dramatically reduce **”)
print()
print(“Please urgently free up disk space on your C: Drive (minimum 35%) to re-enable”)
print()
print(“Your Free Disk space is currently " + str(c3) + " Percent”)
p =1
else:
alert(0)