Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import sys, paramiko
- statuscodes = {'OK':0, 'WARNING':1, 'CRITICAL':2, 'UNKNOWN':3}
- hostname = "netapp8020"
- port = 22
- username = "username"
- password = "password"
- command = "storage disk error show"
- try:
- client = paramiko.SSHClient()
- client.load_system_host_keys()
- client.set_missing_host_key_policy(paramiko.WarningPolicy)
- client.connect(hostname, port=port, username=username, password=password)
- stdin, stdout, stderr = client.exec_command(command)
- result = stdout.read().strip(' \t\n\r')
- except Exception, e:
- print "UNKNOWN - " + e
- exit_code = statuscodes['UNKNOWN']
- finally:
- client.close()
- if result == "This table is currently empty.":
- print "OK"
- exit_code = statuscodes['OK']
- else:
- print "WARNING - " + result
- exit_code = statuscodes['WARNING']
- sys.exit(exit_code)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement