@@ 126-149 (lines=24) @@ | ||
123 | ||
124 | return self.stats |
|
125 | ||
126 | def get_ports_alert(self, port, header="", log=False): |
|
127 | """Return the alert status relative to the port scan return value.""" |
|
128 | ret = 'OK' |
|
129 | if port['status'] is None: |
|
130 | ret = 'CAREFUL' |
|
131 | elif port['status'] == 0: |
|
132 | ret = 'CRITICAL' |
|
133 | elif ( |
|
134 | isinstance(port['status'], (float, int)) |
|
135 | and port['rtt_warning'] is not None |
|
136 | and port['status'] > port['rtt_warning'] |
|
137 | ): |
|
138 | ret = 'WARNING' |
|
139 | ||
140 | # Get stat name |
|
141 | stat_name = self.get_stat_name(header=header) |
|
142 | ||
143 | # Manage threshold |
|
144 | self.manage_threshold(stat_name, ret) |
|
145 | ||
146 | # Manage action |
|
147 | self.manage_action(stat_name, ret.lower(), header, port[self.get_key()]) |
|
148 | ||
149 | return ret |
|
150 | ||
151 | def get_web_alert(self, web, header="", log=False): |
|
152 | """Return the alert status relative to the web/url scan return value.""" |
|
@@ 151-170 (lines=20) @@ | ||
148 | ||
149 | return ret |
|
150 | ||
151 | def get_web_alert(self, web, header="", log=False): |
|
152 | """Return the alert status relative to the web/url scan return value.""" |
|
153 | ret = 'OK' |
|
154 | if web['status'] is None: |
|
155 | ret = 'CAREFUL' |
|
156 | elif web['status'] not in [200, 301, 302]: |
|
157 | ret = 'CRITICAL' |
|
158 | elif web['rtt_warning'] is not None and web['elapsed'] > web['rtt_warning']: |
|
159 | ret = 'WARNING' |
|
160 | ||
161 | # Get stat name |
|
162 | stat_name = self.get_stat_name(header=header) |
|
163 | ||
164 | # Manage threshold |
|
165 | self.manage_threshold(stat_name, ret) |
|
166 | ||
167 | # Manage action |
|
168 | self.manage_action(stat_name, ret.lower(), header, web[self.get_key()]) |
|
169 | ||
170 | return ret |
|
171 | ||
172 | def msg_curse(self, args=None, max_width=None): |
|
173 | """Return the dict to display in the curse interface.""" |