SHARE
TWEET

script-allan.py

a guest May 22nd, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top