Welcome to rsync_watch’s documentation!¶
- rsync_watch.watch: Watch¶
- exception rsync_watch.StatsNotFoundError(msg: str, **data: Unpack)[source]¶
Bases:
CommandWatcherError
Raised when some stats regex couldn’t be found in stdout.
- rsync_watch.convert_number_to_int(formatted_number: str) int [source]¶
Convert a integer containing commas or dots to a integer without commas or dots.
- Parameters:
comma_integer – a integer containing commas or dots
- Returns:
A integer without commas or dots
- rsync_watch.parse_stats(stdout: str) Dict[str, int | float] [source]¶
Parse the standard output of the rsync process.
https://github.com/WayneD/rsync/blob/c69dc7a5ab473bb52a575b5803026c2694761084/main.c#L416-L465
- Parameters:
stdout – The standard output of the rsync process
- Returns:
A dictionary containing all the stats numbers.
- rsync_watch.format_service_name(host_name: str, src: str, dest: str) str [source]¶
Format a service name to use as a Nagios or Icinga service name.
- Parameters:
host_name – The hostname of the machine the rsync job running on.
src – A source string rsync understands
dest – A destination string rsync understands
- Returns:
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] [--exclude EXCLUDE]
[--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¶
- src
The source ([[USER@]HOST:]SRC)
- dest
The destination ([[USER@]HOST:]DEST)
Named Arguments¶
- --host-name
The hostname to submit over NSCA to the monitoring.
- --dest-user-group
Both the user name and the group name of the destination will be set to this name.
- --exclude
See the documention of –exclude in the rsync manual.
- --rsync-args
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
checks¶
Perform different checks before running the rsync task.
- --action-check-failed
Possible choices: exception, skip
Select action what to do when a check failed.
Default: “skip”
- --check-file
Check if a file exists on the local machine.
- --check-ping
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-ssh-login
Check if a remote host is reachable over the network by SSHing into it. SSH_LOGIN: “root@192.168.1.1” or “root@example.com” or “example.com”.