PatchDashboard / patchdashboard

Patch Management Dashboard
Apache License 2.0
37 stars 16 forks source link

check-in frequency #16

Closed faust64 closed 8 years ago

faust64 commented 8 years ago

Am I right to understand the check-in process would run apt-get every minute? On a few systems, arguably, why not. Hosting tens of VMs per physical host, you may suffer high from IO/wait.

I'm not submitting a pull request, feel free to address this or not, however you see fit, ...

Here's a first suggestion, which will take the last bit of the first IP showing up in ip addr, apply a %60, then configure the check-in crontab to be executed every hour:

patches:~# diff /usr/share/patchdashboard/html/client/client_installer.php /var/www/patches/client/client_installer.php 
44a45,46
>   min=$(expr `ip addr|grep -v 127.0.0|awk '/inet /{print $2;exit}'` : '.*\.\([0-9]*\)/.*')
>   min=$(expr \$min % 60)
46c48
<       echo -e \"* * * * * root \${client_path}check-in.sh >> /dev/null 2>&1\" >>  /etc/cron.d/patch-manager

---
>       echo -e \"\$min * * * * root \${client_path}check-in.sh >/dev/null 2>&1\" >>/etc/cron.d/patch-manager
48c50
<       echo -e \"* * * * * root \${client_path}check-in.sh >> /dev/null 2>&1\" >  /etc/cron.d/patch-manager

---
>       echo -e \"\$min * * * * root \${client_path}check-in.sh >/dev/null 2>&1\" >/etc/cron.d/patch-manager

That's just an idea. I could also suggest something based on what I'm used to do, running pakiti2 on a couple setups I host aside, I have the following /etc/cron.daily/pakiti2:

#!/bin/sh

RANDOM_NUMBER=`od -An -N2 -d /dev/random`
WAIT_TIME=`expr 1 + $RANDOM_NUMBER % \( 240 - 1 \)`
sleep $WAIT_TIME
/usr/sbin/pakiti2-client &>/dev/null

exit 0

Could be relevant in your case as well, I guess.

faust64 commented 8 years ago

my bad, just realizing that the package manager is not invoked on every run Some "SELECT * FROM 'servers' WHERE 'last_checked' < NOW() - INTERVAL 2 HOUR AND.... is used defining check_patches, didn't notice, nice. Nevermind that one, good job.