Laravel SNMP Get Poller: Perform network queries using the SNMP protocol

Recommend this page to a friend!
  Info   View files Documentation   View files View files (37)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2021-05-17 (4 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 22 This week: 1All time: 10,342 This week: 178Up
Version License PHP version Categories
snmp-poller 1.0.0Custom (specified...5Networking, PHP 5
Description Author

This package can perform network queries using the SNMP protocol.

It can connect to an SNMP server and performs several types of queries about the network information using poller classes to define the identifiers of the queries to be performed.

Currently, it provides poller classes to query:

- Discovered devices
- Physical devices
- Network interface statistics
- Connection media
- System statistics
- LLDP discovered devices

Innovation Award
PHP Programming Innovation award nominee
May 2021
Number 5
SNMP is a protocol used to discover and poll devices in a network that is useful to obtain details of the state of the network devices like, for instance, routers and other types of devices.

This package simplifies the polling of network devices to obtain many types of information for those devices.

Manuel Lemos
Picture of Angel Campos
Name: Angel Campos <contact>
Classes: 5 packages by
Country: Spain Spain
Age: ???
All time rank: 4177115 in Spain Spain
Week rank: 178 Up7 in Spain Spain Up
Innovation award
Innovation award
Nominee: 2x

Details

Laravel SNMP Poller Package

Packagist PHP Version Support Latest Version on Packagist Build Status Quality Score StyleCI Total Downloads

This Laravel package allows you to run SNMP queries to the snmp-agent of network hosts through laravel applications.

Before you run any SNMP query in your Laravel application, you must install snmp in the operating system and enable the PHP extension ext-php in the php.ini to make queries.

Installation

Requirements

At the Operating System level, you need to install net-snmp.

Debian

apt-get install -y snmp

Centos / RHEL

yum install \
  net-snmp.x86_64 \
  net-snmp-agent-libs.x86_64 \
  net-snmp-libs.x86_64 \
  php-snmp.x86_64

At php.ini enable the extension ext-php.

Composer Install

You can install the package via composer:

composer require acamposm/snmp-poller

Publish vendor assets

Running this command, you can publish the vendor assets. This allows to modify the default package configuration.

php artisan snmp:install

Usage

Single SNMP Poller class

use Acamposm\SnmpPoller\SnmpPoller;
use Acamposm\SnmpPoller\Pollers\IfTablePoller;
use SNMP;

$session = new SNMP(SNMP::VERSION_2C, '192.168.10.254', 'csnmpv2c');

$poller = new SnmpPoller();

$poller->setSnmpSession($session)->addPoller(IfTablePoller::class)->run();

The output of an SNMP query to the snmp-agent of a network host with a single SNMP Poller class returns an array of objects with the data inside the data field.

Note: For demonstration purposes, all ports between 3 and 22 have been removed from the output of the query.

=> [
  "IfTablePoller" => {#653
    +"data": [
      1 => [
        "ifIndex" => 1,
        "ifDescr" => "",
        "ifType" => 6,
        "ifMtu" => 1500,
        "ifSpeed" => 1000000000,
        "ifPhysAddress" => "90:6C:AC:62:82:5B",
        "ifAdminStatus" => 1,
        "ifOperStatus" => 1,
        "ifLastChange" => 0,
        "ifInOctets" => 3808861579,
        "ifInUcastPkts" => 1130144532,
        "ifInDiscards" => 0,
        "ifInErrors" => 2,
        "ifInUnknownProtos" => 0,
        "ifOutOctets" => 1986123900,
        "ifOutUcastPkts" => 735043481,
        "ifOutDiscards" => 0,
        "ifOutErrors" => 0,
      ],
      2 => [
        "ifIndex" => 2,
        "ifDescr" => "",
        "ifType" => 6,
        "ifMtu" => 1500,
        "ifSpeed" => 0,
        "ifPhysAddress" => "90:6C:AC:62:82:5C",
        "ifAdminStatus" => 1,
        "ifOperStatus" => 2,
        "ifLastChange" => 0,
        "ifInOctets" => 0,
        "ifInUcastPkts" => 0,
        "ifInDiscards" => 0,
        "ifInErrors" => 0,
        "ifInUnknownProtos" => 0,
        "ifOutOctets" => 0,
        "ifOutUcastPkts" => 0,
        "ifOutDiscards" => 0,
        "ifOutErrors" => 0,
      ],
      3 => [ ... ],
      4 => [ ... ],
      5 => [ ... ],
      6 => [ ... ],
      7 => [ ... ],
      8 => [ ... ],
      9 => [ ... ],
      10 => [ ... ],
      11 => [ ... ],
      12 => [ ... ],
      13 => [ ... ],
      14 => [ ... ],
      15 => [ ... ],
      16 => [ ... ],
      17 => [ ... ],
      18 => [ ... ],
      19 => [ ... ],
      20 => [ ... ],
      21 => [ ... ],
      22 => [ ... ],
    ],
    +"poller": "Acamposm\SnmpPoller\Pollers\IfTablePoller",
    +"result": "OK",
    +"table": "ifTable",
  },
]

Multiple SNMP Pollers classes

use Acamposm\SnmpPoller\SnmpPoller;
use Acamposm\SnmpPoller\Pollers\IfTablePoller;
use Acamposm\SnmpPoller\Pollers\IfExtendedTablePoller;
use Acamposm\SnmpPoller\Pollers\EntPhysicalTablePoller;
use Acamposm\SnmpPoller\Pollers\LldpRemoteTablePoller;
use SNMP;

$session = new SNMP(SNMP::VERSION_2C, '192.168.10.254', 'csnmpv2c');

$poller = new SnmpPoller();

$pollerClasses = [
   IfTablePoller::class,
   IfExtendedTablePoller::class,
   EntPhysicalTablePoller::class,
   LldpRemoteTablePoller::class,
];

$poller->setSnmpSession($session)
       ->addPollers($pollerClasses)
       ->run();

The output of an SNMP query to the snmp-agent of a network host with multiple SNMP Poller classes returns an array of objects with the data inside the data field.

Note: For demonstration purposes, all ports between 3 and 22 have been removed from the output of the query.

=> [
  "IfTablePoller" => {
    +"data" => [
      1 => [
        "ifIndex" => 1,
        "ifDescr" => "",
        "ifType" => 6,
        "ifMtu" => 1500,
        "ifSpeed" => 1000000000,
        "ifPhysAddress" => "90:6C:AC:62:82:5B",
        "ifAdminStatus" => 1,
        "ifOperStatus" => 1,
        "ifLastChange" => 0,
        "ifInOctets" => 2518775779,
        "ifInUcastPkts" => 1129071509,
        "ifInDiscards" => 0,
        "ifInErrors" => 2,
        "ifInUnknownProtos" => 0,
        "ifOutOctets" => 1941896771,
        "ifOutUcastPkts" => 734653319,
        "ifOutDiscards" => 0,
        "ifOutErrors" => 0,
      ],
      2 => [
        "ifIndex" => 2,
        "ifDescr" => "",
        "ifType" => 6,
        "ifMtu" => 1500,
        "ifSpeed" => 0,
        "ifPhysAddress" => "90:6C:AC:62:82:5C",
        "ifAdminStatus" => 1,
        "ifOperStatus" => 2,
        "ifLastChange" => 0,
        "ifInOctets" => 0,
        "ifInUcastPkts" => 0,
        "ifInDiscards" => 0,
        "ifInErrors" => 0,
        "ifInUnknownProtos" => 0,
        "ifOutOctets" => 0,
        "ifOutUcastPkts" => 0,
        "ifOutDiscards" => 0,
        "ifOutErrors" => 0,
      ],
      3 => [ ... ],
      4 => [ ... ],
      5 => [ ... ],
      6 => [ ... ],
      7 => [ ... ],
      8 => [ ... ],
      9 => [ ... ],
      10 => [ ... ],
      11 => [ ... ],
      12 => [ ... ],
      13 => [ ... ],
      14 => [ ... ],
      15 => [ ... ],
      16 => [ ... ],
      17 => [ ... ],
      18 => [ ... ],
      19 => [ ... ],
      20 => [ ... ],
      21 => [ ... ],
      22 => [ ... ],
    ],
    +"poller": "Acamposm\SnmpPoller\Pollers\IfTablePoller",
    +"result": "OK",
    +"table": "ifTable",
  },
  "IfExtendedTablePoller" => {
    +"data" => [
      1 => [
        "ifName" => "wan1",
        "ifInMulticastPkts" => 0,
        "ifInBroadcastPkts" => 0,
        "ifOutMulticastPkts" => 0,
        "ifOutBroadcastPkts" => 0,
        "ifHCInOctets" => 1123505241577,
        "ifHCInUcastPkts" => 1129071513,
        "ifHCInMulticastPkts" => 0,
        "ifHCInBroadcastPkts" => 0,
        "ifHCOutOctets" => 255344967343,
        "ifHCOutUcastPkts" => 734653320,
        "ifHCOutMulticastPkts" => 0,
        "ifHCOutBroadcastPkts" => 0,
        "ifLinkUpDownTrapEnable" => 1,
        "ifHighSpeed" => 1000,
        "ifPromiscuousMode" => 2,
        "ifConnectorPresent" => 1,
        "ifAlias" => "",
        "ifCounterDiscontinuityTime" => 0,
      ],
      2 => [
        "ifName" => "wan2",
        "ifInMulticastPkts" => 0,
        "ifInBroadcastPkts" => 0,
        "ifOutMulticastPkts" => 0,
        "ifOutBroadcastPkts" => 0,
        "ifHCInOctets" => 0,
        "ifHCInUcastPkts" => 0,
        "ifHCInMulticastPkts" => 0,
        "ifHCInBroadcastPkts" => 0,
        "ifHCOutOctets" => 0,
        "ifHCOutUcastPkts" => 0,
        "ifHCOutMulticastPkts" => 0,
        "ifHCOutBroadcastPkts" => 0,
        "ifLinkUpDownTrapEnable" => 1,
        "ifHighSpeed" => 0,
        "ifPromiscuousMode" => 2,
        "ifConnectorPresent" => 1,
        "ifAlias" => "",
        "ifCounterDiscontinuityTime" => 0,
      ],
      3 => [ ... ],
      4 => [ ... ],
      5 => [ ... ],
      6 => [ ... ],
      7 => [ ... ],
      8 => [ ... ],
      9 => [ ... ],
      10 => [ ... ],
      11 => [ ... ],
      12 => [ ... ],
      13 => [ ... ],
      14 => [ ... ],
      15 => [ ... ],
      16 => [ ... ],
      17 => [ ... ],
      18 => [ ... ],
      19 => [ ... ],
      20 => [ ... ],
      21 => [ ... ],
      22 => [ ... ],
    ],
    +"poller" => "Acamposm\SnmpPoller\Pollers\IfExtendedTablePoller",
    +"result" => "OK",
    +"table" => "ifXTable",
  },
  "EntPhysicalTablePoller" => {
    +"data" => [
      1 => [
        "entPhysicalDescr" => "Fortinet FWF_51E, HW Serial#: FWF51E3U16000691",
        "entPhysicalVendorType" => ".1.3.6.1.4.1.12356.516.516.0",
        "entPhysicalContainedIn" => 0,
        "entPhysicalClass" => 3,
        "entPhysicalParentRelPos" => -1,
        "entPhysicalName" => "FWF_51E",
        "entPhysicalHardwareRev" => "",
        "entPhysicalFirmwareRev" => "",
        "entPhysicalSoftwareRev" => "FortiWiFi-51E v6.2.3,build1066,191218 (GA)",
        "entPhysicalSerialNum" => "FWF51E3U16000691",
        "entPhysicalMfgName" => "Fortinet",
        "entPhysicalModelName" => "FWF_51E",
        "entPhysicalAlias" => "",
        "entPhysicalAssetID" => "",
        "entPhysicalIsFRU" => 1,
      ],
      2 => [
        "entPhysicalDescr" => "Ethernet Port, Vitual Domain: root",
        "entPhysicalVendorType" => ".0.0.0",
        "entPhysicalContainedIn" => 1,
        "entPhysicalClass" => 10,
        "entPhysicalParentRelPos" => 1,
        "entPhysicalName" => "wan1",
        "entPhysicalHardwareRev" => "",
        "entPhysicalFirmwareRev" => "",
        "entPhysicalSoftwareRev" => "",
        "entPhysicalSerialNum" => "",
        "entPhysicalMfgName" => "",
        "entPhysicalModelName" => "",
        "entPhysicalAlias" => "",
        "entPhysicalAssetID" => "",
        "entPhysicalIsFRU" => 2,
      ],
      3 => [
        "entPhysicalDescr" => "Ethernet Port, Vitual Domain: root",
        "entPhysicalVendorType" => ".0.0.0",
        "entPhysicalContainedIn" => 1,
        "entPhysicalClass" => 10,
        "entPhysicalParentRelPos" => 2,
        "entPhysicalName" => "wan2",
        "entPhysicalHardwareRev" => "",
        "entPhysicalFirmwareRev" => "",
        "entPhysicalSoftwareRev" => "",
        "entPhysicalSerialNum" => "",
        "entPhysicalMfgName" => "",
        "entPhysicalModelName" => "",
        "entPhysicalAlias" => "",
        "entPhysicalAssetID" => "",
        "entPhysicalIsFRU" => 2,
      ],
      4 => [
        "entPhysicalDescr" => "Ethernet Port, Vitual Domain: root",
        "entPhysicalVendorType" => ".0.0.0",
        "entPhysicalContainedIn" => 1,
        "entPhysicalClass" => 10,
        "entPhysicalParentRelPos" => 3,
        "entPhysicalName" => "modem",
        "entPhysicalHardwareRev" => "",
        "entPhysicalFirmwareRev" => "",
        "entPhysicalSoftwareRev" => "",
        "entPhysicalSerialNum" => "",
        "entPhysicalMfgName" => "",
        "entPhysicalModelName" => "",
        "entPhysicalAlias" => "",
        "entPhysicalAssetID" => "",
        "entPhysicalIsFRU" => 2,
      ],
    ],
    +"poller": "Acamposm\SnmpPoller\Pollers\EntPhysicalTablePoller",
    +"result": "OK",
    +"table": "entPhysical",
  },
  "LldpRemoteTablePoller" => {
    +"data" => [
      "710800216.10.1" => [
        "lldpRemChassisIdSubtype" => 4,
        "lldpRemChassisId" => "2C:FA:A2:27:2F:5C",
        "lldpRemPortIdSubtype" => 7,
        "lldpRemPortId" => "1021",
        "lldpRemPortDesc" => "Alcatel-Lucent Enterprise 1/21",
        "lldpRemSysName" => "WTG-OS6450P24-SW01",
        "lldpRemSysDesc" => "Alcatel-Lucent Enterprise OS6450-P24 6.7.2.191.R04 GA, June 20, 2018.",
        "lldpRemSysCapSupported" => "(",
        "lldpRemSysCapEnabled" => "(",
      ],
    ],
    +"poller" => "Acamposm\SnmpPoller\Pollers\LldpRemoteTablePoller",
    +"result" => "OK",
    +"table" => "lldpRemTable",
  },
]

Testing

For running the tests, in the console run:

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email angel.campos.m@outlook.com instead of using the issue tracker.

Credits

License

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

  Files folder image Files  
File Role Description
Files folder image.github (4 files)
Files folder imageconfig (1 file)
Files folder imageimg (2 files)
Files folder imagesrc (1 file, 6 directories)
Accessible without login Plain text file .styleci.yml Data Auxiliary data
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE.md Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
  Accessible without login Plain text file CODE_OF_CONDUCT.md Data Auxiliary data
  Accessible without login Plain text file CONTRIBUTING.md Data Auxiliary data
  Accessible without login Plain text file FUNDING.yml Data Auxiliary data
  Accessible without login Plain text file SECURITY.md Data Auxiliary data

  Files folder image Files  /  config  
File Role Description
  Accessible without login Plain text file config.php Aux. Auxiliary script

  Files folder image Files  /  img  
File Role Description
  Accessible without login Image file PackageHeader.png Data Auxiliary data
  Accessible without login Image file SnmpPoller.png Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageConsole (1 directory)
Files folder imageFacades (1 file)
Files folder imageInterfaces (2 files)
Files folder imageParsers (9 files)
Files folder imagePollers (9 files)
Files folder imageProviders (1 file)
  Plain text file SnmpPoller.php Class Class source

  Files folder image Files  /  src  /  Console  
File Role Description
Files folder imageCommands (1 file)

  Files folder image Files  /  src  /  Console  /  Commands  
File Role Description
  Plain text file InstallSnmpPackageCommand.php Class Class source

  Files folder image Files  /  src  /  Facades  
File Role Description
  Plain text file SnmpPoller.php Class Class source

  Files folder image Files  /  src  /  Interfaces  
File Role Description
  Plain text file SnmpParserInterface.php Class Class source
  Plain text file SnmpPollerInterface.php Class Class source

  Files folder image Files  /  src  /  Parsers  
File Role Description
  Plain text file SnmpParser.php Class Class source
  Plain text file SnmpTypeCounter32.php Class Class source
  Plain text file SnmpTypeCounter64.php Class Class source
  Plain text file SnmpTypeGauge32.php Class Class source
  Plain text file SnmpTypeInteger.php Class Class source
  Plain text file SnmpTypeIPAddress.php Class Class source
  Plain text file SnmpTypeOctetString.php Class Class source
  Plain text file SnmpTypeOID.php Class Class source
  Plain text file SnmpTypeTimeticks.php Class Class source

  Files folder image Files  /  src  /  Pollers  
File Role Description
  Plain text file DiscoveryPoller.php Class Class source
  Plain text file EntPhysicalTablePoller.php Class Class source
  Plain text file IfExtendedTablePoller.php Class Class source
  Plain text file IfTablePoller.php Class Class source
  Plain text file IpNetToMediaTablePoller.php Class Class source
  Plain text file IpSystemStatsTablePoller.php Class Class source
  Plain text file LldpLocalPortTablePoller.php Class Class source
  Plain text file LldpRemoteTablePoller.php Class Class source
  Plain text file SnmpBasePoller.php Class Class source

  Files folder image Files  /  src  /  Providers  
File Role Description
  Plain text file SnmpPollerServiceProvider.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:22
This week:1
All time:10,342
This week:178Up
For more information send a message to info at phpclasses dot org.