mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
Merge branch 'plugins-apache-memory'
This commit is contained in:
commit
991d0ab573
2 changed files with 66 additions and 69 deletions
|
@ -1,69 +0,0 @@
|
|||
#!/bin/sh
|
||||
# -*- sh -*-
|
||||
|
||||
: << =cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
apache_memmory -Indicate the medium size of all the apache child process
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
[apache_*]
|
||||
env.apuser user_running_apache
|
||||
env.binname apache_binary_name
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Fraile <rfrail3@yahoo.es>
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=head1 MAGICK MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=cut
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/plugin.sh
|
||||
|
||||
USR=$apuser
|
||||
PROCS=$binname
|
||||
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Medium size of apache child process.'
|
||||
echo 'graph_args --base 1000 -l 0 '
|
||||
echo 'graph_vlabel Kb'
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_category webserver'
|
||||
echo 'graph_info Indicate the memdium size of all the apache child process.'
|
||||
|
||||
|
||||
|
||||
echo "servers.label servers"
|
||||
echo "servers.type GAUGE"
|
||||
echo "servers.min 0"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
VAL1=`ps auxf | grep ${PROCS} | grep ^${USR} | grep -v grep | wc -l`
|
||||
|
||||
VAL2=`ps auxf | grep ${PROCS} | grep ^${USR} | grep -v grep | awk '{s+=$6} END {print s}'`
|
||||
|
||||
VAL3=`expr $VAL2 / $VAL1`
|
||||
|
||||
echo "servers.value $VAL3"
|
||||
|
||||
|
66
plugins/apache/apache_memory
Executable file
66
plugins/apache/apache_memory
Executable file
|
@ -0,0 +1,66 @@
|
|||
#!/bin/sh
|
||||
# -*- sh -*-
|
||||
|
||||
: << =cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
apache_memmory -Indicate the medium size of all the apache child process
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
[apache_*]
|
||||
env.apuser user_running_apache (default: "www-data")
|
||||
env.binname apache_binary_name (default: "apache2")
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Fraile <rfrail3@yahoo.es>
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=head1 MAGICK MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=cut
|
||||
|
||||
. "$MUNIN_LIBDIR/plugins/plugin.sh"
|
||||
|
||||
USR=${apuser:-www-data}
|
||||
PROCS=${binname:-apache2}
|
||||
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Average size of apache child processes'
|
||||
echo 'graph_args --base 1024 -l 0 '
|
||||
echo 'graph_vlabel Bytes'
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_category webserver'
|
||||
echo 'graph_info Indicate the memdium size of all the apache child process.'
|
||||
|
||||
echo "servers.label servers"
|
||||
echo "servers.type GAUGE"
|
||||
echo "servers.min 0"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
matched_processes=$(ps auxf | grep -- "$PROCS" | grep "^$USR" | grep -v grep)
|
||||
if [ -n "$matched_processes" ]; then
|
||||
average_memory=$(printf '%s' "$matched_processes" | awk '{count+=1; sum+=$6} END {print sum / count * 1024}')
|
||||
else
|
||||
average_memory="U"
|
||||
fi
|
||||
|
||||
echo "servers.value $average_memory"
|
Loading…
Add table
Add a link
Reference in a new issue