Revision f5c20e6e
Declaration Serveurs nagios et rrd dans Ventilation
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@2439 b22e2e97-25c9-44ff-b637-2e5ceca36478
maj_bdd.py | ||
---|---|---|
23 | 23 |
from vigilo.models import Host, HostGroup |
24 | 24 |
from vigilo.models import LowLevelService, ServiceGroup |
25 | 25 |
from vigilo.models import PerfDataSource, Graph |
26 |
from vigilo.models import Ventilation, VigiloServer, Application |
|
26 | 27 |
|
27 | 28 |
|
28 | 29 |
# Groupe d'hôtes (HostGroup) |
... | ... | |
147 | 148 |
DBSession.add(ds) |
148 | 149 |
return ds |
149 | 150 |
|
151 |
# VigiloServer |
|
152 |
def create_Server(name, description): |
|
153 |
s = DBSession.query(VigiloServer).filter(VigiloServer.name == name).filter(VigiloServer.description == description).first() |
|
154 |
if not s: |
|
155 |
s = VigiloServer(name=name, description=description) |
|
156 |
print "Ajout du Server Vigilo: %s - %s" % (name, description) |
|
157 |
DBSession.add(s) |
|
158 |
return s |
|
159 |
|
|
160 |
# VigiloApplication |
|
161 |
def create_Application(name): |
|
162 |
a = DBSession.query(Application).filter(Application.name == name).first() |
|
163 |
if not a: |
|
164 |
a = Application(name=name) |
|
165 |
print "Ajout de l'application Vigilo: %s" % name |
|
166 |
DBSession.add(a) |
|
167 |
return a |
|
168 |
|
|
169 |
# Ventilation |
|
170 |
def create_Ventilation(host, server, application): |
|
171 |
v = None |
|
172 |
h = DBSession.query(Host).filter(Host.name == host).first() |
|
173 |
s = DBSession.query(VigiloServer).filter(VigiloServer.name == server).first() |
|
174 |
a = DBSession.query(Application).filter(Application.name == application).first() |
|
175 |
if h and s: |
|
176 |
v = Ventilation(idhost=h.idhost, idvigiloserver=s.idvigiloserver, idapp=a.idapp) |
|
177 |
print "Ajout Ventilation - host %s - server %s - application %s" % (host, server, application) |
|
178 |
DBSession.add(v) |
|
179 |
return v |
|
180 |
|
|
150 | 181 |
|
151 | 182 |
hg1 = create_HostGroup(u'Serveurs') |
152 | 183 |
hg2 = create_HostGroup(u'Telecoms') |
... | ... | |
220 | 251 |
ds8 = create_ds(u'CPU usage (by type)', u'GAUGE', s5 \ |
221 | 252 |
, u'CPU usage (by type)', graphs[7:8]) |
222 | 253 |
|
254 |
# Serveurs Vigilo |
|
255 |
sv1 = create_Server(u'http://localhost', u'RRD+Nagios') |
|
256 |
|
|
257 |
# Applications Vigilo |
|
258 |
ap1 = create_Application(u'rrdgraph') |
|
259 |
ap2 = create_Application(u'nagios') |
|
260 |
|
|
261 |
# Ventilation |
|
262 |
if sv1 is not None and ap1 is not None: |
|
263 |
create_Ventilation(u'par.linux0', sv1.name, ap1.name) |
|
264 |
if sv1 is not None and ap2 is not None: |
|
265 |
create_Ventilation(u'par.linux0', sv1.name, ap2.name) |
|
266 |
|
Also available in: Unified diff