A tool to show what is connected to switch ports
Add new switch:
python3 manage.py switch_info [switch ip] [snmp community]
The following brands are tested:
- Cisco
- HPE Aruba
- HP ProCurve (not able to get all information on all models)
- Extreme Networks
- Korenix
- Westermo SDSL modems
Requirements: https://github.com/xstaticxgpx/netsnmp-py3/
apt-get install libsnmp30 libsnmp-dev libczmq4 libczmq-dev
apt-get install libsnmp40 libsnmp-dev libczmq4 libczmq-dev python3-pip
pip3 install pyzmq netsnmp-py django
pip3 install switchinfo
pip3 install django-switch-config-backup
adduser switch_info
django-admin startproject switch_info /home/switch_info
nano /home/switch_info/switch_info/settings.py
ALLOWED_HOSTS = ['switchinfo']
Add to the end of INSTALLED_APPS:
'switchinfo.apps.SwitchinfoConfig',
'config_backup.apps.ConfigBackupConfig',
USE_TZ = False
Set TIME_ZONE to your local time zone:
TIME_ZONE = 'Europe/Oslo
import os
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
Change /home/switch_info/switch_info/urls.py
to contain this:
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('switchinfo.urls')),
]
apt-get install libperl-dev
apt-get install python3-mysqldb
Change DATABASES key in settings.py to look something like this:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'switch_info',
'USER': 'switch_info',
'PASSWORD': 'asdf',
'HOST': 'localhost'
}
}
Create database and user:
CREATE
DATABASE switch_info;
CREATE
USER 'switch_info'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON switch_info.* TO
'switch_info'@'localhost';
FLUSH
PRIVILEGES;
CREATE
USER 'root'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO
'root'@'%' WITH GRANT OPTION;
FLUSH
PRIVILEGES;
nano /etc/mysql/mariadb.conf.d/50-server.cnf
Change bind-address to 0.0.0.0
Restart MariaDB server:
/etc/init.d/mariadb restart
Copy config to /etc/apache2/sites-available/switchinfo.conf and edit ServerName:
cp switchinfo.conf /etc/apache2/sites-available/switchinfo.conf
<VirtualHost *:80>
ErrorLog /var/log/apache2/switch_info_error.log
CustomLog /var/log/apache2/switch_info_access.log combined
ServerName switchinfo.yourdomain.local
Alias /media /home/switch_info/media
Alias /static /home/switch_info/static
Alias /gitlist /var/www/html/gitlist
Alias /loganalyzer /var/www/html/loganalyzer
<Directory "/var/www/html/gitlist">
Require all granted
AllowOverride all
</Directory>
<Directory "/home/switch_info/static">
Require all granted
</Directory>
<Directory "/home/switch_info/media">
Require all granted
</Directory>
WSGIDaemonProcess switch_info user=switch_info group=switch_info threads=50 maximum-requests=10000 python-path=/home/switch_info
WSGIProcessGroup switch_info
WSGIScriptAlias / /home/switch_info/switch_info/wsgi.py
<Directory /home/switch_info>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
Install mod-wsgi:
apt-get install libapache2-mod-wsgi-py3
Create user:
adduser switch_info
Remove default site:
rm 000-default.conf
Enable site:
a2ensite switchinfo
Initialize database and collect static files:
python3 manage.py collectstatic
python3 manage.py migrate
python3 manage.py createsuperuser
python3 manage.py load_oui