MIRMON(1)

πŸŽ€ hi bestie, welcome to mirmon(1) πŸŽ€

okay so this is the User Contributed Perl Documentation page for mirmon, and it lives in section 1 of the manual. it's the mirror-monitoring girlie and she is so good at her job. buckle up, we're going through every single option and config key together, no skipping, no cap. πŸ’…


✨ NAME ✨

mirmon β€” monitor the state of mirrors πŸͺžπŸ‘‘


🌸 SYNOPSIS 🌸

mirmon [-v] [-q] [-t timeout] [-c conf] [-get all|update|url url]

that's the whole vibe. short, iconic, does exactly what it says. πŸ’–


πŸ’œ OPTIONS πŸ’œ

  • -v β€” be verbose. bestie, mirmon is normally a chill low-key queen: she only reports errors and changes in the mirror list. with -v she starts actually talking.
  • -q β€” be quiet. 🀫
  • -t timeout β€” set the timeout. the default is 300.
  • -get all | update | url <url> β€” pick your adventure:
    • with all, probe all sites. go off.
    • with update, probe a selection of the sites β€” see option max_poll below for how that selection is chosen.
    • with url, probe only the given url, which must appear in the mirror-list.
  • -c name β€” use config file name. the default list is
./mirmon.conf $HOME/.mirmon.conf /etc/mirmon.conf

🌈 USAGE 🌈

the program is intended to be run by cron every hour. like, that's her whole schedule, she's booked and busy:

42 * * * * perl /path/to/mirmon -get update

she quietly probes a subset of the sites in a given list, writes the results in the state file and generates a web page with the results. the subset contains the sites that are new, bad and/or not probed for a specified time. she's doing a vibe check on the whole roster, but efficiently. πŸ’…

when no get option is specified, the program just generates a new web page from the last known state. no probing, just arts and crafts. 🎨

the program checks the mirrors by running a (user specified) program on a pipe. a (user specified) number of probes is run in parallel using nonblocking IO. when something can be read from the pipe, it switches the pipe to blocking IO and reads one line from the pipe. then it flushes and closes the pipe. no attempt is made to kill the probe. πŸ’€

lowkey important: no attempt is made to kill the probe. mirmon just walks away. it's giving "not my problem" energy and honestly? valid.

the probe should return something that looks like

1043625600 ...

that is, a line of text starting with a timestamp. the exit status of the probe is ignored. she literally does not care. πŸ™ˆ


πŸ¦‹ CONFIG FILE πŸ¦‹

πŸ“ location

a config file can be specified with the -c option. if -c is not used, the program looks for a config file in

  • ./mirmon.conf
  • $HOME/.mirmon.conf
  • /etc/mirmon.conf

first one she finds, she commits to. πŸ’–

✍️ syntax

a config file looks like this :

+--------------------------------------------------
|# lines that start with '#' are comment
|# blank lines are ignored too
|# tabs are replaced by a space
|
|# the config entries are 'key' and 'value' pairs
|# a 'key' begins in column 1
|# the 'value' is the rest of the line
|somekey  A_val B_val ...
|otherkey X_val Y_val ...
|
|# indented lines are glued
|# the next three lines mean 'somekey part1 part2 part3'
|somekey part1
|  part2
|  part3
|
|# lines starting with a '+' are concatenated
|# the next three lines mean 'somekey part1part2part3'
|somekey part1
|+ part2
|+ part3
|
|# lines starting with a '.' are glued too
|# don't use a '.' on a line by itself
|# 'somekey' gets the value "part1\n part2\n part3"
|somekey part1
|. part2
|. part3
+--------------------------------------------------

okay so the takeaway: indented lines get glued with spaces, + lines get concatenated with no space, . lines get glued with newlines. and don't use a . on a line by itself. periodt. πŸ’…

πŸ‘‘ required entries

  • project_name name β€” specify a short plaintext name for the project.
project_name Apache
project_name CTAN
  • project_url url β€” specify an url pointing to the 'home' of the project.
project_url http://www.apache.org/
  • mirror_list file-name β€” specify the file containing the mirrors to probe.
mirror_list /path/to/mirror-list

if your mirror list is generated by a program, use

mirror_list /path/to/program arg1 ... |

two formats are supported :

  • plain : lines like
us http://www.tux.org/ [email] ...
nl http://apache.cs.uu.nl/dist/ [email] ...
nl rsync://archive.cs.uu.nl/apache-dist/ [email] ...
  • apache : lines like those in the apache mirrors.list
ftp  us ftp://ftp.tux.org/pub/net/apache/dist/ user@tux.org ...
http nl http://apache.cs.uu.nl/dist/ user@cs.uu.nl ...

note that in style plain the third item is reserved for an optional email address : the site's contact address. πŸ“§

specify the required format with option list_style (see below). the default style is plain.

  • web_page file-name β€” specify where the html report page is written. ✨
  • icons directory-name β€” specify the directory where the icons can be found, relative to the web_page, or relative to the DOCUMENTROOT of the web server.

