[munin/*] Plein de plugins munin qui n'étaient pas trackés
This commit is contained in:
parent
fcc2fef9b0
commit
b55129ef17
9 changed files with 1031 additions and 0 deletions
44
munin/check_ntp
Executable file
44
munin/check_ntp
Executable file
|
@ -0,0 +1,44 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Petit plugin histoire de mesurer la dérive temporelle (spécialement des domU)
|
||||||
|
|
||||||
|
output_config() {
|
||||||
|
echo "graph_title Suivi du temps"
|
||||||
|
echo "graph_category time"
|
||||||
|
echo "local_date.label Date courante"
|
||||||
|
echo "local_date.type DERIVE"
|
||||||
|
}
|
||||||
|
|
||||||
|
output_values() {
|
||||||
|
|
||||||
|
printf "local_date.value %d\n" $(cur_timestamp)
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_timestamp() {
|
||||||
|
date +%s
|
||||||
|
}
|
||||||
|
|
||||||
|
output_usage() {
|
||||||
|
printf >&2 "%s - munin plugin to graph an example value\n" ${0##*/}
|
||||||
|
printf >&2 "Usage: %s [config]\n" ${0##*/}
|
||||||
|
}
|
||||||
|
|
||||||
|
case $# in
|
||||||
|
0)
|
||||||
|
output_values
|
||||||
|
;;
|
||||||
|
1)
|
||||||
|
case $1 in
|
||||||
|
config)
|
||||||
|
output_config
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
output_usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
output_usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
289
munin/ejabberd_
Executable file
289
munin/ejabberd_
Executable file
|
@ -0,0 +1,289 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Munin plugin for ejabberd2.
|
||||||
|
# This script supports versions 2.0 and 2.1 of ejabberd.
|
||||||
|
#
|
||||||
|
# Written by Lasse Karstensen <lkarsten@hyse.org> 2007-05-27.
|
||||||
|
# Based on ejabberd-plugin by Christian Dröge <Christian@draugr.de>
|
||||||
|
#
|
||||||
|
# Status, memory, threads, ejabberd2 and other code optimalisation
|
||||||
|
# by Peter Viskup <skupko.sk@gmail.com>
|
||||||
|
#
|
||||||
|
# As connected users, registered users and server-connections have somewhat
|
||||||
|
# different scales, this plugin uses munins suggest feature to create three
|
||||||
|
# different graphs.
|
||||||
|
#
|
||||||
|
# ejabberd_connections
|
||||||
|
# ejabberd_users
|
||||||
|
# ejabberd_registrations
|
||||||
|
# ejabberd_statuses
|
||||||
|
# ejabberd_memory
|
||||||
|
# ejabberd_threads
|
||||||
|
# ejabberd_usersindays
|
||||||
|
# ejabberd_uptime
|
||||||
|
#
|
||||||
|
# use ln -s ejabberd ejabberd_(connections|users|registrations|statuses|memory|threads|usersindays|uptime)
|
||||||
|
# to activate.
|
||||||
|
#
|
||||||
|
# If the autodetect-feature for vhosts breaks, you can set
|
||||||
|
# """
|
||||||
|
# [ejabberd*]
|
||||||
|
# env.vhosts foo.com bar.com
|
||||||
|
# env.statuses available away chat xa # monitoring of statuses
|
||||||
|
# env.days 1 7 30 # monitoring for usersindays
|
||||||
|
# user ejabberd # user ejabberd should have enough priviledges
|
||||||
|
# # depends on your setup
|
||||||
|
# """
|
||||||
|
# in plugin-conf.d/munin-node to override it.
|
||||||
|
#
|
||||||
|
#%# family=auto
|
||||||
|
#%# capabilities=autoconf suggest
|
||||||
|
|
||||||
|
EJCTL=$(which ejabberdctl)
|
||||||
|
EJVER=$($EJCTL status | awk '/^ejabberd / {print $2}')
|
||||||
|
|
||||||
|
if [ "$1" == "autoconf" ]; then
|
||||||
|
if [ -x $EJCTL > /dev/null ]; then
|
||||||
|
echo yes
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "no (ejabberdctl not found)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" == "suggest" ]; then
|
||||||
|
echo "connections"
|
||||||
|
echo "users"
|
||||||
|
echo "registrations"
|
||||||
|
echo "statuses"
|
||||||
|
echo "memory"
|
||||||
|
echo "threads"
|
||||||
|
echo "usersindays"
|
||||||
|
echo "uptime"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add munin argument to ejabberdctl to prevent a lot of ejabberdctl
|
||||||
|
# records in memory see discussion:
|
||||||
|
# http://lists.jabber.ru/pipermail/ejabberd/2009-September/005337.html
|
||||||
|
# Add these lines to ejabberdctl script to get it work
|
||||||
|
#@@ -56,6 +56,15 @@
|
||||||
|
# $KERNEL_OPTS \
|
||||||
|
# "$@"
|
||||||
|
# ;;
|
||||||
|
#+ munin)
|
||||||
|
#+ shift
|
||||||
|
#+ exec $ERL $SNAME ejabberdctlmunin \
|
||||||
|
#+ -pa $EBIN_DIR \
|
||||||
|
#+ -s ejabberd_ctl \
|
||||||
|
#+ -noinput \
|
||||||
|
#+ $KERNEL_OPTS \
|
||||||
|
#+ -extra $ERLANG_NODE "$@"
|
||||||
|
#+ ;;
|
||||||
|
# *)
|
||||||
|
# exec $ERL $SNAME ejabberdctl$SUFFIX \
|
||||||
|
# -pa $EBIN_DIR \
|
||||||
|
#
|
||||||
|
# Or just comment out following line
|
||||||
|
EJCTL="$EJCTL munin"
|
||||||
|
|
||||||
|
# trying to autodetect running vhosts.
|
||||||
|
if [ -z "$vhosts" ]; then
|
||||||
|
for CFGPATH in /etc/ejabberd /usr/local/ejabberd/etc; do
|
||||||
|
if [ -f "$CFGPATH/ejabberd.cfg" ]; then
|
||||||
|
EJCFG=$CFGPATH/ejabberd.cfg
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ -z "$EJCFG" ]; then
|
||||||
|
echo "Unable to find ejabberd.cfg. Exiting." > /dev/stderr
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
# you have to have all of vhosts defined on one line in $EJCFG or in plugins-conf.d/munin-node config file
|
||||||
|
vhosts=$(awk '/^\s*{hosts/ {gsub( /\{\s?hosts\s?,|[\",\[\]]|\}\s?.|localhost/ ,""); print;}' $EJCFG)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# get ejabberd PID
|
||||||
|
if [[ ${EJVER%\.[0-9]} == 2.1 ]]; then
|
||||||
|
EJPID=$(cat /var/run/ejabberd/ejabberd.pid)
|
||||||
|
else
|
||||||
|
EJPID=$(ps -ef | awk '/\/bin\/beam.smp/ && !/awk/ {print $2}')
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$vhosts" ]; then
|
||||||
|
echo "No vhosts to sample." > /dev/stderr
|
||||||
|
echo "Please set env.vhosts in plugins-conf.d/munin-node." > /dev/stderr
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
MODE=$(basename $0 | sed 's/^ejabberd_//g')
|
||||||
|
|
||||||
|
if ! [ "$MODE" == "connections" -o "$MODE" == "users" \
|
||||||
|
-o "$MODE" == "registrations" -o "$MODE" == "statuses" \
|
||||||
|
-o "$MODE" == "memory" -o "$MODE" == "threads" \
|
||||||
|
-o "$MODE" == "usersindays" -o "$MODE" == "uptime" ]; then
|
||||||
|
echo "ERROR: Unknown mode \"$MODE\". Exiting." > /dev/stderr
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" = "config" ]; then
|
||||||
|
echo 'graph_category ejabberd'
|
||||||
|
echo 'graph_info This graph shows statistics of ejabberd server'
|
||||||
|
if [ "$MODE" == "memory" ]; then
|
||||||
|
echo 'graph_args --base 1024 -l 0'
|
||||||
|
echo 'graph_scale yes'
|
||||||
|
echo 'graph_title Memory usage'
|
||||||
|
echo 'graph_vlabel Bytes'
|
||||||
|
echo "ejabberd_memory_size.label actual memory"
|
||||||
|
echo "ejabberd_memory_size.info Memory used by ejabberd process in Bytes"
|
||||||
|
echo "ejabberd_memory_peak.label memory peak"
|
||||||
|
echo "ejabberd_memory_peak.info Memory peak of ejabberd process in Bytes"
|
||||||
|
else
|
||||||
|
echo 'graph_args --base 1000 -l 0'
|
||||||
|
echo 'graph_scale no'
|
||||||
|
if [ "$MODE" == "connections" ]; then
|
||||||
|
echo 'graph_title Server-to-server conections'
|
||||||
|
echo 'graph_vlabel connections'
|
||||||
|
echo 's2s_connections_out.label outgoing s2s connections'
|
||||||
|
echo 's2s_connections_out.info Number of outgoing server to server connections'
|
||||||
|
echo 's2s_connections_in.label incoming s2s connections'
|
||||||
|
echo 's2s_connections_in.info Number of incoming server to server connections'
|
||||||
|
elif [ "$MODE" == "users" ]; then
|
||||||
|
echo 'graph_title Connected users'
|
||||||
|
echo 'graph_vlabel users'
|
||||||
|
for host in $vhosts; do
|
||||||
|
formathost=$(echo $host | tr '.' '_')
|
||||||
|
echo "connected_users_$formathost.label $host connected users"
|
||||||
|
echo "connected_unique_users_$formathost.label $host unique connected users"
|
||||||
|
done
|
||||||
|
elif [ "$MODE" == "registrations" ]; then
|
||||||
|
echo 'graph_title User registrations'
|
||||||
|
echo 'graph_vlabel users'
|
||||||
|
for host in $vhosts; do
|
||||||
|
formathost=$(echo $host | tr '.' '_')
|
||||||
|
echo "registered_$formathost.label $host registered users"
|
||||||
|
echo "registered_$formathost.info Registered users for vhost $host"
|
||||||
|
done
|
||||||
|
elif [ "$MODE" == "statuses" ]; then
|
||||||
|
echo 'graph_title User statuses'
|
||||||
|
echo 'graph_vlabel users'
|
||||||
|
for host in $vhosts; do
|
||||||
|
for status in $statuses; do
|
||||||
|
formathost=$(echo $host | tr '.' '_')
|
||||||
|
echo "status_${formathost}_${status}.label $status on $host"
|
||||||
|
echo "status_${formathost}_${status}.info Users with status $status on $host [xa=not available, dnd=(do not disturb) or (busy), chat=free for chat]"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
elif [ "$MODE" == "threads" ]; then
|
||||||
|
echo 'graph_title Threads'
|
||||||
|
echo 'graph_vlabel threads'
|
||||||
|
echo "ejabberd_threads.label number of threads"
|
||||||
|
echo "ejabberd_threads.info Number of threads of ejabberd process"
|
||||||
|
elif [ "$MODE" == "usersindays" ]; then
|
||||||
|
echo 'graph_title Active users'
|
||||||
|
echo 'graph_vlabel users'
|
||||||
|
for host in $vhosts; do
|
||||||
|
for num in $days; do
|
||||||
|
formathost=$(echo $host | tr '.' '_')
|
||||||
|
echo "usersindays_${formathost}_${num}.label $host active users [$num days]"
|
||||||
|
echo "usersindays_${formathost}_${num}.info Number of $host users active in last $num days"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
elif [ "$MODE" == "uptime" ]; then
|
||||||
|
echo 'graph_title Uptime'
|
||||||
|
echo 'graph_vlabel days'
|
||||||
|
echo "uptime.label uptime"
|
||||||
|
echo 'uptime.draw AREA'
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ${EJVER%\.[0-9]} == 2.1 ]]; then
|
||||||
|
if [ "$MODE" == "users" ]; then
|
||||||
|
for host in $vhosts; do
|
||||||
|
formathost=$(echo $host | tr '.' '_')
|
||||||
|
echo "connected_users_$formathost.value $($EJCTL stats_host onlineusers $host)"
|
||||||
|
echo "connected_unique_users_$formathost.value $($EJCTL connected_users_vhost $host | awk -v var=$host -F/ '{users[$1]} END {for (user in users) {if (index(user,var)) {count++}} print count}')"
|
||||||
|
done
|
||||||
|
elif [ "$MODE" == "registrations" ]; then
|
||||||
|
for host in $vhosts; do
|
||||||
|
formathost=$(echo $host | tr '.' '_')
|
||||||
|
num=$($EJCTL stats_host registeredusers $host)
|
||||||
|
if [ "$?" != 0 ]; then
|
||||||
|
num="U"
|
||||||
|
fi
|
||||||
|
echo "registered_$formathost.value $num"
|
||||||
|
done
|
||||||
|
elif [ "$MODE" == "statuses" ]; then
|
||||||
|
for host in $vhosts; do
|
||||||
|
formathost=$(echo $host | tr '.' '_')
|
||||||
|
for status in $statuses; do
|
||||||
|
num=$($EJCTL status_num_host $host $status)
|
||||||
|
if [ "$?" != 0 ]; then
|
||||||
|
num="U"
|
||||||
|
fi
|
||||||
|
echo "status_${formathost}_${status}.value $num"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
elif [ "$MODE" == "usersindays" ]; then
|
||||||
|
for host in $vhosts; do
|
||||||
|
for num in $days; do
|
||||||
|
formathost=$(echo $host | tr '.' '_')
|
||||||
|
echo "usersindays_${formathost}_${num}.value $($EJCTL num_active_users $host $num)"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
elif [ "$MODE" == "uptime" ]; then
|
||||||
|
echo "uptime.value $($EJCTL stats uptimeseconds | awk '{printf "%.2f", $1/86400}')"
|
||||||
|
elif [ "$MODE" == "connections" ]; then
|
||||||
|
echo "s2s_connections_out.value $($EJCTL outgoing_s2s_number)"
|
||||||
|
echo "s2s_connections_in.value $($EJCTL incoming_s2s_number)"
|
||||||
|
fi
|
||||||
|
elif [[ ${EJVER%\.[0-9]} == 2.0 ]]; then
|
||||||
|
if [ "$MODE" == "users" ]; then
|
||||||
|
for host in $vhosts; do
|
||||||
|
formathost=$(echo $host | tr '.' '_')
|
||||||
|
echo "connected_users_$formathost.value $($EJCTL vhost $host stats onlineusers)"
|
||||||
|
echo "connected_unique_users_$formathost.value $($EJCTL connected-users | awk -v var=$host -F/ '{users[$1]} END {for (user in users) {if (index(user,var)) {count++}} print count}')"
|
||||||
|
done
|
||||||
|
elif [ "$MODE" == "registrations" ]; then
|
||||||
|
for host in $vhosts; do
|
||||||
|
formathost=$(echo $host | tr '.' '_')
|
||||||
|
num=$($EJCTL vhost $host stats registeredusers)
|
||||||
|
if [ "$?" != 0 ]; then
|
||||||
|
num="U"
|
||||||
|
fi
|
||||||
|
echo "registered_$formathost.value $num"
|
||||||
|
done
|
||||||
|
elif [ "$MODE" == "statuses" ]; then
|
||||||
|
for host in $vhosts; do
|
||||||
|
formathost=$(echo $host | tr '.' '_')
|
||||||
|
for status in $statuses; do
|
||||||
|
num=$($EJCTL vhost $host status-num $status)
|
||||||
|
if [ "$?" != 0 ]; then
|
||||||
|
num="U"
|
||||||
|
fi
|
||||||
|
echo "status_${formathost}_${status}.value $num"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
elif [ "$MODE" == "usersindays" ]; then
|
||||||
|
for host in $vhosts; do
|
||||||
|
for num in $days; do
|
||||||
|
formathost=$(echo $host | tr '.' '_')
|
||||||
|
echo "usersindays_${formathost}_${num}.value $($EJCTL vhost $host num-active-users $num)"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
elif [ "$MODE" == "uptime" ]; then
|
||||||
|
echo "uptime.value $($EJCTL stats uptime-seconds | awk '{printf "%.2f", $1/86400}')"
|
||||||
|
elif [ "$MODE" == "connections" ]; then
|
||||||
|
echo "s2s_connections_out.value $($EJCTL outgoing-s2s-number)"
|
||||||
|
echo "s2s_connections_in.value $($EJCTL incoming-s2s-number)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MODE" == "memory" ]; then
|
||||||
|
echo "ejabberd_memory_size.value $(awk '/VmSize/ {print $2*1024}' /proc/${EJPID}/status)"
|
||||||
|
echo "ejabberd_memory_peak.value $(awk '/VmPeak/ {print $2*1024}' /proc/${EJPID}/status)"
|
||||||
|
elif [ "$MODE" == "threads" ]; then
|
||||||
|
echo "ejabberd_threads.value $(awk '/Threads/ {print $2}' /proc/${EJPID}/status)"
|
||||||
|
fi
|
||||||
|
exit 0
|
85
munin/meteo4J_
Executable file
85
munin/meteo4J_
Executable file
|
@ -0,0 +1,85 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import re
|
||||||
|
import serial
|
||||||
|
import sys
|
||||||
|
|
||||||
|
re_fmt = "^%s[^:]*: (.+)$"
|
||||||
|
h_re = re.compile(re_fmt % "Humidity")
|
||||||
|
t_re = re.compile(re_fmt % "Temperature")
|
||||||
|
exprs = {"H": h_re, "T": t_re}
|
||||||
|
conv = {"T": lambda x: x / 10.}
|
||||||
|
|
||||||
|
lines_to_read = 2
|
||||||
|
|
||||||
|
def read_data(ser):
|
||||||
|
data = {}
|
||||||
|
|
||||||
|
while data == {}:
|
||||||
|
ser.write("\n")
|
||||||
|
for i in xrange(lines_to_read):
|
||||||
|
line = ser.readline()
|
||||||
|
for k, expr in exprs.items():
|
||||||
|
m = expr.match(line)
|
||||||
|
if m is not None:
|
||||||
|
data[k] = float(m.group(1))
|
||||||
|
if k in conv:
|
||||||
|
data[k] = conv[k](data[k])
|
||||||
|
return data
|
||||||
|
|
||||||
|
def main_tty():
|
||||||
|
ser = serial.Serial('/dev/ttyUSB0', 115200, timeout=0.1)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
data = read_data(ser)
|
||||||
|
print data
|
||||||
|
if raw_input("q to quit: ") == "q":
|
||||||
|
break
|
||||||
|
|
||||||
|
ser.close()
|
||||||
|
|
||||||
|
def main_munin():
|
||||||
|
mode = None
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
mode = sys.argv[1]
|
||||||
|
|
||||||
|
arg = sys.argv[0].rsplit("_", 1)[-1]
|
||||||
|
if arg not in ["hygro", "temp"]:
|
||||||
|
return 1
|
||||||
|
|
||||||
|
if mode == "config":
|
||||||
|
print "host_name mdr.crans.org"
|
||||||
|
print "graph_category Environnement"
|
||||||
|
|
||||||
|
if arg == "hygro":
|
||||||
|
print "graph_title Hygrométrie 4J"
|
||||||
|
print "graph_vlabel Humidité (%)"
|
||||||
|
print "graph_args --lower-limit 0 --upper-limit 100 --rigid"
|
||||||
|
print "hygro.label Humidité 4J"
|
||||||
|
elif arg == "temp":
|
||||||
|
print "graph_title Température 4J"
|
||||||
|
print "graph_vlabel Température (°C)"
|
||||||
|
print "temp.label Température 4J"
|
||||||
|
else:
|
||||||
|
ser = serial.Serial('/dev/ttyUSB0', 115200, timeout=0.1)
|
||||||
|
data = read_data(ser)
|
||||||
|
ser.close()
|
||||||
|
|
||||||
|
if arg == "hygro":
|
||||||
|
print "hygro.value %d" % data["H"]
|
||||||
|
elif arg == "temp":
|
||||||
|
print "temp.value %.1f" % data["T"]
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
if sys.argv[0].endswith(".py"):
|
||||||
|
try:
|
||||||
|
main_tty()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print
|
||||||
|
else:
|
||||||
|
sts = main_munin()
|
||||||
|
sys.exit(sts)
|
||||||
|
|
56
munin/ping_bat_
Executable file
56
munin/ping_bat_
Executable file
|
@ -0,0 +1,56 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Copyright (C) 2004 Jimmy Olsen
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; version 2 dated June,
|
||||||
|
# 1991.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Plugin to monitor ping times
|
||||||
|
#
|
||||||
|
# Parameters:
|
||||||
|
#
|
||||||
|
# ping_args - Arguments to ping (default "-c 2")
|
||||||
|
# ping_args2 - Arguments after the host name (required for Solaris)
|
||||||
|
# ping - Ping program to use
|
||||||
|
# host - Host to ping
|
||||||
|
#
|
||||||
|
# Arguments for Solaris:
|
||||||
|
# ping_args -s
|
||||||
|
# ping_args2 56 2
|
||||||
|
#
|
||||||
|
#%# family=manual
|
||||||
|
|
||||||
|
hostname=`hostname --fqdn`
|
||||||
|
file_host=`basename $0 | sed 's/^ping_//g' | sed 's/_/-/g'`
|
||||||
|
host=${host:-${file_host:-www.google.com}}
|
||||||
|
|
||||||
|
if [ "$1" = "config" ]; then
|
||||||
|
echo host_name `basename $host | sed 's/-//g'`
|
||||||
|
echo graph_title Ping times from $hostname
|
||||||
|
echo 'graph_args --base 1000 -l 0'
|
||||||
|
echo 'graph_vlabel seconds'
|
||||||
|
echo 'graph_category network'
|
||||||
|
echo 'graph_info This graph shows ping RTT statistics.'
|
||||||
|
echo "ping.label $host"
|
||||||
|
echo "ping.info Ping RTT statistics for $host."
|
||||||
|
echo 'ping.draw LINE2'
|
||||||
|
echo 'packetloss.label packet loss'
|
||||||
|
# echo 'packetloss.graph no'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
${ping:-ping} ${ping_args:-'-c 2'} ${host} ${ping_args2} | perl -n -e 'print "ping.value ", $1 / 1000, "\n" if m@min/avg/max.*\s\d+(?:\.\d+)?/(\d+(?:\.\d+)?)/\d+(?:\.\d+)?@; print "packetloss.value $1\n" if /(\d+)% packet loss/;'
|
||||||
|
|
281
munin/slapd_
Executable file
281
munin/slapd_
Executable file
|
@ -0,0 +1,281 @@
|
||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
# Copyright Bjorn Ruberg <bjorn@ruberg.no>
|
||||||
|
# Licenced under GPL v2
|
||||||
|
#
|
||||||
|
# TODO:
|
||||||
|
# - Check for OpenLDAP version
|
||||||
|
|
||||||
|
# We use one script for all monitoring.
|
||||||
|
# This script may be symlinked with several names, all
|
||||||
|
# performing different functions:
|
||||||
|
# slapd_statistics_bytes
|
||||||
|
# slapd_statistics_pdu
|
||||||
|
# slapd_statistics_other
|
||||||
|
# slapd_connections
|
||||||
|
# slapd_waiters
|
||||||
|
# slapd_operations
|
||||||
|
# slapd_operations_diff
|
||||||
|
|
||||||
|
# Magic markers
|
||||||
|
#%# family=auto
|
||||||
|
#%# capabilities=autoconf suggest
|
||||||
|
|
||||||
|
# use strict;
|
||||||
|
use Net::LDAP;
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
|
use vars qw ( $config $param $act $scope $descr $cn $vlabel
|
||||||
|
$info $title );
|
||||||
|
|
||||||
|
# Change these to reflect your LDAP ACL. The given DN must have
|
||||||
|
# read access to the Monitor branch.
|
||||||
|
my $basedn = "cn=Monitor";
|
||||||
|
my $server = "localhost";
|
||||||
|
my $userdn = ($ENV{'binddn'} || '');
|
||||||
|
my $userpw = ($ENV{'bindpw'} || '');
|
||||||
|
|
||||||
|
# Remember: bytes, pdu needs scope=base
|
||||||
|
|
||||||
|
# The possible measurements
|
||||||
|
my %ops =
|
||||||
|
('statistics_bytes'
|
||||||
|
=> {
|
||||||
|
'search' => "cn=Bytes,cn=Statistics",
|
||||||
|
'desc' => "The number of bytes sent by the LDAP server.",
|
||||||
|
'vlabel' => "Bytes",
|
||||||
|
'title' => "Number of bytes sent",
|
||||||
|
'info' => "The graph shows the number of bytes sent",
|
||||||
|
'scope' => "base"
|
||||||
|
},
|
||||||
|
'statistics_pdu'
|
||||||
|
=> {
|
||||||
|
'search' => "cn=PDU,cn=Statistics",
|
||||||
|
'desc' => "The number of PDUs sent by the LDAP server.",
|
||||||
|
'vlabel' => "PDUs",
|
||||||
|
'title' => "Number of PDUs sent",
|
||||||
|
'info' => "The graph shows the number of PDUs sent",
|
||||||
|
'scope' => "base"
|
||||||
|
},
|
||||||
|
# Referrals
|
||||||
|
'statistics_referrals'
|
||||||
|
=> {
|
||||||
|
'search' => "cn=Referrals,cn=Statistics",
|
||||||
|
'attrs' => "Referrals",
|
||||||
|
'desc' => "The number of Referrals sent by the LDAP server.",
|
||||||
|
'vlabel' => "Referrals",
|
||||||
|
'title' => "Number of LDAP Referrals",
|
||||||
|
'info' => "The graph shows the number of referrals sent",
|
||||||
|
'scope' => "base"
|
||||||
|
},
|
||||||
|
# Entries
|
||||||
|
'statistics_entries'
|
||||||
|
=> {
|
||||||
|
'search' => "cn=Entries,cn=Statistics",
|
||||||
|
'attrs' => "Entries",
|
||||||
|
'desc' => "The number of Entries sent by the LDAP server.",
|
||||||
|
'vlabel' => "Entries",
|
||||||
|
'title' => "Number of LDAP Entries",
|
||||||
|
'info' => "The graph shows the number of entries sent",
|
||||||
|
'scope' => "base"
|
||||||
|
},
|
||||||
|
# Only read Current and Total
|
||||||
|
'connections'
|
||||||
|
=> {
|
||||||
|
'search' => 'cn=Connections',
|
||||||
|
'filter' => '(|(cn=Current)(cn=Total))',
|
||||||
|
'desc' => 'The number of Connections',
|
||||||
|
'label' => {'current' => 'Current',
|
||||||
|
'total' => 'Total'},
|
||||||
|
'vlabel' => 'Connections',
|
||||||
|
'title' => 'Number of Connections',
|
||||||
|
'info' => 'Number of connections to the LDAP server'
|
||||||
|
},
|
||||||
|
# dn: cn=Write,cn=Waiters,cn=Monitor
|
||||||
|
# dn: cn=Read,cn=Waiters,cn=Monitor
|
||||||
|
'waiters'
|
||||||
|
=> {
|
||||||
|
'search' => 'cn=Waiters',
|
||||||
|
'filter' => '(|(cn=Write)(cn=Read))',
|
||||||
|
'desc' => "The number of Waiters|",
|
||||||
|
'label' => {'write' => 'Write',
|
||||||
|
'read' => 'Read'},
|
||||||
|
'vlabel' => "Waiters",
|
||||||
|
'title' => "Number of Waiters",
|
||||||
|
'info' => "The graph shows the number of Waiters"
|
||||||
|
},
|
||||||
|
'operations'
|
||||||
|
=> {
|
||||||
|
'search' => "cn=Operations",
|
||||||
|
'desc' => "Operations",
|
||||||
|
'vlabel' => "Operations",
|
||||||
|
'title' => "Operations",
|
||||||
|
'info' => "Number of completed LDAP operations"
|
||||||
|
},
|
||||||
|
'operations_diff'
|
||||||
|
=> {
|
||||||
|
'search' => "cn=Operations",
|
||||||
|
'desc' => "Operations deviance",
|
||||||
|
'vlabel' => "Deviance",
|
||||||
|
'title' => "Operations deviance",
|
||||||
|
'info' => "Deviance between Initiated and Completed ops"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
# Config subroutine
|
||||||
|
sub config {
|
||||||
|
my $action = shift;
|
||||||
|
print <<EOF;
|
||||||
|
graph_args --base 1000 -l 0 --vertical-label $ops{$action}->{'vlabel'}
|
||||||
|
graph_title $ops{$action}->{'title'}
|
||||||
|
graph_category OpenLDAP
|
||||||
|
graph_info $ops{$action}->{'info'}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if ($ops{$action}->{'label'}) {
|
||||||
|
while (my ($key, $val) = each (%{$ops{$action}->{'label'}})) {
|
||||||
|
my $name = $action . "_" . $key;
|
||||||
|
print "$name.label $val\n";
|
||||||
|
print "$name.type DERIVE\n";
|
||||||
|
print "$name.min 0\n";
|
||||||
|
}
|
||||||
|
} elsif ($action =~ /^operations(?:_diff)?$/) {
|
||||||
|
my $ldap = Net::LDAP->new ($server) or die "$@";
|
||||||
|
$ldap->bind ($userdn, password => $userpw) or die "$@";
|
||||||
|
my $searchdn = $ops{$action}->{'search'} . "," . $basedn;
|
||||||
|
my $mesg =
|
||||||
|
$ldap->search (
|
||||||
|
base => $searchdn,
|
||||||
|
scope => 'one',
|
||||||
|
filter => '(objectclass=*)',
|
||||||
|
attrs => ['monitorOpInitiated',
|
||||||
|
'monitorOpCompleted',
|
||||||
|
'cn'],
|
||||||
|
);
|
||||||
|
$mesg->code && die $mesg->error;
|
||||||
|
|
||||||
|
my $max = $mesg->count;
|
||||||
|
for (my $i = 0 ; $i < $max ; $i++) {
|
||||||
|
my $entry = $mesg->entry ($i);
|
||||||
|
my $cn = $entry->get_value ('cn');
|
||||||
|
$name = $action . "_" . lc ($cn);
|
||||||
|
print "$name.label $cn\n";
|
||||||
|
print "$name.type DERIVE\n";
|
||||||
|
print "$name.min 0\n";
|
||||||
|
if ($action eq "operations") {
|
||||||
|
print "$name.info The number of $cn operations\n";
|
||||||
|
} else {
|
||||||
|
print "$name.info The difference between Initiated ";
|
||||||
|
print "and Completed operations (should be 0)\n";
|
||||||
|
print "$name.warning 1\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print "$action.label $ops{$action}->{'vlabel'}\n";
|
||||||
|
print "$action.type DERIVE\n";
|
||||||
|
print "$action.min 0\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ARGV[0]) {
|
||||||
|
if ($ARGV[0] eq 'autoconf') {
|
||||||
|
# Check for Net::LDAP
|
||||||
|
if (! eval "require Net::LDAP;") {
|
||||||
|
print "no (Net::LDAP not found)";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
# Check for LDAP version 3
|
||||||
|
my $ldap = Net::LDAP->new ($server, version => 3)
|
||||||
|
or die "no (Needs LDAPv3)";
|
||||||
|
$ldap->bind ($userdn, password => $userpw)
|
||||||
|
or die ("no (Can't log in, check env file)");
|
||||||
|
} elsif ($ARGV[0] eq "config") {
|
||||||
|
if ($0 =~ /slapd_([\w\d_]+)$/) {
|
||||||
|
my $action = $1;
|
||||||
|
&config ($1);
|
||||||
|
} else {
|
||||||
|
die ("Can't run config without a symlinked name\n");
|
||||||
|
}
|
||||||
|
} elsif ($ARGV[0] eq "suggest") {
|
||||||
|
print join ("\n", keys (%ops)), "\n";
|
||||||
|
}
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# We won't run this without parameters.
|
||||||
|
die ("Can't run without a symlinked name\n") if $0 =~ /slapd_$/;
|
||||||
|
|
||||||
|
# Default scope for LDAP searches. We'll change to other scopes if
|
||||||
|
# necessary.
|
||||||
|
$scope = "one";
|
||||||
|
|
||||||
|
# The filename is teh key
|
||||||
|
(my $action = $0) =~ s/^.*slapd_([\w\d_]+)$/$1/;
|
||||||
|
|
||||||
|
# Net::LDAP variant
|
||||||
|
my $ldap = Net::LDAP->new ($server, version => 3)
|
||||||
|
or die "$@";
|
||||||
|
$ldap->bind ($userdn,password => $userpw)
|
||||||
|
or die "$@";
|
||||||
|
|
||||||
|
my $searchdn = $ops{$action}->{'search'} . "," . $basedn;
|
||||||
|
my $searchattrs;
|
||||||
|
|
||||||
|
if ($action =~ /^operations(_diff)?$/) {
|
||||||
|
# We look for different parameters in Operations branch
|
||||||
|
$searchattrs = ['monitorOpInitiated', 'monitorOpCompleted', 'cn'];
|
||||||
|
} else {
|
||||||
|
$searchattrs = ['monitorCounter', 'cn'];
|
||||||
|
}
|
||||||
|
|
||||||
|
my $filter;
|
||||||
|
if ($ops{$action}->{'filter'}) {
|
||||||
|
$filter = "(&(objectclass=*)" . $ops{$action}->{'filter'} . ")";
|
||||||
|
} else {
|
||||||
|
$filter = "(objectClass=*)";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ops{$action}->{'scope'}) {
|
||||||
|
$scope = $ops{$action}->{'scope'};
|
||||||
|
}
|
||||||
|
|
||||||
|
my $mesg =
|
||||||
|
$ldap->search (
|
||||||
|
base => $searchdn,
|
||||||
|
scope => $scope,
|
||||||
|
filter => $filter,
|
||||||
|
attrs => $searchattrs,
|
||||||
|
);
|
||||||
|
|
||||||
|
$mesg->code && die $mesg->error;
|
||||||
|
|
||||||
|
my $max = $mesg->count;
|
||||||
|
|
||||||
|
for (my $i = 0 ; $i < $max ; $i++) {
|
||||||
|
my $entry = $mesg->entry ($i);
|
||||||
|
my $cn = $entry->get_value('cn');
|
||||||
|
if ($action =~ /operations(_diff)?$/) {
|
||||||
|
if ($1) {
|
||||||
|
my $opsInit =
|
||||||
|
$entry->get_value('monitorOpInitiated');
|
||||||
|
my $opsComp =
|
||||||
|
$entry->get_value('monitorOpCompleted');
|
||||||
|
print lc ("operations_diff_${cn}.value ");
|
||||||
|
print ($opsInit - $opsComp);
|
||||||
|
print "\n";
|
||||||
|
} else {
|
||||||
|
print lc ("operations_${cn}.value ");
|
||||||
|
print $entry->get_value('monitorOpCompleted'),
|
||||||
|
"\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
# Hotfix, must do for now
|
||||||
|
if ($action =~ /_/) {
|
||||||
|
print lc ("${action}.value ");
|
||||||
|
} else {
|
||||||
|
print lc ("${action}_${cn}.value ");
|
||||||
|
}
|
||||||
|
print $entry->get_value('monitorCounter'), "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$ldap->unbind;
|
140
munin/slapd_bdb_cache_
Executable file
140
munin/slapd_bdb_cache_
Executable file
|
@ -0,0 +1,140 @@
|
||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
# Plugin copyright Bjorn Ruberg <bjorn@ruberg.no> 20052006
|
||||||
|
#
|
||||||
|
# Licensed under GPLv2. Be nice.
|
||||||
|
#
|
||||||
|
# Environment variables:
|
||||||
|
#
|
||||||
|
# - dbstat The full path to a db_stat binary able to
|
||||||
|
# communicate with the LDAP backend BDB
|
||||||
|
# database files.
|
||||||
|
# - dbdir The full path to the directory where
|
||||||
|
# the LDAP backend BDB database files are.
|
||||||
|
# - title (Optional) The plugin's title. Useful if you
|
||||||
|
# have more than one DIT installed.
|
||||||
|
# - warning (Optional) A threshold integer value. Triggers
|
||||||
|
# plugin to send warnings if cache percentage
|
||||||
|
# drops below the given value.
|
||||||
|
#
|
||||||
|
# Limitations:
|
||||||
|
#
|
||||||
|
# - The plugin only checks _one_ database directory. To work
|
||||||
|
# around that, i.e. if you have more than one DIT in your
|
||||||
|
# OpenLDAP, create symlinked files and corresponding entries
|
||||||
|
# in the Munin environment file(s).
|
||||||
|
#
|
||||||
|
# Magic markers
|
||||||
|
#%# family=auto
|
||||||
|
#%# capabilities=autoconf suggest
|
||||||
|
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use vars qw ( $measure $config $dbdir $dbstat $warning);
|
||||||
|
my $arg = shift (@ARGV);
|
||||||
|
|
||||||
|
# Finding dbN.N_stat should be done here
|
||||||
|
$dbstat = ($ENV{'dbstat'} || "/usr/bin/db4.2_stat");
|
||||||
|
die ("Can't execute db_stat file '$dbstat'") unless -x $dbstat;
|
||||||
|
|
||||||
|
# Also the LDAP database files
|
||||||
|
$dbdir = ($ENV{'dbdir'} || "/var/lib/ldap");
|
||||||
|
die ("Can't open database directory '$dbdir'") unless (-d $dbdir && -r $dbdir);
|
||||||
|
|
||||||
|
# And the graph title
|
||||||
|
my $title = ($ENV{'title'} || '');
|
||||||
|
|
||||||
|
# Die if no valid file ending, unless suggest/autoconf.
|
||||||
|
if ($0 !~ /_(pages|percent)$/) {
|
||||||
|
unless ($arg && $arg =~ /^(suggest|autoconf)$/) {
|
||||||
|
die ("Plugin must be suffixed with 'hits' or 'pages'. Try running 'munin-node-configure suggest'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check file name
|
||||||
|
if ($0 =~ /_pages$/) {
|
||||||
|
$measure = "pages";
|
||||||
|
} elsif ($0 =~ /_percent$/) {
|
||||||
|
$measure = "percent";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Parse command line arguments
|
||||||
|
if ($arg && $arg eq "config") {
|
||||||
|
$config = 1;
|
||||||
|
} elsif ($arg && $arg eq "autoconf") {
|
||||||
|
print "yes\n";
|
||||||
|
exit 0;
|
||||||
|
} elsif ($arg && $arg eq "suggest") {
|
||||||
|
print "pages\n";
|
||||||
|
print "percent\n";
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($config) {
|
||||||
|
print <<EOF;
|
||||||
|
graph_title Requested pages found in cache $title
|
||||||
|
graph_category OpenLDAP
|
||||||
|
graph_info Pages found in cache (indexes)
|
||||||
|
EOF
|
||||||
|
if ($measure eq "pages") {
|
||||||
|
print <<EOF;
|
||||||
|
graph_args --base 1000 -l 0
|
||||||
|
graph_vlabel Cache hits per \${graph_period}
|
||||||
|
EOF
|
||||||
|
} else {
|
||||||
|
print <<EOF;
|
||||||
|
graph_args --base 1000 --upper-limit 100 -l 0 --vertical-label %
|
||||||
|
graph_vlabel Cache hits (percentage)
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my @output = `$dbstat -h $dbdir -m`;
|
||||||
|
my $file = ""; # "Total";
|
||||||
|
my $pages = undef;
|
||||||
|
my $percent = undef;
|
||||||
|
my $counter = 0;
|
||||||
|
|
||||||
|
foreach my $line (@output) {
|
||||||
|
chomp $line;
|
||||||
|
if ($line =~ /^Pool File\: (.*)$/) {
|
||||||
|
$file = $1;
|
||||||
|
}
|
||||||
|
if ($file &&
|
||||||
|
$line =~ /^(\d+)\s+Requested pages found in the cache \((\d+)\%\)/) {
|
||||||
|
$pages = $1;
|
||||||
|
$percent = $2;
|
||||||
|
}
|
||||||
|
if ($file && defined ($pages) && defined ($percent)) {
|
||||||
|
$file =~ s/\.bdb$//;
|
||||||
|
my $val = "slapd_bdb_cache_${measure}_${file}";
|
||||||
|
if ($config) {
|
||||||
|
print "$val.label $file\n";
|
||||||
|
if ($measure eq "pages") {
|
||||||
|
print "$val.type DERIVE\n";
|
||||||
|
print "$val.min 0\n";
|
||||||
|
if ($counter == 0) {
|
||||||
|
print "$val.draw AREA\n";
|
||||||
|
} else {
|
||||||
|
print "$val.draw STACK\n";
|
||||||
|
}
|
||||||
|
print "$val.info Number of $file pages found in cache\n";
|
||||||
|
} else {
|
||||||
|
print "$val.type GAUGE\n";
|
||||||
|
print "$val.info Percentage of $file pages found in cache\n";
|
||||||
|
print "$val.warning $warning:\n" if $ENV{'warning'};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($measure eq "pages") {
|
||||||
|
print "$val.value $pages\n";
|
||||||
|
} else {
|
||||||
|
print "$val.value $percent\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$file = "";
|
||||||
|
$pages = undef;
|
||||||
|
$percent = undef;
|
||||||
|
$counter++;
|
||||||
|
}
|
||||||
|
}
|
26
munin/vigile
Executable file
26
munin/vigile
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
file_host=`basename $0 | sed 's/^vigile_//g' | sed 's/_/-/g'`
|
||||||
|
host=${host:-${file_host}}
|
||||||
|
|
||||||
|
if [ -z "$host" ]; then
|
||||||
|
echo 'no host to ping'
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" = "config" ]; then
|
||||||
|
echo host_name $host
|
||||||
|
echo graph_title Monitoring of $host
|
||||||
|
echo 'graph_args --lower-limit 0 --upper-limit 1024 --rigid'
|
||||||
|
echo 'graph_vlabel units'
|
||||||
|
echo 'graph_category other'
|
||||||
|
echo 'graph_info This graph shows activity.'
|
||||||
|
echo "motion.label motion"
|
||||||
|
echo 'motion.draw LINE2'
|
||||||
|
echo 'light.label light'
|
||||||
|
echo 'light.draw LINE2'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo 'passo,d=?' | nc -w1 -u $host 1200 | perl -ne 'printf("motion.value %d\n",300*($1+$2+$3)) if /d=(\d):(\d):(\d)$/'
|
||||||
|
echo 'passo,a=?' | nc -w1 -u $host 1200 | perl -ne 'printf("light.value %d\n",$1) if /^a=(\d+)$/'
|
77
munin/webalizer_host_
Executable file
77
munin/webalizer_host_
Executable file
|
@ -0,0 +1,77 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: iso-8859-15 -*-
|
||||||
|
|
||||||
|
# Représentation des navigateurs utilisés
|
||||||
|
|
||||||
|
import sys, commands, string, re
|
||||||
|
from time import strftime
|
||||||
|
from operator import add
|
||||||
|
|
||||||
|
# On prend l'argument pour définir la table à analyser
|
||||||
|
SITE = sys.argv[0].split('_')[1]
|
||||||
|
|
||||||
|
# nom de la machine
|
||||||
|
import socket
|
||||||
|
HOSTNAME = socket.gethostname()
|
||||||
|
|
||||||
|
# On traite le fichier de webalizer correspondant
|
||||||
|
FILE = "/var/www/webalizer/%s/webalizer.current" % SITE
|
||||||
|
|
||||||
|
f = open(FILE, 'r')
|
||||||
|
lines = f.readlines()
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
navigateurs = {}
|
||||||
|
|
||||||
|
agent = False
|
||||||
|
for line in lines :
|
||||||
|
#print line
|
||||||
|
if "# -agents-" in line : agent = True
|
||||||
|
if "# End Of Table - agents" in line : break
|
||||||
|
if agent :
|
||||||
|
if line [:2] == "0 " : navigateurs[nom]=int(line[2:])
|
||||||
|
else : nom = line.strip()
|
||||||
|
|
||||||
|
total = reduce(add, navigateurs.values())
|
||||||
|
|
||||||
|
usage = {}
|
||||||
|
for nav in navigateurs.keys() :
|
||||||
|
pourcentage = navigateurs[nav]*100.0/total
|
||||||
|
if pourcentage > 1 :
|
||||||
|
usage[nav] = pourcentage
|
||||||
|
|
||||||
|
reste = 100.0 - reduce(add, usage.values())
|
||||||
|
|
||||||
|
try :
|
||||||
|
arg = sys.argv[1]
|
||||||
|
except :
|
||||||
|
arg = ''
|
||||||
|
|
||||||
|
if arg == "config" :
|
||||||
|
print 'host_name web.%s' % HOSTNAME
|
||||||
|
print 'graph_category %s' % SITE
|
||||||
|
print 'graph_title http://%s.crans.org' % SITE
|
||||||
|
print 'graph_args --base 1000 -r --lower-limit 0 --upper-limit 100'
|
||||||
|
print 'graph_scale no'
|
||||||
|
print 'graph_args --base 1000 --lower-limit 0'
|
||||||
|
print 'graph_vlabel % des visites'
|
||||||
|
for key in usage.keys() :
|
||||||
|
nom = key
|
||||||
|
for char in [' ','_','-','/','\\',':',';','.','+','(',')','!','"','\''] :
|
||||||
|
nom = nom.replace(char, '')
|
||||||
|
print '%s.label %s' % (nom, key[:20])
|
||||||
|
if usage.keys().index(key) == 0 :
|
||||||
|
print '%s.draw AREA' % nom
|
||||||
|
else :
|
||||||
|
print '%s.draw STACK' % nom
|
||||||
|
print 'reste.label Autres'
|
||||||
|
print 'reste.draw STACK'
|
||||||
|
|
||||||
|
else :
|
||||||
|
for key in usage.keys() :
|
||||||
|
nom = key
|
||||||
|
for char in [' ','_','-','/','\\',':',';','.','+','(',')','!','"','\''] :
|
||||||
|
nom = nom.replace(char, '')
|
||||||
|
print '%s.value %.2f' % (nom, usage[key])
|
||||||
|
print 'reste.value %.2f' % reste
|
||||||
|
|
33
munin/wiki_users.new
Executable file
33
munin/wiki_users.new
Executable file
|
@ -0,0 +1,33 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ "$1" = "config" ]; then
|
||||||
|
|
||||||
|
echo 'host_name web.rouge'
|
||||||
|
echo 'graph_category wiki'
|
||||||
|
echo 'graph_title Utilisateurs wiki'
|
||||||
|
echo 'graph_args --base 1000 --lower-limit 0'
|
||||||
|
echo "graph_vlabel nombre d'utilisateurs"
|
||||||
|
echo 'enregistres.label Nb enregistrés'
|
||||||
|
echo 'enregistres.draw AREA'
|
||||||
|
echo 'favoris.label Nb avec favoris'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
wikinoms=( $(grep -h -i -E '^name=' /var/local/wiki/data/user/* | sed 's/name=//g') )
|
||||||
|
|
||||||
|
wikipages=0
|
||||||
|
|
||||||
|
for nom in $(seq 0 $((${#wikinoms[@]} - 1)))
|
||||||
|
do
|
||||||
|
echo "/var/local/wiki/data/pages/${wikinom[$nom]}"
|
||||||
|
if [ -e "/var/local/wiki/data/pages/$nom" ]
|
||||||
|
then
|
||||||
|
echo $nom
|
||||||
|
let "wikipages+=1"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo $wikipages
|
||||||
|
|
||||||
|
echo "enregistres.value" `ls /var/local/wiki/data/user/ | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | wc -l`
|
||||||
|
echo "favoris.value" `ls /var/local/wiki/data/user/ | grep -E '^[0-9]+\.[0-9]+\.[0-9]+\.bookmark$' | wc -l`
|
Loading…
Add table
Add a link
Reference in a new issue