运维笔记

nginx 是利用回调机制来处理进程的

select 是通过轮询进行查询

epoll  模型  是通过回调机制

运维脚本实例

1.通过这种方式把mysql的警告信息去掉

import subprocess
command="/data/mysql/percona5.7/bin/mysql -uroot -psdd -e 'show slave statusG'|grep Seconds|awk '{print $2}'"
res=subprocess.Popen(command,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
print(res.stdout.read().decode('utf-8'))

 2.第二种方式

import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname='192.168.40.230', port=22, username='root', password='m***')
command="/data/mysql/percona5.7/bin/mysql -uroot -pdddd -e 'show slave statusG'|grep Seconds|awk '{print $2}'"
stdin, stdout, stderr = ssh.exec_command(command)
result = stdout.read()
result_err = stderr.read()
print(result.decode('utf-8'))
原文地址:https://www.cnblogs.com/sunkedong/p/7859937.html