I now have set this up as proposed bei Andreas:
checkmk Main site has additional instance for the ‘satellite’:
master
subsite
For other users, here a quick documentation of the file transfer setup:
On the remote satellite:
/omd/sites/sat/etc/cron.d/our_cronjobs:
# export site configuration and upload to master
*/5 * * * * $OMD_ROOT/local/our-push-config.sh >/dev/null 2>&1
# update status
* * * * * $OMD_ROOT/local/our-push-status.sh >/dev/null 2>&1
our-push-config.sh
#!/bin/bash
cmcdump -C > /opt/omd/sites/$OMD_SITE/tmp/$OMD_SITE.mk &&
curl -s -m 5 -T /opt/omd/sites/$OMD_SITE/tmp/$OMD_SITE.mk https://master.checkmk.server/upload/$OMD_SITE.mk
our-push-status.sh
#!/bin/bash
cmcdump > /opt/omd/sites/${OMD_SITE}/tmp/state &&
curl -s -m 5 -T /opt/omd/sites/${OMD_SITE}/tmp/state https://master.checkmk.server/upload/${OMD_SITE}.state
In the central extra ‘satellite’:
etc/crond/our-import-cronjobs
# import site config and state ASAP
* * * * * local/bin/wait-for-files.sh >/dev/null 2>&1
and the import script itself:
local/bin/wait-for-files.sh
#!/bin/bash
# import status from satellite as soon as possible
# kill this job with 'pkill inotifywait'
LOCK=/tmp/upload.lock
if lockfile -l 1 $LOCK ; then
echo $$ > $LOCK
(
cd $HOME
inotifywait -m -e close_write /omd/upload/ |
gawk '{print $1$3; fflush()}' |
while read f; do
file=$(basename $f)
echo file=$file
case $file in
sat.state)
cat /omd/upload/$file | unixcat tmp/run/live
;;
sat.mk)
cp /omd/upload/$file etc/check_mk/conf.d
cmk -O
;;
esac
done
rm -f $LOCK
)&
disown
else
pid=$(cat $LOCK)
kill $pid
rm -f $LOCK
fi
exit 0
The relevant part of the nginx config (ip restricted; not shown here):
# upload folder for satellites
location ~ "/upload/*(\.state|\.mk)$" {
alias /opt/omd/upload/$1$2;
client_body_temp_path /tmp/upload_tmp;
dav_methods PUT DELETE MKCOL COPY MOVE;
create_full_put_path on;
dav_access group:rw all:r;
}
# proxy to sat local satellite shadow site
location /sat {
proxy_pass http://localhost:5001;
}
The advantage of the inotifywait is that the delay is minimized compared to a cron job running every minute. The cron job is only used to make sure the inotifywait script is running.