SNMP Traps into MySQL is Sublime

Posted on in System Administration

I use snmptrapd to catch SNMP traps and then put them into a MySQL database using a pretty generic trap handler. This gives me the opportunity to generate such useful information as:

> SELECT HOUR(time) AS "hour", COUNT(*) AS "bounces" FROM snmptraps
    WHERE hostname = 'XXX' AND time > '2011-07-25'
        AND trap_oid = 'SNMPv2-MIB::snmpTrapOID.0 IF-MIB::linkDown'
    GROUP BY HOUR(time)
;
+------+---------+
| hour | bounces |
+------+---------+
|    0 |     729 |
|    1 |     936 |
|    2 |     841 |
|    3 |     810 |
|    4 |     547 |
|    5 |     316 |
|    6 |     224 |
|    7 |     144 |
|    8 |     481 |
|    9 |     584 |
|   10 |       1 |
+------+---------+
11 rows in set (0.05 sec)
>

This tells us that interfaces on host 'XXX' where bouncing a lot until 10 AM and then stopped.

Slaptijack's Koding Kraken