Welcome to rsync_watch’s documentation!

class rsync_watch.ChecksCollection(raise_exception: bool = True)[source]

Bases: object

Collect multiple check results.

Params raise_exception

Raise an exception it some checks have failed.

_log_fail(message: str) None[source]
check_file(file_path: str) None[source]

Check if a file exists.


file_path – The file to check.

check_ping(dest: str) None[source]

Check if a remote host is reachable by pinging to it.


dest – A destination to ping to.

check_ssh_login(ssh_host: str) None[source]

Check if the given host is online by retrieving its hostname.


ssh_host – A ssh host string in the form of: user@hostname or hostname or alias (as specified in ~/.ssh/config)

have_passed() bool[source]

True in fall checks have passed else false.

Return type


property messages: str

A concatenated string containing all messages of all failed checks.

exception rsync_watch.StatsNotFoundError(msg, **data)[source]

Bases: CommandWatcherError

Raised when some stats regex couldn’t be found in stdout.

rsync_watch.convert_stat_number_to_int(comma_integer: str) int[source]

Convert a integer containing commas to a integer without commas.


comma_integer – a integer containing commas


A integer without commas

rsync_watch.get_argparser() ArgumentParser[source]

A ArgumentParse object.

Return type


rsync_watch.main() None[source]

Main function. Gets called by entry_points console_scripts.

rsync_watch.parse_stats(stdout: str) Dict[str, Union[int, float]][source]

Parse the standard output of the rsync process.


stdout – The standard output of the rsync process


A dictionary containing all the stats numbers.

rsync_watch.service_name(host_name: str, src: str, dest: str) str[source]

Format a service name to use as a Nagios or Icinga service name.

  • host_name – The hostname of the machine the rsync job running on.

  • src – A source string rsync understands

  • dest – A destination string rsync understands


The service name

A Python script to monitor the execution of a rsync task.

usage: rsync-watch.py [-h] [--host-name HOST_NAME]
                      [--dest-user-group USER_GROUP_NAME]
                      [--rsync-args RSYNC_ARGS]
                      [--action-check-failed {exception,skip}]
                      [--check-file FILE_PATH] [--check-ping DESTINATION]
                      [--check-ssh-login SSH_LOGIN] [-v]
                      src dest

Positional Arguments


The source ([[USER@]HOST:]SRC)


The destination ([[USER@]HOST:]DEST)

Named Arguments


The hostname to submit over NSCA to the monitoring.


Both the user name and the group name of the destination will be set to this name.


Rsync CLI arguments. Insert some rsync command line arguments.Wrap all arguments in one string, for example: –rsync-args ‘–exclude “this folder”’

-v, --version

show program’s version number and exit


Perform different checks before running the rsync task.


Possible choices: exception, skip

Select action what to do when a check failed.

Default: “skip”


Check if a file exists on the local machine.


Check if a remote host is reachable by pinging. DESTINATION can a IP address or a host name or a full qualified host name.


Check if a remote host is reachable over the network by SSHing into it. SSH_LOGIN: “root@” or “root@example.com” or “example.com”.