Skip to content

Instantly share code, notes, and snippets.

@Arun-Baskaran
Created January 19, 2018 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arun-Baskaran/065cf743a5e711ad165aa75ff73c6c0b to your computer and use it in GitHub Desktop.
Save Arun-Baskaran/065cf743a5e711ad165aa75ff73c6c0b to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# Program to check whether ClamAV is installed
import paramiko
import os
file1 = "~/ClamAv-Status"
Server_List = "~/server.list"
def ssh_connection(source_server , source_os_password):
Client = paramiko.SSHClient()
Client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
Client.connect(hostname=source_server, password=source_os_password)
return ssh
def ssh_close_connection(ssh):
ssh.close()
def run_command(ssh):
stdin, stdout, stderr = ssh.exec_command('ps -aux | grep -i clamAv')
cmd_out = stdout.readlines()
if cmd_out == '':
print ("ClamAV not installed in the server {}".format(source_server))
with open(file1, 'w') as wf:
wf.write("ClamAV not installed in the server {}".format(source_server))
else:
print("ClamAV is installed in {}".format(source_server))
def main():
print ("")
with open(Server_List,'r') as line:
for server in iter(line):
print ("Connecting to the server")
ssh = ssh_connection(source_server = server , source_os_password = "******")
run_command(ssh)
print("Closing Connection")
ssh_close_connection(ssh)
print ("Done")
print("")
return
if "__name__ == __main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment