-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck_zfs_snapshot.py
executable file
·81 lines (62 loc) · 1.93 KB
/
check_zfs_snapshot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#! /usr/bin/env python3
import argparse
from typing import cast
# from nagiosplugin.runtime import guarded
__version__: str = "1.2"
class OptionContainer:
pass
opts: OptionContainer = OptionContainer()
def get_argparser() -> argparse.ArgumentParser:
parser: argparse.ArgumentParser = argparse.ArgumentParser(
prog="check_zfs_snapshot", # To get the right command name in the README.
formatter_class=lambda prog: argparse.RawDescriptionHelpFormatter(
prog, width=80
), # noqa: E501
description="Copyright (c) 2016-22 Josef Friedrich <[email protected]>\n"
"\n"
"Monitoring plugin to check how long ago the last snapshot of a ZFS dataset was created.\n", # noqa: E501
epilog="Performance data:\n"
" - last_ago\n"
" Time interval in seconds for last snapshot.\n"
" - warning\n"
" Interval in seconds.\n"
" - critical\n"
" Interval in seconds.\n"
" - snapshot_count\n"
" How many snapshot exists in the given dataset and all child\n"
" datasets exists.\n",
)
parser.add_argument(
"-c",
"--critical",
help="Interval in seconds for critical state.",
)
parser.add_argument(
"-d",
"--dataset",
help="The ZFS dataset to check.",
)
parser.add_argument(
"-s",
"--short-description",
help="Show a short description of the command.",
)
parser.add_argument(
"-v",
"--version",
action="version",
version="%(prog)s {}".format(__version__),
)
parser.add_argument(
"-w",
"--warning",
help="Interval in seconds for warning state. Must be lower than -c",
)
return parser
# @guarded(verbose=0)
def main():
pass
global opts
opts = cast(OptionContainer, get_argparser().parse_args())
if __name__ == "__main__":
main()