顯示具有 snmpwalk 標籤的文章。 顯示所有文章
顯示具有 snmpwalk 標籤的文章。 顯示所有文章

2025/08/20

如果要在zabbix要使用不同的mib

找到下方工具 應該是最方便使用的

https://github.com/Sean-Bradley/SNMPWALK2ZABBIX


只要以下指令

python3 snmpwalk2zabbix.py public 192.168.1.1 1.3.6.1.2.1

就會產生 template 的 xml 可以直接從 zabbix 匯入

但執行時出現以下問題
























試了好几次都一樣

原因出在產生出來的xml裡有雙引號

<template>"INSIGHTPOWER" SNMP</template>
<name>"INSIGHTPOWER" SNMP</name>

把雙引號拿掉就正常了


<template>INSIGHTPOWER SNMP</template>

<name>INSIGHTPOWER SNMP</name>

2025/08/15

最近有個新的需求
希望在市電斷電
但發電机無作動是能關几
而且關几要有先後順序
首先詢問環控系統看看能不能讓我捉乾接點的訊號
廠商回覆是沒辦法
但他們可以增加這個功能
要收費
於是換個思考方式
目前就打算捉UPS的snmp值
只捉輸入電壓跟電池剩餘電量
由於現況是使用 AELTA 
找了一下SNMP的oid

輸入電壓有三相
1.3.6.1.2.1.33.1.3.3.1.3.1.0
1.3.6.1.2.1.33.1.3.3.1.3.2.0
1.3.6.1.2.1.33.1.3.3.1.3.3.0

旁路供電 三相

1.3.6.1.2.1.33.1.5.3.1.2.1.0
1.3.6.1.2.1.33.1.5.3.1.2.2.0
1.3.6.1.2.1.33.1.5.3.1.2.3.0 


只捉一相即可

電池剩餘電量

1.3.6.1.2.1.33.1.2.4.0

shell如下

#!/bin/bash

battery=$(/usr/bin/snmpwalk -v 2c -c public 10.0.0.1 1.3.6.1.2.1.33.1.2.4.0 | awk '{print $NF}'|cut -d '.' -f 1 )
#echo $battery

input_voltage=$(/usr/bin/snmpwalk -v 2c -c public 10.0.0.1 1.3.6.1.2.1.33.1.3.3.1.3.1.0 | awk '{print $NF}'|cut -d '.' -f 1 )
#echo $input_voltage

if [ $battery -lt 80 ] && [ $input_voltage -lt 50 ]; then

#       echo "ok"
        /usr/sbin/init 0

fi


2022/05/26

因為要用linux shell 產生值再透過snmp server 讓 librenms 撈出後能畫圖

找到 python snmp server

只要一行指令

Standalone usage: snmp-server.py [-h] [-p PORT] [-c CONFIG] [-d] [-v]

SNMP server

optional arguments:
  -h, --help            show this help message and exit
  -p PORT, --port PORT  port (by default 161 - requires root privileges)
  -c CONFIG, --config CONFIG
                        OIDs config file
  -d, --debug           run in debug mode
  -v, --version         show program's version number and exit

要產生snmp值的範例檔如下

DATA = {
  '1.3.6.1.4.1.1.1.0': integer(12345),
  '1.3.6.1.4.1.1.2.0': bit_string('\x12\x34\x56\x78'),
  '1.3.6.1.4.1.1.3.0': octet_string('test'),
  '1.3.6.1.4.1.1.4.0': null(),
  '1.3.6.1.4.1.1.5.0': object_identifier('1.3.6.7.8.9'),
  # notice the wildcards:
  '1.3.6.1.4.1.1.6.*': lambda oid: octet_string('* {}'.format(oid)),
  '1.3.6.1.4.1.1.?.0': lambda oid: octet_string('? {}'.format(oid)),
  '1.3.6.1.4.1.2.1.0': real(1.2345),
  '1.3.6.1.4.1.3.1.0': double(12345.2345),


snmpwalk 指定 ip port

snmpwalk -c public -v 2c 10.1.1.1:1611 .1.2.3