Skip to content

Commit

Permalink
Second commit to address #5554
Browse files Browse the repository at this point in the history
This is tricky, and still breaks down if the second line has an equal sign.  For example:

.1.3.2.4 = Some Text\n
Some More Text = Stuff\n
This is a real long line.
.1.3.2.5 = Some numeric value

So, it's not perfect.
  • Loading branch information
TheWitness committed Nov 22, 2023
1 parent 58d506b commit 261adbc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/snmp.php
Original file line number Diff line number Diff line change
Expand Up @@ -724,12 +724,18 @@ function cacti_snmp_walk($hostname, $community, $oid, $version, $auth_user = '',
}
}

/**
* Using this technique to catch multi-line
* snmpwalk responses from net-snmp. This happens
* usually on sysDescr on Cisco devices.
*/
$i = 0;

foreach ($temp_array as $index => $value) {
if (preg_match('/(.*) =.*/', $value)) {
$snmp_array[$i]['oid'] = trim(preg_replace('/(.*) =.*/', '\\1', $value));
$snmp_array[$i]['value'] = format_snmp_string($value, true, $value_output_format);
$parts = explode('=', $value, 2);
$snmp_array[$i]['oid'] = trim($parts[0]);
$snmp_array[$i]['value'] = format_snmp_string($parts[1], false, $value_output_format);
$i++;
} else {
$snmp_array[$i - 1]['value'] .= $value;
Expand Down

0 comments on commit 261adbc

Please sign in to comment.