ndum/laravel-snmp
Composer 安装命令:
composer require ndum/laravel-snmp
包简介
A FreeDSx/SNMP SNMP-Wrapper for Laravel
README 文档
README
This Laravel-Package provides an simple Laravel-Wrapper for the excellent FreeDSx/SNMP class.
Requirements
Requires: Laravel >= 5.5 or higher
Installation
Install via Composer.
$ composer require ndum/laravel-snmp
Documentation
The official documentation can be found here
Examples
Traditionally:
use Ndum\Laravel\Snmp; $snmp = new Snmp(); $snmp->newClient('servername', 2, 'secret'); $result = $snmp->getValue('1.3.6.1.2.1.1.5.0'); ## hostname dd($result);
Facade:
use Ndum\Laravel\Facades\Snmp; $snmp = Snmp::newClient('servername', 2, 'secret'); $result = $snmp->getValue('1.3.6.1.2.1.1.5.0'); ## hostname dd($result);
Extras
Timeout-Settings:
use Ndum\Laravel\Snmp; $snmp = new Snmp(); $snmp->newClient('servername', 2, 'secret'); $snmp->setTimeoutConnectValue(5); # set a value for timeout_connect $snmp->setTimeoutReadValue(10); # set a value for timeout_read $result = $snmp->getValue('1.3.6.1.2.1.1.5.0'); ## hostname dd($result);
SNMP traps part 1. (sending traps):
v1
$snmp = new Snmp(); $snmp->newClient('targetserver', 1, 'secret', 162); # Parameters: # The enterprise OID to trigger (string) # The IP address. (string) # The generic trap type (int) # The specific trap type (int) # The system uptime (in seconds/int) # The OIDs and their values (string/int) $snmp->sendTrapV1('1.3.6.1.4.1.2021.251.1','localhost', 0, 0, 60, '1.3.6.1.2.1.1.3', 60);
v2c / v3
use Ndum\Laravel\Snmp; $snmp = new Snmp(); $snmp->newClient('targetserver', 2, 'secret', 162); # Parameters: # The system uptime (in seconds/int) # The trap OID (string) # The OIDs and their values (string/int) $snmp->sendTrap(60, '1.3.6.1.4.1.2021.251.1', '1.3.6.1.2.1.1.3', 60));
inform-request (same as v2c / v3 but require a response from target)
use Ndum\Laravel\Snmp; $snmp = new Snmp(); $snmp->newClient('targetserver', 2, 'secret', 162); # Parameters: # The system uptime (in seconds/int) # The trap OID (string) # The OIDs and their values (string/int) $snmp->sendInform(60, '1.3.6.1.4.1.2021.251.1', '1.3.6.1.2.1.1.3', 60));
SNMP traps part 2. (Receiving traps / trap sink):
- First, create a trap listener-class (examples can be found here
- Then use it like the following example:
use Ndum\Laravel\SnmpTrapServer; # don't forget to use your listener also! # default options $options = [ 'ip' => '0.0.0.0', 'port' => 162, 'transport' => 'udp', 'version' => null, 'community' => null, 'whitelist' => null, 'timeout_connect' => 5, ]; $listener = new TrapListener(); ### your in step 1 created listener-class $server = new SnmpTrapServer() $server->prepare($listener, $options) # $options only needed if other than default $server->listen(); # in addition: (only if needed) $server->getOptions(); # to get the options $server->setOptions($options); # to set the options
The official documentation for trap sink can be found here
Issues / Contributions
Directly via GitHub
License
This project is licensed under the MIT License - see the LICENSE.md file for details
ndum/laravel-snmp 适用场景与选型建议
ndum/laravel-snmp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.12k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2020 年 02 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ndum/laravel-snmp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ndum/laravel-snmp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 12.12k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 34
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-21