#!/bin/bash #Script monitor.sh Usermonitor() { LoginUser=`uptime |awk ‘{print $6}‘` if [ $LoginUser -ge 2 ] then Critical="当前系统的登录人数过多,具体人数为:$LoginUser个,请确认操作人数." status=0 else echo "loginuser ok" status=1 fi } for n in Usermonitor do $n if [ $status -eq 0 ] then mail -s "告警!" 346487106@qq.com < ‘/root/test.txt‘ fi done
原文地址:http://xushaojie.blog.51cto.com/6205370/1786404