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