2017 © Pedro Peláez
 

library snmp-extension

Wrapper over the SNMP extension.

image

surrealcristian/snmp-extension

Wrapper over the SNMP extension.

  • Wednesday, November 9, 2016
  • by surrealcristian
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

SNMP Extension

Wrapper over the SNMP extension., (*1)

Install

Via Composer, (*2)

``` bash $ composer require surrealcristian/snmp-extension, (*3)



## Requirements - PHP 5.4+ - SNMP extension ## Usage ### `SimpleSnmpV2c` #### `setup` ```php <?php require __DIR__ . '/../vendor/autoload.php'; use SurrealCristian\SnmpExtension\Builder; use SurrealCristian\SimpleSnmp\Exception\SimpleSnmpException; use SurrealCristian\SimpleSnmp\Exception\TimeoutException; $host = '127.0.0.1'; $community = 'private'; $timeout = 1000000; // microseconds $retries = 3; $snmp = (new Builder)->getSimpleSnmpV2c();

get

<?php

try {
    $oid = '1.2.3.4.5.0';

    $res = $snmp->get($host, $community, $oid, $timeout, $retries);

    var_export($res);
} catch (TimeoutException $e) {
    // handle exception
} catch (SimpleSnmpException $e) {
    // handle exception
}

// array (
//   'oid' => '1.2.3.4.5.0',
//   'type' => 'STRING',
//   'value' => '"foo 0"',
// )

getNext

<?php

try {
    $oid = '1.2.3.4.5.0';

    $res = $snmp->getNext($host, $community, $oid, $timeout, $retries);

    var_export($res);
} catch (TimeoutException $e) {
    // handle exception
} catch (SimpleSnmpException $e) {
    // handle exception
}

// array (
//   'oid' => null,
//   'type' => 'STRING',
//   'value' => '"foo 1"',
// )

walk

<?php

try {
    $oid = '1.2.3.4.5';

    $res = $snmp->walk($host, $community, $oid, $timeout, $retries);

    var_export($res);
} catch (TimeoutException $e) {
    // handle exception
} catch (SimpleSnmpException $e) {
    // handle exception
}

// array (
//   0 => array (
//     'oid' => '1.2.3.4.5.0',
//     'type' => 'STRING',
//     'value' => '"foo 0"',
//   ),
//   1 => array (
//     'oid' => '1.2.3.4.5.1',
//     'type' => 'STRING',
//     'value' => '"foo 1"',
//   ),
// )

bulkWalk

<?php

try {
    $oid = '1.2.3.4.5';

    $res = $snmp->bulkWalk($host, $community, $oid, $timeout, $retries);

    var_export($res);
} catch (TimeoutException $e) {
    // handle exception
} catch (SimpleSnmpException $e) {
    // handle exception
}

// array (
//   0 => array (
//     'oid' => '1.2.3.4.5.0',
//     'type' => 'STRING',
//     'value' => '"foo 0"',
//   ),
//   1 => array (
//     'oid' => '1.2.3.4.5.1',
//     'type' => 'STRING',
//     'value' => '"foo 1"',
//   ),
// )

set

<?php

try {
    $oid = '1.2.3.4.6.0';

    $snmp->set($host, $community, $oid, 's', 'test', $timeout, $retries);
} catch (TimeoutException $e) {
    // handle exception
} catch (SimpleSnmpException $e) {
    // handle exception
}

API

namespace SurrealCristian\SnmpExtension


class Builder

public SimpleSnmpV2c getSimpleSnmpV2c ()


class SimpleSnmpV2c implements SnmpV2cInterface

public array get ( string $host, string $community, string $oid, int $timeout, int $retries )

public array getNext ( string $host, string $community, string $oid, int $timeout, int $retries )

public array walk ( string $host, string $community, string $oid, int $timeout, int $retries )

public array bulkWalk ( string $host, string $community, string $oid, int $timeout, int $retries )

public set ( string $host, string $community, string $oid, string $type, string $value, int $timeout, int $retries )

Change log

Please see CHANGELOG for more information, (*4)

Testing

$ cd /path/to/repo
$ phpunit

License

The MIT License (MIT). Please see License File for more information., (*5)

The Versions

09/11 2016

1.0.x-dev

1.0.9999999.9999999-dev https://github.com/surrealcristian/snmp-extension-php

Wrapper over the SNMP extension.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Cristian Cabrera

extension snmp net-snmp

09/11 2016

dev-master

9999999-dev https://github.com/surrealcristian/snmp-extension-php

Wrapper over the SNMP extension.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Cristian Cabrera

extension snmp net-snmp

09/11 2016

1.0.0

1.0.0.0 https://github.com/surrealcristian/snmp-extension-php

Wrapper over the SNMP extension.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Cristian Cabrera

extension snmp net-snmp