-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrc3check.py
More file actions
29 lines (22 loc) · 717 Bytes
/
rc3check.py
File metadata and controls
29 lines (22 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/python3
import ssh
import getpass
import translate as t
from term import bcolors
"""
This module checks if all the machines are on from rc3-1 to rc3-24.
It uses SSH and uptime command. If anything is returned we know host
is up.
"""
def check(password):
command = "uptime"
for host in ssh.gethostnames():
print(t.translate("checking").format(host), end="")
try:
ssh.run(host, 22, "rc3-admin", password, ssh.suwrap(password, command))
print(bcolors.OKGREEN + "ON" + bcolors.ENDC)
except:
print(bcolors.FAIL + "OFF" + bcolors.ENDC)
print("--------")
if __name__ == "__main__":
check(ssh.getpassword())