From 31b6569204b15747e78c1b9f8c74e10f48e4b665 Mon Sep 17 00:00:00 2001 From: Leonardo Date: Sat, 17 Apr 2010 12:23:25 +0200 Subject: [PATCH] Aggiunto supporto per altri gruppi. --- phcstats.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/phcstats.py b/phcstats.py index 651fefc..810687b 100755 --- a/phcstats.py +++ b/phcstats.py @@ -4,21 +4,23 @@ # Monitora se i computer dell'aula studenti sono accesi # e restituisce delle statistiche a proposito. -import subprocess, time +import subprocess, time, os from optparse import OptionParser # Qualche variabile globale database_directory = '/home/robol/client_stats/' # Il traling slash ci serve max_time = 86400 * 10 # 10 giorni +group = '/etc/dsh/group/all' -def LoadClients(group = 'all'): +def LoadClients(): """ Ritorna una lista con tutti i client all'interno del gruppo group di dsh. Il default รจ 'all' """ + global group clients = [] try: - for client in open('/etc/dsh/group/' + group, 'r'): + for client in open(group, 'r'): client = client.strip() if client.strip != '' and client[0] != '#': clients.append (client) @@ -108,8 +110,11 @@ if __name__ == "__main__": parser.add_option("-s", "--stats", dest="stats", help = "Print stats about collected informations", action = "store_true", default = False) + parser.add_option("-g", "--group-file", dest="group_file", + help="The dsh group file to use", default='/etc/dsh/group/all') (options, args) = parser.parse_args() + group = os.path.expand_user(options.group_file) if options.check: for client in LoadClients(): -- 2.1.4