Installing manual

Pavel Polyakov edited this page Nov 11, 2016 · 5 revisions

How do I can deploy it on my network?

  1. Install needed packages

    $ yum -y install net-snmp net-snmp-utils
    $ yum -y install mysql
    $ yum -y install epel-release
    $ yum -y install rabbitmq-server
    $ yum -y install -y python-pip
    $ pip install sqlalchemy
    $ pip install pymysql
    $ pip install celery
  2. Configure mySQL

    • Login to mysql

      $ mysql
    • Create database

      MariaDB [(none)]> create database traps;
    • Create user

      MariaDB [(none)]> CREATE USER 'flap'@'localhost' IDENTIFIED BY 'flapmyport';
      MariaDB [(none)]> GRANT ALL PRIVILEGES ON * . traps TO 'flap'@'localhost';
      MariaDB [(none)]> GRANT ALL PRIVILEGES ON `traps`.* TO `flap`@`localhost`;
      MariaDB [(none)]> FLUSH PRIVILEGES;
  3. Configure Celery

    • Copy https://github.com/celery/celery/blob/3.1/extra/generic-init.d/celeryd into /etc/init.d/celeryd
    • Make it executable
      $ chmod +x /etc/init.d/celeryd
    • Create /etc/default/celeryd as in example
      CELERYD_NODES="worker"
      CELERY_BIN="/usr/local/bin/celery"
      CELERYD_CHDIR="/path/to/folder/containing/tasks/"
      CELERYD_OPTS="--time-limit=3000 --concurrency=3 -A tasks"
      CELERYD_LOG_FILE="/var/log/celery/%N.log"
      CELERYD_PID_FILE="/var/run/celery/%N.pid"
      CELERYD_USER="celery"
      CELERYD_GROUP="celery"
      CELERY_CREATE_DIRS=1
      
    • Create user celery
      $ sudo useradd -N -M --system -s /bin/bash celery
    • Create group celery
      $ sudo groupadd celery
    • Add user to the group
      $ sudo usermod -g celery celery
  4. Configure snmptrapd

    • Edit /etc/snmp/snmptrapd.conf

      disableAuthorization yes
      sqlMaxQueue 10
      sqlSaveInterval 0
      outputOption X
      traphandle default /usr/local/src/trapharvester/trap_handler.py
    • And start snmtrapd

      $ sudo snmptrapd -fnLo &
  5. Configure trap harvester

    • Clone this repo to /usr/local/src/trapharvester/

      $ cd /usr/local/src
      $ git clone http://github.com/Pavel-Polyakov/trapharvester.git
      $ cd trapharvester
    • Rename config_default.py to config.py

      $ mv config_default.py config.py
    • Edit config.py with your favorite text editor

      • Configure it for your mysql database.
        • your_username: instead 'flap'
        • your_server: instead 'localhost'
        • your_database: instead 'traps'
        > If you have configured the database as I described above that there is nothing needed to change
        DB_URL = 'mysql+pymysql://flap:flapmyport@localhost/traps'
        
      • Change from and to mail-adresses
        MAIL_FROM = 'trap_harvester@yourdomain.com'
        MAIL_TO = ['user_first@yourdomain.com','user_second@yourdomain.com']
        
      • Configure SNMP_COMMUNITY — it's needed for getting description of interface and hostname of device
        SNMP_COMMUNITY = 'your_SNMP_community'
        
      • This parameter change only if you understand what you do

        Flapping interface flaps more then FLAP_THR_COUNT in the last FLAP_THR_MINUTES

        FLAP_THR_MINUTES = 15
        FLAP_THR_COUNT = 20
        
      • Set this variable to True for receive mails in Russian
        TRANSLATE = False
        
  6. Start processess

    $ sudo service rabbitmq-server start
    $ sudo service celeryd start
  7. Or without service just
    $ /usr/bin/python /bin/celery -A tasks worker
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.