Ejemplo n.º 1
0
# -*- coding:utf-8 -*-
import redis
import sys
from ser_tools.Tools import readFile
import os

FILE_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                         "conf/redis.lst")
CONFIG = readFile(FILE_PATH)


def test_conn(host, password, port):
    conn_res = False
    command = '/usr/local/bin/redis-cli -h {} -p {} -a {} PING'.format(
        host, port, password)
    res = os.popen(command)
    result = res.read().replace('\n', '')

    if 'Authentication' in result:
        print(result)
    if result == 'PONG':
        conn_res = True
    return conn_res


def query_redis(r, key):
    r_type = r.type(key)
    if r_type == 'hash':
        print(str(r.hgetall(key)).decode('utf8'))
    elif r_type == 'list':
        #list从左到右取全部
Ejemplo n.º 2
0
# -*- coding:utf-8 -*-
# author : zhou xy
import sys
import paramiko
import time
import os
from ser_tools.Tools import readFile,chkTools
import threading
from conf import settings
from ser_tools.param_ssh import sshConnection
from ser_tools.Managment import Args

date=time.strftime('%Y%m%d',time.localtime(time.time())) 
FILE_PATH=settings.IPLIST_PATH
config=readFile(FILE_PATH)
check_tools=chkTools()
#lock=threading.RLock()

def get_log(ip,path,frame,log_dt,key_word,log_name,ssh):
	command=''
	if frame == 'ics' :
		query_path=os.path.join(path,log_dt[2:])
		stdin,stdout,stderr=ssh.exec_command('cd '+query_path+' ;ls -lrt '+log_name)
		file_list=stdout.readlines()
		if not file_list :
			print('='*5+ip+'='*5+'\n'+' no such file')
			return
		log_list=check_tools.filter_log_time(file_list,log_dt)
		is_gz=check_tools.chk_is_gz(log_list)
		if is_gz:
			command='cd '+query_path+' ;zgrep '+key_word+' '+log_name
Ejemplo n.º 3
0
# -*- coding:utf-8 -*-
import paramiko
from ser_tools.Tools import readFile, chkTools
import datetime
import os, sys
import re
from conf import settings
import threading

rlock = threading.RLock()
__MIN_DUR = settings.MIN_DURATION  # 设置执行时长阀值
file_path = settings.IPLIST_PATH
config = readFile(file_path)
check_tools = chkTools()
cur_date = datetime.datetime.now().strftime('%Y%m%d')
__PATTERN = r'\"dur\":(.*?)\,'


def query_ntp(ssh, log_path, file_name, tx_name, min_dur, ip):
    def get_file_name(ssh, file_name):
        '''找到新框架日志中不包含日期的txnPlt日志'''
        command = 'cd ' + log_path + ';ls ' + file_name + '|grep -v "[0-9]"'
        stdin, stdout, stderr = ssh.exec_command(command)
        result = stdout.read()
        return result

    real_file_name = get_file_name(ssh, file_name)
    command = 'cd ' + log_path + '; grep \'"tc":"' + tx_name + '"\' ' + real_file_name
    stdin, stdout, stderr = ssh.exec_command(command)
    rlock.acquire()
    result_list = stdout.readlines()