Commit d048b868 by jajapi

Add gads-pm, Modify check.sh

parent edde508a
......@@ -286,7 +286,12 @@ function GET_CMS_UXEN_LOG()
REFINED_UXEN3_API_LOG=/tmp/refined_uxenapi.log
REFINED_UWSGI_LOG=/tmp/uwsgi.log
DATE=0
date -R > $DATE
MONTH=$(cut $DATE -f 3 -d' ')
YEAR=$(cut $DATE -f 4 -d' ')
ls -r $DEFAULT_UXEN3_API_LOG | xargs cat > $ENTIRE_UXEN3_API_LOG
echo -e "\n\x1b[45m"UXENAPI"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire uxenapi"\x1b[0m---------------------\n"
......@@ -306,7 +311,7 @@ function GET_CMS_UXEN_LOG()
tail $DEFAULT_UWSGI_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $DEFAULT_UWSGI_LOG | grep --color=yes -E "1.1 400" |grep --color=yes -E "2018"|grep --color=yes "Nov"
cat $DEFAULT_UWSGI_LOG | grep --color=yes -E "1.1 400" |grep --color=yes -E "$YEAR"|grep --color=yes "$MONTH"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see $DEFAULT_UWSGI_LOG"
......@@ -324,6 +329,11 @@ function GET_WEB_UXEN_LOG()
REFINED_UXEN3_API_LOG=/tmp/refined_uxenapi.log
REFINED_UWSGI_LOG=/tmp/uwsgi.log
DATE=0
date -R > $DATE
MONTH=$(cut $DATE -f 3 -d' ')
YEAR=$(cut $DATE -f 4 -d' ')
ls -r $DEFAULT_UXEN3_API_LOG | xargs cat > $ENTIRE_UXEN3_API_LOG
echo -e "\n\x1b[45m"UXENAPI"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire uxenapi"\x1b[0m---------------------\n"
......@@ -343,7 +353,7 @@ function GET_WEB_UXEN_LOG()
tail $DEFAULT_UWSGI_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $DEFAULT_UWSGI_LOG | grep --color=yes -E "1.1 400" |grep --color=yes -E "2018"|grep --color=yes "Nov"
cat $DEFAULT_UWSGI_LOG | grep --color=yes -E "1.1 400" |grep --color=yes -E "$YEAR"|grep --color=yes "$MONTH"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see $DEFAULT_UWSGI_LOG"
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import paramiko
import getpass
......@@ -7,66 +7,64 @@ 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)
# initialize factor value
fac = subprocess.check_output('cat factor', shell=True)
fac2 = subprocess.check_output('cat factor', shell=True)
### read serverlists
# read serverlists
serverlist = open("cms_serverlist.txt", 'r')
serverhost = serverlist.readlines()
### input password
password = getpass.getpass("orchard password :")
# input password
password = getpass.getpass("orchard password :")
### static value
# static value
username = "orchard"
port = 22
### check.sh
# check.sh
for svrhost in serverhost:
host = svrhost.strip()
### ssh 접속, 명령어 실행,접속종료
# ssh 접속, 명령어 실행,접속종료
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host,username=username,password='%s' %(password))
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))
print("%s check.sh excution" % (host))
### sftp 접속
transport = paramiko.Transport((host,port))
# sftp 접속
transport = paramiko.Transport((host, port))
transport.connect(username=username, password=password)
sftp=paramiko.SFTPClient.from_transport(transport)
sftp = paramiko.SFTPClient.from_transport(transport)
### 인자값 비교해서 달라질때 까지 반복
# 인자값 비교해서 달라질때 까지 반복
while fac == fac2:
time.sleep(1)
filepath = ('/home/orchard/factor')
localpath = ('/home/orchard/CSCS/MgmtPM/CMSmgmt/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)
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/CMSmgmt/factor')
sftp.put(localpath,filepath)
fac =subprocess.check_output ('cat factor',shell=True)
sftp.put(localpath, filepath)
fac = subprocess.check_output('cat factor', shell=True)
### sftp 접속종료
# sftp 접속종료
sftp.close()
transport.close()
......@@ -17,3 +17,9 @@ web-p-pm04
web-p-pm05
web-t-pm01
web-t-pm02
gads-p-pm01
gads-p-pm02
gads-p-pm03
gads-p-pm04
gads-p-pm05
gads-t-pm01
......@@ -3,49 +3,46 @@
import paramiko
import getpass
### read serverlists
# read serverlists
serverlist = open("cms_serverlist.txt", 'r')
serverhost = serverlist.readlines()
### input password
password = getpass.getpass("orchard password :")
# input password
password = getpass.getpass("orchard password :")
### static value
# static value
username = "orchard"
port = 22
### update check.sh
# update check.sh
for svrhost in serverhost:
host = svrhost.strip()
transport = paramiko.Transport((host,port))
transport = paramiko.Transport((host, port))
transport.connect(username=username, password=password)
sftp=paramiko.SFTPClient.from_transport(transport)
sftp = paramiko.SFTPClient.from_transport(transport)
filepath = '/home/orchard/Seocho_uxen_check.sh'
localpath = '/home/orchard/CSCS/GuestPM/Integration/Seocho_uxen_check.sh'
sftp.put(localpath,filepath)
sftp.put(localpath, filepath)
filepath = '/home/orchard/factor'
localpath = '/home/orchard/CSCS/MgmtPM/CMSmgmt/factor'
sftp.put(localpath,filepath)
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.connect(host, username=username, password='%s' % (password))
ssh.exec_command('sudo chmod 700 /home/orchard/Seocho_uxen_check.sh')
ssh.close()
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