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
This commit is contained in:
parent
87e88a6443
commit
d84a8c6d82
1 changed files with 21 additions and 0 deletions
21
adm/stats-ip.py
Executable file
21
adm/stats-ip.py
Executable file
|
@ -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)
|
Loading…
Add table
Add a link
Reference in a new issue