<返回更多

通过python批量巡检多台服务器

2023-08-10  微信公众号  凉兮
加入收藏

背景

因为工作需要,每天要对系统内的多台linux服务器做巡检,主要检查的内容有CPU,内存,进程,硬盘空间等。

源码

Python/ target=_blank class=infotextkey>Python部分

    paramiko模块需要自己安装

    pip install paramiko

#-*- coding:utf8 -*-import paramikoimport subprocessimport datetime
# 定义服务器列表和巡检脚本路径servers = [    {'hostname': 'server1', 'ip': '192.168.1.254', 'username': 'root', 'password': 'root@1234'},    {'hostname': 'server2', 'ip': '192.168.1.253', 'username': 'root', 'password': 'root@1234'},    # 添加更多服务器]script_path = 'D:\python_project\database_export\xj.sh'  # 替换为您的巡检脚本路径
# 遍历服务器列表进行巡检for server in servers:    try:        # 建立SSH连接        ssh = paramiko.SSHClient()        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())        ssh.connect(server['ip'], username=server['username'], password=server['password'])
        # 上传巡检脚本至远程服务器        sftp = ssh.open_sftp()        sftp.put(script_path, 'script.sh')        sftp.close()
        # 执行巡检脚本        stdin, stdout, stderr = ssh.exec_command('chmod +x script.sh && ./script.sh')        output = stdout.read().decode()
        # 打印巡检结果        print(f"Server: {server['hostname']}")        print(f"Output: {output}")        print("----------------------------------------")        #写入日志out.log        current_time = datetime.datetime.now()        logout = current_time.strftime("%Y-%m-%d.txt")        with open(logout,"a",encoding="utf-8") as file:            file.write(f"Server: {server['hostname']}rn")            file.write(f"Output: {output}")        # 关闭SSH连接        ssh.close()#屏幕打印,如果不需要则注释并注释上面try    except paramiko.AuthenticationException as e:        print(f"FAIled to connect to {server['hostname']}: {str(e)}")    except paramiko.SSHException as e:        print(f"Error occurred while connecting to {server['hostname']}: {str(e)}")

shell部分

