def transform(): if component and evt.eventKey: try: current = float(evt.current) totalBytes = int(component.totalBytes()) except Exception: return if totalBytes < 1: return usedPercent, usedBytes, freeBytes = None, None, None # SNMP (Platform) if 'usedBlocks' in evt.eventKey: usedBytes = int(current) * component.blockSize usedPercent = (usedBytes / totalBytes) * 100.0 freeBytes = totalBytes - usedBytes # Linux SSH (LinuxMonitor ZenPack) elif 'percentUsed' in evt.eventKey: usedPercent = current usedBytes = totalBytes * (current * 0.01) freeBytes = totalBytes - usedBytes # Windows (Windows ZenPacks) elif 'FreeMegabytes' in evt.eventKey: freeBytes = int(current) * 1048576 usedBytes = totalBytes - freeBytes usedPercent = (usedBytes / totalBytes) * 100.0 else: return # Make a nicer event summary. from Products.ZenUtils.Utils import convToUnits evt.summary = "disk space threshold: %3.1f%% used (%s free)" % ( usedPercent, convToUnits(freeBytes)) evt.message = evt.summary transform()