From 05a77b7bd2388eb45b2e66d0198396cf0b1f63fd Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Sat, 25 Aug 2018 03:57:28 -0500 Subject: [PATCH] Optimize OSPF poller (#9080) if there are no instances, don't check for areas, neighbors, and ports DO NOT DELETE THIS TEXT #### Please note > Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting. - [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/) #### Testers If you would like to test this pull request then please run: `./scripts/github-apply `, i.e `./scripts/github-apply 5926` --- includes/polling/ospf.inc.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/includes/polling/ospf.inc.php b/includes/polling/ospf.inc.php index 6d20aa91c5..7e4f4aed6a 100644 --- a/includes/polling/ospf.inc.php +++ b/includes/polling/ospf.inc.php @@ -42,7 +42,12 @@ foreach ($vrfs_lite_cisco as $vrf_lite) { ->where(['device_id' => $device['device_id'], 'context_name' => $device['context_name']]) ->whereNotIn('id', $ospf_instances->pluck('id'))->delete(); - echo $ospf_instances->count(); + $instance_count = $ospf_instances->count(); + echo $instance_count; + if ($instance_count == 0) { + // if there are no instances, don't check for areas, neighbors, and ports + return; + } echo ' Areas: '; @@ -145,7 +150,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('neighbours', 'GAUGE', 0, 1000000); $fields = [ - 'instances' => $ospf_instances->count(), + 'instances' => $instance_count, 'areas' => $ospf_areas->count(), 'ports' => $ospf_ports->count(), 'neighbours' => $ospf_neighbours->count(), @@ -158,6 +163,7 @@ echo PHP_EOL; unset( $ospf_instances, + $instance_count, $ospf_areas, $ospf_ports, $ospf_neighbours,