Cambiato IsAlive() con IsLastAlive() nelle statistiche per

Leonardo [2010-04-17 13:13]
Cambiato IsAlive() con IsLastAlive() nelle statistiche per
non rallentare tutto.
Filename
phcstats.py
diff --git a/phcstats.py b/phcstats.py
index 9a580ca..40c1993 100755
--- a/phcstats.py
+++ b/phcstats.py
@@ -37,6 +37,14 @@ def IsAlive(client):
                             stderr = subprocess.PIPE)
     return (alive == 0)

+def IsLastAlive(client):
+    """
+    Ritorna True se il client era acceso durante l'ultimo check
+    effettuato.
+    """
+    data = LoadClientData(client)
+    return data.items()[-1:][0][1]
+
 def LoadClientData(client):
     """
     Carica i dati relativi a quel determinato client. Questi
@@ -95,7 +103,7 @@ def PrintStats(client):
     ss = ss / (d[-1:][0][0] - d[0][0])

     uptime = 100.0 * ss
-    if IsAlive(client):
+    if IsLastAlive(client):
         is_online = "yes"
     else:
         is_online = "no"
ViewGit