From b9cecfbc9e250f73d492751fc11f7c8c38f15c3f Mon Sep 17 00:00:00 2001 From: Daniel STAN Date: Thu, 13 Aug 2015 19:09:40 +0200 Subject: [PATCH] retrait plugin stats-ip_ (redondant) --- munin/scripts/hosts_plugins.py | 5 --- munin/stats-ip_ | 57 ---------------------------------- 2 files changed, 62 deletions(-) delete mode 100755 munin/stats-ip_ diff --git a/munin/scripts/hosts_plugins.py b/munin/scripts/hosts_plugins.py index f557f6a9..044506b3 100755 --- a/munin/scripts/hosts_plugins.py +++ b/munin/scripts/hosts_plugins.py @@ -21,7 +21,6 @@ cron_plugins = { # %s est remplacé par le lien dans /etc/munin/plugins "audimat": ("root", "nice -n 14 %s generate 2> /dev/null"), "batiments": ("root", "nice -n 14 %s fichier 2> /dev/null"), - "stats-ip_": ("root", "nice -n 14 %s fichier 2> /dev/null"), "stats-ip": ("root", "nice -n 14 %s fichier 2> /dev/null"), "wiki_pages": ("www-data", "%s fichier 2> /dev/null"), } @@ -153,10 +152,6 @@ general_plugins = { for mge_truc in ["batt", "hygro", "intensite", "temp", "temps", "tension"]: hosts_plugins["munin-server"]["mge_%s" % mge_truc] = "mge_%s" % mge_truc -# Stats d'utilisation des réseaux -for net in config.NETs: - hosts_plugins["munin-server"]["stats-ip_%s" % net] = "stats-ip_" - # Stats de peuplement des bâtiments for bat in annuaires.bat_switchs: if bat not in ('v',): diff --git a/munin/stats-ip_ b/munin/stats-ip_ deleted file mode 100755 index 0f503070..00000000 --- a/munin/stats-ip_ +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Plugin pour visualiser l'utilisation des plages ip - -fichier = '/var/lib/munin/tmp/stats-ip_' - -import sys, os, string -sys.path.append('/usr/scripts/gestion') - -# On prend l'argument pour définir la plage d'ip à analyser -SUBNET = sys.argv[0].split('_')[1] - -try : - arg = sys.argv[1] -except : - arg = '' - -if arg == "config" : - if len(SUBNET) == 1 : NOM = "Bâtiment %s" % string.upper(SUBNET) - else: NOM = SUBNET - - print 'host_name adresses-ip' - print 'graph_title Statistiques adresses IP - %s' % NOM - print 'graph_args --base 1000 --lower-limit 0' - print 'graph_category network' - print "graph_vlabel nb d'ips" - print "utilisees.label IP utilisées" - print "utilisees.draw AREA" - print "total.label Total disponibles" - -elif arg == "fichier" : - - from ldap_crans import crans_ldap - from config import NETs - from iptools import AddrInNet - - ips = [ x.ip() for x in crans_ldap().search('ip=*')['machine'] ] - - file = open('%s%s.next' % (fichier, SUBNET), 'w') - - total = 0 - for net in NETs[SUBNET]: - total += 2 ** ( 32 - int( net.split('/')[1] ) ) - # on ne prend pas en compte les adresses .0 et .255 - total = total - int(total/128) - - utilisees = len( [ ip for ip in ips if AddrInNet( ip, NETs[SUBNET] ) ] ) - - file.write("utilisees.value %d\n" % utilisees) - file.write("total.value %s\n" % total) - file.close() - - os.system('mv %s%s.next %s%s' % (fichier, SUBNET, fichier, SUBNET)) - -else : - os.system('cat %s%s' % (fichier, SUBNET))