check_tftp
check_tftp is an Icinga2/Nagios plugin which monitors a TFTP server by downloading a file from the server and optionally verifying its contents.
Requires Python 3.6+
Installation
You can install with pip:
python3 -m pip install check-tftp
Or install from source:
git clone https://gitlab.com/cspeterson/check_tftp.git check_tftp.git
pip install check_tftp.git
Usage
usage: check_tftp [-h] [--checksum CHECKSUM | --pattern PATTERN]
[--critical CRITICAL] --hostname HOST [--port PORT]
[--timeout TIMEOUT] [--verbose] [--warning WARNING]
files
check_tftp is an Icinga2/Nagios plugin that monitors a TFTP server by
downloading a file from the server and optionally verifying its
contents
positional arguments:
files The remote path of the file to check
options:
-h, --help show this help message and exit
--checksum CHECKSUM, -k CHECKSUM
MD5 checksum to verify the remote file
--pattern PATTERN, -r PATTERN
Python regular expression to look for in the remote
file. The check will fail if the pattern is not
present.
--critical CRITICAL, -c CRITICAL
Critical range for download duration in seconds
--hostname HOST, -H HOST
The TFTP server address
--port PORT, -p PORT The TFTP server port
--timeout TIMEOUT, -t TIMEOUT
Total transmission timeout for the file transfer.
--verbose, -v Set output verbosity (-v=warning, -vv=debug)
--warning WARNING, -w WARNING
Warning range for download duration in seconds
examples:
# Check that a file can be downloaded from a tftp server:
check_tftp --hostname host.name.tld some.file
# As above, but check for pattern in the file:
check_tftp --hostname host.name.tld --pattern 'some text' some.file
# Or verify the file by md5 checksum:
check_tftp --hostname host.name.tld \
--checksum 75170fc230cd88f32e475ff4087f81d9 some.file
# WARN if download takes longer than 5s, CRIT if longer than 10s:
check_tftp --hostname host.name.tld --warning 5 --critical 10 some.file
# For more on how to set ranges for warning or critical, see Nagios
# Plugin Development Guidelines:
#
# https://nagios-plugins.org/doc/guidelines.html#THRESHOLDFORMAT
Icinga2
Here is an Icinga2 CheckCommand object for this plugin:
object CheckCommand "check_tftp" {
command = [ PluginDir + "/check_tftp", ]
arguments = {
"--checksum" = {
description = "MD5 checksum to verify the remote file"
key = "--checksum"
set_if = "$tftp_checksum$"
value = "$tftp_checksum$"
}
"--critical" = {
description = "Critical range for download duration in seconds"
key = "--critical"
set_if = "$tftp_critical$"
value = "$tftp_critical$"
}
"--hostname" = {
description = "The TFTP server address"
key = "--hostname"
value = "$tftp_hostname$"
}
"--pattern" = {
description = "Python regular expression to look for in the remote file. The check will fail if the pattern is not present."
key = "--pattern"
set_if = "$tftp_pattern$"
value = "$tftp_pattern$"
}
"--port" = {
description = "The TFTP server port"
key = "--port" set_if = "$tftp_port$"
value = "$tftp_port$"
}
"--timeout" = {
description = "Total transmission timeout for the file transfer"
key = "--timeout"
set_if = "$tftp_timeout$"
value = "$tftp_timeout$"
}
"--warning" = {
description = "Warning range for download duration in seconds"
key = "--warning"
set_if = "$tftp_warning$"
value = "$tftp_warning$"
}
file = {
description = "The remote path of the file to check"
required = true
skip_key = true
value = "$tftp_file$"
}
}
vars.tftp_hostname = "$address$"
}
And a minimal example Icinga Service:
}
object Service "host.domain.tld_check" {
import "generic-service"
display_name = "TFTP server verify download"
host_name = "host.domain.tld"
check_command = "check_tftp"
notes = "The `check_tftp` command is a custom plugin to monitor a TFTP server by downloading a file and verifying its contents"
notes_url = "https://gitlab.com/cspeterson/check_tftp"
vars.tftp_file = "any_file_name.txt"
vars.tftp_warning = 5
vars.tftp_critical = 10
vars.tftp_pattern = "your.regex"
}
NOTE on the command path: the above Icinga2 configuration object points to the check_tftp command in Icinga2's configured PluginDir, but this can be configured however you like. For instance:
- point it to wherever it is installed by its full path
- symlink from the specified path to the actual script.
- or take the kludge route, leave it as-is, and copy
check_tftp/__main__.pyfrom this repo intoPluginDir + "/check_tftp"
Up to you!
Contributing
Pull/Merge requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
To run the test suite:
# `all` includes venv creation and installation of dependencies
make
Please make sure to update tests as appropriate.
License
Metadata
Release files for check-tftp 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| check_tftp-0.3.2.tar.gz | 6.4 kB | Without provenance | Details for check_tftp-0.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| check_tftp-0.3.2-py3-none-any.whl | Python 3 | none | any | Details for check_tftp-0.3.2-py3-none-any.whl |
Total release size: 13.4 kB
Release files / check_tftp-0.3.2.tar.gz
| Download URL | check_tftp-0.3.2.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
426d129595bebbc17633066497652c2482b83454b84b823ebf17da1ada89cc98
|
|
BLAKE2b-256 checksum How to use checksums |
e88d1bac5179804409360898de16ebc631f525002c677a2a444de7196068f315
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Release files / check_tftp-0.3.2-py3-none-any.whl
| Download URL | check_tftp-0.3.2-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d26340994d0196f2c40edbc2a9ae9714e20c373f8fed7abba59ad36a996b2c22
|
|
BLAKE2b-256 checksum How to use checksums |
ce101f10dd0e786737c30c32df819fb149e803e4ac5c305f1f770df31efaa9f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Security for check-tftp 0.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.