Repository: librenms/librenms (language: php)

Issue:
Squid Application Support doesnt work correctly due to out of order OIDs
The squid application support is a simple snmp passthrough. Squid SNMP doesn't output in order, so you get messages about the OIDs not incrementing.

This seems to be a known issue with squid - http://etutorials.org/Server+Administration/Squid.+The+definitive+guide/Chapter+14.+Monitoring+Squid/14.3+Using+SNMP/

Can we some how manage to support squid with out-of-order OIDs



Discussion / hints:
@adamboutcher 
You need to add option "-Cc" to the LibreNMS SNMPwalk calls. snmpget are not impacted as far as I know. 

I would suggest to change this line at first : 
line 30 of `~/includes/discovery/applications.inc.php`

`$results = snmpwalk_cache_oid($device, 'nsExtendStatus', [], 'NET-SNMP-EXTEND-MIB', null, ['-OQUs', '-Cc']); `

Other specific calls for squid are snmpget and those should not be impacted with the "not incrementing" issue. 

I tested it in my env, and it does not break the apps I have, but I don't have squid so I cannot tell if it helps. Could you please test it ?
In my lab, we can see the -Cc added when debug mode is enabled:  
```
Applications: SNMP['/usr/bin/snmpbulkwalk' '-v2c' '-c' 'xxxxxxxxxxx' '-OQUs' '-Cc' '-m' 'NET-SNMP-EXTEND-MIB' '-M' '/opt/librenms/mibs' 'udp:xxxxxxxxxxxx:161' 'nsExtendStatus']
nsExtendStatus."smart" = active
```

If the issue is not fixed, please run in verbose and debug mode the discovery and the polling to find out which snmp call is failing. 

Thx
I'll try this on Monday. 
So I made the change suggested, however I run in a distributed container so I only edited the front end system and tried a capture.

discovery ran
poller ran
snmp failed

Squid didn't show up in the apps after running the capture. But I also couldnt see -Cc being added during those captures.
My version is a little behind too 21.3.0
after upgrading to actual LibreNMS Version, does the problem still exists?
I'll try and run an upgrade tomorrow (update to the latest docker
container).

On Mon, 23 Aug 2021, 6:10 pm SourceDoctor, ***@***.***> wrote:

> after upgrading to actual LibreNMS Version, does the problem still exists?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/librenms/librenms/issues/12988#issuecomment-903957264>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAOSVC4WXFIE7DWVXWD4RJDT6J6IRANCNFSM47KFAWKQ>
> .
>

So I need to do some minor tweaks my end to verify some things first. I am still here trying... 
I still get this error when I try to capture the SNMP to test..

```
.1.3.6.1.4.1.3495.1.5.2.2.1.nnn.60.193.132 = INTEGER: 1
.1.3.6.1.4.1.3495.1.5.2.2.1.nnn.60.192.111 = INTEGER: 1

Error: OID not increasing: .1.3.6.1.4.1.3495.1.5.2.2.1.nnn.60.192.122
 >= .1.3.6.1.4.1.3495.1.5.2.2.1.nnn.60.192.111

.1.3.6.1.4.1.3495.1.5.2.2.1.nnn.60.193.50 = INTEGER: 1
.1.3.6.1.4.1.3495.1.5.2.2.1.nnn.60.193.107 = INTEGER: 1
.1.3.6.1.4.1.3495.1.5.2.2.1.nnn.60.193.237 = INTEGER: 1
.1.3.6.1.4.1.3495.1.5.2.2.1.nnn.60.192.117 = INTEGER: 1
.1.3.6.1.4.1.3495.1.5.2.2.1.xxx.142.236.35 = INTEGER: 1

Error: OID not increasing: .1.3.6.1.4.1.3495.1.5.2.2.1.nnn.60.192.122
 >= .1.3.6.1.4.1.3495.1.5.2.2.1.nnn.60.192.117

Error: OID not increasing: .1.3.6.1.4.1.3495.1.5.2.2.1.nnn.60.192.122
 >= 
.1.3.6.1.4.1.3495.1.5.2.2.1.nnn.60.192.53 = INTEGER: 1

.1.3.6.1.4.1.3495.1.5.2.2.1.xxx.142.236.35

Error: OID not increasing: .1.3.6.1.4.1.3495.1.5.2.2.1.nnn.60.192.122
 >= 
.1.3.6.1.4.1.3495.1.5.2.2.1.nnn.60.192.53
 ```
 
 `nnn` and `xxx` are redacted IP octets; all `nnn` are the same and all `xxx` are the same but `nnn` and `xxx` are different
I can confirm that this issue is still present in version 22.8.0


Fix patch:
diff --git a/includes/polling/applications/squid.inc.php b/includes/polling/applications/squid.inc.php
index 18c10073bb1d..fb769a2bd6b1 100644
--- a/includes/polling/applications/squid.inc.php
+++ b/includes/polling/applications/squid.inc.php
@@ -44,7 +44,9 @@
     '.1.3.6.1.4.1.3495.1.3.2.2.1.10.5',
     '.1.3.6.1.4.1.3495.1.3.2.2.1.10.60',
 ];
-$returnedoids = snmp_get_multi_oid($device, $oids);
+
+// apparently squid is notorious for returning unordered oids (which can result in loops)
+$returnedoids = SnmpQuery::allowUnordered()->numeric()->get($oids);
 
 $memmaxsize = $returnedoids['.1.3.6.1.4.1.3495.1.2.5.1.0'];
 $swapmaxsize = $returnedoids['.1.3.6.1.4.1.3495.1.2.5.2.0'];


Test patch: