Skip to content

Commit

Permalink
Mark OID not increasing as invalid (librenms#13548)
Browse files Browse the repository at this point in the history
* Mark OID not increasing as invalid

* Provisional test data

* verified return code is 1
  • Loading branch information
murrant committed Nov 24, 2021
1 parent 42fdbea commit 61eae8f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion LibreNMS/Data/Source/SnmpResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function isValid(): bool
{
$this->errorMessage = '';
// not checking exitCode because I think it may lead to false negatives
$invalid = preg_match('/(Timeout: No Response from .*|Unknown user name|Authentication failure)/', $this->stderr, $errors)
$invalid = preg_match('/(Timeout: No Response from .*|Unknown user name|Authentication failure|Error: OID not increasing: .*)/', $this->stderr, $errors)
|| empty($this->raw)
|| preg_match('/(No Such Instance|No Such Object|No more variables left).*/', $this->raw, $errors);

Expand Down
5 changes: 5 additions & 0 deletions tests/Unit/SnmpResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,10 @@ public function testErrorHandling(): void
$response = new SnmpResponse('', "snmpget: Authentication failure (incorrect password, community or key) (Sub-id not found: (top) -> sysDescr)\n", 1);
$this->assertFalse($response->isValid());
$this->assertEquals('Authentication failure', $response->getErrorMessage());

// OID not increasing
$response = new SnmpResponse(".1.3.6.1.2.1.2.2.1.1.1 = INTEGER: 1\n", "Error: OID not increasing: .1.3.6.1.2.100.2.2.1.1\n >= .1.3.6.1.2.1.2.2.1.1.1\n", 1);
$this->assertFalse($response->isValid());
$this->assertEquals('Error: OID not increasing: .1.3.6.1.2.100.2.2.1.1', $response->getErrorMessage());
}
}

0 comments on commit 61eae8f

Please sign in to comment.