-
Notifications
You must be signed in to change notification settings - Fork 0
/
station_monitor.py
203 lines (145 loc) · 7.64 KB
/
station_monitor.py
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#autogenerated by sqlautocode
from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relation
engine = create_engine('mysql://root:[email protected]:3306/station_monitor')
DeclarativeBase = declarative_base()
metadata = DeclarativeBase.metadata
metadata.bind = engine
rel_sta_target = Table(u'rel_sta_target', metadata,
Column(u'rst_id', INTEGER(), primary_key=True, nullable=False),
Column(u's_id', INTEGER(), ForeignKey('stations.s_id'), nullable=False),
Column(u'mt_id', INTEGER(), ForeignKey('monitor_target.mt_id'), nullable=False),
Column(u'response', FLOAT()),
)
rel_team_user = Table(u'rel_team_user', metadata,
Column(u'rid', INTEGER(), primary_key=True, nullable=False),
Column(u'tid', INTEGER(), ForeignKey('team.tid'), nullable=False),
Column(u'uid', INTEGER(), ForeignKey('user.uid'), nullable=False),
)
class AlarmTpl(DeclarativeBase):
__tablename__ = 'alarm_tpl'
__table_args__ = {}
#column definitions
alarm_type = Column(u'alarm_type', VARCHAR(length=8), nullable=False)
at_id = Column(u'at_id', INTEGER(), primary_key=True, nullable=False)
creator = Column(u'creator', VARCHAR(length=64), nullable=False)
max_alarm_num = Column(u'max_alarm_num', SMALLINT(), nullable=False)
min_continue_num = Column(u'min_continue_num', SMALLINT(), nullable=False)
min_sta_num = Column(u'min_sta_num', SMALLINT(), nullable=False)
name = Column(u'name', VARCHAR(length=64), nullable=False)
note = Column(u'note', VARCHAR(length=256))
strategy = Column(u'strategy', VARCHAR(length=1024), nullable=False)
#relation definitions
class CollectHttpModel(DeclarativeBase):
__tablename__ = 'collect_http_model'
__table_args__ = {}
#column definitions
chm_id = Column(u'chm_id', INTEGER(), primary_key=True, nullable=False)
cookie = Column(u'cookie', TEXT())
creator = Column(u'creator', VARCHAR(length=64), nullable=False)
interval = Column(u'interval', SMALLINT(), nullable=False)
match = Column(u'match', Enum(u'true', u'false', u'ignore'))
method = Column(u'method', VARCHAR(length=8), nullable=False)
name = Column(u'name', VARCHAR(length=32), nullable=False)
postcontent = Column(u'postcontent', String())
response = Column(u'response', String())
#relation definitions
class CollectPingModel(DeclarativeBase):
__tablename__ = 'collect_ping_model'
__table_args__ = {}
#column definitions
cpm_id = Column(u'cpm_id', INTEGER(), primary_key=True, nullable=False)
creator = Column(u'creator', VARCHAR(length=64), nullable=False)
interval = Column(u'interval', SMALLINT(), nullable=False)
name = Column(u'name', VARCHAR(length=32), nullable=False)
#relation definitions
class Log(DeclarativeBase):
__tablename__ = 'log'
__table_args__ = {}
#column definitions
action = Column(u'action', VARCHAR(length=8), nullable=False)
created = Column(u'created', TIMESTAMP(), nullable=False)
l_id = Column(u'l_id', INTEGER(), primary_key=True, nullable=False)
monitor_name = Column(u'monitor_name', VARCHAR(length=32), nullable=False)
target = Column(u'target', VARCHAR(length=512), nullable=False)
user = Column(u'user', VARCHAR(length=64), nullable=False)
#relation definitions
class MonitorAuthUser(DeclarativeBase):
__tablename__ = 'monitor_auth_user'
__table_args__ = {}
#column definitions
creator = Column(u'creator', VARCHAR(length=64), nullable=False)
mau_id = Column(u'mau_id', INTEGER(), primary_key=True, nullable=False)
monitor_name = Column(u'monitor_name', VARCHAR(length=32), nullable=False)
other_views_users = Column(u'other_views_users', VARCHAR(length=512), nullable=False)
views_users = Column(u'views_users', VARCHAR(length=4096), nullable=False)
#relation definitions
class MonitorTarget(DeclarativeBase):
__tablename__ = 'monitor_target'
__table_args__ = {}
#column definitions
at_id = Column(u'at_id', INTEGER(), ForeignKey('alarm_tpl.at_id'), nullable=False)
cm_id = Column(u'cm_id', INTEGER(), nullable=False)
created = Column(u'created', TIMESTAMP(), nullable=False)
creator = Column(u'creator', VARCHAR(length=64), nullable=False)
enabled = Column(u'enabled', Integer())
monitor_type = Column(u'monitor_type', VARCHAR(length=8), nullable=False)
mt_id = Column(u'mt_id', INTEGER(), primary_key=True, nullable=False)
name = Column(u'name', VARCHAR(length=32), nullable=False)
note_group = Column(u'note_group', VARCHAR(length=512), nullable=False)
notify_method = Column(u'notify_method', INTEGER(), nullable=False)
request_method = Column(u'request_method', VARCHAR(length=8))
run_begin = Column(u'run_begin', VARCHAR(length=16), nullable=False)
run_end = Column(u'run_end', VARCHAR(length=16), nullable=False)
stations = Column(u'stations', VARCHAR(length=1024), nullable=False)
target = Column(u'target', VARCHAR(length=512), nullable=False)
updated = Column(u'updated', TIMESTAMP(), nullable=False)
#relation definitions
stations = relation('Station', primaryjoin='MonitorTarget.mt_id==RelStaTarget.mt_id', secondary=rel_sta_target, secondaryjoin='RelStaTarget.s_id==Station.s_id')
alarm_tpl = relation('AlarmTpl', primaryjoin='MonitorTarget.at_id==AlarmTpl.at_id')
class RelStaTarget(DeclarativeBase):
__table__ = rel_sta_target
#relation definitions
stations = relation('Station', primaryjoin='RelStaTarget.s_id==Station.s_id')
monitor_target = relation('MonitorTarget', primaryjoin='RelStaTarget.mt_id==MonitorTarget.mt_id')
class RelTeamUser(DeclarativeBase):
__table__ = rel_team_user
#relation definitions
user = relation('User', primaryjoin='RelTeamUser.uid==User.uid')
team = relation('Team', primaryjoin='RelTeamUser.tid==Team.tid')
class Station(DeclarativeBase):
__tablename__ = 'stations'
__table_args__ = {}
#column definitions
alias = Column(u'alias', VARCHAR(length=64))
name = Column(u'name', VARCHAR(length=8))
s_id = Column(u's_id', INTEGER(), primary_key=True, nullable=False)
#relation definitions
monitor_targets = relation('MonitorTarget', primaryjoin='Station.s_id==RelStaTarget.s_id', secondary=rel_sta_target, secondaryjoin='RelStaTarget.mt_id==MonitorTarget.mt_id')
class Team(DeclarativeBase):
__tablename__ = 'team'
__table_args__ = {}
#column definitions
created = Column(u'created', TIMESTAMP(), nullable=False)
creator = Column(u'creator', VARCHAR(length=64), nullable=False)
name = Column(u'name', VARCHAR(length=64), nullable=False)
tid = Column(u'tid', INTEGER(), primary_key=True, nullable=False)
#relation definitions
users = relation('User', primaryjoin='Team.tid==RelTeamUser.tid', secondary=rel_team_user, secondaryjoin='RelTeamUser.uid==User.uid')
class User(DeclarativeBase):
__tablename__ = 'user'
__table_args__ = {}
#column definitions
created = Column(u'created', TIMESTAMP(), nullable=False)
creator = Column(u'creator', VARCHAR(length=64), nullable=False)
email = Column(u'email', VARCHAR(length=255), nullable=False)
name = Column(u'name', VARCHAR(length=64), nullable=False)
nickname = Column(u'nickname', VARCHAR(length=128))
passwd = Column(u'passwd', VARCHAR(length=64), nullable=False)
phone = Column(u'phone', VARCHAR(length=16), nullable=False)
qq = Column(u'qq', VARCHAR(length=16))
role = Column(u'role', Integer(), nullable=False)
uid = Column(u'uid', INTEGER(), primary_key=True, nullable=False)
#relation definitions
teams = relation('Team', primaryjoin='User.uid==RelTeamUser.uid', secondary=rel_team_user, secondaryjoin='RelTeamUser.tid==Team.tid')