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