LoginSignup
0
0

More than 1 year has passed since last update.

【Linux】ZabbixとかSNMPについて

Last updated at Posted at 2022-06-09

概要

snmp v2cとv3で異なることは、snmp v3は認証機能と暗号化機能が追加されv2cよりもセキュアになっている。Zabbixで監視する際はSNMPTrapを投げる機器とSNMPTrapを受信する機器間での認証が行われるだけでZabbixサーバ側の設定はv2cと変わりはない。

SNMPTrap v3コマンドのセキュリティレベルについて

レベル 名称 説明
1 noAuthNoPriv ユーザ名だけを利用して認証する。
2 authNoPriv HMAC-MD5 HMAC-SHAを利用し認証する。暗号化はなし。
3 authPriv HMAC-MD5 HMAC-SHAを利用し認証する。 AESまたはDESで暗号化する。

SNMPTrapを受信する側の設定

・「/etc/snmp/snmptrapd.conf」を編集する。
(エンジンID、ユーザ、認証方式(ハッシュ)、暗号方式が必要)
※エンジンIDは、機器ごとに異なるため事前に調べておくこと。

createUser -e 0x0123456789 user01 SHA authpass AES cryptpass
authUser log,execute,net user01 priv

SNMPTrapの送信コマンド

・snmp v2cでトラップを投げるコマンド。

snmptrap -v2c -c public 192.168.10.123 '' .1.3.6.1.6.3.1.1.5.3

・noAuthNoprivでsnmptrapを投げる

snmptrap -e 0x0123456789 -v 3 -l NoauthNoPriv -u user01 192.168.10.123 '' .1.3.6.1.6.3.1.1.5.3

・AuthNoprivでsnmptrapを投げる

snmptrap -e 0x0123456789 -v 3 -l authNoPriv -u user01 -a SHA -A shapass01 192.168.10.123 '' .1.3.6.1.6.3.1.1.5.3

・Authprivでsnmptrapを投げる

snmptrap -e 0x0123456789 -v 3 -l authPriv -u user01 -a SHA -A  authpass -x AES -X cryptpass 192.168.10.123 '' .1.3.6.1.6.3.1.1.5.3

ZabbixでMIBファイルを配置するディレクトリについて

ZabbixでMIBファイルを配置するディレクトリは、/etc/snmp/snmp.confで記載する。
デフォルトでは、/usr/share/snmp/mibs/に配置される。
MIBファイルのパスは再帰的に読み込まれないためベンダーごとにディレクトリを作成してMIBファイルを配置する場合には、親ディレクトリである/usr/share/snmp/mibs/だけではなく子ディレクトリのパスも記述する必要がある。

・/etc/snmp/snmp.conf サンプル

MIBDIRS /usr/share/snmp/mibs:/usr/share/snmp/cisco:/usr/share/snmp/yamaha:/usr/share/snmp/dell
MIBS all

ちなみに設定ファイルに記載しなくてもMIBDIRSという環境変数が定義されていれば問題ない。
/etc/environmentに記載していれば問題ない。

export MIBDIRS=/usr/share/snmp/mibs:/usr/share/snmp/cisco:/usr/share/snmp/yamaha:/usr/share/snmp/dell

snmptrapコマンドのオプション(おまけ)

[root@zabbix5 snmp]# snmptrap -h
USAGE: snmptrap [OPTIONS] AGENT TRAP-PARAMETERS

  Version:  5.8
  Web:      http://www.net-snmp.org/
  Email:    net-snmp-coders@lists.sourceforge.net

OPTIONS:
  -h, --help            display this help message
  -H                    display configuration file directives understood
  -v 1|2c|3             specifies SNMP version to use
  -V, --version         display package version number
SNMP Version 1 or 2c specific
  -c COMMUNITY          set the community string
