Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import sys, paramiko
  4.  
  5. statuscodes = {'OK':0, 'WARNING':1, 'CRITICAL':2, 'UNKNOWN':3}
  6. hostname = "netapp8020"
  7. port = 22
  8. username = "username"
  9. password = "password"
  10. command = "storage disk error show"
  11.  
  12. try:
  13. client = paramiko.SSHClient()
  14. client.load_system_host_keys()
  15. client.set_missing_host_key_policy(paramiko.WarningPolicy)
  16. client.connect(hostname, port=port, username=username, password=password)
  17. stdin, stdout, stderr = client.exec_command(command)
  18. result = stdout.read().strip(' \t\n\r')
  19. except Exception, e:
  20. print "UNKNOWN - " + e
  21. exit_code = statuscodes['UNKNOWN']
  22. finally:
  23. client.close()
  24.  
  25. if result == "This table is currently empty.":
  26. print "OK"
  27. exit_code = statuscodes['OK']
  28. else:
  29. print "WARNING - " + result
  30. exit_code = statuscodes['WARNING']
  31.  
  32. sys.exit(exit_code)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement