nagios 分发文件实现代码
Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设置,打印机等。在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员,在状态恢复后发出正常的邮件或短信通知。
#!/bin/bash #!/usr/bin/expect -f #!/usr/bin/env bash for((i=101;i<=177;i++)) do #cmd="wget http://172.16.92.99/scripts/nagios_client_install.sh && chmod 777 nagios_client_install.sh && sh nagios_client_install.sh" line="192.168.89.$i" cmd1="/etc/init.d/xinetd restart" cmd2="ssh root@$line" cmd3="scp -r ./nagios/libexec $line:/usr/local/nagios" cmd4="scp ./nagios/nrpe.cfg $line:/usr/local/nagios/etc/" expect -c "#set timeout 20; #spawn $cmd4; set timeout 200; spawn $cmd3; set timeout 20; #spawn $cmd2; set timeout 1200; #expect "*@*";send "$cmd1r exitr";; expect eof;" if [ $i -eq 145 ] then i=151 fi done
阿里云云服务器Linux系统更新yum源Shell脚本
所有执行的脚本都需要root身份来执行,执行方法:以root身份执行命令:bashxxx.sh功能:自动检测系统并更新源适用系统版本:兼容线上所有linux版本执行