Skip to content

Commit

Permalink
Update monitor role to run a daily check for running containers
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkcuys committed Jul 2, 2021
1 parent 540ad8d commit 2db64ed
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
16 changes: 0 additions & 16 deletions roles/knight-rabbitmq/tasks/main.yml

This file was deleted.

2 changes: 0 additions & 2 deletions roles/learningcircles-app/files/robots.txt

This file was deleted.

19 changes: 19 additions & 0 deletions roles/monitor/files/p2pu-netwell/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,22 @@
Path('/').free_space(gb=2)
#Path('/var/log/syslog').modified_within(hours=1)
#Repo('/home/deploy/src/project').is_clean()

import docker
import os
DOMAIN = os.environ.get('DOMAIN')
client = docker.from_env()
containers = [c.name for c in client.containers.list()]
expected_container = [
'p2pu-nginx',
f'{DOMAIN}-celerybeat',
f'{DOMAIN}-celery',
f'{DOMAIN}',
'nginx-letsencrypt-companion',
'learningcircles-rabbitmq',
'p2pu-postgres',
'fluentd',
]
for c in expected_container:
oknotok = "OK" if c in containers else "ERROR"
print(f'Checking that docker container {c} is running: {oknotok}')
2 changes: 2 additions & 0 deletions roles/monitor/files/p2pu-netwell/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
certifi==2020.6.20
chardet==3.0.4
docker==5.0.0
idna==2.10
netwell==0.4.0
python-dateutil==2.8.1
requests==2.24.0
six==1.15.0
urllib3==1.25.10
websocket-client==1.1.0
2 changes: 1 addition & 1 deletion roles/monitor/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
name: "check dirs"
minute: "0"
hour: "2"
job: "docker run --rm -t --env-file /usr/local/etc/p2pu-netwell.env p2pu/netwell-mailer"
job: "docker run -v /var/run/docker.sock:/var/run/docker.sock:ro --rm -t --env-file /usr/local/etc/p2pu-netwell.env p2pu/netwell-mailer"

0 comments on commit 2db64ed

Please sign in to comment.