vigiboard / app_cfg.py @ 20834406
History | View | Annotate | Download (3.95 KB)
1 |
# -*- coding: utf-8 -*-
|
---|---|
2 |
# vim: set fileencoding=utf-8 sw=4 ts=4 et :
|
3 |
# Copyright (C) 2007-2018 CS-SI
|
4 |
# License: GNU GPL v2 <http://www.gnu.org/licenses/gpl-2.0.html>
|
5 |
|
6 |
"""
|
7 |
Global configuration file for TG2-specific settings in vigiboard.
|
8 |
|
9 |
This file complements development/deployment.ini.
|
10 |
|
11 |
Please note that **all the argument values are strings**. If you want to
|
12 |
convert them into boolean, for example, you should use the
|
13 |
:func:`paste.deploy.converters.asbool` function, as in::
|
14 |
|
15 |
from paste.deploy.converters import asbool
|
16 |
setting = asbool(global_conf.get('the_setting'))
|
17 |
|
18 |
"""
|
19 |
|
20 |
from vigilo.turbogears import VigiloAppConfig |
21 |
|
22 |
import vigiboard |
23 |
from vigiboard.lib import app_globals # pylint: disable-msg=W0611 |
24 |
# W0611: Unused import: imports nécessaires pour le fonctionnement
|
25 |
|
26 |
|
27 |
import logging |
28 |
LOGGER = logging.getLogger(__name__) |
29 |
|
30 |
class VigiboardConfig(VigiloAppConfig): |
31 |
def setup_sqlalchemy(self): |
32 |
super(VigiboardConfig, self).setup_sqlalchemy() |
33 |
|
34 |
# On est obligés d'attendre que la base de données
|
35 |
# soit configurée pour charger les plugins.
|
36 |
from pkg_resources import working_set |
37 |
from vigiboard.controllers.plugins import VigiboardRequestPlugin |
38 |
from tg import config |
39 |
|
40 |
plugins = [] |
41 |
for plugin_name in config['vigiboard_plugins']: |
42 |
try:
|
43 |
ep = working_set.iter_entry_points( |
44 |
"vigiboard.columns", plugin_name).next()
|
45 |
except StopIteration: |
46 |
pass
|
47 |
|
48 |
if ep.name in dict(plugins): |
49 |
continue
|
50 |
|
51 |
try:
|
52 |
plugin_class = ep.load(require=True)
|
53 |
if issubclass(plugin_class, VigiboardRequestPlugin): |
54 |
plugins.append((unicode(ep.name), plugin_class()))
|
55 |
except Exception: # pylint: disable-msg=W0703 |
56 |
# W0703: Catch "Exception"
|
57 |
LOGGER.exception(u'Unable to import plugin %s', plugin_name)
|
58 |
|
59 |
config['columns_plugins'] = plugins
|
60 |
|
61 |
base_config = VigiboardConfig('VigiBoard')
|
62 |
base_config.package = vigiboard |
63 |
base_config.mimetype_lookup = { |
64 |
'.csv': 'text/csv', |
65 |
} |
66 |
|
67 |
##################################
|
68 |
# Settings specific to Vigiboard #
|
69 |
##################################
|
70 |
|
71 |
# Configuration des liens
|
72 |
# Les elements suivants peuvent etre utilises dans la chaine de formatage :
|
73 |
# - %(idcorrevent)d : identifiant de l'aggregat (alerte correlee)
|
74 |
# - %(host)s : le nom de l'hote concerne par l'alerte
|
75 |
# - %(service)s : le nom du service concerne par l'alerte
|
76 |
# - %(message) : le message transmis par Nagios dans l'alerte
|
77 |
#
|
78 |
# Permet de satisfaire l'exigence VIGILO_EXIG_VIGILO_BAC_0130.
|
79 |
base_config['vigiboard_links.eventdetails'] = (
|
80 |
{ |
81 |
'label': u'Détail de l\'hôte dans Nagios', |
82 |
'uri': '/nagios/%(host)s/cgi-bin/status.cgi?host=%(host)s', |
83 |
}, |
84 |
{ |
85 |
'label': u'Détail de la métrologie', |
86 |
'uri': 'http://vigilo.example.com/vigilo/vigigraph/rpc/fullHostPage?host=%(host)s', |
87 |
}, |
88 |
{ |
89 |
'label': u'Détail de la sécurité', |
90 |
'uri': 'http://security.example.com/?host=%(host)s', |
91 |
}, |
92 |
{ |
93 |
'label': 'Inventaire', |
94 |
'uri': 'http://cmdb.example.com/?host=%(host)s', |
95 |
}, |
96 |
{ |
97 |
'label': 'Documentation', |
98 |
'uri': 'http://doc.example.com/?q=%(message)s', |
99 |
}, |
100 |
) |
101 |
|
102 |
# URL des tickets, possibilités:
|
103 |
# - %(idcorrevent)d
|
104 |
# - %(host)s
|
105 |
# - %(service)s
|
106 |
# - %(tt)s
|
107 |
base_config['vigiboard_links.tt'] = 'http://bugs.example.com/?ticket=%(tt)s' |
108 |
|
109 |
# Plugins to use
|
110 |
base_config['vigiboard_plugins'] = (
|
111 |
# 'id',
|
112 |
'details',
|
113 |
# 'state',
|
114 |
'groups',
|
115 |
'date',
|
116 |
'priority',
|
117 |
'occurrences',
|
118 |
# 'address',
|
119 |
'hostname',
|
120 |
'servicename',
|
121 |
'output',
|
122 |
# 'masked_events',
|
123 |
'hls',
|
124 |
'status',
|
125 |
# 'test',
|
126 |
'map',
|
127 |
) |
128 |
|
129 |
base_config['csv_columns'] = (
|
130 |
'id',
|
131 |
'state',
|
132 |
'initial_state',
|
133 |
'peak_state',
|
134 |
'date',
|
135 |
'duration',
|
136 |
'priority',
|
137 |
'occurrences',
|
138 |
'hostname',
|
139 |
'servicename',
|
140 |
'output',
|
141 |
'ack',
|
142 |
'trouble_ticket_id',
|
143 |
'trouble_ticket_link',
|
144 |
) |