Welcome to rsync_watch’s documentation!¶
-
class
rsync_watch.
Checks
(raise_exception=True)[source]¶ Bases:
object
Collect multiple check results.
- Params boolean raise_exception
Raise exception it some checks have failed.
-
check_file
(file_path)[source]¶ Check if a file exists.
- Parameters
file_path (string) – The file to check.
-
check_ping
(dest)[source]¶ Check if a remote host is reachable by pinging to it.
- Parameters
dest (string) – A destination to ping to.
-
check_ssh_login
(ssh_host)[source]¶ Check if the given host is online by retrieving its hostname.
- Parameters
ssh_host (string) – A ssh host string in the form of: user@hostname or hostname or alias (as specified in ~/.ssh/config)
- Returns
True or False
- Return type
boolean
-
property
messages
¶ - Returns
A concatenated string containing all messages of all failed checks.
- Return type
string
-
exception
rsync_watch.
StatsNotFoundError
(msg, **data)[source]¶ Bases:
jflib.command_watcher.CommandWatcherError
Raised when some stats regex couldn’t be found in stdout.
-
rsync_watch.
comma_int_to_int
(comma_integer)[source]¶ Convert a integer containing commas to a integer without commas.
- Parameters
comma_integer (string) – a integer containing commas
- Returns
A integer without commas
- Return type
-
rsync_watch.
parse_stats
(stdout)[source]¶ Parse the standard output of the rsync process.
- Parameters
stdout (string) – The standard output of the rsync process
- Returns
A dictionary containing all the stats numbers.
- Return type
-
rsync_watch.
service_name
(host_name, src, dest)[source]¶ Format a service name to use as a Nagios or Icinga service name.
- Parameters
host_name (string) – The hostname of the machine the rsync job running on.
src (string) – A source string rsync understands
dest (string) – A destination string rsync understands
- Returns
The service name
- Return type
string
A Python script to monitor the execution of a rsync task.
usage: rsync-watch.py [-h] [--host-name HOST_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¶
- 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.
- --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”.