1.网站图片域名

[root@10-6-8-200 libexec]# more /usr/local/nagios/etc/webpage.txt
http://radfile.example.info/201108/12/717_20110804012.mp3
http://tvcpic.example.info/smallpic/200309/12/030912_3774.jpg
http://iadpic.example.info/200104/20010406/dang01040613.jpg
http://wcresource.example.info/201002/23/79d3816e-5e49-40e3-966a-a40c47fca403_1.jpg
http://odgpic.example.info/1304/sh/nearphoto/SHD007L01A0513041.JPG
http://micepic.example.info/201207/25/11801343157855425.jpg
http://pospic.example.info/201011/24/26629_9.jpg
http://nadpic.example.info/200901/15/4953766_1.jpg

2.监控脚本

#!/bin/bash
state_ok=0
state_warning=1
state_critical=2
state_unknown=3
WEBPAGE='/usr/local/nagios/etc/webpage.txt'
web(){
        /usr/bin/wget  $1 -O /tmp/down &> /dev/null
        if [ $? -eq 0 ]
        then
                echo "ok"
                return $state_ok
        else
                echo "$line is down"
                return $state_critical
        fi
}
while read line
do
        web $line
done < $WEBPAGE
3.脚本放在/usr/local/nagios/libexec下
chown nagios. check_webpage.sh
chown nagios. check_webpage.sh

4.nrpe定义

command[check_webpages]=/usr/local/nagios/libexec/check_webpage.sh

5.主机定义

define service{
        use     generic-service
        host_name       varnish
        service_description     check-webpages
        check_command   check_nrpe!check_webpages
}

6.效果如下

监控网站图片下载_第1张图片