if/when the web_page lives in directory .../mirmon/ and the icons live in directory .../mirmon/icons/, specify

icons icons

if/when the icons live in /path/to/DOCUMENTROOT/icons/mirmon/, specify

icons /icons/mirmon
  • probe program + arguments β€” specify the program+args to probe the mirrors. example:
probe /usr/bin/wget -q -O - -T %TIMEOUT% -t 1 %URL%TIME.txt

before the program is started, %TIMEOUT% and %URL% are substituted with the proper timeout and url values.

here it is assumed that each hour the root server writes a timestamp in /path/to/archive/TIME.txt, for instance with a crontab entry like

42 * * * * perl -e 'print time, "\n"' > /path/to/archive/TIME.txt

mirmon reads one line of output from the probe and interprets the first word on that line as a timestamp ; for example :

1043625600
1043625600 Mon Jan 27 00:00:00 2003
1043625600 www.apache.org Mon Jan 27 00:00:00 2003

mirmon is distributed with a program probe that handles ftp, http and rsync urls. 🫢

  • state file-name β€” specify where the file containing the state is written.

the program reads this file on startup and writes the file when mirrors are probed (-get is specified).

  • countries file-name β€” specify the file containing the country codes ; the file should contain lines like
us - United States
nl - Netherlands

the mirmon package contains a recent ISO list. 🌍

fake domains like Backup, Master are allowed, and are listed first in the report ; lowercase-first fake domains (like backup) are listed last. noted. πŸ’…

🌟 optional entries

  • max_probes number β€” optionally specify the number of parallel probes (default 25).
  • timeout seconds β€” optionally specify the timeout for the probes (default 300).

after the last probe is started, the program waits for <timeout> + 10 seconds, cleans up and exits. so it's timeout plus a lil ten-second grace period, she's not rude. πŸŽ€

  • project_logo logo β€” optionally specify (the SRC of the IMG of) a logo to be placed top right on the page.
project_logo /icons/apache.gif
project_logo http://www.apache.org/icons/...
  • htm_head html β€” optionally specify some HTML to be placed before </HEAD>.
htm_head
  <link REL=StyleSheet HREF="/style.css" TYPE="text/css">
  • htm_top html β€” optionally specify some HTML to be placed near the top of the page.
htm_top testing 1, 2, 3
  • htm_foot html β€” optionally specify HTML to be placed near the bottom of the page.
htm_foot
  <HR>
  <A HREF="..."><IMG SRC="..." BORDER=0></A>
  <HR>
  • put_histo top|bottom|nowhere β€” optionally specify where the age histogram must be placed. the default is top.
  • min_poll time-spec β€” for min_poll see next item. a time-spec is a number followed by a unit s (seconds), or m (minutes), or h (hours), or d (days). for example 3d (three days) or 36h (36 hours). ⏰
  • max_poll time-spec β€” optionally specify the maximum probe interval. when the program is called with option -get update, all sites are probed which are :
    • new β€” the site appears in the list, but there is no known state. ✨ brand new girlie
    • bad β€” the last probe of the site was unsuccessful. 😭
    • old β€” the last probe was more than max_poll ago.

sites are not probed if the last probe was less than min_poll ago. so, if you specify

min_poll 4h
max_poll 12h

the 'reachable' sites are probed twice daily and the 'unreachable' sites are probed at most six times a day. balanced. πŸ’…

the default min_poll is 1h (1 hour). the default max_poll is 4h (4 hours).

  • min_sync time-spec β€” optionally specify how often the mirrors are required to make an update.

the default min_sync is 1d (1 day).

  • max_sync time-spec β€” optionally specify the maximum allowable sync interval.

sites exceeding the limit will be considered 'old'. the default max_sync is 2d (2 days).

  • always_get region ... β€” optionally specify a list of regions that must be probed always.
always_get Master Tier1

this is intended for fake regions like Master etc. πŸ‘‘

  • no_randomize β€” mirmon tries to balance the probe load over the hourly mirmon runs. if the current run has a below average number of mirrors to probe, mirmon probes a few extra, randomly chosen mirrors, picked from the runs that have the highest load.

if you don't want this behaviour, use no_randomize.

  • no_add_slash β€” if the url part of a line in the mirror_list doesn't end in a slash (/), mirmon adds a slash and issues a warning unless it is in quiet mode.

if you don't want this behaviour, use no_add_slash.

  • list_style plain|apache β€” optionally specify the format (plain or apache) of the mirror-list.

see the description of mirror_list above. the default list_style is plain.

  • site_url site url β€” optionally specify a substitute url for a site.

when access to a site is restricted (in Australia, for instance), another (sometimes secret) url can be used to probe the site. the <site> of an url is the part between :// and the first /. 🀫

  • env key value β€” optionally specify an environment variable.
  • include file-name β€” optionally specify a file to include.

