ocolin/easysnmp 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ocolin/easysnmp

最新稳定版本:2.3

Composer 安装命令:

composer require ocolin/easysnmp

包简介

Bare bones SNMP library

README 文档

README

About

A bare-bones basic SNMP client. It can be configured either by usein constructor arguments, or using environment variables.

Constructor Arguments

  • $ip - IP address of device to query.
  • $community - Community string of device to query.
  • $version - SNMP version of device. Defaults to 2. 3 is not yet supported.
  • $prefix - Environment variable prefix. Used when you may be using multiple devices with different environment variable.

Environment Variables

Default Variables

  • SNMP_IP - IP address of device to query.
  • SNMP_COMMUNITY - Community string of device to query.
  • SNMP_VERSION - SNMP version of device. Defaults to 2. 3 is not yet supported.

Prefixed Variables

Example with the prefix value 'PREFIX':

  • PREFIX_SNMP_IP - IP address of device to query.
  • PREFIX_SNMP_COMMUNITY - Community string of device to query.
  • PREFIX_SNMP_VERSION - SNMP version of device. Defaults to 2. 3 is not yet supported.

Examples

Basic Constructor Arguments

$snmp = new \Ocolin\EasySNMP\SNMP(
           ip: '192.168.1.1',
    community: 'public',
      version: 2
);

Environment Constructor

$_ENV['SNMP_IP'] = '192.168.1.1';
$_ENV['SNMP_COMMUNITY'] = 'public';
$_ENV['SNMP_VERSION'] = 2;

$snmp = new \Ocolin\EasySNMP\SNMP();

Environment Prefix Constructor

$_ENV['MY_SNMP_IP'] = '192.168.1.1';
$_ENV['MY_SNMP_COMMUNITY'] = 'public';
$_ENV['MY_SNMP_VERSION'] = 2;

$snmp = new \Ocolin\EasySNMP\SNMP( prefix: 'MY_' );

SNMP Get

$output = $snmp->get(
        oid: '.1.3.6.1.2.1.1.1.0',
    numeric: false
);

SNMP Get Next

$output = $snmp->getnext(
        oid: '.1.3.6.1.2.1.1.1.0',
);

SNMP Walk

$output = $snmp->walk();

SNMP Bulk Walk

$output = $snmp->walk(
              oid: '.1.3.6.1.2.1.1.1.0',
             bulk: true,
        enumerate: true
);

统计信息

  • 总下载量: 24
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-30