Skip to content

Instantly share code, notes, and snippets.

@higebu
Last active December 22, 2023 09:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save higebu/01c63b0057e3a17494e6 to your computer and use it in GitHub Desktop.
Save higebu/01c63b0057e3a17494e6 to your computer and use it in GitHub Desktop.
Setup SNMP Trap monitoring for vCenter Server Appliance with Zabbix

Setup SNMP Trap monitoring for vCenter Server Appliance with Zabbix

Environment

  • VCSA 6.0
  • Zabbix 3.0
    • on Ubuntu 14.04

Zabbix Server side

  • Install snmpd and snmptt

    apt-get install snmpd snmp snmp-mibs-downloader snmptt libnet-snmp-perl
    
  • Edit /etc/snmp/snmptrapd.conf

    cat <<EOF >> /etc/snmp/snmptrapd.conf
    authCommunity log,execute,net public
    perl do "/usr/lib/snmptt/snmptthandler-embedded";
    EOF
    
  • Edit /etc/default/snmpd

    sed -i 's/TRAPDRUN=no/TRAPDRUN=yes/' /etc/default/snmpd
    sed -i "s/TRAPDOPTS='-Lsd/TRAPDOPTS='-On -Lsd/" /etc/default/snmpd
    
  • Start snmpd

    service snmpd start
    
  • Edit /etc/snmp/snmptt.ini

    sed -i 's;#date_format = %a %b %e %Y;date_format = %H:%M:%S %Y/%m/%d;' /etc/snmp/snmptt.ini
    sed -i 's/syslog_enable = 1/syslog_enable = 0/' /etc/snmp/snmptt.ini
    sed -i 's/net_snmp_perl_enable = 0/net_snmp_perl_enable = 1/' /etc/snmp/snmptt.ini
    sed -i 's/net_snmp_perl_cache_enable = 0/net_snmp_perl_cache_enable = 1/' /etc/snmp/snmptt.ini
    
  • Download MIB file from SNMP MIB module file download (1013445)

  • Import MIB files

    unzip 1013445_VMware-mibs-6.0.0-2906283.zip
    mkdir -p /usr/share/mibs/site/
    cp -p vmw/*.mib /usr/share/mibs/site/
    
  • Convert MIB files to SNMPTT config

    mkdir -p snmpttconf/vmw
    for i in `ls vmw/*.mib`; do snmpttconvertmib --in=$i --out=snmpttconf/$i.conf; done
    cat snmpttconf/vmw/*.conf > snmptt.vmw.conf
    sed -i 's/FORMAT/FORMAT ZBXTRAP $aA/g' snmptt.vmw.conf
    cp -pb snmptt.vmw.conf /etc/snmp/snmptt.conf
    
  • Restart snmptt

    service snmptt restart
    
  • Edit /etc/zabbix/zabbix_server.conf

    cat <<EOF >> /etc/zabbix/zabbix_server.conf 
    StartSNMPTrapper=1
    SNMPTrapperFile=/var/log/snmptt/snmptt.log
    EOF
    
  • Restart Zabbix Server

    service zabbix-server restart
    
  • Create SNMP Trap item. And set the key like snmptrap["Events"].

vCenter side

  • Set snmp trap target

    snmp.set --targets {Zabbix Server Address}@162/public
    
  • Enable snmp service

    snmp.enable
    

Test

  • Send a test trap from VCSA.

    snmp.test
    
  • In /var/log/syslog on Zabbix Server

    Mar  2 09:19:32 zabbixserver snmptrapd[27061]: 2016-03-02 18:19:32 0.0.0.0(via UDP: [x.x.x.x]:41827->[y.y.y.y]:162) TRAP, SNMP v1, community public#012#011.1.3.6.1.6.3.1.1.5 Warm Start Trap (0) Uptime: 1:45:32.48#012
    
  • In /var/log/snmptt/snmptt.log

    Wed Mar  2 18:19:32 2016 .1.3.6.1.6.3.1.1.5.2 Normal "Status Events" x.x.x.x - ZBXTRAP x.x.x.x A warmStart trap signifies that the SNMP entity,
    

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment