我正在尝试将 freeradius 统计信息扩展到 snmp。我想监视这些值并将它们收集到 rrd 文件中。我的问题是这些值应该是 rrd 计数器,但似乎计数器值需要检索 INTEGER 而不是 STRING。您可以在此 snmpwalk 中看到该值以 STRING 形式返回。
snmpwalk -v2c -c public 127.0.0.1 .1.3.6.1.3.1983.1.1
# output
iso.3.6.1.3.1983.1.1.1.0 = INTEGER: 1
iso.3.6.1.3.1983.1.1.2.1.2.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = STRING: "/bin/cat"
iso.3.6.1.3.1983.1.1.2.1.3.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = STRING: "/var/log/freeradius/statistics/total_access_requests"
iso.3.6.1.3.1983.1.1.2.1.4.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = ""
iso.3.6.1.3.1983.1.1.2.1.5.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = INTEGER: 5
iso.3.6.1.3.1983.1.1.2.1.6.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = INTEGER: 1
iso.3.6.1.3.1983.1.1.2.1.7.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = INTEGER: 1
iso.3.6.1.3.1983.1.1.2.1.20.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = INTEGER: 4
iso.3.6.1.3.1983.1.1.2.1.21.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = INTEGER: 1
iso.3.6.1.3.1983.1.1.3.1.1.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = STRING: "9566"
iso.3.6.1.3.1983.1.1.3.1.2.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = STRING: "9566"
iso.3.6.1.3.1983.1.1.3.1.3.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = INTEGER: 1
iso.3.6.1.3.1983.1.1.3.1.4.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = INTEGER: 0
iso.3.6.1.3.1983.1.1.4.1.2.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115.1 = STRING: "9566"
# /etc/snmp/snmpd.conf
extend .1.3.6.1.3.1983.1.1 access_requests /bin/cat /var/log/freeradius/statistics/total_access_requests
通过打印文件中的值来扩展 snmp 脚本。/bin/cat使用的文件由脚本/usr/local/sbin/radstat.sh生成
如何使此输出成为整数?
iso.3.6.1.3.1983.1.1.4.1.2.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115.1 = STRING: "9566"
谢谢多米尼克