the specified file is processed 'in situ'. after the specified file is read and processed, config processing is resumed in the file where the include was encountered. the include depth is unlimited. however, it is a fatal error to include a file twice under the same name. πŸ’€

  • show β€” when the config processor encounters the show command, it dumps the content of the current config to standout, if option -v is specified. this is intented for debugging. πŸ”
  • exit β€” when the config processor encounters the exit command, it terminates the program. this is intented for debugging. πŸšͺ

okay bestie, that's part 1 β€” and there is more coming, so don't go anywhere. πŸ’–

πŸ’Ύ STATE FILE FORMAT πŸ’Ύ

okay so bestie, the state file is literally just lines β€” one line per site. Each line is white-space-separated fields, and there are seven of them. Here's the whole lineup:

  • field 1 : url β€” the url as given in the mirror list. 🫢
  • field 2 : age β€” the mirror's timestamp found by the last successful probe, or 'undef' if no probe was ever successful. πŸ’€
  • field 3 : status last probe β€” the status of the last probe, or 'undef' if the mirror was never probed. πŸ‘€
  • field 4 : time last successful probe β€” the timestamp of the last successful probe or 'undef' if the mirror was never successfully probed. ⏰
  • field 5 : probe history β€” a list of 's' (for success) and 'f' (for failure) characters indicating the result of the probe. New results are appended whenever the mirror is probed. ✨
  • field 6 : state history β€” this one's the drama. It's a timestamp, a '-' char, and a list of chars indicating a past status: 's' (fresh), 'b' (oldish), 'f' (old), 'z' (bad) or 'x' (skip). The timestamp indicates when the state history was last updated. The current status of the mirror is determined by the mirror's age and a few configuration parameters (min_sync, max_sync, max_poll). The state history is updated when the mirror is probed. If the last update of the history was less than 24 hours ago, the last status is replaced by the current status. If the last update of the history was more than 24 hours ago, the current status is appended to the history. One or more 'skip's is inserted, if the timestamp is two or more days old (when mirmon hasn't run for more than two days). πŸŒ€
  • field 7 : last probe β€” the timestamp of the last probe, or 'undef' if the mirror was never probed. πŸ•°οΈ

That's the whole state file vibe. No cap.


πŸ› οΈ INSTALLATION πŸ› οΈ

general

  • Note: The (empty) state file must exist before mirmon runs. like, it has to be there first, bestie. 🫑
  • The mirmon repository is here:
https://svn.science.uu.nl/repos/project.mirmon/trunk/
  • The mirmon tarball is here:
http://www.staff.science.uu.nl/~penni101/mirmon/mirmon.tar.gz

installation suggestions

To install and configure mirmon, take the following steps:

  • First, make the webdir:
cd DOCUMENTROOT
mkdir mirmon

For DOCUMENTROOT, substitute the full pathname of the document root of your webserver.

  • Check out the mirmon repository:
cd /usr/local/src
svn checkout REPO mirmon

where

REPO = https://svn.science.uu.nl/repos/project.mirmon/trunk/

or download the package and unpack it.

  • Chdir to directory mirmon:
cd mirmon
  • Create the (empty) state file:
touch state.txt
  • Install the icons in the webdir:
mkdir DOCUMENTROOT/mirmon/icons
cp icons/* DOCUMENTROOT/mirmon/icons
  • Create a mirror list "mirror_list"; use your favorite editor, or genererate the list from an existing database.
nl http://archive.cs.uu.nl/your-project/ contact@cs.uu.nl
uk http://mirrors.this.org/your-project/ mirrors@this.org
us http://mirrors.that.org/your-project/ mirrors@that.org

The email addresses are optional.

  • Create a mirmon config file "mirmon.conf" with your favorite editor.
# lines must start in the first column ; no leading white space
project_name ....
project_url  ....
mirror_list mirror_list
state state.txt
countries countries.list
web_page DOCUMENTROOT/mirmon/index.html
icons /mirmon/icons
probe /usr/bin/wget -q -O - -T %TIMEOUT% -t 1 %URL%TIME.txt

This assumes the project's timestamp is in file "TIME.txt".

  • If you have rsync urls, change the probe line to:
probe perl /usr/local/src/mirmon/probe -t %TIMEOUT% %URL%TIME.txt
  • Run mirmon:
perl mirmon -v -get all

The mirmon report should now be in 'DOCUMENTROOT/mirmon/index.html'

http://www.your.project.org/mirmon/
  • If/when, at a later date, you want to upgrade mirmon:
cd /usr/local/src/mirmon
svn status -u
svn up

πŸ‘€ SEE ALSO πŸ‘€

  • mirmon.pm(3) β€” go read it, bestie. it's giving essential. πŸ’…

πŸ‘‘ AUTHOR πŸ‘‘

shoutout to the legend behind this:

(c) 2003-2016 Henk P. Penning
Faculty of Science, Utrecht University
http://www.staff.science.uu.nl/~penni101/ -- penning@uu.nl
mirmon-2.11 - Sat Jul 23 09:12:31 2016 ; henkp

and that's the whole page, bestie! this was MIRMON(1), built with perl v5.8.8, dated 2016-07-23. periodt. πŸ’–βœ¨