用shell脚本检测多台机器cpu使用情况的实例,学习sar -u的用法。
要实现用shell脚本检测多台机器的cpu使用情况,需要做到:
注:以下脚本在HP-UX上通过,hp-ux的bash为/sbin/sh,sun-solaris为/sbin/bash。
复制代码代码示例:
# cat ./saru.sh
#!/sbin/sh
#monitor the check-logfile in-real-time
#define shell-script's option
#main shell-script begin
#monitor if check-log-file has been finished
#get brief-result from detail check-log-file for per-host
#exit and kill the tail-f process exit 0
调用方法:
复制代码代码示例:
saru.sh [intervals] [counts] [sleeptimes]
(责任编辑:IT)note: default value: interval=30,counts=60,sleeptimes=60 sleeptimes:the interval-times, to check if detail-check-logfile has been finished. you must be sure that the machine in the hostlist-file can be logined by use "rlogin" command. example: ./saru.sh 30 60 & ./saru.sh 5 10 10 & nohup ./saru.sh & |