mirrorchecker¶
Introduction¶
mirrorchecker is a small tool that checks if mirror sites are synchronized
with a source site. It uses python3.5
and asyncio
.
It was inspired by mirmon, but unlike mirmon, runs as a daemon in
the background, optionally in a container, and adds some more features.
Notable Features¶
- Check mirror sites freshness by comparing timestamps automatically.
- Retrieve each mirror site status individually using a simple GET request.
- Retrieve all mirror sites status using a GET request.
- Serve the
mirrorlist
file, filtered by mirror synchronization status suited for use with RPM repositories(withyum
ordnf
). - Allows to easily build monitoring alerts(Icinga/Nagios plugin provided).
How does it work?¶
mirrorchecker assumes you have SSH access to the source site (the site which mirror sites connect to, in order to pull updates). mirrorchecker does 4 things:
- Send periodically timestamp files to pre-specified locations in the source site over SFTP.
- Pull periodically the timestamps from the mirror sites URLs.
- Exposes a small async http server, which can be queried to check the status of the mirroring sites, see nagios_alert as an example.
- Optionally, the web server can also serve the
mirrorlist
URL in yum based repositories. This allow to filter mirror sites by the time they were last syncronized.
At its base, it uses the simple concept that if mirroring is working properly, the timestamps ‘planted’ in the source site would reach to the mirror sites.
How does mirrorchecker determines if a mirror site is synchronized?¶
By default, all timestamps are fetched from the mirror sites URLs and compared
to the local time, the maximal difference is set as the last synchronization
time. This is, of course, not accurate, assuming the synchronization is done
with rsync
, it could be that the timestamps files were downloaded
but the synchronization did not finish. However, from my experience this is
usually sufficient. If what you are looking for is an accurate and atomic
synchronization verification, this is not the tool for you.
Installation¶
Make sure you are using
python3.5
(in venv or global) and run:pip install git+http://gerrit.ovirt.org/mirrorchecker.git
Running:
mirror_checker.py
See mirrors.yaml for a working example of the configuration file. See mirrors.txt for a working example of separating the mirror sites lists to a different file(referenced in mirrors.yaml).
Examples¶
- See this for an example of deploying mirrorchecker in a Docker container, as used in the oVirt project.
- For building a monitoring alert: see the nagios plugin: mirrorchecker_nagios_plugin
Development¶
- mirrorchecker works with
python 3.5
, and usesasyncio
andaiohttp
, other than that its only major depdency is paramiko. - The git repository is at: https://gerrit.ovirt.org/mirrorchecker.git
- For general information on how to use gerrit, see here.
- Patches are welcome!