Skip to content

Commit

Permalink
bw/bundles/mqtt-monitoring: execute daily tasks independent of normal…
Browse files Browse the repository at this point in the history
… check_system tasks
  • Loading branch information
Kunsi committed Apr 8, 2024
1 parent de7eaaf commit d618f70
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
11 changes: 11 additions & 0 deletions bundlewrap/bundles/mqtt-monitoring/files/check_system_daily.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash


[[ -n "$DEBUG" ]] && set -x

for file in /usr/local/sbin/check_system_daily.d/*.sh
do
if [ -x "${file}" ]; then
. "${file}"
fi
done
9 changes: 4 additions & 5 deletions bundlewrap/bundles/mqtt-monitoring/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
}

files['/usr/local/sbin/alert_shutdown.sh'] = {
'content_type': 'mako',
'mode': '0755',
}

files['/usr/local/sbin/check_system.sh'] = {
'content_type': 'jinja2',
'context': {
'event': node.metadata.get('event'),
},
'mode': '0755',
}

files['/usr/local/sbin/check_system_daily.sh'] = {
'mode': '0755',
}

Expand Down
11 changes: 9 additions & 2 deletions bundlewrap/bundles/mqtt-monitoring/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,16 @@
'check_system_and_send_mqtt_message': {
'command': '/usr/local/sbin/check_system.sh',
'when': 'minutely',
'environment': {
'DAILY_TASK_TIME': str(6+(node.magic_number%3)).rjust(2, '0') + str(node.magic_number%60).rjust(2, '0'),
'requires': {
'network.target',
},
},
'check_system_daily_tasks': {
'command': '/usr/local/sbin/check_system_daily.sh',
'when': '{}:{}:00'.format(
str(6+(node.magic_number%3)).rjust(2, '0'),
str(node.magic_number%60).rjust(2, '0'),
),
'requires': {
'network.target',
},
Expand Down

0 comments on commit d618f70

Please sign in to comment.