由于进入nagios要输入用户名与密码才能进入,故用curl模拟输入用户名与密码取得当前所有主机的报警信息:
# curl -u nagiosadmin:password http://192.168.5.10/nagios/cgi-bin/status.cgi?host=all
# curl -u nagiosadmin:skylink -s http://192.168.5.10/nagios/cgi-bin/status.cgi?host=all | grep hostTotalsPROBLEMS | grep -o '[[:digit:]]'
1
# curl -u nagiosadmin:skylink -s http://192.168.5.10/nagios/cgi-bin/status.cgi?host=all | grep serviceTotalsPROBLEMS | grep -o '[[:digit:]]'
2
参数:
-s 不显示进度
grep -o 匹配输出