Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/FreeDSx/SNMP
A Pure PHP SNMP Library.
https://github.com/FreeDSx/SNMP
php snmp snmp-trap-listener snmp-traps snmpv2 snmpv3
Last synced: 3 months ago
JSON representation
A Pure PHP SNMP Library.
- Host: GitHub
- URL: https://github.com/FreeDSx/SNMP
- Owner: FreeDSx
- License: mit
- Created: 2018-05-27T19:34:23.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-22T00:11:09.000Z (almost 2 years ago)
- Last Synced: 2024-03-24T17:22:36.396Z (10 months ago)
- Topics: php, snmp, snmp-trap-listener, snmp-traps, snmpv2, snmpv3
- Language: PHP
- Homepage:
- Size: 367 KB
- Stars: 56
- Watchers: 5
- Forks: 12
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-snmp - FreeDSx/SNMP - A Pure PHP SNMP Library. (Libraries / PHP)
README
# FreeDSx SNMP ![](https://github.com/FreeDSx/SNMP/workflows/Build/badge.svg)
FreeDSx SNMP is a pure PHP SNMP library. It has no requirement on the core PHP SNMP extension. It implements SNMP
client functionality described in [RFC 3412](https://tools.ietf.org/html/rfc3412) / [RFC 3416](https://tools.ietf.org/html/rfc3416) / [RFC 3414](https://tools.ietf.org/html/rfc3414).
It also includes functionality described in various other RFCs, such as SHA2 authentication ([RFC 7860](https://tools.ietf.org/html/rfc7860)) and strong encryption
mechanisms ([3DES](https://tools.ietf.org/html/draft-reeder-snmpv3-usm-3desede-00) / [AES-192-256](https://tools.ietf.org/html/draft-blumenthal-aes-usm-04)).
Some main features include:* SNMP version 1, 2, and 3 support.
* Supports all authentication mechanisms (md5, sha1, sha224, sha256, sha384, sha512).
* Supports all privacy encryption mechanisms (des, 3des, aes128, aes192, aes256).
* Supports all client request types (Get, GetNext, GetBulk, Set, Inform, TrapV1, TrapV2).
* Supports sending SNMPv1 and SNMPv2 traps (including inform requests).
* Trap Sink server for receiving and processing incoming traps.The OpenSSL extension is required for privacy / encryption support. The GMP extension is required for 64-bit counters (BigCounter).
# Documentation
* [SNMP Client](/docs/Client)
* [Configuration](/docs/Client/Configuration.md)
* [General Usage](/docs/Client/General-Usage.md)
* [Request Types](/docs/Client/Request-Types.md)
* [SNMP Walk](/docs/Client/SNMP-Walk.md)
* [SNMP Server](/docs/Server)
* [Trap Sink](/docs/Server/Trap-Sink.md)# Getting Started
Install via composer:
```bash
composer require freedsx/snmp
```Use the SnmpClient class and the helper classes:
```php
use FreeDSx\Snmp\SnmpClient;$snmp = new SnmpClient([
'host' => 'servername',
'version' => 2,
'community' => 'secret',
]);# Get a specific OID value as a string...
echo $snmp->getValue('1.3.6.1.2.1').PHP_EOL;# Get a specific OID as an object...
$oid = $snmp->getOid('1.3.6.1.2.1');
var_dump($oid);echo sprintf("%s == %s", $oid->getOid(), (string) $oid->getValue()).PHP_EOL;
# Get multiple OIDs and iterate through them as needed...
$oids = $snmp->get('1.3.6.1.2.1.1.1', '1.3.6.1.2.1.1.3', '1.3.6.1.2.1.1.5');
foreach($oids as $oid) {
echo sprintf("%s == %s", $oid->getOid(), (string) $oid->getValue()).PHP_EOL;
}# Using the SnmpClient, get the helper class for an SNMP walk...
$walk = $snmp->walk();# Keep the walk going until there are no more OIDs left
while($walk->hasOids()) {
try {
# Get the next OID in the walk
$oid = $walk->next();
echo sprintf("%s = %s", $oid->getOid(), $oid->getValue()).PHP_EOL;
} catch (\Exception $e) {
# If we had an issue, display it here (network timeout, etc)
echo "Unable to retrieve OID. ".$e->getMessage().PHP_EOL;
}
}echo sprintf("Walked a total of %s OIDs.", $walk->count()).PHP_EOL;
```For a complete configuration reference please see the [configuration doc](/docs/Client/Configuration.md). There are also
SNMP v3 examples for [NoAuthNoPriv](/docs/Client/General-Usage.md#noauthnopriv), [AuthNoPriv](/docs/Client/General-Usage.md#authnopriv), and [AuthPriv](/docs/Client/General-Usage.md#authpriv)
in the [general usage doc](/docs/Client/General-Usage.md).