Déplace les scripts de stats vers utils et non plus tools

This commit is contained in:
Gabriel Detraz 2015-08-18 01:28:17 +02:00
parent dd32a30814
commit 7e072aca3c
4 changed files with 0 additions and 0 deletions

33
utils/list_droits.py Executable file
View file

@ -0,0 +1,33 @@
#!/bin/bash /usr/scripts/python.sh
# -*- coding: utf-8 -*-
from lc_ldap import shortcuts
ldap = shortcuts.lc_ldap_readonly()
txts = []
adhs = ldap.search(u"droits=*")
droits={}
for adh in adhs:
for droit in adh['droits']:
droit = unicode(droit)
droits[droit] = droits.get(droit, []) + [adh]
d=droits.keys()
d.sort()
for droit in d:
adhs = droits[droit]
noms = []
txt = '%s\n' % droit
for adh in adhs :
noms.append(u'%s %s (%s)' % (adh['prenom'][0],adh['nom'][0],adh['historique'][0].split()[0].split('/',2)[-1]))
noms.sort()
txt += u' %s' % '\n '.join(noms)
txts.append(txt)
print '\n- - - - - - = = = = = = # # # # # # # # = = = = = = - - - - - -\n'.join(txts)

22
utils/list_exempt.py Executable file
View file

@ -0,0 +1,22 @@
#!/bin/bash /usr/scripts/python.sh
# -*- coding: utf-8 -*-
from lc_ldap import shortcuts
ldap = shortcuts.lc_ldap_readonly()
machines = ldap.search(u"exempt=*")
txts = []
for m in machines :
# texte pour la machine
txt = u''
txt += u'Propriétaire : %s\n' % str(m.proprio()).decode('utf8')
txt += u'Machine : %s\n' % m['host'][0]
txt += u'destination : %s\n' % ', '.join([unicode(i) for i in m['exempt']])
txts.append(txt.strip())
print '\n- - - - - - = = = = = = # # # # # # # # = = = = = = - - - - - -\n'.join(txts)

32
utils/list_firewall.py Executable file
View file

@ -0,0 +1,32 @@
#!/bin/bash /usr/scripts/python.sh
# -*- coding: utf-8 -*-
from lc_ldap import shortcuts
ldap = shortcuts.lc_ldap_readonly()
machines = ldap.search(u"(|(portTCPin=*)(portTCPout=*)(portUDPin=*)(portUDPout=*))")
txts = []
for m in machines :
# On se fiche des machines crans
if m['objectClass'][0] not in ["machineFixe","machineWifi"]:
continue
# texte pour la machine
txt = u''
txt += u'Propriétaire : %s\n' % str(m.proprio()).decode('utf8')
txt += u'Machine : %s\n' % m['host'][0]
if m['portTCPin']:
txt += u'ports TCP in : %s\n' % ' '.join([unicode(port) for port in m['portTCPin']])
if m['portTCPout']:
txt += u'ports TCP out : %s\n' % ' '.join([unicode(port) for port in m['portTCPout']])
if m['portUDPin']:
txt += u'ports UDP in : %s\n' % ' '.join([unicode(port) for port in m['portUDPin']])
if m['portUDPout']:
txt += u'ports UDP out : %s\n' % ' '.join([unicode(port) for port in m['portTCPout']])
txts.append(txt.strip())
print '\n- - - - - - = = = = = = # # # # # # # # = = = = = = - - - - - -\n'.join(txts)