(and snmp for now ;-) )
The goal here is to have an automated replacement to weathermap.
That means that this project aims to output a map of the network topology and regularly poll the devices to show the links utilization.
(Was greatly inspired by a similar PoC project from zerxen
at first)
python3 -m venv venv
. venv/bin/activate
python3 -m pip install -r requirements-dev.txt
cd frontend ; nodeenv --without-ssl nodeenv ; . nodeenv/bin/activate ; npm install terser -g ; npm install html-minifier-terser -g ; cd ..
export REPO_PATH=$(pwd)
- export LLDP_INIT_NODE_FQDN="node_name" (or LLDP_INIT_NODE_IP if there is no fqdn. LLDP_INIT_NODE_PORT if different snmp port)
- If scrapping must stop at a particular device : LLDP_STOP_NODES_FQDN or LLDP_STOP_NODES_IP
- export LLDP_STOP_NODES_FQDN=fqdn1,fqdn2
- Those LLDP variables can be specified in a
.env
file if usingdocker-compose
cd frontend/ ; . nodeenv/bin/activate ; terser automapping-script.js -o public-html/automapping-script.min.js ; html-minifier-terser --collapse-whitespace --remove-comments --remove-optional-tags --remove-redundant-attributes --remove-script-type-attributes --remove-tag-whitespace --use-short-doctype --minify-css true --minify-js true index.html -o public-html/index.html ; cd .. ; docker-compose up -V --force-recreate --always-recreate-deps --build --remove-orphans
- Browser to http://127.0.0.1:8080
- Getting
kind
:
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
chmod +x ./kind
mv ./kind /usr/local/bin/kind
- Creating a kind cluster with extra port mapping
cat <<EOF | kind create cluster --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
EOF
- Adding an ingress to the cluster :
kubectl apply -f resources/ingress-nginx.yaml
- Applying Naasgul yaml :
kubectl apply -f resources/k8s-deploy.yaml
You can fake a fabric with tests/add_fake_data_to_db.py
script.
For example, a 5-stage fabric with 12 devices can be generated with : python3 tests/add_fake_data_to_db.py -n 15 -s 5
Interfaces will have random bytes values (but for one timestamp only).
If you want to add more stats to interfaces, you can add the flag -a 1
(so interfaces' graphs will be a lil' more than just a point ;-) )
By throwing some -a 1
, you should get something like this :
With graphs like :
ci_tests.sh
allows to play Gitlab-ci jobs locally for development purposes.
Simply run ./scripts/ci_tests.sh
and it should run.
After running pytest
with --cov=backend/
(remember that a mongodb & a snmpsim must be running -> Gitlab-ci takes care of everything), we get a .coverage
file.
From there, we can just coverage-badge -o resources/coverage.svg
Pylint and stuff can be generated with : anybadge -l pylint -v SCORE_OBTAINED -f pylint.svg 2=red 4=orange 8=yellow 10=green