forked from QthCN/hmonitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhmonitor.py
More file actions
98 lines (79 loc) · 3.67 KB
/
hmonitor.py
File metadata and controls
98 lines (79 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# -*- coding: utf-8 -*-
import os
import tornado
import tornado.httpserver
from tornado.options import define, options
from hmonitor.autofix import load_autofix_scripts
from hmonitor.autofix.manager import AutoFixManager
from hmonitor.handlers.events import (MyEventsHandler,
AllEventsHandler)
from hmonitor.handlers.account import AccoundPasswordHandler
from hmonitor.handlers.alert import AlertHandler
from hmonitor.handlers.alerts import (MySubscribeAlertsHandler,
SubscribeAlertsHandler,
AlertsStatHandler,
AlertFilterHandler)
from hmonitor.handlers.autofix import (AutoFixHandler,
AutoFixStatHandler,
ShowScriptsHandler,
BindScriptHandler)
from hmonitor.handlers.login import LoginHandler, LogoutHandler
#MySQL
define("port", default=8888, help="run on the given port", type=int)
define("mysql_host", default="127.0.0.1:3306", help="hmonitor database host")
define("mysql_database", default="hmonitor", help="hmonitor database name")
define("mysql_user", default="root", help="hmonitor database user")
define("mysql_password", default="rootroot", help="hmonitor database password")
#Zabbix
define("zabbix_user", default="Admin", help="Zabbix user name")
define("zabbix_password", default="zabbix", help="Zabbix password")
define("zabbix_url", default="http://127.0.0.1/zabbix", help="Zabbix URL")
#Executor
define("executor_driver", default="ssh", help="remote executor driver")
define("executor_user", default="stack", help="remote executor user")
class Application(tornado.web.Application):
def __init__(self, autofix_manager):
handlers = [
(r"/", MyEventsHandler),
(r"/index.html", MyEventsHandler),
(r"/myevents.html", MyEventsHandler),
(r"/allevents.html", AllEventsHandler),
(r"/mysubscribealerts.html", MySubscribeAlertsHandler),
(r"/subscribealerts.html", SubscribeAlertsHandler),
(r"/alertsstat.html", AlertsStatHandler),
(r"/alertfilter.html", AlertFilterHandler),
(r"/autofixscriptslist.html", ShowScriptsHandler),
(r"/autofixbinding.html", BindScriptHandler),
(r"/autofixstat.html", AutoFixStatHandler),
(r"/accountupdatepassword.html", AccoundPasswordHandler),
(r"/autofix", AutoFixHandler),
(r"/alert", AlertHandler),
(r"/login.html", LoginHandler),
(r"/logout.html", LogoutHandler),
]
settings = dict(
blog_title="Monitor",
template_path=os.path.join(os.path.dirname(__file__),
"hmonitor",
"templates"),
static_path=os.path.join(os.path.dirname(__file__),
"hmonitor",
"static"),
debug=True,
cookie_secret="61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=",
login_url="/login.html",
)
super(Application, self).__init__(handlers, **settings)
self.autofix_manager = autofix_manager
def get_autofix_manager():
am = AutoFixManager(worker=8, executor=options.executor_driver)
return am
def main():
tornado.options.parse_command_line()
load_autofix_scripts()
am = get_autofix_manager()
http_server = tornado.httpserver.HTTPServer(Application(am))
http_server.listen(options.port)
tornado.ioloop.IOLoop.current().start()
if __name__ == "__main__":
main()