当前位置:网站首页>Net SNMP development I
Net SNMP development I
2022-07-19 03:15:00 【Rock–】
Net-Snmp Development One
1. add to mib file
Find default mib Storage path :
net-snmp-config --default-mibdirs
Enter default mib Storage path
cd /mib default path
Import new mib file name
export MIBS=TEST-SMS-MIB
Copy the file into mibs Folder
cp /src…/TEST-SMS-MIB.txt ./TEST-SMS-MIB.txt
see mib Whether the document is written correctly ( If there are grammatical errors , There will be errors thrown )
snmptranslate -IR -Dparse testMIB
View all information under the specified node
snmptranslate -IR -Tp smsMIB
basis mib File generation .C.H file
Generate content based on your mib Structure to generate , Generally, one table generates one .c .h file The file name is based on mib2c The last assigned name
for example ( Generate testMIB The table below ): mib2c -c mib2c.iterate.conf testMIB::testTable
If the above steps are too troublesome , You can customize mib Files in net-snmp Of mibs In the folder , And then execute
export MIBS=“+/src…/testMIBS” mib2c -c mib2c.iterate.conf testMIB::testTable
choose 1 perhaps 2, Generate specific code ( See clearly SNMP A hint of )
( Because the generated code and the running oid Inquire about 、 Set up 、 Based on mib file , So we need to put net-snmp Of mibs In the folder )
2. compile 、 install 、 function
Use it directly ./configure Perform reconfiguration
configure The file in net-snmp Under the path , Download the net-snmp In the development package configure The file may not have permission , Add executable rights .Use ./configure + Parameter configuration
Example :./configure --prefix=/usr/local/net-snmp --with-default-snmp-version=“3” --with-sys-contact=“[email protected]” --with-sys-location=“beijing” --with-persistent-directory=“/var/net-snmp” --with-logfile=“/var/log/snmpd.log” --with-libs=“-lpthread” --with-out-mib-modules=“notification-log-mib” --with-mib-modules="test-sms-mib/management/myTestTable "
explain :./configure --prefix=/usr/local/net-snmp --with-default-snmp-version=“3” --with-sys-contact=“ Contacts Email” --with-sys-location=“ Address ” --with-persistent-directory=“ Persistent data file path ” --with-logfile=“ Log file path and file name ” --with-libs=“ Link library ” --with-out-mib-modules=“notification-log-mib” --with-mib-modules=“ Private implementation file ( route )”
perform configure The function of is to generate corresponding makefile file ,–with-out-mib-modules All you add are your private implementations .
If you execute configure There will be a mistake , Then see clearly –with-out-mib-modules Whether there is a problem in the process .perform make && make install
function snmpd -Lo -f
-Lo Log output to standard output ,-f The logo runs in the foreground
in addition , In the installation net-snmp On the system , Input snmpd -h The command prompt will be output
net-snmp Library main Function in snmpd.c Of documents 434 That's ok .
Every time the code of the agent is updated , perform ./configure You need to specify modules –with-mib-modules=“ private mib Implementation files ( route )”
2.1 install ( Into new equipment )
Enter into /usr/local/net-snmp, tar -cvf net-snmp.tar *
Packed net-snmp.tar Download to new device , In new equipment /usr/local/ Create under directory net-snmp,
hold net-snmp.tar Copied to the /usr/local/net-snmp, perform tar -xvf net-snmp.tar, decompression , Change authority chmod 777 *Set the running environment variable
In the system etc Under the table of contents , There is one profile file , Add at the end of the file :PATH= P A T H : PATH: PATH:HOME/bin:/usr/local/net-snmp/sbin/
rebootfunction snmpd
snmpd -Lo -fIf you lack anything, just pack it , I remember that some will have link library problems , Put the missing ones under the corresponding links .
An updated version
net-snmp The code of is compiled in the Library , You need to recompile after changing the code , Replace the old library .
code
In the compilation environment ./configure then make && make install
Compilation environment lib pack , reference < The first step in installing into a new device >
Don't write about mib Problems with documents , Conventional structures can be used , Can be in Windows Use under platform MG-SOFT MIB Toolset ,
You can refer to MG-SOFT Use the tutorial
https://codeantenna.com/a/6HyBNU7p86
MIB builder Good use of , Use after writing export view Options , Copy the content to the development environment , Import it , Use command snmptranslate -IR -Dparse testMIB
Just check whether there is a problem , If there is a problem, please correct it .
Just learned this open source library , If there's something wrong with the article , Please point out , I will correct it in time .
边栏推荐
- MySQL面试题(2022)
- 05_服务调用Ribbon
- Go language realizes sending SMS verification code and logging in
- [MCU simulation] (XVII) control transfer instructions - call and return instructions
- Graphql first acquaintance
- DDD 超越 MVC了吗
- 一个优酷VIP会员帐号可以几个人用的设备同时登录如何共享多人使用优酷会员账号?
- 要开源节流
- 【单片机仿真】(十二)指令系统逻辑运算指令 — 逻辑异或指令XRL、累加器清0和取反指令
- [single chip microcomputer simulation] (10) instruction system - multiplication instruction and division of arithmetic operation instruction
猜你喜欢

2002 - Can‘t connect to server on ‘127.0.0.1‘ (36)

Tools and methods - Excel plug-in xltools

MySQL optimized index
![[MySQL] MHA high availability](/img/d3/d9830f3c331193fd40b8f00ebe35fa.png)
[MySQL] MHA high availability

Systick timer basic learning and hand tearing code

Flutter development: running the flutter upgrade command reports an error exception:flutter failed to create a directory at... Solution

Graphql first acquaintance

05_服务调用Ribbon

【单片机仿真】(二十)ORG — 设置起始地址

【模板记录】字符串哈希判断回文串
随机推荐
Face key point detection
[MCU simulation] (VI) addressing mode - index addressing and relative addressing
仿射变换实现
Yolov5 ncnn reasoning
Tools and methods - Excel plug-in xltools
Bisenetv2 face segmentation
【单片机仿真】(六)寻址方式 — 变址寻址与相对寻址
MySQL面试题(2022)
【单片机仿真】(十六)控制转移类指令 — 无条件转移指令、条件转移指令
[MCU simulation] (XIII) instruction system logic operation instruction shift instruction
Go语言 实现发送短信验证码 并登录
RTX3090安装pytorch3D
CorelDRAW cannot be installed. Solution
OpenVINO中的FCOS人脸检测模型代码演示
【单片机仿真】(十七)控制转移类指令 — 调用及返回指令
MySQL multi table query
[MCU simulation] (VII) addressing mode - bit addressing
In depth understanding of machine learning - unbalanced learning: sample sampling technology - [smote sampling method and borderline smote sampling method of manual sampling technology]
LETV has more than 400 employees? Living a fairy life without a boss, the official responded
【单片机仿真】(十五)指令系统位操作类指令 — 位运算指令、位条件转移指令