scripts/adm/stats-ip.py
Antoine Durand-Gasselin 4a68475e34 [wiki-lenny] suppression de static/
darcs-hash:20090314092631-bd074-b01256aeaf71e935851b3ecdbd623eaae8c9e8a1.gz
2009-03-14 10:26:31 +01:00

21 lines
544 B
Python

#! /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)