From d84a8c6d82d8a99fe30291e81888b12e8e2add44 Mon Sep 17 00:00:00 2001 From: chove Date: Sun, 19 Mar 2006 19:43:49 +0100 Subject: [PATCH] petit outil pour voir l'utilisation des plages d'ip d'ailleurs, faudrait penser ajouter quelques ip pour le wifi un de ces jours... vince tu t'en occupe ? darcs-hash:20060319184349-4ec08-e0bcbdcd455dc16f1a6b57230a74ce983f3dd389.gz --- adm/stats-ip.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 adm/stats-ip.py diff --git a/adm/stats-ip.py b/adm/stats-ip.py new file mode 100755 index 00000000..abcdb9d4 --- /dev/null +++ b/adm/stats-ip.py @@ -0,0 +1,21 @@ +#! /usr/bin/env python +# -*- coding: iso8859-15 -*- + +import sys +sys.path.append('/usr/scripts/gestion') + +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'] ] + +for n in NETs: + + nb_total = 0 + for net in NETs[n]: + nb_total += 2 ** ( 32 - int( net.split('/')[1] ) ) + + nb_occupe = len( [ ip for ip in ips if AddrInNet( ip, NETs[n] ) ] ) + + print '%12s %2s%% (%s/%s)' % (n, 100*nb_occupe/nb_total, nb_occupe, nb_total)