Skip to content

guycole/mellow-skunk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mellow-skunk

Mellow Skunk is a django-rest application for mellow collectors such as mellow-heeler and mellow-hyena. Mellow Skunk provides a easy mechanism to share the most recent results of a collection cycle. Mellow Skunk also exposes collection metrics to prometheus by using django-prometheus.

There is only one skunk instance per host and it exposes statistics for all collection operations on the host.

deployment

deployment

Mellow collector hosts are all based on Raspberry Pi. The mellow skunk application is distributed via github and expected to reside at /home/gsc/Documents/github/mellow-skunk, and this path is hard coded in many scripts.

The django-rest application executes from gunicorn invoked by systemd(1), and should always be available.

nginx(8) acts as a reverse proxy to gunicorn and is also started by systemd(1), and should always be available.

operation

Once mellow skunk has been installed and configured, the collection applications can post a JSON payload for each collection cycle. All previous results will be deleted and only the freshest content will be retained. Also, the prometheus gauge for collection population will be updated. The uploaded content can be reviewed w/a GET at the URL below.

installation

  1. Clone mellow skunk repo within /home/gsc/Documents/github
    • Scripts are expecting application at /home/gsc/Documents/github/mellow-skunk
  2. Establish python environment
    • cd mellow-skunk/src/django-rest
    • Invoke virtualenv, i.e. virtualenv -p /usr/local/opt/python@3.9/bin/python3.9 venv
    • source venv/bin/activate
    • pip install -r requirements.txt
  3. Verify you can start django
    • cd mellow
    • python manage.py migrate
    • python manage.py runserver
  4. Verify you can run mellow skunk with gunicorn
    • gunicorn --bind 0.0.0.0:8000 mellow.wsgi
  5. Configure systemd(1) to invoke gunicorn
    • cd ..;ls (you should see two gunicorn.* files)
    • sudo cp gunicorn.* /etc/systemd/system
    • sudo systemctl start gunicorn.socket
    • sudo systemctl enable gunicorn.socket
    • sudo systemctl status gunicorn.socket
    • curl -v --unix-socket /run/gunicorn.sock localhost
      • should see a JSON payload from skunk
    • sudo systemctl status gunicorn
  6. Configure nginx(8) reverse proxy
    • Install nginx(8) if not already present
      • sudo apt-get install nginx
    • cp reverse-proxy.conf /etc/nginx/sites-available
    • ln /etc/nginx/sites-available/reverse-proxy.conf /etc/nginx/sites-enabled
    • rm /etc/nginx/sites-enabled/default
    • sudo systemctl restart nginx
  7. mellow-skunk should now be responding at http://localhost

configuration

  1. Define the host.
  2. Define a task.

URL

URL Verb Payload
/heeler/ get, post JSON Example
/host get, post JSON
/hyena/ get, post JSON Example
/groups get JSON
/metrics get Prometheus Text Example
/poodle/ get, post JSON
/task/ get, post JSON
/users get, post JSON

Relevant Links