-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsshcheck.py
More file actions
37 lines (23 loc) · 685 Bytes
/
sshcheck.py
File metadata and controls
37 lines (23 loc) · 685 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
30
31
32
33
34
35
36
37
from SSHLibrary import SSHLibrary
import sshlista
lista = sshlista.ssh
def service_check(hostname,login,password):
ssh = SSHLibrary()
try:
ssh.open_connection(hostname)
ssh.login(login, password)
except:
print('Erro ao conectar no host!')
ssh_command = ssh.execute_command('systemctl status nginx')
if str(ssh_command).find('(running)') != -1 :
status = 'Servico ok!'
else:
status = 'Servico com problemas!'
return status
for l in lista.items():
alias = l[0]
hostname = l[1][0]
login = l[1][1]
password = l[1][2]
print(alias)
print(service_check(hostname,login,password))