#!/bin/bash
function RED(){#在页面上打印成红色#  echo -e "33[31m$@33[0m"#在日志输出不乱码echo -e "$@"}
function GRE(){#在页面上打印成绿色#  echo -e "33[36m$@33[0m"#在日志输出echo -e "$@"}
function OS_INFO(){  # 系统名  local OS_NAME=`uname -n`  # 系统版本  local OS_VERSION=`cat /etc/.kyinfo | grep dist_id | grep -oE "Kylin.*" 2>/dev/null || echo 获取信息失败`  # 系统类型  local OS_TYPE=`uname`  # 主机序列号  local OS_NUM=`dmidecode -t system | grep 'Serial Number' | awk '{print $3}'`  # 系统内核版本  local OS_KERNEL=`uname -r`  # 系统机器码  local OS_CODE=""  # 系统语言环境  local OS_LANG=`echo $LANG`  # 系统时间  local OS_DATE=`date +"%Y-%m-%d %H:%M:%S"`  # 系统运行时间  local OS_UPTIME=`uptime | awk -F',' '{sub(/.*up /,"",$1);print $1'} || echo 获取信息失败`  # 系统上次重启时间  local OS_LAST_REBOOT=`last reboot | head -1 | awk '{print $5,$6,$7,$8,$10}'`  # 系统上次关机时间  local OS_LAST_SHUTDOWN=`last -x | grep shutdown | head -1 | awk '{print $5,$6,$7,$8,$10}'`
  RED "################################# [ 系统信息巡检区 ] ######################################"  GRE "主机名:$OS_NAME"  GRE "主机类型:$OS_TYPE"  GRE "主机序列号:${OS_NUM:-获取信息失败}"  GRE "系统版本:$OS_VERSION"  GRE "系统内核版本:$OS_KERNEL"  GRE "系统机器码:${OS_CODE:-获取信息失败}"  GRE "系统语言环境:${OS_LANG}"  GRE "系统时间;$OS_DATE"  GRE "系统已运行时间:$OS_UPTIME"  GRE "系统上次重启时间:${OS_LAST_REBOOT:-获取信息失败}"  GRE "系统上次关机时间:${OS_LAST_SHUTDOWN:-获取信息失败}"}
function OS_HDWARE(){  # CPU架构  local CPU_ARCH=`uname -m`  # CPU型号  local CPU_TYPE=`cat /proc/cpuinfo | grep "model name" | uniq | awk -F':' '{sub(/ /,"",$2);print $2}'`  # CPU个数  local CPU_NUM=`cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l`  # CPU 核数  local CPU_CORE=`cat /proc/cpuinfo | grep cores | uniq | awk -F':' '{sub(/ /,"",$2);print $2}'`  # CPU 频率  local CPU_HZ=`cat /proc/cpuinfo | grep "cpu MHz" | uniq | awk -F':' '{sub(/ /,"",$2);printf "%s MHzn",$2}'`
  # 内存容量  local ME_SIZE=$(echo "scale=2;`cat /proc/meminfo | grep 'MemTotal:' | awk '{print $2}'`/1048576"|bc)  # 空闲内存  local ME_FREE=$(echo "scale=2;`cat /proc/meminfo | grep 'MemFree:' | awk '{print $2}'`/1048576"|bc)  # 可用内存  local ME_FREEE=$(echo "scale=2;`cat /proc/meminfo | grep 'MemAvailable:' | awk '{print $2}'`/1048576" | bc)  # 内存使用率  local ME_USE=$(awk 'BEGIN{printf "%.1f%n",('$ME_SIZE'-'$ME_FREEE')/'$ME_SIZE'*100}')  # SWAP大小  local ME_SWAP_SIZE=$(echo "scale=2;`cat /proc/meminfo | grep 'SwapTotal:' | awk '{print $2}'`/1048576"|bc)  # SWAP可用  local ME_SWAP_FREE=$(echo "scale=2;`cat /proc/meminfo | grep 'SwapFree:' | awk '{print $2}'`/1048576"|bc)  # SWAP使用率  local ME_SWAP_USE=$(awk 'BEGIN{printf "%.1f%n",('$ME_SWAP_SIZE'-'$ME_SWAP_FREE')/'$ME_SWAP_SIZE'*100}')  # Buffer大小  local ME_BUF=$(cat /proc/meminfo | grep 'Buffers:' | awk '{printf "%s KB",$2}')  # 内存Cache大小  local ME_CACHE=$(cat /proc/meminfo | grep '^Cached:' | awk '{printf "%s KB",$2}')
  # 当前系统所有网卡  local.NET_DEVICE=(`cat /proc/net/dev | awk 'NR>2 && $1 !~/lo/ {sub(/:/,"");print $1}'`)
  RED "################################# [ 系统硬件巡检区 ] ######################################"  GRE "CPU型号:$CPU_TYPE"  GRE "CPU架构:$CPU_ARCH"  GRE "CPU个数:$CPU_NUM"  GRE "CPU核数: $CPU_CORE"  GRE "CPU频率:$CPU_HZ"  GRE "内存容量:${ME_SIZE} GB"  GRE "内存空闲:${ME_FREE} GB"  GRE "内存可用:${ME_FREEE} GB"  GRE "内存使用率:${ME_USE}"  GRE "SWAP容量:$ME_SWAP_SIZE GB"  GRE "SWAP可用容量:$ME_SWAP_FREE GB"  GRE "SWAP使用率:$ME_SWAP_USE"  GRE "内存Buffer大小:${ME_BUF}"  GRE "内存Cache大小:${ME_CACHE}"
  for i in ${NET_DEVICE[@]}  do    GRE "网卡:$i  状态: $(ip link show ens33 | awk 'NR==1{print $9}') RX: $(ethtool -g ens33 | grep "RX:" | tail -1 | awk '{print $2}') TX: $(ethtool -g ens33 | grep "TX:" | tail -1 | awk '{print $2}')"  done}
function OS_NETWORK(){  # 系统IP  local IP=$(hostname -I)  # 网关地址  local GATEWAY=$(ip route | grep default &>/dev/null && ip route | grep default | awk '{print $3}' || echo '未设置默认网关')  # DNS地址  local DNS=(`cat /etc/resolv.conf | grep nameserver | uniq | awk '{print $2}'`)
  RED "################################# [ 系统网络巡检区 ] ######################################"  GRE "IP地址:$IP"  GRE "网关地址:$GATEWAY"  GRE "DNS地址:${DNS[@]}"  GRE "网关[$GATEWAY]连接情况: $(ping -t 1 -i 1 -c 5 -W 1 192.168.0.2 &>/dev/null && echo '正常通信' || echo '无法通信')"}
function OS_RESOURCE(){  # 系统磁盘列表  local DISK_LIST=(`lsblk | egrep "^[a-z].*" | grep -v "^sr" | awk '{print $1}'`)  # 系统磁盘使用率情况  local DISK_PER=(`df -h | awk 'NR>1 && $1 !~/sr/ {gsub(/%/,"",$5);print $5}'`)
  # CPU空闲率  local CPU_FREE=$(top -d 1 -n 1 -b | awk 'NR==3{print $8}')  # CPU使用率  local CPU_USE=$(awk 'BEGIN{printf "%.1f%n",100-'$CPU_FREE'}')  # CPU_TOP_TEN  local CPU_TOP_TEN=$(top -d 1 -n 1 -b | column -t | awk 'NR>=7 && NR<=15')
  # 当前进程数  local CPU_PROCESSORS=$(top -d 1 -n 1 -b | awk 'NR==2{print $2}')  # 当前正在运行进程数  local CPU_RUN_PROCESSORS=$(top -d 1 -n 1 -b | awk 'NR==2{print $4}')  # 当前正在休眠进程数  local CPU_SL_PROCESSORS=$(top -d 1 -n 1 -b | awk 'NR==2{print $6}')  # 当前停止运行进程数  local CPU_STOP_PROCESSORS=$(top -d 1 -n 1 -b | awk 'NR==2{print 8}')  # 当前僵尸进程数  local CPU_ZOM_PROCESSORS=$(top -d 1 -n 1 -b | awk 'NR==2{print $10}')

  RED "################################# [ 系统资源巡检区 ] ######################################"  GRE "CPU使用率:$CPU_USE"  GRE "CPU使用率前十进程信息:"  GRE "$(ps -eo user,pid,pcpu,pmem,args --sort=-pcpu | head -n 10)"  GRE "n内存使用率前十进程信息:"  GRE "$(ps -eo user,pid,pcpu,pmem,args --sort=-pmem | head -n 10)"  GRE "n磁盘IO信息:$(iotop -bon 1 &>/dev/null || echo 'io top 未安装信息获取失败')"  GRE "$(iotop -bon 1 &>/dev/null && iotop -bon 1 | head -n 13)"  GRE "n磁盘分区使用率是否正常:正常"  for i in ${DISK_LIST[@]}  do    if [[ -z "$(lsblk --nodeps -no serial /dev/$i)" ]]; then      GRE "磁盘:$i  磁盘序列号:获取信息失败"    else      GRE "磁盘:$i  磁盘序列号:$(lsblk --nodeps -no serial /dev/$i)"    fi  done  for i in ${DISK_PER[@]}  do    if [ $i -gt 80 ]; then      RED "某分区磁盘使用率为:$i% > 80% 请及时扩容"    fi  done  GRE "n系统磁盘分区inode使用情况:"  GRE "$(df -Thi)"  GRE "n系统当前进程数:$CPU_PROCESSORS"  GRE "系统当前进程运行数:$CPU_RUN_PROCESSORS"  GRE "系统当前休眠进程数:$CPU_SL_PROCESSORS"  GRE "系统当前停止进程数:$CPU_STOP_PROCESSORS"  GRE "系统当前僵尸进程数:$CPU_ZOM_PROCESSORS"
  GRE "n系统当前允许最大fd数量:$(cat /proc/sys/fs/file-nr | awk '{print $3}')"  GRE "系统当前已打开fd数量:$(cat /proc/sys/fs/file-nr | awk '{print $1}')"  GRE "系统单个进程运行打开fd数量:$(ulimit -n)"
  GRE "n系统当前socket连接数:$(netstat -anp &>/dev/null && netstat -anp | wc -l || echo 'net-tools 未安装,获取信息失败')"  GRE "系统 established socket数量: $(netstat -anp &>/dev/null && netstat -anp | grep "ESTABLISHED" | wc -l || echo 'net-tools 未安装,获取信息失败')"  GRE "系统 sync socket数量:$(netstat -anp &>/dev/null && netstat -anp | grep "SYN" | wc -l || echo 'net-tools 未安装,获取信息失败')"  GRE "系统当前已建立socket如下:"  GRE "$(netstat -anp &>/dev/null && netstat -anp | grep ESTABLISHED | awk '{printf "  本地:%-20s <=>    外部:%-22sn",$4,$5}' || echo '')"}
function OS_SECURITY(){  # 系统所有能登录的用户  local OS_USER=(`cat /etc/passwd | awk -F':' '$NF !~/nologin|sync|shutdown|halt/ {print $1}'`)  # Selinux  local OS_SELINUX=`getenforce`  # 防火墙状态  local OS_FIREWALLD=`service firewalld status &>/dev/null | grep "running" && echo on || echo off`
  RED "################################# [ 系统安全巡检区 ] ######################################"  GRE "防火墙状态: $OS_FIREWALLD"  GRE "Selinux状态:${OS_SELINUX}n"  GRE "系统可登录用户数:$(cat /etc/passwd | awk -F':' '$NF !~/nologin|sync|shutdown|halt/ {print $1}' | wc -l)"  GRE "系统可登录用户:${OS_USER[@]}"  for i in ${OS_USER[@]}  do    GRE "用户 $i 最后1次登录信息: $(lastlog -u $i | awk 'NR==2')"  done  GRE "系统当前登录用户:"  GRE "$(who | sed 's#[()]##g' | awk '{printf "   用户: %10s 终端: %7s 登录时间: %7s %7s 登录IP: %7sn",$1,$2,$3,$4,$5}')"}
function OS_SERVICE(){  RED "################################# [ 系统服务巡检区 ] ######################################"  GRE "自行添加"}
if [ $(id -u -n) != "root" ]; then  ERROR "请以ROOT用户运行这个脚本"fi
OS_INFOOS_HDWAREOS_NETWORKOS_RESOURCEOS_SECURITY

结果(日志文件名会是今天的日期)

Server: server1Output: ################################# [ 系统信息巡检区 ] ######################################主机名:openstack.if010.com主机类型:Linux主机序列号:VMware-56系统版本:获取信息失败系统内核版本:3.10.0-1160.el7.x86_64系统机器码:获取信息失败系统语言环境:en_US.UTF-8系统时间;2023-08-08 11:42:36系统已运行时间:3 days系统上次重启时间:Fri Aug 4 17:02 11:42系统上次关机时间:Fri Aug 4 17:02 17:02################################# [ 系统硬件巡检区 ] ######################################CPU型号:Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHzCPU架构:x86_64CPU个数:16CPU核数: 1CPU频率:2300.000 MHz内存容量:31.26 GB内存空闲:6.50 GB内存可用:18.91 GB内存使用率:39.5%SWAP容量:15.74 GBSWAP可用容量:15.74 GBSWAP使用率:0.0%内存Buffer大小:2108 KB内存Cache大小:13138240 KB网卡:ens192  状态:  RX:  TX: 网卡:brqe3a66b78-84  状态:  RX:  TX: 网卡:tap1c3dbd77-89  状态:  RX:  TX: ################################# [ 系统网络巡检区 ] ######################################IP地址:192.168.1.254 网关地址:192.168.1.1DNS地址:网关[192.168.1.1]连接情况: 无法通信################################# [ 系统资源巡检区 ] ######################################CPU使用率:1.4%CPU使用率前十进程信息:USER       PID %CPU %MEM COMMANDrabbitmq  1283  3.4  1.1 /usr/lib64/erlang/erts-8.3.5.3/bin/beam.smp -W w -A 256 -P 1048576 -t 5000000 -stbt db -zdbbl 128000 -K true -- -root /usr/lib64/erlang -progname erl -- -home /var/lib/rabbitmq -- -pa /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.16/ebin -noshell -noinput -s rabbit boot -sname rabbit@openstack -boot start_sasl -config /etc/rabbitmq/rabbitmq -kernel inet_default_connect_options [{nodelay,true}] -sasl errlog_type error -sasl sasl_error_logger false -rabbit error_logger {file,"/var/log/rabbitmq/rabbit@openstack.log"} -rabbit sasl_error_logger {file,"/var/log/rabbitmq/rabbit@openstack-sasl.log"} -rabbit enabled_plugins_file "/etc/rabbitmq/enabled_plugins" -rabbit plugins_dir "/usr/lib/rabbitmq/plugins:/usr/lib/rabbitmq/lib/rabbitmq_server-3.6.16/plugins" -rabbit plugins_expand_dir "/var/lib/rabbitmq/mnesia/rabbit@openstack-plugins-expand" -os_mon start_cpu_sup false -os_mon start_disksup false -os_mon start_memsup false -mnesia dir "/var/lib/rabbitmq/mnesia/rabbit@openstack" -kernel inet_dist_listen_min 25672 -kernel inet_dist_listen_max 25672cinder    3607  2.3  0.3 /usr/bin/python2 /usr/bin/cinder-volume --config-file /usr/share/cinder/cinder-dist.conf --config-file /etc/cinder/cinder.conf --logfile /var/log/cinder/volume.logMySQL     3429  1.5  3.1 /data/mysql/bin/mysqld --basedir=/data/mysql --datadir=/data/mysql/data --plugin-dir=/data/mysql/lib/plugin --user=mysql --log-error=openstack.if010.com.err --pid-file=/data/mysql/data/openstack.if010.com.pid --socket=/var/lib/mysql/mysql.sock --port=3306designa+  1280  1.4  0.2 /usr/bin/python2 /usr/bin/designate-central --config-file /etc/designate/designate.conf --log-file /var/log/designate/central.logneutron   1290  1.0  0.2 /usr/bin/python2 /usr/bin/neutron-dhcp-agent --config-file /usr/share/neutron/neutron-dist.conf --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/dhcp_agent.ini --config-dir /etc/neutron/conf.d/common --config-dir /etc/neutron/conf.d/neutron-dhcp-agent --log-file /var/log/neutron/dhcp-agent.lognova      1279  0.9  0.2 /usr/bin/python2 /usr/bin/nova-conductornova      1285  0.9  0.3 /usr/bin/python2 /usr/bin/nova-apiheat      1294  0.9  0.2 /usr/bin/python /usr/bin/heat-engine --config-file /usr/share/heat/heat-dist.conf --config-file /etc/heat/heat.confcinder    1268  0.8  0.4 /usr/bin/python2 /usr/bin/cinder-api --config-file /usr/share/cinder/cinder-dist.conf --config-file /etc/cinder/cinder.conf --logfile /var/log/cinder/api.log
内存使用率前十进程信息:USER       PID %CPU %MEM COMMANDmysql     3429  1.5  3.1 /data/mysql/bin/mysqld --basedir=/data/mysql --datadir=/data/mysql/data --plugin-dir=/data/mysql/lib/plugin --user=mysql --log-error=openstack.if010.com.err --pid-file=/data/mysql/data/openstack.if010.com.pid --socket=/var/lib/mysql/mysql.sock --port=3306rabbitmq  1283  3.4  1.1 /usr/lib64/erlang/erts-8.3.5.3/bin/beam.smp -W w -A 256 -P 1048576 -t 5000000 -stbt db -zdbbl 128000 -K true -- -root /usr/lib64/erlang -progname erl -- -home /var/lib/rabbitmq -- -pa /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.16/ebin -noshell -noinput -s rabbit boot -sname rabbit@openstack -boot start_sasl -config /etc/rabbitmq/rabbitmq -kernel inet_default_connect_options [{nodelay,true}] -sasl errlog_type error -sasl sasl_error_logger false -rabbit error_logger {file,"/var/log/rabbitmq/rabbit@openstack.log"} -rabbit sasl_error_logger {file,"/var/log/rabbitmq/rabbit@openstack-sasl.log"} -rabbit enabled_plugins_file "/etc/rabbitmq/enabled_plugins" -rabbit plugins_dir "/usr/lib/rabbitmq/plugins:/usr/lib/rabbitmq/lib/rabbitmq_server-3.6.16/plugins" -rabbit plugins_expand_dir "/var/lib/rabbitmq/mnesia/rabbit@openstack-plugins-expand" -os_mon start_cpu_sup false -os_mon start_disksup false -os_mon start_memsup false -mnesia dir "/var/lib/rabbitmq/mnesia/rabbit@openstack" -kernel inet_dist_listen_min 25672 -kernel inet_dist_listen_max 25672Apache    5779  0.0  0.4 /usr/sbin/httpd -DFOREGROUNDnova      2662  0.0  0.4 /usr/bin/python2 /usr/bin/nova-apinova      2663  0.0  0.4 /usr/bin/python2 /usr/bin/nova-apinova      2651  0.0  0.4 /usr/bin/python2 /usr/bin/nova-apinova      2653  0.0  0.4 /usr/bin/python2 /usr/bin/nova-apinova      2659  0.0  0.4 /usr/bin/python2 /usr/bin/nova-apinova      2649  0.0  0.4 /usr/bin/python2 /usr/bin/nova-api
磁盘IO信息:io top 未安装信息获取失败

磁盘分区使用率是否正常:正常磁盘:sda  磁盘序列号:获取信息失败磁盘:sdb  磁盘序列号:获取信息失败
系统磁盘分区inode使用情况:Filesystem              Type     Inodes IUsed IFree IUse% Mounted ondevtmpfs                devtmpfs   4.0M   477  4.0M    1% /devtmpfs                   tmpfs      4.0M     1  4.0M    1% /dev/shmtmpfs                   tmpfs      4.0M   796  4.0M    1% /runtmpfs                   tmpfs      4.0M    16  4.0M    1% /sys/fs/cgroup/dev/mApper/centos-root xfs         25M   90K   25M    1% //dev/sda1               xfs        512K   327  512K    1% /boot/dev/mapper/centos-home xfs        217M     3  217M    1% /hometmpfs                   tmpfs      4.0M     1  4.0M    1% /run/user/0
系统当前进程数:510系统当前进程运行数:1系统当前休眠进程数:509系统当前停止进程数:8系统当前僵尸进程数:0
系统当前允许最大fd数量:3138986系统当前已打开fd数量:7232系统单个进程运行打开fd数量:1024
系统当前socket连接数:net-tools 未安装,获取信息失败系统 established socket数量: net-tools 未安装,获取信息失败系统 sync socket数量:net-tools 未安装,获取信息失败系统当前已建立socket如下:
################################# [ 系统安全巡检区 ] ######################################防火墙状态: offSelinux状态:Disabled
系统可登录用户数:2系统可登录用户:root mysql用户 root 最后1次登录信息: root             pts/5    192.168.1.118    Fri Aug  4 17:03:15 +0800 2023用户 mysql 最后1次登录信息: mysql                                      **Never logged in**系统当前登录用户:   用户:       root 终端:   pts/0 登录时间: 2023-08-04   17:03 登录IP: 192.168.1.118   用户:       root 终端:   pts/1 登录时间: 2023-08-04   17:03 登录IP: 192.168.1.118   用户:       root 终端:   pts/2 登录时间: 2023-08-04   17:03 登录IP: 192.168.1.118   用户:       root 终端:   pts/4 登录时间: 2023-08-04   17:03 登录IP: 192.168.1.118   用户:       root 终端:   pts/6 登录时间: 2023-08-04   17:03 登录IP: 192.168.1.118   用户:       root 终端:   pts/3 登录时间: 2023-08-04   17:03 登录IP: 192.168.1.118   用户:       root 终端:   pts/5 登录时间: 2023-08-04   17:03 登录IP: 192.168.1.118
----------------------------------------Server: server2Output: ################################# [ 系统信息巡检区 ] ######################################主机名:openstack.node1.if010.com主机类型:Linux主机序列号:VMware-56系统版本:获取信息失败系统内核版本:3.10.0-1160.el7.x86_64系统机器码:获取信息失败系统语言环境:en_US.UTF-8系统时间;2023-08-08 11:42:44系统已运行时间:3 days系统上次重启时间:Fri Aug 4 17:09 11:42系统上次关机时间:Fri Aug 4 17:02 17:02################################# [ 系统硬件巡检区 ] ######################################CPU型号:Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHzCPU架构:x86_64CPU个数:4CPU核数: 1CPU频率:2300.000 MHz内存容量:7.63 GB内存空闲:6.58 GB内存可用:6.57 GB内存使用率:13.9%SWAP容量:7.87 GBSWAP可用容量:7.87 GBSWAP使用率:0.0%内存Buffer大小:2108 KB内存Cache大小:201300 KB网卡:ens192  状态:  RX:  TX: 网卡:brqe3a66b78-84  状态:  RX:  TX: 网卡:tap0b074ce1-d4  状态:  RX:  TX: ################################# [ 系统网络巡检区 ] ######################################IP地址:192.168.1.253 网关地址:192.168.1.1DNS地址:网关[192.168.1.1]连接情况: 无法通信################################# [ 系统资源巡检区 ] ######################################CPU使用率:3.1%CPU使用率前十进程信息:USER       PID %CPU %MEM COMMANDqemu      2448  4.5  1.8 /usr/libexec/qemu-kvm -name guest=instance-00000003,debug-threads=on -S -object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-2-instance-00000003/master-key.aes -machine pc-i440fx-rhel7.6.0,accel=tcg,usb=off,dump-guest-core=off -cpu EPYC,acpi=on,ss=on,hypervisor=on,erms=on,mpx=on,pcommit=on,clwb=on,pku=on,ospke=on,la57=on,3dnowext=on,3dnow=on,vme=off,fma=off,avx=off,f16c=off,rdrand=off,avx2=off,rdseed=off,sha-ni=off,xsavec=off,fxsr_opt=off,misalignsse=off,3dnowprefetch=off,osvw=off,topoext=off -m 64 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid 9e30d5ff-98d9-4319-99db-dc63ed7101e7 -smbIOS type=1,manufacturer=RDO,product=OpenStack Compute,version=17.0.13-1.el7,serial=5d53ad5e-aeda-4081-8d98-3f370c6b49ca,uuid=9e30d5ff-98d9-4319-99db-dc63ed7101e7,family=Virtual Machine -no-user-config -nodefaults -chardev socket,id=charmonitor,fd=26,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -boot strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/var/lib/nova/instances/9e30d5ff-98d9-4319-99db-dc63ed7101e7/disk,format=qcow2,if=none,id=drive-virtio-disk0,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1,write-cache=on -netdev tap,fd=28,id=hostnet0 -device virtio-net-pci,host_mtu=1500,netdev=hostnet0,id=net0,mac=fa:16:3e:62:6e:cc,bus=pci.0,addr=0x3 -add-fd set=2,fd=30 -chardev pty,id=charserial0,logfile=/dev/fdset/2,logappend=on -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0,bus=usb.0,port=1 -vnc 0.0.0.0:0 -k en-us -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny -msg timestamp=onnova      2314  0.6  1.7 /usr/bin/python2 /usr/bin/nova-computeroot     15945  0.5  0.0 sshd: root@nottyroot     15962  0.2  0.0 /bin/bash ./script.shneutron   1103  0.1  1.4 /usr/bin/python2 /usr/bin/neutron-linuxbridge-agent --config-file /usr/share/neutron/neutron-dist.conf --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/linuxbridge_agent.ini --config-dir /etc/neutron/conf.d/common --config-dir /etc/neutron/conf.d/neutron-linuxbridge-agent --log-file /var/log/neutron/linuxbridge-agent.logroot         1  0.0  0.0 /usr/lib/systemd/systemd --switched-root --system --deserialize 22root         2  0.0  0.0 [kthreadd]root         4  0.0  0.0 [kworker/0:0H]root         6  0.0  0.0 [ksoftirqd/0]
内存使用率前十进程信息:USER       PID %CPU %MEM COMMANDqemu      2448  4.5  1.8 /usr/libexec/qemu-kvm -name guest=instance-00000003,debug-threads=on -S -object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-2-instance-00000003/master-key.aes -machine pc-i440fx-rhel7.6.0,accel=tcg,usb=off,dump-guest-core=off -cpu EPYC,acpi=on,ss=on,hypervisor=on,erms=on,mpx=on,pcommit=on,clwb=on,pku=on,ospke=on,la57=on,3dnowext=on,3dnow=on,vme=off,fma=off,avx=off,f16c=off,rdrand=off,avx2=off,rdseed=off,sha-ni=off,xsavec=off,fxsr_opt=off,misalignsse=off,3dnowprefetch=off,osvw=off,topoext=off -m 64 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid 9e30d5ff-98d9-4319-99db-dc63ed7101e7 -smbios type=1,manufacturer=RDO,product=OpenStack Compute,version=17.0.13-1.el7,serial=5d53ad5e-aeda-4081-8d98-3f370c6b49ca,uuid=9e30d5ff-98d9-4319-99db-dc63ed7101e7,family=Virtual Machine -no-user-config -nodefaults -chardev socket,id=charmonitor,fd=26,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -boot strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/var/lib/nova/instances/9e30d5ff-98d9-4319-99db-dc63ed7101e7/disk,format=qcow2,if=none,id=drive-virtio-disk0,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1,write-cache=on -netdev tap,fd=28,id=hostnet0 -device virtio-net-pci,host_mtu=1500,netdev=hostnet0,id=net0,mac=fa:16:3e:62:6e:cc,bus=pci.0,addr=0x3 -add-fd set=2,fd=30 -chardev pty,id=charserial0,logfile=/dev/fdset/2,logappend=on -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0,bus=usb.0,port=1 -vnc 0.0.0.0:0 -k en-us -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny -msg timestamp=onnova      2314  0.6  1.7 /usr/bin/python2 /usr/bin/nova-computeneutron   1103  0.1  1.4 /usr/bin/python2 /usr/bin/neutron-linuxbridge-agent --config-file /usr/share/neutron/neutron-dist.conf --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/linuxbridge_agent.ini --config-dir /etc/neutron/conf.d/common --config-dir /etc/neutron/conf.d/neutron-linuxbridge-agent --log-file /var/log/neutron/linuxbridge-agent.logroot      2374  0.0  0.4 /usr/bin/python2 /bin/privsep-helper --config-file /usr/share/nova/nova-dist.conf --config-file /etc/nova/nova.conf --privsep_context nova.privsep.sys_admin_pctxt --privsep_sock_path /tmp/tmp0RlouT/privsep.sockroot      2416  0.0  0.4 /usr/bin/python2 /bin/privsep-helper --config-file /usr/share/nova/nova-dist.conf --config-file /etc/nova/nova.conf --privsep_context vif_plug_linux_bridge.privsep.vif_plug --privsep_sock_path /tmp/tmpDVcaHW/privsep.sockroot      2223  0.0  0.2 /usr/bin/python2 /usr/bin/neutron-rootwrap-daemon /etc/neutron/rootwrap.confroot      1101  0.0  0.2 /usr/sbin/libvirtdroot      1084  0.0  0.2 /usr/bin/python2 -Es /usr/sbin/tuned -l -Ppolkitd    827  0.0  0.1 /usr/lib/polkit-1/polkitd --no-debug
磁盘IO信息:io top 未安装信息获取失败

磁盘分区使用率是否正常:正常磁盘:sda  磁盘序列号:获取信息失败
系统磁盘分区inode使用情况:Filesystem              Type     Inodes IUsed IFree IUse% Mounted ondevtmpfs                devtmpfs   975K   391  975K    1% /devtmpfs                   tmpfs      978K     1  978K    1% /dev/shmtmpfs                   tmpfs      978K   670  978K    1% /runtmpfs                   tmpfs      978K    16  978K    1% /sys/fs/cgroup/dev/mapper/centos-root xfs         25M   65K   25M    1% //dev/sda1               xfs        512K   371  512K    1% /boot/dev/mapper/centos-home xfs         71M    91   71M    1% /hometmpfs                   tmpfs      978K     1  978K    1% /run/user/0
系统当前进程数:211系统当前进程运行数:1系统当前休眠进程数:210系统当前停止进程数:8系统当前僵尸进程数:0
系统当前允许最大fd数量:763901系统当前已打开fd数量:2240系统单个进程运行打开fd数量:1024
系统当前socket连接数:net-tools 未安装,获取信息失败系统 established socket数量: net-tools 未安装,获取信息失败系统 sync socket数量:net-tools 未安装,获取信息失败系统当前已建立socket如下:
################################# [ 系统安全巡检区 ] ######################################防火墙状态: offSelinux状态:Disabled
系统可登录用户数:2系统可登录用户:root ftpuser用户 root 最后1次登录信息: root             pts/1    192.168.1.118    Fri Aug  4 17:10:29 +0800 2023用户 ftpuser 最后1次登录信息: ftpuser                                    **Never logged in**系统当前登录用户:   用户:       root 终端:   pts/0 登录时间: 2023-08-04   17:10 登录IP: 192.168.1.118   用户:       root 终端:   pts/1 登录时间: 2023-08-04   17:10 登录IP: 192.168.1.118
关键词:服务器      点击(5)
声明:本站部分内容来自互联网,如有版权侵犯或其他问题请与我们联系,我们将立即删除或处理。
▍相关推荐
更多服务器相关>>>