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