Installing and Troubleshooting eNMS

Because i started with LibreNMS and then with Netbox, i saw that eNMS can be synced with Librenms. The installation documentation was not the best, really don’t know the exact reason behind. No VM machine for DEMO. I’m guessing that docker demo can be the easier to do it but if i have enough space, i would like to avoid it.

Because i recently did a Netbox installation, i discovered that 80% of eNMS installation is really the same and i’m going to explain how i did it. I don’t know if this is the right way, the perfect way or not but at least this works for me.

First think first, the installation has been done to a really new VM machine with Ubuntu 18.04, updated today.

Step1. Update the VM of Ubuntu 18.04 to the latest package updates.

sudo apt-get update

Step2. We are going install and prepare the database.
Based on the documentation, database can be MySQL or PostgreSQL. Because i just did the installation for Netbox, we are going to use PostgreSQL as database for this.

sudo apt-get install -y postgresql libpq-dev
sudo -u postgres psql

And to create database we are going to use the below commands (without postgres=#):

postgres=# CREATE DATABASE enms;
postgres=# CREATE USER enms WITH PASSWORD 'enms_password';
postgres=# GRANT ALL PRIVILEGES ON DATABASE enms TO enms;
postgres=# \q

Step3. We are going to install all package dependecies.

sudo apt-get install -y python3 python3-pip python3-dev build-essential libxml2-dev libxslt1-dev libffi-dev libpq-dev libssl-dev redis-server zlib1g-dev

Step4. Preparing the application and download it from the source GIT.

cd /opt
sudo apt-get install -y git
sudo git clone https://github.com/afourmy/eNMS.git

Step5. Installation the python requirements from the application eNMS.
The requirements files are located in: “/opt/eNMS/build/requirements/” . To install requirements we are going to:

pip3 install -r /opt/eNMS/build/requirements/requirements.txt

Add python3 command to run as python simple command. The reason is that some scripts inside application are running with “python” command but they require to have python3 at least installed.

sudo ln -s /usr/bin/python3 /usr/bin/python

And install some other requirements for database but not only:

pip3 install --upgrade setuptools
sudo apt-get install libpcap-dev libpq-dev
sudo apt-get install python3.6-dev libmysqlclient-dev
pip3 install -r /opt/eNMS/build/requirements/requirements_db.txt

Step6. Based on the documentation, to run the application dev mode, we have to run this:

cd /opt/eNMS/
export FLASK_APP=app.py
flask run --host=0.0.0.0

And the application should be reachable on the port 5000.

root@enms:/opt/eNMS# flask run --host=0.0.0.0
 * Serving Flask app "app.py"
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
...
2020-07-30 12:52:52,224 INFO     Loading service: /opt/eNMS/eNMS/services/data_validation/napalm_getters.py
2020-07-30 12:52:52,228 INFO     Loading service: /opt/eNMS/eNMS/services/data_validation/scrapli.py
2020-07-30 12:52:52,233 INFO     Loading service: /opt/eNMS/eNMS/services/data_validation/netmiko_validation.py
2020-07-30 12:52:52,649 INFO      * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

Step7. We have to deploy the application into the production mode. For this we have to run:

cd /opt/eNMS/
export DATABASE_URL="postgresql://enms:enms_password@localhost/enms"
export SECRET_KEY=a1b2c3d4e5
gunicorn --config gunicorn.py app:app

And the results are:

2020-07-30 10:45:01,522 INFO     Topology successfully imported.
2020-07-30 10:45:01,523 ERROR    Git pull failed (/opt/eNMS/network_data)
2020-07-30 10:45:01,550 INFO     CREATION: server '345051660178'
[2020-07-30 10:45:01 +0000] [29361] [INFO] Starting gunicorn 20.0.4
[2020-07-30 10:45:01 +0000] [29361] [DEBUG] Arbiter booted
[2020-07-30 10:45:01 +0000] [29361] [INFO] Listening at: http://0.0.0.0:5000 (29361)
[2020-07-30 10:45:01 +0000] [29361] [INFO] Using worker: sync
[2020-07-30 10:45:01 +0000] [29437] [INFO] Booting worker with pid: 29437
[2020-07-30 10:45:01 +0000] [29361] [DEBUG] 1 workers
...
2020-07-30 10:42:28,666 INFO      * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

Having gunicorn running the application we can continue using the Netbox installation guide to finish our deployment.

Step8. Start nginx and Supervisor and configure them for our application.

sudo apt install -y nginx
sudo apt install -y supervisor

And for the nginx configuration we have:

sudo cp /opt/eNMS/build/nginx/enms.conf /etc/nginx/sites-available/
cd /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default
sudo ln -s /etc/nginx/sites-available/enms.conf

For the Supervisor application we have:

sudo nano /etc/supervisor/conf.d/enms.conf

and inside of the file “enms.conf” we have:

[program:enms]
command =  gunicorn --config gunicorn.py app:app
directory = /opt/eNMS/

Give permision to log files:

sudo chmod 777 /opt/eNMS/logs/enms.log
sudo chmod 777 /opt/eNMS/logs/security.log

Save the file and restart both services:

sudo service nginx restart
sudo service supervisor restart

and the application is now reachable. To test this you can do also:

sudo service supervisor status

And you should have as results:

paulierco@enms:/opt/eNMS$ sudo service supervisor status
● supervisor.service - Supervisor process control system for UNIX
   Loaded: loaded (/lib/systemd/system/supervisor.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2020-07-30 13:17:02 UTC; 58s ago
     Docs: http://supervisord.org
  Process: 31347 ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown (code=exited, status=0/SUCCESS)
 Main PID: 31431 (supervisord)
    Tasks: 2 (limit: 4659)
   CGroup: /system.slice/supervisor.service
           ├─31431 /usr/bin/python /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
           └─31448 /usr/bin/python3 /usr/local/bin/gunicorn --config gunicorn.py app:app

Jul 30 13:17:02 enms systemd[1]: Started Supervisor process control system for UNIX.
Jul 30 13:17:02 enms supervisord[31431]: 2020-07-30 13:17:02,566 CRIT Supervisor running as root (no user in config file)
Jul 30 13:17:02 enms supervisord[31431]: 2020-07-30 13:17:02,567 INFO Included extra file "/etc/supervisor/conf.d/enms.conf" during parsing
Jul 30 13:17:02 enms supervisord[31431]: 2020-07-30 13:17:02,577 INFO RPC interface 'supervisor' initialized
Jul 30 13:17:02 enms supervisord[31431]: 2020-07-30 13:17:02,577 CRIT Server 'unix_http_server' running without any HTTP authentication checking
Jul 30 13:17:02 enms supervisord[31431]: 2020-07-30 13:17:02,577 INFO supervisord started with pid 31431
Jul 30 13:17:03 enms supervisord[31431]: 2020-07-30 13:17:03,581 INFO spawned: 'enms' with pid 31448
Jul 30 13:17:04 enms supervisord[31431]: 2020-07-30 13:17:04,671 INFO success: enms entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
paulierco@enms:/opt/eNMS$
eNMS login page

Default username and passwords are: admin/admin. You can read documentation how you can do some changes.

eNMS default dashboard

3 comments On Installing and Troubleshooting eNMS

Leave a Reply to Davide Cancel Reply

Your email address will not be published.

Site Footer