Giter Site home page Giter Site logo

snmp's Introduction

FreeDSx SNMP

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 / RFC 3416 / RFC 3414. It also includes functionality described in various other RFCs, such as SHA2 authentication (RFC 7860) and strong encryption mechanisms (3DES / AES-192-256). 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

Getting Started

Install via composer:

composer require freedsx/snmp

Use the SnmpClient class and the helper classes:

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. There are also SNMP v3 examples for NoAuthNoPriv, AuthNoPriv, and AuthPriv in the general usage doc.

snmp's People

Contributors

chadsikorra avatar simpod avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.