Advertisement
Guest User

script-allan.py

a guest
May 22nd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. # libraries you import here, must be present on the target node.
  4. import sys
  5. import re
  6. import subprocess
  7.  
  8.  
  9. def main():
  10. try:
  11. result = subprocess.check_output(['df', '-h'])
  12. lines = result.decode('utf-8').split('\n')
  13. capa = []
  14. totalOut = []
  15. for line in lines:
  16. tmp = line.split(' ')
  17. tmp = list(filter(None, tmp))
  18. for z in tmp:
  19. if re.match("^(\\d[75-99]|100)%$", z):
  20. totalOut.append(line)
  21. capa.append(z)
  22. print("\n".join(totalOut))
  23. except Exception as e:
  24. sys.stderr.write("Error: %s" % str(e))
  25. exit(1)
  26.  
  27.  
  28. if __name__ == '__main__':
  29. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement