Download the PHP package ocolin/easysnmp without Composer

On this page you can find all versions of the php package ocolin/easysnmp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package easysnmp

[!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 PHP Version License Downloads

ocolin/easysnmp

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.


Requirements


Installation


Configuration

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

Explicit configuration

Environment variables

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

Multiple devices with prefixes

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

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

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 Variable Constructor Argument Type Default Description
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

System information

Interface table (ifTable)

Fetch only specific columns to reduce SNMP calls:

Extended interface table (ifXTable)

ARP table

LLDP remote table

IP address table

IpAddrTable properties

Property Type Description
$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

MacTable properties

Property Type Description
$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

IpForwardTable properties

Property Type Description
$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

StpPortEntry properties

Property Type Description
$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

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

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


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:

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

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

IfTable properties

Property Type Description
$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

Property Type Description
$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

Property Type Description
$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

Property Type Description
$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

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

These methods return raw FreeDSx objects. See the FreeDSx documentation for details on working with the returned values.


License

MIT


All versions of easysnmp with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
freedsx/snmp Version >=0.5.2
ocolin/global-type Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ocolin/easysnmp contains the following files

Loading the files please wait ...