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

mistake in the calculation of shared memory, this feature was lost.

This commit is contained in:
rti 2011-08-02 01:58:20 +02:00 committed by Steve Schnepp
parent ce8f95f171
commit b4c1a51462

View file

@ -1,105 +1,92 @@
#!/bin/bash #!/bin/bash
# #
#healthcheck on munin #healthcheck on munin
#check process and alert. #check process 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_process] #[healthcheck_process]
#env.process_1 httpd #env.process_1 httpd
#--------------------------------------------------- #---------------------------------------------------
# #
#chcek two process #chcek two process
#--------------------------------------------------- #---------------------------------------------------
#[healthcheck_process] #[healthcheck_process]
#env.process_1 httpd #env.process_1 httpd
#env.process_2 samba #env.process_2 samba
#--------------------------------------------------- #---------------------------------------------------
# #
#chcek three process #chcek three process
#--------------------------------------------------- #---------------------------------------------------
#[healthcheck_process] #[healthcheck_process]
#env.process_1 httpd #env.process_1 httpd
#env.process_2 samba #env.process_2 samba
#env.process_3 mysqld #env.process_3 mysqld
#--------------------------------------------------- #---------------------------------------------------
# #
#set alert memory(MB) #
#--------------------------------------------------- #
#[healthcheck_process]
#env.process_1 httpd #edakari speed up.
#env.alertmemory_1 1024 #1G (sum all httpd process) CHECKMAX=`env | grep process_ | wc -l`
#--------------------------------------------------- let CHECKMAX="$CHECKMAX + 1"
#
# if [ "$1" = "autoconf" ]; then
if [ $CHECKMAX -le 1 ]; then
#edakari speed up. echo no
CHECKMAX=`env | grep process_ | wc -l` exit 1
let CHECKMAX="$CHECKMAX + 1" fi
echo yes
if [ "$1" = "autoconf" ]; then exit 0
if [ $CHECKMAX -le 1 ]; then fi
echo no
exit 1 if [ "$1" = "config" ]; then
fi
echo yes echo 'graph_title process memory Usage(MB)'
exit 0 echo "graph_args --base 1000 -l 0 --vertical-label MB"
fi echo 'graph_scale no'
echo 'graph_vlabel process memory'
if [ "$1" = "config" ]; then echo 'graph_category healthcheck'
MemTotal=`cat /proc/meminfo | grep MemTotal | awk '{ print $2 }'` echo 'graph_info This graph shows the Memory used by process'
let MemTotal="$MemTotal / 1024 " #MB
let MemTotal15="$MemTotal * 3 / 2" #$MemTotal*1.5 for(( I = 1; I < $CHECKMAX; ++I ))
do
echo 'graph_title process memory Usage(MB)' eval process=\$process_${I}
echo "graph_args --base 1000 -l 0 --vertical-label MB" eval alertmemory=\$alertmemory_${I}
echo 'graph_scale no' if [ "x${process}" = "x" ]; then
echo 'graph_vlabel process memory' continue
echo 'graph_category healthcheck' fi
echo 'graph_info This graph shows the Memory used by process'
echo "$process.label $process"
for(( I = 1; I < $CHECKMAX; ++I )) echo "$process.info Memory used by $process"
do echo "$process.draw LINE2"
eval process=\$process_${I} echo "$process.min -10"
eval alertmemory=\$alertmemory_${I} echo "$process.critical 0:"
if [ "x${process}" = "x" ]; then done
continue
fi exit 0
if [ "x${alertmemory}" = "x" ]; then fi
alertmemory=${MemTotal}
fi for(( I = 1; I < $CHECKMAX; ++I ))
do
echo "$process.label $process" eval process=\$process_${I}
echo "$process.info Memory used by $process" if [ "x${process}" = "x" ]; then
echo "$process.draw LINE2" continue
echo "$process.min -10" fi
echo "$process.max ${MemTotal15}"
echo "$process.critical 0:${alertmemory}" vrets=(`ps u --no-headers -C $process | awk 'BEGIN { count = 0 ; sum = 0; } { count ++ ; sum += $6/1024 ; } END { printf("%d %d\n",count,sum); }'`)
done count=${vrets[0]}
value=${vrets[1]}
exit 0 if [ $count -le 0 ]; then
fi echo "$process.value -10"
echo "$process.extinfo process down"
for(( I = 1; I < $CHECKMAX; ++I )) else
do echo "$process.value $value"
eval process=\$process_${I} fi
if [ "x${process}" = "x" ]; then done
continue
fi
vrets=(`ps u --no-headers -C $process | awk 'BEGIN { count = 0 ; sum = 0; } { count ++ ; sum += $6/1024 ; } END { printf("%d %d\n",count,sum); }'`)
count=${vrets[0]}
value=${vrets[1]}
if [ $count -le 0 ]; then
echo "$process.value -10"
echo "$process.extinfo process down"
else
echo "$process.value $value"
fi
done