3 from mod_python
import apache
,util
7 return os
.path
.normpath(req
.uri
).split("/")[1]
9 def get_version(sitename
):
10 return [ l
.split()[2] for l
11 in file("/omd/sites/%s/share/omd/omd.info" % sitename
).readlines()
12 if l
.startswith("OMD_VERSION") ][0]
14 def config_load(sitename
):
15 confpath
= "/omd/sites/%s/etc/omd/site.conf" % sitename
16 if not os
.path
.exists(confpath
):
20 for line
in file(confpath
):
22 if line
== "" or line
[0] == "#":
24 var
, value
= line
.split("=", 1)
25 conf
[var
.strip()[7:]] = value
.strip('"').strip("'")
28 def page_welcome(req
):
29 req
.headers_out
.add("Cache-Control", "max-age=7200, public");
31 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
32 "http://www.w3.org/TR/html4/frameset.dtd">
35 <title>OMD - Open Monitoring Distribution</title>
38 font-family:Verdana,sans-serif;
61 border:1px #DADADA solid;
62 background-color:#FFFFDD;
67 border:1px #DADADA solid;
74 background-color:#EEEEEE;
79 background-color:#759FCF
87 vertical-align:middle;
97 <h1>OMD - Open Monitoring Distribution</h1>
99 <p>This page gives you a central view on the available GUIs in OMD.
100 Just have a look and feel free to choose your favorite GUI. At the
101 bottom of this page you can find short instructions on how to change
102 the default GUI of OMD.</p>
103 """ % get_version(site_name(req
)))
105 for id, title
, path
, desc
in [ ('nagios', 'Classic Nagios GUI',
106 'share/nagios/htdocs',
107 'The classic Nagios GUI is based on CGI program written '
108 'in C. It retrieves its status information from <tt>status.dat</tt>. '
109 'This interface is not longer actively developed and does not perform '
110 'well in large installations.'),
111 ('check_mk', 'Check_MK Multisite',
112 'share/check_mk/web',
113 'Check_MK Multisite is a fast and flexibile status GUI written '
114 'in Python. It supports user definable views and is able to '
115 'display the status of several sites in one combined view. It '
116 'uses MK Livestatus for getting the status data from the sites.'),
117 ('thruk', 'Thruk Monitoring Webinterface',
119 'Thruk is a complete rework of the classic interface '
120 'in Perl. While maintainig the original look and feel it '
121 'brings lots of improvements and new features. Just as Multisite '
122 'it uses MK Livestatus as backend and supports the visualization '
123 'of multiple sites.'),
124 ('icinga', 'Classic Icinga GUI',
125 'share/icinga/htdocs',
126 'Icinga\'s "classical" GUI is a derivate of the classical Nagios GUI '
127 'and has been directly evolved from the original '
128 'CGI programs in C. It has its own look and feel and brings useful '
129 'improvements. It is not bound to Icinga and can be used with the '
130 'other monitoring cores as well.'),
131 ('shinken', 'Shinken WebUI',
133 'Shinken enhances the ok/non-ok concept of Nagios by adding '
134 'root problems and impacts. Monitored objects also can get a rank '
135 'identifying their importance to the business.'
136 'The Shinken WebUI was designed to visualize these new concepts '
137 'and can not be used with the other monitoring cores.'),
138 ('nagvis', 'NagVis - The visualization addon',
139 'share/nagvis/htdocs',
140 '<p>NagVis is the leading visualization addon for Nagios.</p>'
141 '<p>NagVis can be used to visualize Nagios status data, e.g. '
142 'to display IT processes like a mail system or a '
143 'network infrastructure.</p>'),
144 ('pnp4nagios', 'PNP4Nagios',
145 'share/pnp4nagios/htdocs',
146 'PNP is an addon to Nagios which analyzes performance data '
147 'provided by plugins and stores them automatically into '
148 'RRD-databases (Round Robin Databases, see RRDTool).'),
150 'share/dokuwiki/htdocs',
151 'DokuWiki is a standards compliant, simple to use Wiki, '
152 'mainly aimed at creating documentation of any kind.') ]:
154 if os
.path
.exists("/omd/sites/%s/%s" % (site_name(req
), path
)):
156 <a class="gui" href="../%s/">
157 <img src="img/%s-small.png" title="%s" />
161 """ % (id, id, id, title
, desc
))
165 <p>You can replace this page by logging into your sites system account
166 and execute the commands:</p>
169 Then browse to "Web Gui -> DEFAULT_GUI" entry in the list and hit enter. Select
170 the default GUI and quit all dialogs. After that start your site again by
177 Copyright (c) 2010-2011 OMD Team and Contributors -
178 <a href="http://omdistro.org/" title="Official OMD Homepage"
179 target="_blank">omdistro.org</a>
185 def load_process_env(req
):
187 Load process env into regular python environment
188 Be aware of eventual lists as values
190 for k
, v
in dict(req
.subprocess_env
).iteritems():
196 req
.content_type
= "text/html; charset=UTF-8"
197 req
.header_sent
= False
198 req
.myfile
= req
.uri
.split("/")[-1][:-3]
200 if req
.myfile
== "error":
205 req
.write("<html><body><h1>Internal Error</h1>Cannot output error log: %s</body></html>" % e
)
208 sitename
= site_name(req
)
209 config
= config_load(sitename
)
210 gui
= 'DEFAULT_GUI' in config
and config
['DEFAULT_GUI'] or 'nagios'
212 load_process_env(req
)
217 gui_url
= '/%s/%s/' % (sitename
, gui
)
218 util
.redirect(req
, gui_url
)
223 if os
.environ
.get('OMD_SITE', '') == pwd
.getpwuid(os
.getuid())[0]:
228 def show_apache_log(req
):
229 if omd_mode(req
) == 'own':
230 log_path
= '/omd/sites/%s/var/log/apache/error_log' % site_name(req
)
234 req
.write("<html><head><style>\n")
235 req
.write("b.date { color: #888; font-weight: normal; }\n")
236 req
.write("b.level.error { color: #f00; }\n")
237 req
.write("b.level.notice { color: #8cc; }\n")
238 req
.write("b.level { color: #cc0; }\n")
239 req
.write("b.msg.error { background-color: #fcc; color: #c00; }\n")
240 req
.write("b.msg.warn { background-color: #ffc; color: #880; }\n")
241 req
.write("b.msg { font-weight: normal; }\n")
242 req
.write("b.msg b.line { background-color: #fdd; color: black; }\n")
244 req
.write("</style><body>\n")
245 req
.write("<h1>Internal Server Error</h1>")
246 req
.write("<p>An internal error occurred. Details can be found in the Apache error log")
250 logfile
= file(log_path
)
251 lines
= logfile
.readlines()
255 req
.write(" (%s)" % log_path
)
256 req
.write("Here are the last couple of lines from that log file:</p>")
257 req
.write("<pre class=errorlog>\n")
259 parts
= line
.split(']', 2)
261 parts
+= [ "" ] * (3 - len(parts
))
262 date
= parts
[0].lstrip('[').strip()
263 level
= parts
[1].strip().lstrip('[')
264 message
= parts
[2].strip()
265 message
= re
.sub("line ([0-9]+)", "line <b class=line>\\1</b>", message
)
266 req
.write("<b class=date>%s</b> <b class=\"level %s\">%s</b> <b class=\"msg %s\">%s</b>\n" %
267 (date
, level
, "%-7s" % level
, level
, message
))
268 req
.write("</pre>\n")
269 req
.write("</body></html>\n")