In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Requirements: view multiple machines to see multiple system CPU, specified process CPU, active and standby status, memory usage; and display on one machine
First: set ssh password-free login first
Ssh-keygen-t rsa playing'- f ~ / .ssh/id_rsa does not prompt to generate the secret key directly
Ssh-copy-id-I / .ssh/id_rsa.pub root@ip
Second: query script, which is copied to each machine
Scp / usr/local/src/cpu_men.sh root@ip: / usr/local/src/
Script content
#! / bin/bash
Cpu=top-bn1 | awk-F "[,:%]" / Cpu/ {print $2}'
Men_total=free-m | grep Mem | awk'{print $2}'
Men_used=free-m | grep Mem | awk'{print $3}'
Men_av=awk 'BEGIN {printf "% .0f\ n", (' ${men_used}'/'${men_total}') * 100}'
Num=ifconfig | awk'/ eth.:./ {print $1}'| wc-l
Syseth= "Lord"
[${num}-eq 0] & & syseth= "preparation"
IP=ifconfig | awk-F "[:] +" NR==2 {print $4}'
Pronum=ps aux | grep tdci | grep-Ev "$$| grep" | awk'{print $3}'| wc-l
Procpu=ps aux | grep tdci | grep-Ev "$$| grep" | awk'{print $3}'| xargs
# awk 'BEGIN {printf "%-20s%-10s%-10s%-10s%-20s\ n", "IP-", "status-", "CPU%-", "men%-", "procpu%-"}'
Awk 'BEGIN {printf "%-20s%-13s%-12s%-10s", "' ${IP}'", "'$syseth'", "'" ${cpu} "'",'"${men_av}"'}'
Echo "$procpu (${pronum}" tdic ")"
Third: overall query and display the script on a host: ssh_exec.sh
#! / bin/bash
Awk 'BEGIN {printf "%-20s%-10s%-10s%-10s%-20s\ n", "IP-", "status-", "CPU%-", "men%-", "procpu%-"}' arry= (
192.168.50.5
192.168.50.6
192.168.50.9
)
For ((iTuno / iarry = (
192.168.50.5
192.168.50.6
192.168.50.9
)
For ((iTun0) I [root@INTSVR-B src] # sh ssh_exec.sh > IP-status-CPU%-men%-procpu%- > 192.168.50.5 / 3.6101.3 0.5 (2 tdic) > 192.168.50.6 Master 8.4 12 24.8 2.4 (2 tdic) > 192.168.50.9 Master 4.5 30 0.7 (1 tdic) > 192.168.5010 standby 1.4 10 (0 tdic) > [root@INTSVR-B src] #
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.