mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
squash! squash! [ssl-certificate-expiry] Add asynchronous update via cron
* use find to detect only recent cache files * reduce cron periodicity to an hour * use variable instead of TMP file
This commit is contained in:
parent
793b75b9ee
commit
7e995a0210
1 changed files with 10 additions and 8 deletions
|
@ -39,9 +39,13 @@ of the hosts are slow.
|
||||||
|
|
||||||
To do so, add a cron job running the plugin with cron as the argument:
|
To do so, add a cron job running the plugin with cron as the argument:
|
||||||
|
|
||||||
*/5 * * * * <user> /usr/sbin/munin-run/ssl-certificate-expiry cron
|
<minute> * * * <user> /usr/sbin/munin-run/ssl-certificate-expiry cron
|
||||||
|
|
||||||
<user> should be the user that has write permission to the MUNIN_PLUGSTATE.
|
<user> should be the user that has write permission to the MUNIN_PLUGSTATE.
|
||||||
|
<minute> should be a number between 0 and 59 when the check should run every hour.
|
||||||
|
|
||||||
|
If, for any reason, the cron script stops running, the script will revert to
|
||||||
|
uncached updates after the cache file is older than an hour.
|
||||||
|
|
||||||
=head1 AUTHORS
|
=head1 AUTHORS
|
||||||
|
|
||||||
|
@ -120,6 +124,7 @@ main() {
|
||||||
valid_days=$(print_expire_days "$host" "$port")
|
valid_days=$(print_expire_days "$host" "$port")
|
||||||
[ -z "$valid_days" ] && valid_days="U"
|
[ -z "$valid_days" ] && valid_days="U"
|
||||||
printf "%s.value %s\\n" "$fieldname" "$valid_days"
|
printf "%s.value %s\\n" "$fieldname" "$valid_days"
|
||||||
|
echo "${fieldname}.extinfo Last checked: $(date)"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,19 +144,16 @@ case ${1:-} in
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
cron)
|
cron)
|
||||||
TMP=$(mktemp "${CACHEFILE}.XXXXXXXX")
|
UPDATE="$(main)"
|
||||||
trap 'rm -f "${TMP}"' EXIT
|
echo "${UPDATE}" > "${CACHEFILE}"
|
||||||
main > "${TMP}"
|
chmod 0644 "${CACHEFILE}"
|
||||||
chmod 0644 "${TMP}"
|
|
||||||
mv "${TMP}" "${CACHEFILE}"
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ -e "${CACHEFILE}" ]; then
|
if [ -n "$(find "${CACHEFILE}" -mmin -60 2>/dev/null)" ]; then
|
||||||
cat "${CACHEFILE}"
|
cat "${CACHEFILE}"
|
||||||
rm "${CACHEFILE}"
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue