0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

snmpd に任意の値を出力させる

Posted at

設定

ubuntu で設定しています
これでなんでも(shellを使って取れるものなら) cacti でグラフの表示とアラートをあげることができるようになった

cron などで値をキャッシュする

$ vi /etc/cron.d/get-value
$ cat /etc/cron.d/get-value
* * * * * root cd /tmp && /usr/local/bin/count_custom_value.sh > .value.cache && mv .value.cache value.cache

snmp extend を設定

$ vi /etc/snmp/snmpd.conf
$ cat /etc/snmp/snmpd.conf
...
extend-sh custom-value1 cat /tmp/value.cache
...
$ systemctl restart snmpd

snmpwalk で確認

$ snmpwalk -v1 -c $COMMUNITY $AGENT nsExtendOutputFull
NET-SNMP-EXTEND-MIB::nsExtendOutputFull."custom-value1" = STRING: 0

oid を知りたい場合は -On をつける

その他

snmp の value type が STRING になってしまうが、どうしようもない

#!/bin/bash
exit 10

exit code で値を表現すれば INTEGER にできるが 0-255 まで

STRING でも cacti でのグラフ表示や thold のアラートも問題なかった

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?