Commit f672fa49 authored by salles's avatar salles

On regroupe les plugins munin dans un rpertoire commun toutes les machines

darcs-hash:20060420130121-72cb0-50f87f8f01382a2ddc9afec1b1b6e02890d8d32c.gz
parent 674ee00e
#!/bin/sh
#
# Plugin to monitor the amavis mail filter.
#
# Usage: Place in /etc/lrrd/client.d/ (or link it there using ln -s)
#
# Parameters understood:
#
# config (required)
# autoconf (optional)
#
# Config variables:
#
# amavislog - file where amavis logs are written
#
TEMP_FILE=/tmp/lrrd-amavis
AMAVIS_LOG=/var/log/mail/mail.info
OFFSET=/var/lib/munin/plugin-state/amavis.offset
LOGTAIL=`which logtail`
if [ "$amavislog" ]; then AMAVIS_LOG=$amavislog ; fi
if [ "$1" = "autoconf" ]; then
if [ -f ${AMAVIS_LOG} -a -x ${LOGTAIL} ] ; then
echo yes
exit 0
else
echo no
exit 1
fi
fi
if [ "$1" = "config" ]; then
echo 'graph_title Amavis filter statistics'
echo 'graph_order virus spam_maybe spam_sure total'
echo 'graph_vlabel nb'
echo 'virus.label virus'
echo 'spam_maybe.label probably spam'
echo 'spam_sure.label surely spam'
echo 'total.label total'
exit 0
fi
logtail -o ${OFFSET} -f ${AMAVIS_LOG} ${OFFSET} | grep 'amavis\[.*\]:' > ${TEMP_FILE}
total=`cat ${TEMP_FILE} | wc -l`
virus=`grep infected ${TEMP_FILE} | wc -l`
spamm=`grep 'Passed.*Hits: 1[0-9][.]' ${TEMP_FILE} | wc -l`
spams=`grep 'Passed.*Hits: [2-9][0-9][0-9]*[.]' ${TEMP_FILE} | wc -l`
echo "virus.value ${virus}"
echo "spam_maybe.value ${spamm}"
echo "spam_sure.value ${spams}"
echo "total.value ${total}"
#! /usr/bin/env python
# -*- coding: iso-8859-15 -*-
"""
Systme de monitoring des abonns au diffrents flux multicast
Frdric Pauget, Nicolas Salles, Etienne Chov
"""
import sys, os
sys.path.append('/usr/scripts/gestion')
from hptools import hpswitch
from annuaires import all_switchs, uplink_prises
####################################################################
## Dfinition des chaines audimater
####################################################################
# On construit un dictionnaire au format "ip" : "nom_de_la_chaine"
# On log les chaines qui font des annonces sap
# on essaie de tlcharger le fichier sap.txt
# si on y arrive pas on continue avec l'ancien
chaines = {}
try :
os.system("/usr/bin/wget http://television.crans.org/sap.txt -O /tmp/sap.txt -q 2> /dev/null")
except :
pass
# lecture du fichier
diffusion = open ('/tmp/sap.txt','r')
for l in diffusion.readlines() :
chaines[l.rstrip().split(":")[1]] = l.split(":")[0].replace('.','_').replace('-','_')[0:18]
####################################################################
## Configuration pour munin
####################################################################
if 'autoconf' in sys.argv :
print "yes" # Surement y rajouter le up du backbone, ...
sys.exit(0)
if 'config' in sys.argv :
print "host_name backbone"
print "graph_title AudimatTV";
print "graph_args --base 1000";
print "graph_vlabel nb clients/chaines";
inc = 0
chaines = chaines.values()
chaines.sort()
for nom in chaines :
if not nom : continue
nom1 = nom.replace(' ','_')
print "%s.label %s" % (nom1, nom)
if inc == 0 :
print "%s.draw AREA" % nom1
else:
print "%s.draw STACK" % nom1
inc = 1
print "total.label Total"
sys.exit(0)
####################################################################
## Mesure de l'audimat, lanc par cron cause du timeout de munin
####################################################################
if 'generate' in sys.argv :
stats = {} # { IP : [ prises ] }
for switch in all_switchs() :
# on vrifie que le switch est pingable
if os.system('ping -c 3 %s > /dev/null 2> /dev/null' % switch ) :
continue
sw = hpswitch(switch)
switch=switch.split('.')[0]
if switch[-1].isalpha() :
bat = switch[-1].lower()
sw_num = 0
else :
bat = switch[-3].lower()
sw_num = int(switch[-1])
for ip, liste in sw.multicast().items() :
stats.setdefault(ip,[])
for port in liste :
num_port = 100 * sw_num + int(port)
if num_port not in uplink_prises[bat].keys() :
stats[ip].append('%s%03i' % (bat, num_port) )
total = 0
f = open('/tmp/audimat','w')
for ip, nom in chaines.items() :
if not nom : continue
nb_clients = len(stats.get(ip,[]))
total += nb_clients
if 'prises' in sys.argv :
f.write( "%s (%i) : %s\n" % (nom, nb_clients, ', '.join(stats.get(ip,[])).upper() ) )
else :
f.write( "%s.value %i\n" % ( nom.replace(' ','_'), nb_clients ) )
f.write("total.value %i" % total )
sys.exit(0)
####################################################################
## Retour des audimats pour munin
####################################################################
try :
print file("/tmp/audimat").read()
except :
pass
#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
fichier = '/var/lib/munin/tmp/batiments'
import sys,os
try :
arg = sys.argv[1]
except :
arg = ''
if arg == "config" :
print 'host_name adherents'
print 'graph_title Adhrents par batiments'
print "graph_args --base 1000 --lower-limit 0"
print "graph_vlabel nb d'adhrents"
print 'bata.label Btiment A'
print 'bata.draw AREA'
print 'batb.label Btiment B'
print 'batb.draw STACK'
print 'batc.label Btiment C'
print 'batc.draw STACK'
print 'batg.label Btiment G'
print 'batg.draw STACK'
print 'bath.label Btiment H'
print 'bath.draw STACK'
print 'bati.label Btiment I'
print 'bati.draw STACK'
print 'batj.label Btiment J'
print 'batj.draw STACK'
print 'batm.label Btiment M'
print 'batm.draw STACK'
print 'batp.label PdJ'
print 'batp.draw STACK'
print 'wifi.label Wifi'
print 'wifi.draw STACK'
print 'total.label Total'
elif arg == "fichier" :
file = open(fichier,'w')
sys.path.append('/usr/scripts/gestion')
from ldap_crans import crans_ldap
db = crans_ldap()
def count(filtre) :
data = db.search(filtre)
return len(data['adherent']) + len(data['club'])
total = 0
for bat in 'abcghijmp' :
nb = count('paiement=ok&chbre=%s*' % bat)
total += nb
file.write("bat%s.value %d\n" % (bat, nb))
nb = count('paiement=ok&chbre=EXT')
total += nb
file.write("wifi.value %d\n" % nb)
file.write("total.value %d\n" % total)
file.close()
else :
os.system('cat %s' % fichier)
#!/bin/sh
if [ "$1" = "config" ]; then
echo 'host_name adherents'
echo 'graph_title Blacklist'
echo "graph_args --base 1000 --lower-limit 0"
echo "graph_vlabel nb de machines"
echo 'carte_et.label Certif. tudes'
echo 'carte_et.draw AREA'
echo 'chbre.label Chambre invalide'
echo 'chbre.draw STACK'
echo 'upload.label Upload'
echo 'upload.draw STACK'
echo 'p2p.label P2P'
echo 'p2p.draw STACK'
echo 'auto_upload.label Autodisc. Upload'
echo 'auto_upload.draw STACK'
echo 'auto_p2p.label Autodisc. P2P'
echo 'auto_p2p.draw STACK'
echo 'virus.label Virus'
echo 'virus.draw STACK'
echo 'warez.label Warez'
echo 'warez.draw STACK'
echo 'total.label Total'
exit 0
fi
echo -n "carte_et.value "
cat /etc/squid/blacklist_carte_et | wc -l
echo -n "chbre.value "
cat /etc/squid/blacklist_chbre | wc -l
echo -n "virus.value "
cat /etc/squid/blacklist_virus | wc -l
echo -n "upload.value "
cat /etc/squid/blacklist_upload | wc -l
echo -n "p2p.value "
cat /etc/squid/blacklist_p2p | wc -l
echo -n "auto_upload.value "
cat /etc/squid/blacklist_autodisc_upload | wc -l
echo -n "auto_p2p.value "
cat /etc/squid/blacklist_autodisc_p2p | wc -l
echo -n "warez.value "
cat /etc/squid/blacklist_warez | wc -l
echo -n "total.value "
cat /etc/squid/blacklist_* | wc -l
#!/bin/sh
#
# Plugin to monitor harddrive temperatures through SMART.
#
# client-conf.d/-options:
#
# drives -- List drives to monitor. E.g. "hda hdc".
#
# $Log: hddtemp,v $
# Revision 1.1 2006-04-20 13:01:20 salles
# On regroupe les plugins munin dans un rpertoire commun toutes les machines
#
# Revision 1.1 2004/10/08 14:59:48 salles
# Ajout des scripts persos pour les graphes munins.
# Apparition d'un graphe pour compter les blacklists.
#
# Revision 1.2 2004/01/29 19:39:00 jimmyo
# Generic plugins now use printf instead of echo -n, as this is more portable (SF#885564)
#
# Revision 1.1 2004/01/02 18:50:00 jimmyo
# Renamed occurrances of lrrd -> munin
#
# Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo
# Import of LRRD CVS tree after renaming to Munin
#
# Revision 1.2 2003/12/18 19:16:00 jimmyo
# Changes from Alexandre
#
# Revision 1.1 2003/12/18 19:04:37 jimmyo
# New plugin: Alexandre Dupouy contributed "hddtemp".
#
#
#%# family=contrib
HDDTEMP=/usr/sbin/hddtemp
drives="sda sdb sdc sdd"
if [ "$1" = "autoconf" ]; then
if [ -x "$HDDTEMP" ]; then
echo yes
exit 0
else
echo no
exit 1
fi
fi
if [ "$1" = "config" ]; then
echo 'graph_title HDD temperature'
echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel temp in C'
for a in $drives ; do echo $a.label $a "`$HDDTEMP -q /dev/$a | cut -f 2 -d ':' | cut -d ' ' -f3`" ; done
exit 0
fi
for a in $drives ; do printf "$a.value " ; echo "`$HDDTEMP -q /dev/$a | cut -f 3 -d ':' | cut -d ' ' -f2`" | awk -F \ '{print $1}' ; done
#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
# Compteur des rgles iptables
import sys,commands,string
# On prend l'argument pour dfinir la table analyser
TABLE = sys.argv[0].split('_')[1]
if TABLE :
IPTABLES = "iptables -t %s -L " % TABLE
else :
IPTABLES = "iptables -L "
try :
arg = sys.argv[1]
except :
arg = ''
CHAINS = commands.getoutput('%s | grep Chain | awk \'{print $2}\'' % IPTABLES).split('\n')
if arg == "config" :
print 'graph_title Firewall %s' % string.lower(TABLE)
print 'graph_args --base 1000 --lower-limit 0'
print 'graph_category network'
print "graph_vlabel nb de regles"
for chain in CHAINS :
nom = string.lower(chain.replace('_', '').replace('-', ''))
label = chain.replace('_', '-')
print "%s.label %s" % (nom, label)
if CHAINS.index(chain) == 0 :
print "%s.draw AREA" % nom
else :
print "%s.draw STACK" % nom
if label == "TEST-MAC-IP" :
print "%s.warning 100:" % nom
print "%s.critical 1:" % nom
else :
for chain in CHAINS :
nom = string.lower(chain.replace('_', '').replace('-', ''))
value = int(commands.getoutput('%s %s | wc -l' % (IPTABLES, chain))) - 2
print "%s.value %d" % (nom, value)
#!/bin/sh
if [ "$1" = "config" ]; then
# echo 'host_name adherents'
echo 'graph_title Machines connectes'
echo "graph_args --base 1000 --lower-limit 0"
echo "graph_vlabel nombre de machines"
echo 'fixe.label Fixe'
echo 'fixe.draw AREA'
echo 'adm.label ADM'
echo 'adm.draw STACK'
echo 'ens.label ENS'
echo 'ens.draw STACK'
echo 'total.label Total'
exit 0
fi
echo "fixe.value" `arp -a -i crans | wc -l`
echo "adm.value" `arp -a -i crans.2 | wc -l`
echo "ens.value" `arp -a -i ens | wc -l`
echo "total.value" `arp -a | wc -l`
#!/bin/sh
#
# Plugin to monitor MGE battery state.
if [ "$1" = "config" ]; then
echo 'host_name pulsar.crans.org'
echo 'graph_category Batteries'
echo 'graph_title Etat batteries'
echo 'graph_vlabel charge (%)'
echo 'pcent.label Charge'
exit 0
fi
cmd="snmpget -O vq -v1 -c public pulsar.adm.crans.org SNMPv2-SMI::enterprises.705.1."
echo "pcent.value $(${cmd}5.4.0)"
#!/bin/sh
if [ "$1" = "config" ]; then
echo 'host_name pulsar.crans.org'
echo 'graph_category Environnement'
echo 'graph_title Hygromtrie 0B'
echo 'graph_vlabel Humitid (%)'
echo 'hygro.label Humidit 0B'
exit 0
fi
cmd="snmpget -O vq -v1 -c public pulsar.adm.crans.org SNMPv2-SMI::enterprises.705.1."
echo "hygro.value $(${cmd}8.2.0)"
#!/bin/sh
#
# Plugin to monitor MGE battery state.
if [ "$1" = "config" ]; then
echo 'host_name pulsar.crans.org'
echo 'graph_category B4'
echo 'graph_args --lower-limit 0'
echo 'graph_title Intensit'
echo 'graph_vlabel I (A)'
echo 'input.label Entre'
echo 'input.min 0'
echo 'output.label Sortie'
echo 'output.min 0'
exit 0
fi
cmd="snmpget -O vq -v1 -c public pulsar.adm.crans.org SNMPv2-SMI::enterprises.705.1."
input=$(${cmd}6.2.1.6.0)
output=$(${cmd}7.2.1.5.0)
echo "input.value $(($input/10)).$(($input%10))"
echo "output.value $(($output/10)).$(($output%10))"
#!/bin/sh
if [ "$1" = "config" ]; then
echo 'host_name pulsar.crans.org'
echo 'graph_category Environnement'
echo 'graph_title Temprature 0B'
echo 'graph_vlabel Temprature en (C)'
echo 'temp.label Temprature 0B'
echo 'temp.warning 22'
echo 'temp.critical 24'
exit 0
fi
cmd="snmpget -O vq -v1 -c public pulsar.adm.crans.org SNMPv2-SMI::enterprises.705.1."
t=$(${cmd}8.1.0)
echo "temp.value $(($t/10)).$(($t%10))"
#!/bin/sh
#
# Plugin to monitor MGE battery state.
if [ "$1" = "config" ]; then
echo 'host_name pulsar.crans.org'
echo 'graph_category Batteries'
echo 'graph_title Autonomie'
echo 'graph_vlabel t (minutes)'
echo 'remain.label Autonomie restante'
echo 'charg.label Temps de recharge'
exit 0
fi
cmd="snmpget -O vq -v1 -c public pulsar.adm.crans.org SNMPv2-SMI::enterprises.705.1."
remain=$(${cmd}5.1.0) # autonomie restante
charg=$(${cmd}5.8.0) # temps avant charge complre des batteries
echo "remain.value $(($remain/60)).$(($remain%60*10/6))"
echo "charg.value $(($charg/60)).$(($charg%60*10/6))"
#!/bin/sh
#
# Plugin to monitor MGE battery state.
if [ "$1" = "config" ]; then
echo 'host_name pulsar.crans.org'
echo 'graph_category B4'
echo 'graph_title Tensions'
echo 'graph_vlabel U (V)'
echo 'input.label Entre'
echo 'input.min 0'
echo 'output.label Sortie'
echo 'output.min 0'
exit 0
fi
cmd="snmpget -O vq -v1 -c public pulsar.adm.crans.org SNMPv2-SMI::enterprises.705.1."
input=$(${cmd}6.2.1.2.0)
output=$(${cmd}7.2.1.2.0)
echo "input.value $(($input/10)).$(($input%10))"
echo "output.value $(($output/10)).$(($output%10))"
#!/bin/sh
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo "graph_title NTP servers offset"
echo 'graph_args --base 1000 -l 0 '
echo 'graph_vlabel offset in sec'
ntpq -p | grep -i '^[*+-]' | awk '{gsub("^.","",$1) ; gsub("[.-]", "_", $1); print $1 ".label " $1}'
exit 0
fi;
ntpq -p | grep -i '^[*+-]' | awk '{gsub("^.","",$1) ; gsub("[.-]", "_", $1); print $1 ".value " $9}'
#!/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
file_host=`basename $0 | sed 's/^ping_//g'`
host=${host:-${file_host:-www.google.com}}
if [ "$1" = "config" ]; then
echo host_name $host
echo graph_title Ping times from sila
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/;'
#!/usr/bin/perl -w
#
# $Log: snmp__if__,v $
# Revision 1.1 2006-04-20 13:01:21 salles
# On regroupe les plugins munin dans un rpertoire commun toutes les machines
#
# Revision 1.1 2004/11/14 10:36:39 salles
# Ajout des plugins personnaliss
#
# Revision 1.2 2004/07/27 14:32:46 salles
# nom en premier pour qu'on les ait dans l'ordre alphabtique. mo
#
# Revision 1.1 2004/07/27 12:17:28 bernat
# Et tournez mange !
#
# Revision 1.1 2004/07/27 11:37:16 bernat
# Deplacement (encore !)
#
# Revision 1.1 2004/07/27 11:27:43 bernat
# Deplacement (pour pas qu'il soit execut)
#
# Revision 1.1 2004/07/27 11:19:26 bernat
# SNMP un peu modifi pour avoir le nom des bats en "clair"
#
# Revision 1.4 2004/04/30 16:58:14 jimmyo
# Added max.
#
# Revision 1.3 2004/02/22 20:17:58 jimmyo
# Typo fix
#
# Revision 1.2 2004/02/18 21:54:56 jimmyo
# Did a bit of work on the snmp-thingie.
#
# Revision 1.1 2004/01/02 18:50:00 jimmyo
# Renamed occurrances of lrrd -> munin
#
# Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo
# Import of LRRD CVS tree after renaming to Munin
#
# Revision 1.1 2003/12/19 20:53:45 jimmyo
# Created by jo
#
#
use strict;
use Net::SNMP;
my $DEBUG = 1;