Ajout de la weathermap : cron, sites nginx et fichier de conf dans /etc/weathermap pour fy

This commit is contained in:
Gabriel Detraz 2015-07-29 16:28:12 +02:00
parent 73ab4ff3fe
commit 56624dae40
7 changed files with 287 additions and 0 deletions

View file

@ -0,0 +1,250 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
info['owner'] = 'munin'
info['group'] = 'adm'
include("ldap_conn")
import annuaires_pg
out("""<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE weathermap SYSTEM "weathermap.dtd">
<weathermap>
<global>
<scales_position x="1" y="1" />
<title x="150" y="10">Weathermap du réseau Cr@ns</title>
<size x="1500" y="800" />
</global>
<scales>
<scale>
<low>0</low>
<high>1</high>
<color red="255" green="255" blue="255" />
</scale>
<scale>
<low>1</low>
<high>3</high>
<color red="230" green="255" blue="230" />
</scale>
<scale>
<low>3</low>
<high>6</high>
<color red="200" green="255" blue="200" />
</scale>
<scale>
<low>6</low>
<high>9</high>
<color red="160" green="255" blue="160" />
</scale>
<scale>
<low>9</low>
<high>12</high>
<color red="200" green="150" blue="255" />
</scale>
<scale>
<low>12</low>
<high>15</high>
<color red="190" green="100" blue="255" />
</scale>
<scale>
<low>15</low>
<high>18</high>
<color red="185" green="50" blue="255" />
</scale>
<scale>
<low>18</low>
<high>21</high>
<color red="130" green="0" blue="255" />
</scale>
<scale>
<low>21</low>
<high>23</high>
<color red="10" green="10" blue="255" />
</scale>
<scale>
<low>23</low>
<high>25</high>
<color red="0" green="130" blue="255" />
</scale>
<scale>
<low>25</low>
<high>40</high>
<color red="0" green="192" blue="255" />
</scale>
<scale>
<low>40</low>
<high>55</high>
<color red="0" green="240" blue="0" />
</scale>
<scale>
<low>55</low>
<high>70</high>
<color red="240" green="240" blue="0" />
</scale>
<scale>
<low>70</low>
<high>85</high>
<color red="255" green="150" blue="0" />
</scale>
<scale>
<low>85</low>
<high>100</high>
<color red="255" green="0" blue="0" />
</scale>
<scale>
<low>100</low>
<high>999</high>
<color red="170" green="0" blue="0" />
</scale>
</scales>
<nodes>""")
# On genere les noeud bat par bat
out(""" <node name="node_bata">
<position x="550" y="550" />
<label>Batiment A (bata-4)</label>
</node>
<node name="node_batb">
<position x="1000" y="400" />
<label>Batiment B (batb-4)</label>
</node>
<node name="node_batc">
<position x="120" y="320" />
<label>Batiment C (batc-3)</label>
</node>
<node name="node_batm">
<position x="220" y="250" />
<label>Batiment M (batm-7)</label>
</node>
<node name="node_batk">
<position x="200" y="100" />
<label>Kfet (batk-0)</label>
</node>
<node name="node_bath">
<position x="200" y="500" />
<label>Batiment H (bath-3)</label>
</node>
<node name="node_bati">
<position x="400" y="600" />
<label>Batiment I (bati-3)</label>
</node>
<node name="node_batj">
<position x="700" y="600" />
<label>Batiment J (batj-3)</label>
</node>
<node name="node_batg">
<position x="900" y="500" />
<label>Batiment G (batg-0)</label>
</node>
<node name="node_bato">
<position x="1000" y="100" />
<size x="100" y="300" />
<label>Autocom (bato-1)</label>
</node>
<node name="node_batp">
<position x="1000" y="250" />
<label>Pavillon des Jardins (batp-4)</label>
</node>""")
# On recupere le nom du node dans l'annuaire
bat_to_prise = {v:k for k, v in annuaires_pg.uplink_prises['backbone'].items()}
#Batiment A
out(""" <node name="node_backbone_%s">
<position x="550" y="430" />
<label>%s</label>
</node>""" % (bat_to_prise['bata'],bat_to_prise['bata']))
# Bat B
out(""" <node name="node_backbone_%s">
<position x="610" y="300" />
<label>%s</label>
</node>""" % (bat_to_prise['batb'],bat_to_prise['batb']))
# Bat G
out(""" <node name="node_backbone_%s">
<position x="615" y="350" />
<label>%s</label>
</node>""" % (bat_to_prise['batg'],bat_to_prise['batg']))
# Bat o
out(""" <node name="node_backbone_%s">
<position x="615" y="150" />
<label>%s</label>
</node>""" % (bat_to_prise['bato'],bat_to_prise['bato']))
# Bat K
out(""" <node name="node_backbone_%s">
<position x="485" y="150" />
<label>%s</label>
</node>""" % (bat_to_prise['batk'],bat_to_prise['batk']))
# Bat M
out(""" <node name="node_backbone_%s">
<position x="485" y="180" />
<label>%s</label>
</node>""" % (bat_to_prise['batm'],bat_to_prise['batm']))
# Bat C
out(""" <node name="node_backbone_%s">
<position x="485" y="320" />
<label>%s</label>
</node>""" % (bat_to_prise['batc'],bat_to_prise['batc']))
# Bat h
out(""" <node name="node_backbone_%s">
<position x="485" y="360" />
<label>%s</label>
</node>""" % (bat_to_prise['bath'],bat_to_prise['bath']))
# Bat i
out(""" <node name="node_backbone_%s">
<position x="485" y="400" />
<label>%s</label>
</node>""" % (bat_to_prise['bati'],bat_to_prise['bati']))
# Bat j
out(""" <node name="node_backbone_%s">
<position x="615" y="400" />
<label>%s</label>
</node>""" % (bat_to_prise['batj'],bat_to_prise['batj']))
out(""" </nodes>
<links>""")
# On genere les liens bat par bat avec le backbone
for prise in annuaires_pg.uplink_prises['backbone']:
bat = annuaires_pg.uplink_prises['backbone'][prise]
offset = 0
if "B" in prise:
offset = 24
interface = offset + int(prise[1:])
if "bat" in bat:
out(""" <link name="link_%s" type="rrd">""" % (bat,))
out(""" <members>
<member>node_backbone_%s</member>""" % (prise,))
out(""" <member>node_%s</member>
</members>""" % (bat,))
out(""" <targetin href="/var/lib/munin/switchs.crans.org/backbone.adm.crans.org-if_bytes-if_%s-recv-d.rrd" coef="1"/>""" % (interface,))
out(""" <targetout href="/var/lib/munin/switchs.crans.org/backbone.adm.crans.org-if_bytes-if_%s-send-d.rrd" coef="1"/>
<bandwidth>1000000</bandwidth>
</link>""" % (interface,))
out(""" <link name="link_batp" type="rrd">
<members>
<member>node_bato</member>
<member>node_batp</member>
</members>
<targetin href="/var/lib/munin/switchs.crans.org/bato-1.adm.crans.org-if_bytes-if_24-recv-d.rrd" coef="1"/>
<targetout href="/var/lib/munin/switchs.crans.org/bato-1.adm.crans.org-if_bytes-if_24-send-d.rrd" coef="1"/>
<bandwidth>1000000</bandwidth>
</link>
</links>
<objects>
<object name="obj_backbone">
<label>Backbone 0B</label>
<position x="500" y="120" />
<size x="100" y="300" />
</object>
</objects>
<comments>
<comment name="c_speed_a_b">
<text>1Gbit/s</text>
<position x="320" y="380" />
</comment>
</comments>
<images>
<image name="img_nfrance" href="http://www.ens-cachan.fr/images/photos/0004/img_1322577636104.jpg" type="png">
<position x="550" y="150" />
<size x="400" y="150" />
</image>
</images>
</weathermap>""")