Package zephir :: Package monitor :: Package agents :: Module configperso
[hide private]
[frames] | no frames]

Source Code for Module zephir.monitor.agents.configperso

 1  # -*- coding: UTF-8 -*- 
 2  ########################################################################### 
 3  # Eole NG - 2007 
 4  # Copyright Pole de Competence Eole  (Ministere Education - Academie Dijon) 
 5  # Licence CeCill  cf /root/LicenceEole.txt 
 6  # eole@ac-dijon.fr 
 7  ########################################################################### 
 8   
 9  """ 
10  Agent zephir informant de la personnalisation de Samba 
11  """ 
12   
13  from zephir.monitor.agentmanager.agent import Agent 
14  from zephir.monitor.agentmanager.data import HTMLData, TableData 
15  from zephir.monitor.agentmanager import status 
16  from os import listdir 
17   
18 -class ConfigPerso(Agent):
19 - def __init__(self, name, **params):
20 Agent.__init__(self, name, **params) 21 self.table = TableData([ 22 ('share', 'Partages personnalisés', {'align':'center'}, None)]) 23 #title1 = HTMLData("<h3>Derniers virus détectés<h3>") 24 self.table2 = TableData([ 25 ('script', 'Scripts de connexion personnalisés', {'align':'center'}, None)]) 26 self.data = [self.table, HTMLData('<br>'), self.table2]
27
28 - def measure(self):
29 sharepath = '/usr/share/eole/backend/conf/' 30 scriptpath = '/home/netlogon/scripts/' 31 tscripts = ['users', 'groups', 'os', 'machine'] 32 noresult = '** AUCUN **' 33 34 ## partages personnalisés 35 try: 36 allshare = listdir(sharepath) 37 except: 38 allshare = [] 39 res1 = [] 40 for share in allshare : 41 # partage.conf 42 if share.endswith('.conf') and share != 'smb.conf' : 43 res1.append({ 'share' : share[0:-5] }) 44 if res1 == [] : 45 res1.append({ 'share' : noresult }) 46 47 ## scripts personnalisés 48 res2 = [] 49 for tscript in tscripts: 50 try: 51 allscript = listdir(scriptpath+tscript) 52 except: 53 allscript = [] 54 for script in allscript: 55 # script.bat 56 if script.endswith('.bat'): 57 res2.append({ 'script' : tscript+' : '+script[0:-4] }) 58 if res2 == [] : 59 res2.append({ 'script' : noresult }) 60 61 62 return { 'statistics' : res1, 63 'statistics2' : res2 }
64 65
66 - def write_data(self):
67 Agent.write_data(self) 68 if self.last_measure is not None: 69 self.table.table_data = self.last_measure.value['statistics'] 70 self.table2.table_data = self.last_measure.value['statistics2']
71
72 - def check_status(self):
73 return status.OK()
74