Advertisement
Guest User

script-allan.py

a guest
May 22nd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 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. fs = []
  14. capa = []
  15. totalOut = []
  16. for line in lines:
  17. tmp = line.split(' ')
  18. tmp = list(filter(None, tmp))
  19. if len(tmp) > 4 and re.match("^(\\d[75-99]|100)%$", tmp[4]):
  20. totalOut.append(line)
  21. fs.append(tmp[0])
  22. capa.append(tmp[4])
  23. print(fs)
  24. print(totalOut)
  25. print(capa)
  26. except Exception as e:
  27. sys.stderr.write("Error: %s" % str(e))
  28. exit(1)
  29.  
  30.  
  31. if __name__ == '__main__':
  32. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement