1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-25 18:38:30 +00:00

mistake upload file

This commit is contained in:
rti 2011-08-02 01:54:57 +02:00 committed by Steve Schnepp
parent ea1e9c7369
commit ce8f95f171

View file

@ -1,177 +1,161 @@
#!/bin/bash #!/bin/bash
# #
#healthcheck on munin #healthcheck on munin
#check site speed. #egrep system log and alert.
#egrep contents string #
# ... and alert. #programed by rti (hiroyuki fujie) super.rti@gmail.com @super_rti
# #LICENSE: NYSL (public domain)
#programed by rti (hiroyuki fujie) super.rti@gmail.com @super_rti #
#LICENSE: NYSL (public domain) #
# #config file
#config file # /etc/munin/plugin-conf.d/munin-node
# /etc/munin/plugin-conf.d/munin-node #
# #example minimum config
#example minimum config #---------------------------------------------------
#--------------------------------------------------- #[healthcheck_log]
#[healthcheck_url] #user root
#env.url_1 http://127.0.0.1/ #env.log_1 /var/log/messages
#--------------------------------------------------- #---------------------------------------------------
# #
#chcek two site #check two log
#--------------------------------------------------- #---------------------------------------------------
#[healthcheck_url] #[healthcheck_log]
#env.url_1 http://127.0.0.1/ #user root
#env.url_2 http://www.google.com/ #env.log_1 /var/log/messages
#--------------------------------------------------- #env.log_2 /var/log/syslog
# #---------------------------------------------------
#chcek three site #
#--------------------------------------------------- #check two three
#[healthcheck_url] #---------------------------------------------------
#env.url_1 http://127.0.0.1/ #[healthcheck_log]
#env.url_2 http://www.google.com/ #user root
#env.url_3 http://www.yahoo.com/ #env.log_1 /var/log/messages
#--------------------------------------------------- #env.log_2 /var/log/syslog
# #env.log_3 /var/log/dmesg
#set name #---------------------------------------------------
#--------------------------------------------------- #
#[healthcheck_url] #set name
#env.url_1 http://127.0.0.1/ #---------------------------------------------------
#env.name_1 homhom #[healthcheck_log]
#--------------------------------------------------- #user root
# #env.log_1 /var/log/messages
#check over proxy #env.name_1 my_server_messages
#--------------------------------------------------- #---------------------------------------------------
#[healthcheck_url] #
#env.url_1 http://127.0.0.1/ #set egrep string
#env.proxy_1 127.0.0.1:8080 #---------------------------------------------------
#--------------------------------------------------- #[healthcheck_log]
# #user root
#set slow speed(second) #env.log_1 /var/log/messages
#--------------------------------------------------- #env.grep_1 alert|warning
#[healthcheck_url] #---------------------------------------------------
#env.url_1 http://127.0.0.1/ #
#env.slowspeed_1 30 #set egrep string
#--------------------------------------------------- #---------------------------------------------------
# #[healthcheck_log]
#grep string #user root
#--------------------------------------------------- #env.log_1 /var/log/messages
#[healthcheck_url] #env.grep_1 alert|warning
#env.url_1 http://127.0.0.1/ #---------------------------------------------------
#env.grep_1 saysaya #
#--------------------------------------------------- #full option
# #/etc/munin/plugin-conf.d/munin-node
#full option #---------------------------------------------------
#/etc/munin/plugin-conf.d/munin-node #[healthcheck_log]
#--------------------------------------------------- #user root #log file is read only root user.
#[healthcheck_url] #env.log_1 /var/log/messages #target log filename
#env.url_1 http://127.0.0.1/ #check url #env.grep_1 critical|error #egrep string.
#env.grep_1 apache #check egrep string #defualt by critical|error|warning|crash|fatal|kernel
#env.name_1 127.0.0.1 #set line name. default by url domain #---------------------------------------------------
#env.proxy_1 127.0.0.1:8080 #over proxy #
#env.slowspeed_1 30 #slow time on alert
#---------------------------------------------------
# #edakari speed up.
# CHECKMAX=`env | grep log_ | wc -l`
let CHECKMAX="$CHECKMAX + 1"
#edakari speed up. MINUTE_BY_GREP_RANGE=10
CHECKMAX=`env | grep url_ | wc -l`
let CHECKMAX="$CHECKMAX + 1" if [ "$1" = "autoconf" ]; then
if [ $CHECKMAX -le 1 ]; then
CURL=/usr/bin/curl echo no
exit 1
if [ "$1" = "autoconf" ]; then fi
if [ $CHECKMAX -le 1 ]; then echo yes
echo no exit 0
exit 1 fi
fi
echo yes if [ "$1" = "config" ]; then
exit 0 echo 'graph_title log grep (match count)'
fi echo "graph_args --base 1000 -l 0 --vertical-label match_count"
echo 'graph_scale no'
if [ "$1" = "config" ]; then echo 'graph_vlabel match_count'
echo 'graph_title site speed (second)' echo 'graph_category healthcheck'
echo "graph_args --base 1000 -l 0 --vertical-label second" echo 'graph_info This graph shows the bad event count on log'
echo 'graph_scale no'
echo 'graph_vlabel second' for(( I = 1; I < $CHECKMAX; ++I ))
echo 'graph_category healthcheck' do
echo 'graph_info This graph shows the site speed' eval log=\$log_${I}
eval name=\$name_${I}
for(( I = 1; I < $CHECKMAX; ++I )) eval grep=\$grep_${I}
do if [ "x${log}" = "x" ]; then
eval url=\$url_${I} continue
eval name=\$name_${I} fi
eval slowspeed=\$slowspeed_${I} if [ "x${name}" = "x" ]; then
if [ "x${url}" = "x" ]; then name=`echo $log | sed 's#[/|\.]#_#g'`
continue fi
fi if [ "x${name}" = "x" ]; then
if [ "x${name}" = "x" ]; then grep="critical|error|crash|fatal|kernel"
#default name by domain fi
name=`echo $url | sed 's#\.#_#g' | sed -e 's/[^/]*\/\/\([^@]*@\)\?\([^:/]*\).*/\2/'`
fi echo "$name.label $name"
if [ "x${slowspeed}" = "x" ]; then echo "$name.info egrep $grep $log | wc -l"
slowspeed=10 echo "$name.draw LINE2"
fi echo "$name.min 0"
let slowspeed15="slowspeed * 3 / 2" #slowspeed * 1.5 echo "$name.max 20"
echo "$name.critical 0:0"
echo "$name.label $name" done
echo "$name.info $url"
echo "$name.draw LINE2" exit 0
echo "$name.min -10" fi
echo "$name.max ${slowspeed15}"
echo "$name.critical 0:${slowspeed}" NOWTIME=`date --date "$MINUTE_BY_GREP_RANGE minute ago" +%s`
done
for(( I = 1; I < $CHECKMAX; ++I ))
exit 0 do
fi eval log=\$log_${I}
eval name=\$name_${I}
for(( I = 1; I < $CHECKMAX; ++I )) eval grep=\$grep_${I}
do if [ "x${log}" = "x" ]; then
eval url=\$url_${I} continue
eval grep=\$htmlgrep_${I} fi
eval name=\$name_${I} if [ "x${name}" = "x" ]; then
eval proxy=\$proxy_${I} name=`echo $log | sed 's#[/|\.]#_#g'`
eval slowspeed=\$slowspeed_${I} fi
if [ "x${grep}" = "x" ]; then
if [ "x${url}" = "x" ]; then grep="critical|error|crash|fatal|kernel"
continue fi
fi
if [ "x${name}" = "x" ]; then COUNT=0
#default name by domain MESSAGE=
name=`echo $url | sed 's#\.#_#g' | sed -e 's/[^/]*\/\/\([^@]*@\)\?\([^:/]*\).*/\2/'` IFS=$'\n'
fi MATCHLINES=(`egrep -i "$grep" "$log"`)
for(( N = ${#MATCHLINES[@]} - 1; N >= 0 ; --N ))
PROXY_CMD="" do
if [ "x${proxy}" != "x" ]; then LINE=${MATCHLINES[$N]}
PROXY_CMD=" --proxy ${proxy} " DATESTRING=`echo $LINE | awk '{ printf("%s %s %s",$1,$2,$3)}'`
fi LOGTIME=`date --date "$DATESTRING" +%s`
if [ "x${slowspeed}" = "x" ]; then if [ $LOGTIME -lt $NOWTIME ]; then
slowspeed=10 break
fi fi
let timeout="${slowspeed} + 1" let COUNT="$COUNT + 1"
MESSAGE="$MESSAGE$LINE //@LINE@// "
START=`date +%s` done
HTML_RESULT=`$CURL "${url}" -s --connect-timeout ${timeout} ${PROXY_CMD}`
CURLEXITCODE=$?
END=`date +%s` if [ $COUNT -eq 0 ]; then
echo "${name}.value 0"
GREPEXITCODE=0 else
if [ "x${grep}" != "x" ]; then echo "${name}.value ${COUNT}"
echo $HTML_RESULT | egrep -i "${grep}" > /dev/null echo "${name}.extinfo ${MESSAGE}"
GREPEXITCODE=$? fi
fi done
if [ $CURLEXITCODE -ne 0 ]; then
echo "$name.value -10"
echo "$name.extinfo curl return $CURLEXITCODE"
continue
fi
if [ $GREPEXITCODE -ne 0 ]; then
echo "$name.value -9"
echo "$name.extinfo can not found $grep regex strings"
continue
fi
let SPEED="$END - $START"
echo "$name.value $SPEED"
done