1
2
3
4
5
6
7
8
9 """
10
11 """
12
13 try: _
14 except NameError: _ = str
15
16 from datetime import datetime
17 import time
18 from twisted.web.microdom import *
19
20 from zephir.monitor.agentmanager import util
21
22 DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
23
25 """Résultat d'une mesure à un instant donné."""
26
30
34
36 """
37 @return: représentation texte de la date de mesure en temps
38 local"""
39 return datetime.fromtimestamp(self.date).strftime(DATE_FORMAT)
42
44 return "[%s : %s]" % (self.get_strdate(), str(self.value))
45
47
48 if other == None:
49 return 1
50 else:
51 return cmp(self.get_date(), other.get_date())
52
53
54
56 """Élément de données généré par l'agent
57 """
58 pass
59
60
62 """Fichier quelconque dans le répertoire de l'agent
63
64 TODO: optional copying to the agent data dir
65 """
67 self.filename = filename
68
70 """Fichier RRD"""
71 pass
72
74 """Fichier image, à afficher directement plutôt que par un lien"""
75 pass
76
78 """Code HTML, du niveau d'une balise <div> ou <p>"""
81
83 """Table de mesures C{zephir.monitor.agentmanager.data.Measure}"""
84 - def __init__(self, measures, fields = ['value']):
85 self.measures = measures
86 self.fields = fields
87
89 """Table de valeurs
90 """
91 - def __init__(self, columns_format, table_data=None):
92 """
93 @param table_data: a list of C{{key:value}} dicts (one dict
94 per row, one key per column)
95
96 @param columns_format: a list of (key, title, attributes,
97 formatter) tuples, one for each column in C{table_data},
98 where:
99
100 - attributes is a C{{attr:value}} dict which describes HTML
101 attributes of the corresponding table cell
102
103 - formatter is a function returning a string to display the
104 value in the cell; you will probably have to define a
105 real function instead of using lambda.
106 """
107 self.table_data = table_data
108 self.columns_format = []
109 for (field, title, attrs, format) in columns_format:
110 if format is None: format = identity
111 if attrs is None: attrs = ""
112 else:
113 attrs = " " + ' '.join(['%s="%s"' % (k,v) for k,v in attrs.items()])
114 self.columns_format.append((field, title, attrs, format))
115
117