Just a small program using Python language that prints every 30 seconds (configurable through the INTERVAL env var) the following data in json format: RX/TX packets, bytes and errors of the default network interface.
sample output
{
"interface": "eth0",
"rx": {
"rx_bytes": "2809",
"rx_errors": "0",
"rx_packets": "322"
},
"tx": {
"tx_bytes": "367",
"tx_errors": "0",
"tx_packets": "36"
}
}you will need python, docker for the installation
In order to install the application you can create a python virtual environment just to keep your system clear without unnused python modules.
cd /path/to/the/project/
python3 -m venv venv
source venv/bin/activate
pip install --no-cache-dir -r requirements.txt
gunicorn -c gunicorn_config.py app:app
# now you should be able to access the web api through http://0.0.0.0:5000/and for the deployment to kubernetes I strongly recommend you to use kustomize
cd /path/to/the/project/
# if you wanna change the image use the command kustomize edit set image <image>=<newimage>:<newtag>
# default files
kubectl apply -k k8s
# Overlays
kubectl apply -k k8s/overlays/dev/if you only want to test the application you can deploy the minimal_k8s.yaml file after checking that the deployment image is pointing to the correct value
cd /path/to/the/project/
kubectl apply -f k8s/minimal_k8s.yaml # notice the difference with -f instad of -kjust use the browser to http://0.0.0.0:5000/ or you can also use curl :)
curl http://0.0.0.0:5000/ | jq # jq must be installed (no needed)The application expose a dummy healthcheck under the following path http://0.0.0.0:5000/healthz
| Name | Status | |
|---|---|---|
| Daniel Ramirez | dxas90@gmail.com | active |