Git Product home page Git Product logo

php-snmptraps's Introduction

php-snmptraps

php snmptrap handler and web UI for management

php-snmptraps is an php trpahandler that processes snmp traps, writes them to database and/or file and sends notifications via sms/email/pushover to users, based on web settings.

It comes with nice HMTL5 UI:

  • Dashboard that shows overview of last messages
  • Displays messages sent by specific host
  • Displays messages per severity
  • Displays specific messages received
  • Live update of received traps

and more.

You can set severity level for each received message, ignore specific message types, create maintenance periods for hosts, set per-user quiet hours and more.

Notifications are set per-user/severity, by default aupported are:

  • Email notification
  • Pushover notification
  • SMS notification
  • Slack/Mattermost notification

The can be easily extended to any other custom notification type.

screenshots

Some sample UI screenshots can be found below: Screen1 Screen2 Screen3 Screen4

setup

This guide assumes you have a working net-snmp, apache, php and mysql installation with default apache files stored in /var/www/.

1.Set traphandler

First, edit file /etc/snmp/snmptrapd.conf and add traphandler for default files to traphandler.php:

# listen on
agentaddress my_ip_address:162
# set php-snmptraps as default trap handler
traphandle default /usr/bin/php /var/www/traphandler.php

2.Prepare and edit config file

Now go to /var/www/ directory and copy config.dist.php to config.php:

cp /var/www/config.dist.php /var/www/config.php

and edit the config file to match your settings.

3.Set mod_rewrite

mod_rewrite is required for snmptraps. Example here:

http://phpipam.net/documents/prettified-links-with-mod_rewrite/

4.Import database schema

Now you have to import chema for mysql database with following command:

mysql -u root -p
Enter password:

mysql> create database snmptraps;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL on snmptraps.* to snmptraps@localhost identified by "snmptraps";
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

# import SCHEMA.SQL file
mysql -u root -p snmptraps < db/SCHEMA.sql

That should be it, fire up browser and login. Default user/pass is Admin/snmptraps.

5.Send test message and debugging

To test snmptrap you can use the following command:

snmptrap -v 2c -c public my_public_ip '' .1.3.6.1.4.1.2636.4.1.1 .1.3.6.1.4.1.2636.4.1.1 s "Power supply failure"

Check also the file you set in config.php for possible errors:

tail -f /tmp/trap.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.