|
47 | 47 | use LibreNMS\Enum\MaintenanceStatus; |
48 | 48 | use LibreNMS\Enum\Severity; |
49 | 49 | use LibreNMS\Exceptions\AlertTransportDeliveryException; |
| 50 | +use LibreNMS\Exceptions\RrdException; |
50 | 51 | use LibreNMS\Polling\ConnectivityHelper; |
51 | 52 | use LibreNMS\Util\Number; |
52 | 53 | use LibreNMS\Util\Time; |
@@ -127,20 +128,20 @@ public function describeAlert($alert) |
127 | 128 | $obj['proc'] = $alert['proc']; |
128 | 129 | $obj['status'] = $device->status; |
129 | 130 | $obj['status_reason'] = $device->status_reason; |
130 | | - if (ConnectivityHelper::pingIsAllowed($device)) { |
| 131 | + |
| 132 | + if ((new ConnectivityHelper($device))->icmpIsEnabled()) { |
131 | 133 | try { |
132 | 134 | $last_ping = Rrd::lastUpdate(Rrd::name($device->hostname, 'icmp-perf')); |
133 | | - } catch (\Exception $e) { |
| 135 | + if ($last_ping) { |
| 136 | + $obj['ping_timestamp'] = $last_ping->timestamp; |
| 137 | + $obj['ping_loss'] = Number::calculatePercent($last_ping->get('xmt') - $last_ping->get('rcv'), $last_ping->get('xmt')); |
| 138 | + $obj['ping_min'] = $last_ping->get('min'); |
| 139 | + $obj['ping_max'] = $last_ping->get('max'); |
| 140 | + $obj['ping_avg'] = $last_ping->get('avg'); |
| 141 | + $obj['debug'] = 'unsupported'; |
| 142 | + } |
| 143 | + } catch (RrdException $e) { |
134 | 144 | Log::error("Error getting last ping for device {$device->hostname}: {$e->getMessage()}"); |
135 | | - $last_ping = null; |
136 | | - } |
137 | | - if ($last_ping) { |
138 | | - $obj['ping_timestamp'] = $last_ping->timestamp; |
139 | | - $obj['ping_loss'] = Number::calculatePercent($last_ping->get('xmt') - $last_ping->get('rcv'), $last_ping->get('xmt')); |
140 | | - $obj['ping_min'] = $last_ping->get('min'); |
141 | | - $obj['ping_max'] = $last_ping->get('max'); |
142 | | - $obj['ping_avg'] = $last_ping->get('avg'); |
143 | | - $obj['debug'] = 'unsupported'; |
144 | 145 | } |
145 | 146 | } |
146 | 147 | $extra = $alert['details']; |
@@ -761,7 +762,7 @@ public function isParentDown($device) |
761 | 762 | return false; |
762 | 763 | } |
763 | 764 |
|
764 | | - $down_parent_count = dbFetchCell("SELECT count(*) from devices as d LEFT JOIN devices_attribs as a ON d.device_id=a.device_id LEFT JOIN device_relationships as r ON d.device_id=r.parent_device_id WHERE d.status=0 AND d.ignore=0 AND d.disabled=0 AND r.child_device_id=? AND (d.status_reason='icmp' OR (a.attrib_type='override_icmp_disable' AND a.attrib_value=true))", [$device]); |
| 765 | + $down_parent_count = dbFetchCell('SELECT count(*) from devices as d LEFT JOIN device_relationships as r ON d.device_id=r.parent_device_id WHERE d.status=0 AND d.ignore=0 AND d.disabled=0 AND r.child_device_id=?', [$device]); |
765 | 766 | if ($down_parent_count == $parent_count) { |
766 | 767 | return true; |
767 | 768 | } |
|
0 commit comments