SNMP Version 3 specific
  -a PROTOCOL           set authentication protocol (MD5|SHA|SHA-224|SHA-256|SHA-384|SHA-512)
  -A PASSPHRASE         set authentication protocol pass phrase
  -e ENGINE-ID          set security engine ID (e.g. 800000020109840301)
  -E ENGINE-ID          set context engine ID (e.g. 800000020109840301)
  -l LEVEL              set security level (noAuthNoPriv|authNoPriv|authPriv)
  -n CONTEXT            set context name (e.g. bridge1)
  -u USER-NAME          set security name (e.g. bert)
  -x PROTOCOL           set privacy protocol (DES|AES|AES-192|AES-256)
  -X PASSPHRASE         set privacy protocol pass phrase
  -Z BOOTS,TIME         set destination engine boots/time
General communication options
  -r RETRIES            set the number of retries
  -t TIMEOUT            set the request timeout (in seconds)
Debugging
  -d                    dump input/output packets in hexadecimal
  -D[TOKEN[,...]]       turn on debugging output for the specified TOKENs
                           (ALL gives extremely verbose debugging output)
General options
  -m MIB[:...]          load given list of MIBs (ALL loads everything)
  -M DIR[:...]          look in given list of directories for MIBs
    (default: $HOME/.snmp/mibs:/usr/share/snmp/mibs)
  -P MIBOPTS            Toggle various defaults controlling MIB parsing:
                          u:  allow the use of underlines in MIB symbols
                          c:  disallow the use of "--" to terminate comments
                          d:  save the DESCRIPTIONs of the MIB objects
                          e:  disable errors when MIB symbols conflict
                          w:  enable warnings when MIB symbols conflict
                          W:  enable detailed warnings when MIB symbols conflict
                          R:  replace MIB symbols from latest module
  -O OUTOPTS            Toggle various defaults controlling output display:
                          0:  print leading 0 for single-digit hex characters
                          a:  print all strings in ascii format
                          b:  do not break OID indexes down
                          e:  print enums numerically
                          E:  escape quotes in string indices
                          f:  print full OIDs on output
                          n:  print OIDs numerically
                          p PRECISION:  display floating point values with specified PRECISION (printf format string)
                          q:  quick print for easier parsing
                          Q:  quick print with equal-signs
                          s:  print only last symbolic element of OID
                          S:  print MIB module-id plus last element
                          t:  print timeticks unparsed as numeric integers
                          T:  print human-readable text along with hex strings
                          u:  print OIDs using UCD-style prefix suppression
                          U:  don't print units
                          v:  print values only (not OID = value)
                          x:  print all strings in hex format
                          X:  extended index format
  -I INOPTS             Toggle various defaults controlling input parsing:
                          b:  do best/regex matching to find a MIB node
                          h:  don't apply DISPLAY-HINTs
                          r:  do not check values for range/type legality
                          R:  do random access to OID labels
                          u:  top-level OIDs must have '.' prefix (UCD-style)
                          s SUFFIX:  Append all textual OIDs with SUFFIX before parsing
                          S PREFIX:  Prepend all textual OIDs with PREFIX before parsing
  -L LOGOPTS            Toggle various defaults controlling logging:
                          e:           log to standard error
                          o:           log to standard output
                          n:           don't log at all
                          f file:      log to the specified file
                          s facility:  log to syslog (via the specified facility)

                          (variants)
                          [EON] pri:   log to standard error, output or /dev/null for level 'pri' and above
                          [EON] p1-p2: log to standard error, output or /dev/null for levels 'p1' to 'p2'
                          [FS] pri token:    log to file/syslog for level 'pri' and above
                          [FS] p1-p2 token:  log to file/syslog for levels 'p1' to 'p2'
  -C APPOPTS            Set various application specific behaviour:
                          i:  send an INFORM instead of a TRAP

  -v 1 TRAP-PARAMETERS:
         enterprise-oid agent trap-type specific-type uptime [OID TYPE VALUE]...
  or
  -v 2 TRAP-PARAMETERS:
         uptime trapoid [OID TYPE VALUE] ...
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