Commit 228b48e8 by jajapi

Add updateSH_kpf.py, checkPM_kpf.py / rename checkPM, updatePM

parent b50f33f0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import paramiko
import getpass
......@@ -32,7 +33,7 @@ for svrhost in serverhost:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host,username=username,password='%s' %(password))
ssh.exec_command('./Seocho_uxen_check.sh > %s' % (host))
ssh.exec_command('sudo ./Seocho_uxen_check.sh > %s' % (host))
ssh.close()
print("%s check.sh excution"%(host))
......
......@@ -32,7 +32,7 @@ for svrhost in serverhost:
sftp.put(localpath,filepath)
filepath = '/home/orchard/factor'
localpath = '/home/orchard/CSCS/GuestPM/Integration/factor'
localpath = '/home/orchard/CSCS/MgmtPM/CMSmgmt/factor'
sftp.put(localpath,filepath)
sftp.close()
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import paramiko
import getpass
import time
import os
import subprocess
### initialize factor value
fac = subprocess.check_output ('cat factor',shell=True)
fac2 = subprocess.check_output ('cat factor',shell=True)
### read serverlists
serverlist = open("kpf_serverlist.txt", 'r')
serverhost = serverlist.readlines()
### input password
password = getpass.getpass("orchard password :")
### static value
username = "orchard"
port = 22
### check.sh
for svrhost in serverhost:
host = svrhost.strip()
### ssh 접속, 명령어 실행,접속종료
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host,username=username,password='%s' %(password))
ssh.exec_command('sudo ./Seocho_uxen_check.sh > %s' % (host))
ssh.close()
print("%s check.sh excution"%(host))
### sftp 접속
transport = paramiko.Transport((host,port))
transport.connect(username=username, password=password)
sftp=paramiko.SFTPClient.from_transport(transport)
### 인자값 비교해서 달라질때 까지 반복
while fac == fac2:
time.sleep(1)
filepath = ('/home/orchard/factor')
localpath = ('/home/orchard/CSCS/MgmtPM/KPFmgmt/factor')
sftp.get(filepath,localpath)
fac =subprocess.check_output ('cat factor',shell=True)
### 인자값이 달라지면 실행할 sftp
filepath = ('/home/orchard/%s' %(host))
localpath = ('/home/orchard/result/%s'%(host))
sftp.get(filepath,localpath)
print("%s Successful copy" % host)
### 인자값 초기화
os.system('sed -i "s/1/0/" factor')
filepath = ('/home/orchard/factor')
localpath = ('/home/orchard/CSCS/MgmtPM/KPFmgmt/factor')
sftp.put(localpath,filepath)
fac =subprocess.check_output ('cat factor',shell=True)
### sftp 접속종료
sftp.close()
transport.close()
wcms-pm01
wcms-pm02
wcms-pm03
wcms-pm04
wcms-pm05
wcms-pm06
wcms-backup
ad-pm01
ad-pm02
ad-pm03
ad-pm04
ad-backup
media-pm01
media-pm02
media-pm03
media-backup
digital-pm01
digital-pm02
digital-pm03
digital-pm04
digital-pm05
digital-backup
bigdata-pm01
bigdata-pm02
bigdata-pm03
bigdata-pm04
bigdata-pm05
bigdata-pm06
bigdata-pm07
......@@ -4,7 +4,7 @@ import paramiko
import getpass
### read serverlists
serverlist = open("cms_serverlist.txt", 'r')
serverlist = open("kpf_serverlist.txt", 'r')
serverhost = serverlist.readlines()
......@@ -27,12 +27,25 @@ for svrhost in serverhost:
sftp=paramiko.SFTPClient.from_transport(transport)
filepath = '/home/orchard/Integration_uxen_check.sh'
localpath = '/home/orchard/CSCS/GuestPM/Integration/Integration_uxen_check.sh'
filepath = '/home/orchard/Seocho_uxen_check.sh'
localpath = '/home/orchard/CSCS/GuestPM/Integration/Seocho_uxen_check.sh'
sftp.put(localpath,filepath)
print("%s Successful updates" % host)
filepath = '/home/orchard/factor'
localpath = '/home/orchard/CSCS/MgmtPM/KPFmgmt/factor'
sftp.put(localpath,filepath)
sftp.close()
transport.close()
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host,username=username,password='%s' %(password))
ssh.exec_command('sudo chmod 700 /home/orchard/Seocho_uxen_check.sh')
ssh.close()
print("%s Successful updates" % host)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment