Commit Graph

51 Commits

Author SHA1 Message Date
Tony Murray
9d35fbc6a7 Entity Physical discovery: Rewrite to modern style (#16289)
* Initial entity-physical code

* Split out Entity-MIB trait

* Cisco Cellular inventory

* Fix bad test data

* alfo80hd - we now include all entPhysical entries

* Correct aos7 test data

* Add entPhysicalClass as last resort for label in ui

* aos add previously filtered data

* Fixup arista-eos data

* Update ariast_eos data

* Arris, clean garbage in Rev fields

* Aruba Instant custom inventory ported

* ArubaOS CX add vendor type mib

* aviat-wtm test data refresh

* axos add shelf fix data fields a bit

* ciena-rls

* ciena-sds

* Skip cimc for now... no test data

* Cisco updates

* Comware data update

* Update dnos

* Clean Edgeos garbage, make code from Arris shareable

* Relaxed ifIndex match, some devices cheat and send back static strings instead of formatted OIDs

* Regex refinement and updated edgeos with new clean data

* Update edgeswitch data

* Update eltex-mes21xx data

* eltex-mes23xx

* Guess at eltex-mes24xx since there is no test data

* Update eurostor, fix firmware version

* Apply fixes from StyleCI

* fixes

* Update fortigate data

* Update fortiweb, ftd, and fusion

* Update linux LSI

* Fix hexToAscii null removal with different seperator handling

* icotera add final snmprec data to avoid snmpsim bug

* Update IOS data

* Update mrv-od

* Add junos translation

* Generic data updates n-r

* ruijie workaround snmpsim bug

* Port saf-cfm

* Recode Schleifenbauer, and fix entPhysicalIndex values

* SmartAX fixes

* sm-os and tait-infra93

* timos inventory was not right, fix it up

* ubiquoss-pon

* VRP, has custom data collection on top of normal
adapt port ifIndex lookup to handle it

* VRP exceeded the string length specified in ENTITY-MIB...

* data updates

* Final data update and code cleanup

* Apply fixes from StyleCI

* Lint fixes

* Add missing SnmpResponse->pluck() code

* Update db_schema.yaml

* Fix bad test data

* Another instant-on update

* oops

* Remove some unused code

# Conflicts:
#	includes/html/pages/device/overview.inc.php

---------

Co-authored-by: Tony Murray <murrant@users.noreply.github.com>
2024-08-21 01:12:09 -05:00
Tony Murray
55f603c30c Refactor SnmpResponse mapTable (#16238)
Replace previous code with a couple of foreach loops
2024-07-22 21:23:10 -05:00
Tony Murray
04101c2c6f SnmpQuery default improvements (#16204)
Always ignore underscores. Vendors constantly break this rule and it doesn't seem to have any side effects to enable -Pu.
translate respect hideMib() option
2024-07-15 08:52:37 -05:00
Tony Murray
3aedfb4f3b Fix some testing issues (#16174)
* Fix some testing issues
index doesn't exist in ModuleTestHelper
Cache issue in NetSnmpQuery (specifically affects testing)

* Apply fixes from StyleCI

---------

Co-authored-by: Tony Murray <murrant@users.noreply.github.com>
2024-07-02 09:21:39 -05:00
Tony Murray
8bf40c5eef Fix fping bulk (#16085)
* Fix Fping bulk
When an ICMP unreachable message was returned (stderr), the output processing would save it as if it were a partial line, breaking parsing.
Only save a line if it is the last line of the output (not ending in a new line)

* Add test case

* safer logic
2024-06-03 21:29:29 -05:00
Tony Murray
49f8269262 Improved Latency graph (#15940)
* Improved Latency graph
Store loss+jitter info in rrd instead of database
New graph icmp_perf (legacy ping_perf still valid referencing part of the newer data)
Delete device_perf table

* Change loss to an area so it is more visible

* Style fixes

* Cleanups from phpstan & tests

* exit_code fix

* Remove alert usage of device_perf

* Don't use magic __get

* Add test for bulkPing
Add host to previous tests

* style fixes

* Fix issue fping error responses
2024-04-18 09:57:01 -05:00
PipoCanaja
63f33642b8 string VS array (#15533) 2023-10-31 15:22:18 -05:00
Tony Murray
7c542d70af SnmpQuery runtime cache (#15512)
* SnmpQuery runtime cache
Optionally cache the SnmpResponse from queries for the rest of the runtime.
It would be nice to have cache hits for these to help prevent wasting memory caching data that is only used once.
Key data must match: device, context, options, oids

* Apply fixes from StyleCI

* Add command to the cache key

* Caching in the wrong spot, cache individual commands...

* Apply fixes from StyleCI

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
2023-10-29 22:46:04 -05:00
Tony Murray
5386b24888 Type safety check (#15409)
* Type safety check
now fails silently, we already have schema validation to check it is a string, but... people find a way.

* Fixup
2023-10-07 18:45:30 -05:00
Tony Murray
be24993cbb Remove snmp functions that are barely used (#15377)
* Remove snmp functions that are barely used
Replace them with SnmpQuery calls

* Apply fixes from StyleCI

* Fix missing namespace

* Import Oid

* No more variables left may be repeated multiple times at the end with snmpsim, remove them all

* update data fixed by SnmpResponse bugfix

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
2023-10-05 01:29:22 -05:00
Tony Murray
e978025553 Fix typo in default mibs for SnmpQuery (#15297) 2023-09-08 08:32:01 -05:00
AdamB
daf36ef48f fping 4.0+ prefers IPv6 (#14825)
Additionally fping6 is no longer a thing - this breaks IPv4 hosts entirely in a dual stack environment

It's not possible to reconcile these options, so we have to have a toggle until distro's with fping 3.x fall out of support.
2023-08-10 20:16:59 -05:00
Tony Murray
d1b7004fef Severity Enum (#14620)
* Severity Enum
Replace old Alert constants

* Fix whitespace

* Additional uses

* style fixes

* Fix test too

* More missed locations

* More
2023-08-05 12:12:36 -05:00
Tony Murray
9382959c8c Set mibs explicitly in SnmpQuery (#15199)
* Set mibs explicitly in SnmpQuery
Always override system mibs, so we have consistency
New method to control mibs

* Lint fixes
2023-08-05 14:45:15 +02:00
Tony Murray
d09c5540ed Fix SnmpQuery and max_oid (#14955)
If the snmpget had less oids than the max, it would run them one at a time instead of all together.
2023-04-10 12:07:32 -05:00
Jellyfrog
68e0b3df28 Apply fixes from StyleCI (#14899)
Co-authored-by: StyleCI Bot <bot@styleci.io>
2023-03-13 22:32:22 +01:00
Tony Murray
d3f02e6bb7 SnmpQuery, respect snmp.max_oid (#14894)
Previously, the code would query all the oids it received. Now it will split it up into multiple queries if too many are sent.

Prevents some devices snmp service from crashing.
2023-03-13 10:17:34 -05:00
Tony Murray
e8c3b2c924 Improve SnmpResponse value() (#14605)
* Improve SnmpResponse value
Can now return a specific oid or the first non-empty oid in a list.
Cache values() call on object to avoid repeated parsing
Improved types

* fix style

* extract getOidParts to fix errors from different parts of the code parsing differently

* new object to deal with cache

* More tests

* whitespace

* style
2022-11-30 19:50:46 -06:00
Tony Murray
7635ace4fa Split out lnms snmp convenience commands (#14603)
* Split out lnms snmp convenience commands

* Use SnmpQuery->valuesByIndex()

* Fix style
2022-11-19 22:10:25 -06:00
Jellyfrog
71d740770b Remove Log::event (#14526)
* Remove Log::event

Use the Eventlog class directly instead

* wip

* wip

* wip

* Apply fixes from StyleCI

* Update Eventlog.php
2022-11-09 09:47:19 +01:00
Tony Murray
0801af7a81 Consolidate and improve snmptranslate usage (#14567)
* Consolidate and improve snmptranslate usage

* Fix style

* lint fixes

* fix typo

* allow multiple mib directories

* Only add mib if it is not already set

* oid first, in case we have key length issues

* if there is a full oid, don't add other mibs

* debug in ci

* more debug in ci

* better debug in ci

* remove debug

* Use numeric index

* revert dlink change

* Don't add -On twice

* unit tests and hopefully better heuristics

* remove dump and add one more set of tests

* style fixes

* handle bad input in old functions

* shortcut whole snmp_translate function
2022-11-07 12:00:47 -06:00
Tony Murray
e5e169358f SnmpQuery Handle empty oids in get more gracefully (#14577) 2022-11-05 00:38:20 -05:00
Tony Murray
35bea945ba SnmpQuery fix mib directory order (#14580) 2022-11-04 23:12:56 -05:00
Tony Murray
0c365d08e3 SnmpQuery numeric accept a boolean (#14565) 2022-11-02 18:50:46 -05:00
Tony Murray
69d1c2022a SnmpResponse filterBadLines fix (#14306)
Actually filter lines (instead of full responses) with No Such Instance regex
2022-09-06 12:10:29 +02:00
Tony Murray
a664d12eb7 Fix ipv6 hexdec error (#14254)
* Fix ipv6 hexdec error
convert to SnmpQuery and Ipv6 util

* Don't walk other oids if one fails.
2022-08-28 20:47:51 -05:00
Tony Murray
08c4d7f3b3 Allow SnmpQuery to optionally abort walks if one fails (#14255)
* Allow SnmpQuery to optionally abort walks if one fails

* style

* remove baseline
2022-08-28 19:47:20 -05:00
Tony Murray
82be234bae SnmpQuery walk multiple oids (#14015)
Makes it easier to walk select oids from a large table.
Walking oids with different indexes will break some logic and is undefined so far.
2022-06-07 09:04:32 +02:00
Tony Murray
d026e9f0cc Allow unordered OIDs (global and per-os) (#13923)
* Allow unordered OIDs (global and per-os)
Fix global no_bulk setting, was ignored before
(to fix global needed to rework Config::getCombined() a bit to allow a global prefix to be specified)
Removed invalid use of getCombined and updated tests

* fix whitespace

* update os schema
2022-04-21 21:49:26 -05:00
Tony Murray
b7d22a768b Fix snmpv3 context when empty SnmpQuery (#13832)
* Fix snmpv3 context when empty SnmpQuery
Fixes: #13820

* Cleaner fix
2022-03-10 21:27:09 +01:00
Tony Murray
29bd6789cb Stp module rewrite (#13570)
* STP module rewrite WIP

* Finish rewrite

* Ignore disabled and log root/topology changes

* Remove interfaces for now

* fix style

* Lint fixes

* Document ResolvesPortIds and hide map functions

* whitespace fixes

* Revert to stpInstances in case someone writes mstp support

* missed one

* phpstan fixes

* Handle table and oids separately

* forgot to register observer

* Test data and correct non-table handling in SnmpResponse->table()

* update test

* test data

* revert aos7 silly things

* minimal polling

* Update test data

* order ports_ntp and rename new field to port_index

* forgot the db_schema

* revert ciena-sds port things

* MSTP support, maybe

* Adding test data

* Filter bad lines instead of discarding the entire snmp response
and capture fixes and test data

* fresh data

* add os data

* update data, ignore unfound ports, obviously bad device implementation.

* fixes

* Ignore context files in os detection test

* Remove empty table data

* add ciena-sds vlan

* designatedCost column is too small

* Update stp webui

* Refactor code to interfaces, to allow vendor mibs

* update schema

* fix issues added by abstraction

* STP fixes

* Default to no context for vlan 1

* never store vlan 1

* Update test data

* remove eltex brokenness

* fix style

* fix stan

* Fix Rewrite MAC to Hex padding with floats

* fix sqlite migration
2022-01-30 16:28:18 -06:00
Peca Nesovanovic
592a0efa51 added oids.no_bulk os setting (#13666)
* forcewalk param

* [snmp][no_bulk]

* var names, test, schema

* Key off OIDs, not mibs

luminato is POC and needs to be reverted before merge.

* fix up os schema

* docs

* remove luminato arbitrary changes

Co-authored-by: Tony Murray <murraytony@gmail.com>
2022-01-15 09:59:23 -06:00
Tony Murray
0eccd1aac3 Fix SnmpQuery bulk boolean backwards (#13636) 2021-12-27 16:19:13 -06:00
Tony Murray
5ce7a5ad0e snmp.unescape setting (#13590)
* snmp.unescape setting
Works around issue with (I think net-snmp < 5.8.0) where it adds backslashes.

* Updated test data
2021-11-30 21:33:18 -06:00
Tony Murray
9d2633bf09 Escape net-snmp unformatted strings, try 2 (#13584)
* Escape net-snmp unformatted strings, try 2

* Add some tests
2021-11-30 00:12:42 -06:00
Tony Murray
61eae8fb6a Mark OID not increasing as invalid (#13548)
* Mark OID not increasing as invalid

* Provisional test data

* verified return code is 1
2021-11-24 18:22:15 +01:00
Tony Murray
7893b8bebe OSPF issue when devices don't support OSPF-MIB::ospfIfTable (#13530)
* OSPF devices return wrong ospfIfTable index

* Handle "End of MIB" string
2021-11-17 16:26:50 -06:00
Tony Murray
7e98e03338 Polling cleanup, fix PHP warnings (#13460)
* Fix warnings up to Arbos

* fixes a-c

* a-r

* a-vrp

* There and back again

* Update test data, couple fixes

* PHPSStan fixes

* style fixes, and fix Asyncos, whoops

* flip serial back.......

* less bogus data

* Poweralert sysName during polling too

* make sure things are calculated in the correct order

* fix style and bad nullables

* update test data

* A comple more conversions

* cambium ptp, misc, and hardware_mib

* remaining except vmware-esxi

* Fixes

* Update baseline

* fixes and fix up baseline

* adjust SnmpQueryMock to upstream options change

* data corrections

* restore slashes

* correctly handle all options input in SnmpQueryMock

* undo ftos changes

* restore vccodec sysDescr
2021-11-14 14:58:13 -06:00
Tony Murray
0adf37b4e1 OSPF port module (#13498)
* OSPF to module

* Update mock

* lint and style fixes

* enums as strings
2021-11-12 13:49:09 -06:00
Tony Murray
666638eeaa Fix bad snmp context option (#13497)
* Fix bad snmp context option
Just port queries to SnmpQuery and remove bad code to prevent new usages

* Allow unordered

* add stub on Mock
2021-11-12 12:40:37 -06:00
PipoCanaja
29f1cb53ab Added TOS support for fping (#13496)
* TOS support for fping in LibreNMS/Data/Source/Fping.php

* TOS support for fping in app/Jobs/PingCheck.php

* Doc

* Improve doc
2021-11-11 22:33:01 +01:00
Tony Murray
06701870cd Change how options are handled for SnmpQuery (#13488)
* Change how options are handled for SnmpQuery
Fix added backslashes when collecting snmp data.

* fix lint
2021-11-10 20:49:06 -06:00
Tony Murray
15632bb875 Fix net-snmp unformatted strings (#13486)
* Fix net-snmp unformatted strings
When net-snmp returns an unformatted string (with quotes around it), it also has backslashes to escape certain characters.  Remove those.

* Clean up sysDescr and sysName when setting to Device model.

* Lint fixes

* Hmm, additional formatting spots
2021-11-10 20:48:22 -06:00
Tony Murray
90e2570d38 Fix SnmpQuery mibdir from os group (#13475) 2021-11-04 22:58:36 +01:00
Tony Murray
5fafb11c8f Rename concrete SnmpQuery class to avoid confusion (#13412) 2021-10-23 01:43:55 -05:00
Tony Murray
f94f7f23b8 Fully convert core to a modern module (#13347)
* Core module WIP

* update OS::make()

* core WIP

* try to finish up

* switch all core do os Model

* Mock WIP

* Working tests

* cleanup

* phpstan fixes

* style fixes

* fix agent

* trim space too
and a couple of cleanups

* corrected ios test data

* missed space

* update test data

* put escapes back

* another net-snmp difference

* Fix class description

* revert snmp.inc.php change, that can be a different PR

* revert snmp.inc.php change, that can be a different PR
2021-10-19 15:43:43 -05:00
Tony Murray
526afd437f SnmpQuery updates and more tests (#13359)
* SnmpQuery updates and more tests
improvements to translate handling

* fix method description

* fix whitespace
2021-10-13 08:49:19 -05:00
Tony Murray
4e94c1e0a1 Rename NetSnmp to SnmpQuery (#13344)
* Rename NetSnmp to SnmpQuery
Always resolve a new instance.  It was not expected to be a singleton, set options persisted.
This means numeric() works properly now

* fix snmpfetch call and style

* Ability to set device from device array
2021-10-07 17:03:53 -05:00
Tony Murray
8d5bc3fc41 Use Measurements for all statistic collection (#13333)
* Use Measurements for all statistic collection

* fix space

* Use colors
cleanup

* fix style

* manually fix license notice

* add return times and new line

* add return times and new line

* fix mistake in copyright template

* fix style
2021-10-06 17:09:54 -05:00
Tony Murray
aa35d2f0c0 Connectivity Helper to check and record device reachability (#13315)
* Fping WIP

* Update availability, move ping rrd update in the same place as db update.

* move classes around

* make device:ping command work

* use new code, remove legacy code

* save metrics boolean prevents all saves
style fixes

* update device array

* style fixes

* Update unit test

* fix whitespace

* Fix Fping stub

* fix backwards if

* fix phpstan complaining

* Fix return type

* add fillable to DeviceOutage model.

* device_outage migration to add id...

* missed line in db_schema.yaml

* 1 billion more comments on the brain damage up/down code

* tests for status and status_reason fields

* fix style again :D

* Duplicate legacy isSNMPable() functionality
but with only one snmp call ever 😎

* Remove unused variable

* fix migrations for sqlite
2021-10-03 22:45:10 -05:00