Advertisement
chitambira

Untitled

Jul 23rd, 2012
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. import re
  2.  
  3. node = str(evt.device)
  4. grp = str(evt.DeviceGroups)
  5. comp = str(evt.component)
  6. sum = evt.summary
  7. sev = str(evt.severity)
  8.  
  9. fs_id = device.prepId(evt.component)
  10. if evt.severity > 0:
  11. for f in device.os.filesystems():
  12. if f.id != fs_id: continue
  13. if evt.severity < 1: continue
  14. offset = float(getattr(device, "zFileSystemSizeOffset", 1))
  15. p = ((float(f.usedBytes()) / f.totalBytes()) / offset) * 100
  16. freeAmt = float((offset * f.totalBytes()) - f.usedBytes())
  17.  
  18. if p<94:
  19. evt._action="drop"
  20. break
  21.  
  22. if p>100:
  23. p=100
  24.  
  25. if freeAmt<0:
  26. freeAmt=0
  27.  
  28. # TB utilization
  29. if freeAmt > 1000000000000:
  30. freeAmtTB = freeAmt / 1099511627776
  31. evt.summary = "Disk space low: %3.1f%% used (%3.2f TB free)" % (p,freeAmtTB)
  32. evt.message = evt.summary
  33.  
  34. # GB utilization
  35. elif freeAmt > 1000000000:
  36. freeAmtGB = freeAmt / 1073741824
  37. evt.summary = "Disk space low: %3.1f%% used (%3.2f GB free)" % (p,freeAmtGB)
  38. evt.message = evt.summary
  39.  
  40. # MB utilization
  41. elif freeAmt > 1000000:
  42. freeAmtMB = freeAmt / 1048576
  43. evt.summary = "Disk space low: %3.1f%% used (%3.2f MB free)" % (p,freeAmtMB)
  44. evt.message = evt.summary
  45.  
  46. # KB utilization
  47. elif freeAmt < 1000000:
  48. freeAmtKB = freeAmt / 1024
  49. evt.summary = "Disk space low: %3.1f%% used (%3.2f KB free)" % (p,freeAmtKB)
  50. evt.message = evt.summary
  51.  
  52. # This is where we change to a per device threshold
  53. perDeviceThreshold = 95.0
  54. m = re.search("zz(\d{3})", f.id)
  55. #perDeviceThreshold = m and float(m.groups()[0]) or 95.0
  56. if evt.severity<4:
  57. if p >= perDeviceThreshold: evt.severity = 3
  58. if p >= 98.0: evt.severity = 5
  59. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement