PHPackages                             ocolin/easysnmp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. ocolin/easysnmp

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

ocolin/easysnmp
===============

PHP SNMP client providing formatted, DTO-backed access to standard MIB-II data without requiring SNMP knowledge

v4.0.3(1mo ago)1373MITPHPPHP &gt;=8.4

Since May 18Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/ocolin/EasySNMP)[ Packagist](https://packagist.org/packages/ocolin/easysnmp)[ RSS](/packages/ocolin-easysnmp/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (13)Versions (24)Used By (3)

Warning

v3.0.0 is a complete rewrite and is not compatible with v1.x or v2.x. Requires PHP 8.4+ and FreeDSx SNMP. [![Packagist Version](https://camo.githubusercontent.com/dcdaa015384f44415b3466048e5816cce725b764fc073c1aeb2170c0a7af3035/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f636f6c696e2f65617379736e6d70)](https://camo.githubusercontent.com/dcdaa015384f44415b3466048e5816cce725b764fc073c1aeb2170c0a7af3035/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f636f6c696e2f65617379736e6d70)[![PHP Version](https://camo.githubusercontent.com/cac9be1d966d8295b23706ea5dbf705d398693679d8bead07e2fc843b461ffce/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6f636f6c696e2f65617379736e6d702f706870)](https://camo.githubusercontent.com/cac9be1d966d8295b23706ea5dbf705d398693679d8bead07e2fc843b461ffce/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6f636f6c696e2f65617379736e6d702f706870)[![License](https://camo.githubusercontent.com/1a69d0a454598a4664a81890387595028ed372eda8ba9b3ad5591a236527c8d1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6f636f6c696e2f65617379736e6d70)](https://camo.githubusercontent.com/1a69d0a454598a4664a81890387595028ed372eda8ba9b3ad5591a236527c8d1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6f636f6c696e2f65617379736e6d70)[![Downloads](https://camo.githubusercontent.com/9f6dd0133be3c49826a258c2c3b7da5c303d13c51092766f45b54b7222531318/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f636f6c696e2f65617379736e6d70)](https://camo.githubusercontent.com/9f6dd0133be3c49826a258c2c3b7da5c303d13c51092766f45b54b7222531318/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f636f6c696e2f65617379736e6d70)

ocolin/easysnmp
===============

[](#ocolineasysnmp)

A PHP SNMP client that provides formatted, DTO-backed access to standard MIB-II data without requiring SNMP knowledge. Pass in your authentication credentials, call a method, get structured data back.

Built on top of [FreeDSx SNMP](https://github.com/FreeDSx/SNMP).

---

Requirements
------------

[](#requirements)

- PHP 8.4+
- [FreeDSx SNMP](https://github.com/FreeDSx/SNMP) `^0.5.1`
- [ocolin/global-type](https://packagist.org/packages/ocolin/global-type) `^2.0`

---

Installation
------------

[](#installation)

```
composer require ocolin/easysnmp
```

---

Configuration
-------------

[](#configuration)

Configuration is handled by the `Config` class. Credentials can be passed explicitly or read automatically from environment variables.

### Explicit configuration

[](#explicit-configuration)

```
use Ocolin\EasySNMP\Config;
use Ocolin\EasySNMP\EasySNMP;

$config = new Config(
    host:      '10.0.0.1',
    community: 'public'
);

$snmp = new EasySNMP( config: $config );
```

### Environment variables

[](#environment-variables)

If no explicit values are passed, `Config` falls back to environment variables using the `EASY_SNMP_` prefix by default:

```
// Reads from EASY_SNMP_* environment variables
$snmp = new EasySNMP( config: new Config() );
// Or alternatively
$snmp = new EasySNMP();
```

### Multiple devices with prefixes

[](#multiple-devices-with-prefixes)

When monitoring multiple devices, use the `$prefix` parameter to namespace your environment variables:

```
JUNIPER_SNMP_HOST=10.0.0.1
JUNIPER_SNMP_COMMUNITY=public

MIKROTIK_SNMP_HOST=10.0.0.2
MIKROTIK_SNMP_COMMUNITY=private
```

```
$juniper  = new EasySNMP( config: new Config( prefix: 'JUNIPER' ) );
$mikrotik = new EasySNMP( config: new Config( prefix: 'MIKROTIK' ) );
```

Prefix values are case-insensitive — `'juniper'` and `'JUNIPER'` both resolve to `JUNIPER_SNMP_*`.

### Configuration reference

[](#configuration-reference)

The `EASY` prefix in all ENV variable names is replaced by your custom prefix when using the `$prefix` parameter. For example, with `prefix: 'JUNIPER'` the variable `EASY_SNMP_HOST` becomes `JUNIPER_SNMP_HOST`.

ENV VariableConstructor ArgumentTypeDefaultDescription`EASY_SNMP_HOST``$host``?string``null`Hostname or IP of device`EASY_SNMP_COMMUNITY``$community``?string``null`SNMP v1/v2c community string`EASY_SNMP_PORT``$options['port']``?int``161`SNMP port`EASY_SNMP_VERSION``$options['version']``?int``2`SNMP version (1, 2, 3)`EASY_SNMP_TIMEOUT_CONNECT``$options['timeout_connect']``?int``5`Connection timeout in seconds`EASY_SNMP_TIMEOUT_READ``$options['timeout_read']``?int``10`Read timeout in seconds`EASY_SNMP_USER``$options['user']``?string``null`SNMPv3 username`EASY_SNMP_AUTH_PWD``$options['auth_pwd']``?string``null`SNMPv3 auth password`EASY_SNMP_PRIV_PWD``$options['priv_pwd']``?string``null`SNMPv3 privacy password`EASY_SNMP_AUTH_MECH``$options['auth_mech']``?string``null`SNMPv3 auth mechanism`EASY_SNMP_PRIV_MECH``$options['priv_mech']``?string``null`SNMPv3 privacy mechanism`EASY_SNMP_ENGINE_ID``$options['engine_id']``?string``null`SNMPv3 engine ID`EASY_SNMP_CONTEXT_NAME``$options['context_name']``?string``null`SNMPv3 context name`EASY_SNMP_USE_AUTH``$options['use_auth']``?bool``null`Enable SNMPv3 authentication`EASY_SNMP_USE_PRIV``$options['use_priv']``?bool``null`Enable SNMPv3 privacy---

Usage
-----

[](#usage)

### System information

[](#system-information)

```
$system = $snmp->getSystem();

echo $system->name;      // Router-01
echo $system->descr;     // Linux Router 5.15.0
echo $system->location;  // Server Room A
echo $system->contact;   // admin@example.com
echo $system->upTime;    // TimeTicks integer
echo $system->objectId;  // 1.3.6.1.4.1.14988.1

// Formatted version:
$system = Format::System( $snmp->getSystem());
```

### Interface table (ifTable)

[](#interface-table-iftable)

```
$interfaces = $snmp->getIfTable();

foreach( $interfaces as $interface ) {
    echo $interface->index;        // Interface index
    echo $interface->description;  // Interface description
    echo $interface->speed;        // Speed in bps
    echo $interface->adminStatus;  // Raw integer (1=up, 2=down, 3=testing)
    echo $interface->operStatus;   // Raw integer (1=up, 2=down, etc.)
    echo $interface->macAddress;   // Raw MAC address
}

// Formatted version:
$interfaces = Format::IfTables( $snmp->getIfTable());
```

Fetch only specific columns to reduce SNMP calls:

```
$interfaces = $snmp->getIfTable( columns: ['description', 'operStatus'] );
```

### Extended interface table (ifXTable)

[](#extended-interface-table-ifxtable)

```
$interfaces = $snmp->getIfXTable();

foreach( $interfaces as $interface ) {
    echo $interface->name;        // Interface name
    echo $interface->alias;       // Administrator-set alias
    echo $interface->highSpeed;   // Speed in Mbps
    echo $interface->inHcOctets;  // 64-bit input byte counter
    echo $interface->outHcOctets; // 64-bit output byte counter
}

// Formatted version:
$interfaces = Format::IfXTables( $snmp->getIfXTable());
```

### ARP table

[](#arp-table)

```
$arp = $snmp->getArpTable();

foreach( $arp as $entry ) {
    echo $entry->interface;  // Interface index
    echo $entry->ipAddress;  // IP address
    echo $entry->mac;        // Raw MAC address
    echo $entry->type;       // Raw integer (1=other, 2=invalid, 3=dynamic, 4=static)
}

// Formatted version:
$arp = Format::ArpTables( $snmp->getArpTable());
```

### LLDP remote table

[](#lldp-remote-table)

```
$lldp_rem = $snmp->getLldpRemTable();
foreach( $arp as $entry ) {
    echo $entry->localPort;     // Local port index
    echo $entry->chassisIdType; // Chassis ID subtype
    echo $entry->chassisId;     // Chassis identifier
    echo $entry->portIdType;    // Port ID subtype
    echo $entry->portId;        // Remote port identifier
    echo $entry->portDesc;      // Remote port description
    echo $entry->sysName;       // Remote system name
    echo $entry->sysDesc;       // Remote system description
    echo $entry->capSupported;  // Supported capabilities
    echo $entry->capEnabled;    // Enabled capabilities
}

// Formatted values:
$lldp_rem = Format::LldpRemTable( $snmp->getLldpRemTable());
```

### IP address table

[](#ip-address-table)

```
$addresses = $snmp->getIpAddrTable();

foreach( $addresses as $entry ) {
    echo $entry->address;    // 10.0.0.1
    echo $entry->interface;  // Interface index — matches ifTable
    echo $entry->netmask;    // 255.255.255.0
    echo $entry->bcast;      // Broadcast address bit
    echo $entry->reasmMaxSize; // Max datagram size for reassembly
}

// Fetch only specific columns
$addresses = $snmp->getIpAddrTable( columns: ['address', 'interface', 'netmask'] );
```

### IpAddrTable properties

[](#ipaddrtable-properties)

PropertyTypeDescription`$address``?string`IP address`$interface``?int`Interface index — matches `IfTable` index`$netmask``?string`Subnet mask`$bcast``?int`Broadcast address bit`$reasmMaxSize``?int`Maximum datagram size for reassembly### MAC address table

[](#mac-address-table)

```
$macs = $snmp->getMacTable();

foreach( $macs as $entry ) {
    echo $entry->mac;        // Raw MAC address
    echo $entry->bridge;     // Bridge port number
    echo $entry->interface;  // Interface index — matches ifTable index
    echo $entry->status;     // Raw integer (3=learned, 4=self etc.)
}

// Formatted version
$macs = Format::macTables( $snmp->getMacTable() );
```

### MacTable properties

[](#mactable-properties)

PropertyTypeDescription`$mac``?string`Raw MAC address. Use `SnmpHelper::formatMacAddress()``$bridge``?int`Bridge port number`$interface``?int`Interface index — matches `IfTable` index. Null indicates the MAC is associated with the bridge interface itself rather than a physical port`$status``?int`Entry status. Use `SnmpHelper::formatMacStatus()`### IP forwarding table

[](#ip-forwarding-table)

```
$routes = $snmp->getIpForwardTable();

foreach( $routes as $route ) {
    echo $route->destination;  // Destination network
    echo $route->mask;         // Subnet mask
    echo $route->nextHop;      // Next hop IP address
    echo $route->interface;    // Interface index — matches ifTable
    echo $route->type;         // Raw integer. Use SnmpHelper::formatIpForwardType()
    echo $route->protocol;     // Raw integer. Use SnmpHelper::formatIpForwardProto()
    echo $route->status;       // Raw integer. Use SnmpHelper::formatRowStatus()
}

// Fetch additional columns
$routes = $snmp->getIpForwardTable( columns: [
    'interface', 'type', 'protocol', 'metric1', 'status',
    'age', 'nextHopAs', 'metric2', 'metric3', 'metric4', 'metric5'
]);

// Formatted version
$routes = Format::ipForwardTables( $snmp->getIpForwardTable() );
```

### IpForwardTable properties

[](#ipforwardtable-properties)

PropertyTypeDescription`$destination``?string`Destination network address — always present`$mask``?string`Destination subnet mask — always present`$policy``?int`Route policy, typically 0 — always present`$nextHop``?string`Next hop IP address — always present`$interface``?int`Interface index — matches `IfTable` index`$type``?int`Route type. Use `SnmpHelper::formatIpForwardType()``$protocol``?int`Routing protocol. Use `SnmpHelper::formatIpForwardProto()``$age``?int`Seconds since route was last updated`$info``?string`Protocol specific info, rarely populated`$nextHopAs``?int`Next hop autonomous system number`$metric1``?int`Primary routing metric`$metric2``?int`Secondary routing metric`$metric3``?int`Tertiary routing metric`$metric4``?int`Fourth routing metric`$metric5``?int`Fifth routing metric`$status``?int`Row status. Use `SnmpHelper::formatRowStatus()`### STP port table

[](#stp-port-table)

```
$ports = $snmp->getStpPorts();

foreach( $ports as $port ) {
    echo $port->bridge;    // Bridge port number — matches MacEntry bridge
    echo $port->priority;  // Port priority (0-255)
    echo $port->state;     // Raw integer. Use SnmpHelper::formatStpPortState()
    echo $port->enable;    // Raw integer. Use SnmpHelper::formatStpPortEnable()
    echo $port->pathCost;  // STP path cost
    echo $port->desRoot;   // Designated root bridge ID (8 bytes binary)
    echo $port->desCost;   // Designated path cost to root
    echo $port->desBridge; // Designated bridge ID (8 bytes binary)
    echo $port->desPort;   // Designated port ID (2 bytes binary)
}

// Formatted version
$ports = Format::stpPortEntries( $snmp->getStpPorts() );
```

### StpPortEntry properties

[](#stpportentry-properties)

PropertyTypeDescription`$bridge``?int`Bridge port number — matches `$bridge` in `MacEntry``$priority``?int`Port priority (0-255), default 128`$state``?int`STP port state. Use `SnmpHelper::formatStpPortState()``$enable``?int`Port enabled status. Use `SnmpHelper::formatStpPortEnable()``$pathCost``?int`STP path cost for this port`$desRoot``?string`Designated root bridge ID (8 bytes). Use `SnmpHelper::formatBridgeId()``$desCost``?int`Designated path cost to root bridge`$desBridge``?string`Designated bridge ID (8 bytes). Use `SnmpHelper::formatBridgeId()``$desPort``?string`Designated port ID (2 bytes). Use `SnmpHelper::formatStpPortId()`---

Formatting helpers
------------------

[](#formatting-helpers)

Raw integer values can be converted to human-readable labels using `SnmpHelper`:

```
use Ocolin\EasySNMP\SnmpHelper;

// Interface status
SnmpHelper::formatOperStatus( $interface->operStatus );
// "up", "down", "testing", "unknown", "dormant", "notPresent", "lowerLayerDown"

SnmpHelper::formatAdminStatus( $interface->adminStatus );
// "up", "down", "testing"

// Interface type
SnmpHelper::formatIfType( $interface->type );
// "ethernet", "softwareLoopback", "tunnel", "ieee8023adLag", etc.

// MAC address formatting
SnmpHelper::formatMacAddress( $interface->macAddress );
// "00:11:22:33:44:55"

SnmpHelper::formatMacAddress( $entry->mac );
// "00:11:22:33:44:55"

// ARP entry type
SnmpHelper::formatArpType( $entry->type );
// "other", "invalid", "dynamic", "static"
```

All helper methods accept `null` and return `null`, so they are safe to call directly on nullable DTO properties.

---

Extending for vendor-specific devices
-------------------------------------

[](#extending-for-vendor-specific-devices)

`EasySNMP` is designed to be extended. Vendor-specific functionality can be added by extending the base class and adding traits for proprietary OID trees:

```
namespace Ocolin\Hyconext;

use Ocolin\EasySNMP\EasySNMP;
use Ocolin\Hyconext\Traits\PoeTrait;

class HyconextSNMP extends EasySNMP
{
    use PoeTrait;
}
```

The extending class inherits all standard MIB-II methods and gains access to `bulkWalk()`, `getColumn()`, and `getCompositeColumn()` for building vendor-specific trait methods.

---

PHP 8.4 compatibility
---------------------

[](#php-84-compatibility)

FreeDSx SNMP was written for PHP 7.4 and contains a nullable type deprecation that triggers on PHP 8.4. This is handled internally within `EasySNMP` and does not affect consuming code. A fix has been submitted upstream via pull request.

---

Property Lists
--------------

[](#property-lists)

### IfTable properties

[](#iftable-properties)

PropertyTypeDescription`$index``int`Interface index`$description``?string`Interface description string`$type``?int`IANA interface type. Use `SnmpHelper::formatIfType()``$mtu``?int`Maximum transmission unit in bytes`$speed``?int`Interface speed in bits per second`$macAddress``?string`Raw MAC address. Use `SnmpHelper::formatMacAddress()``$adminStatus``?int`Administrative status. Use `SnmpHelper::formatAdminStatus()``$operStatus``?int`Operational status. Use `SnmpHelper::formatOperStatus()``$lastChange``?int`Time of last status change in TimeTicks`$inOctets``?int`32-bit input byte counter`$outOctets``?int`32-bit output byte counter`$inErrors``?int`Input error counter`$outErrors``?int`Output error counter### IfXTable properties

[](#ifxtable-properties)

PropertyTypeDescription`$index``int`Interface index — matches `IfTable` index`$name``?string`Interface name`$inMcast``?int`32-bit multicast inbound packets`$outMcast``?int`32-bit multicast outbound packets`$inBcast``?int`32-bit broadcast inbound packets`$outBcast``?int`32-bit broadcast outbound packets`$inHcOctets``?int`64-bit input byte counter, use instead of `inOctets` on fast interfaces`$inHcUcast``?int`64-bit unicast inbound packets`$inHcMcast``?int`64-bit multicast inbound packets`$inHcBcast``?int`64-bit broadcast inbound packets`$outHcOctets``?int`64-bit output byte counter, use instead of `outOctets` on fast interfaces`$outHcUcast``?int`64-bit unicast outbound packets`$outHcMcast``?int`64-bit multicast outbound packets`$outHcBcast``?int`64-bit broadcast outbound packets`$highSpeed``?int`Speed in Mbps, use instead of `speed` on fast interfaces`$alias``?string`Administrator-set interface alias### System properties

[](#system-properties)

PropertyTypeDescription`$descr``?string`Full description of the device`$upTime``?int`System uptime in TimeTicks`$contact``?string`Contact information`$name``?string`Device name`$location``?string`Physical location`$objectId``?string`Vendor enterprise OID### ArpTable properties

[](#arptable-properties)

PropertyTypeDescription`$interface``?int`Interface index — matches `IfTable` index`$mac``?string`Raw MAC address. Use `SnmpHelper::formatMacAddress()``$ipAddress``?string`IP address of ARP entry`$type``?int`Entry type. Use `SnmpHelper::formatArpType()`---

Direct SNMP access
------------------

[](#direct-snmp-access)

For custom queries beyond the built-in methods, pass-through access to the underlying FreeDSx client is available:

```
// Fetch specific OIDs
$result = $snmp->get( '1.3.6.1.2.1.1.1.0', '1.3.6.1.2.1.1.5.0' );

// Fetch next OID
$result = $snmp->getNext( '1.3.6.1.2.1.1.1.0' );

// Walk an OID subtree
$walk = $snmp->walk( startAt: '1.3.6.1.2.1.1' );

// Bulk walk an OID subtree — returns paginated Oid[] array
$oids = $snmp->bulkWalk( oid: '1.3.6.1.2.1.2.2.1' );
```

These methods return raw FreeDSx objects. See the [FreeDSx documentation](https://github.com/FreeDSx/SNMP) for details on working with the returned values.

---

License
-------

[](#license)

MIT

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance92

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~35 days

Recently: every ~4 days

Total

22

Last Release

38d ago

Major Versions

1.5 → 2.02025-05-09

2.3 → v3.0.02026-05-08

v3.6.0 → v4.0.02026-05-10

PHP version history (3 changes)v1.4PHP &gt;=8.0

2.0PHP &gt;=8.2

v3.0.0PHP &gt;=8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/e97ac0aa452b872ddc3f7f4c56c83852574a27bb74622f8c054d11ca20008fc9?d=identicon)[Ocolin](/maintainers/Ocolin)

---

Top Contributors

[![ocolin](https://avatars.githubusercontent.com/u/8870196?v=4)](https://github.com/ocolin "ocolin (11 commits)")

---

Tags

phpinterfacesmonitoringnetworksnmpmibarp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ocolin-easysnmp/health.svg)

```
[![Health](https://phpackages.com/badges/ocolin-easysnmp/health.svg)](https://phpackages.com/packages/ocolin-easysnmp)
```

###  Alternatives

[ptrofimov/beanstalk_console

Admin console for Beanstalk queue server

1.3k126.1k](/packages/ptrofimov-beanstalk-console)[inspector-apm/inspector-php

Inspector monitoring for PHP applications.

353.0M31](/packages/inspector-apm-inspector-php)[bacula-web/bacula-web

The open source web based reporting and monitoring tool for Bacula

1557.7k](/packages/bacula-web-bacula-web)[treblle/treblle-php

Runtime Intelligence Platform

2084.4k2](/packages/treblle-treblle-php)[inspector-apm/inspector-symfony

Code Execution Monitoring for Symfony applications.

2839.2k10](/packages/inspector-apm-inspector-symfony)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
