From 881c76757188299640cb7e9a14675b083341c18c Mon Sep 17 00:00:00 2001 From: cmk-bonobo Date: Mon, 27 Mar 2023 15:12:48 +0200 Subject: [PATCH] Version 2.3.1, Bug fix paramater handling --- README.md | 1 + .../check_mk/agents/special/agent_nextcloud | 65 +++++++++++------- mkp/Nextcloud-2.3.1.mkp | Bin 0 -> 9907 bytes 3 files changed, 40 insertions(+), 26 deletions(-) create mode 100755 mkp/Nextcloud-2.3.1.mkp diff --git a/README.md b/README.md index 661d740..d56569f 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Version History: -- |Date|Version|Changes| |----|-------|-------| +|2023/03/27|2.3.1|Fixed bugs in parameter handling| |2023/03/23|2.2.1|Adjusted parameter handling| |||Added check for "free space on disk" (incl. adjustable levels)| |||Added adjustable levels for "number of files"| diff --git a/local/share/check_mk/agents/special/agent_nextcloud b/local/share/check_mk/agents/special/agent_nextcloud index 9d5bdba..6160272 100755 --- a/local/share/check_mk/agents/special/agent_nextcloud +++ b/local/share/check_mk/agents/special/agent_nextcloud @@ -19,18 +19,20 @@ USAGE: agent_nextcloud_info -u [username] -p [password] agent_nextcloud_info -h OPTIONS: - -H, --hostname Hostname (FQDN or IP) of Nextcloud server - -u, --username Username - -p, --password Password - -P, --port Port - -f, --folder Subfolder if not installed in web root - -t, --token Token (recommended) - --no-https Disable HTTPS, use HTTP (not recommended!) - --no-cert-check Disable TLS certificate check (not recommended!) - -h, --help Show this help message and exit + -H, --hostname Hostname (FQDN or IP) of Nextcloud server + -u, --username Username + -p, --password Password + -P, --port Port + -f, --folder Subfolder if not installed in web root + -t, --token Token (recommended) + --no-https True|False If "True": Disable HTTPS, use HTTP (not recommended!) + --no-cert-check True|False If "True": Disable TLS certificate check (not recommended!) + -h, --help Show this help message and exit """) # set this to true to produce debug output (this clutters the agent output) +# be aware: activating this logs very sensitive information to debug files in ~/tmp +# !!DO NOT FORGET to delete these files after debugging is done!! DEBUG = False nc_api_endpoint = "ocs/v2.php/apps/serverinfo/api/v1/info?format=json" @@ -48,7 +50,7 @@ opt_no_cert_check = False short_options = 'hH:u:p:P:f:t:' long_options = [ - 'hostname=', 'username=', 'password=', 'port=', 'token=', 'folder=', 'no-https', 'no-cert-check', 'help' + 'hostname=', 'username=', 'password=', 'port=', 'token=', 'folder=', 'no-https=', 'no-cert-check=', 'help' ] def getOptions(): @@ -65,7 +67,7 @@ def getOptions(): for opt, arg in opts: if opt in ['-H', '--hostname']: opt_hostname = arg - if opt in ['-u', '--username']: + elif opt in ['-u', '--username']: opt_username = arg elif opt in ['-p', '--password']: opt_password = arg @@ -76,28 +78,39 @@ def getOptions(): elif opt in ['-t', '--token']: opt_token = arg elif opt in ['--no-https']: - opt_no_https = True + if arg == 'True': + opt_no_https = True + else: + opt_no_https = False elif opt in ['--no-cert-check']: - opt_no_cert_check = True + if arg == 'True': + opt_no_cert_check = True + else: + opt_no_cert_check = False elif opt in ['-h', '--help']: showUsage() sys.exit(0) - -def showOptions(): - print(f"Hostname: {opt_hostname}") - print(f"Username: {opt_username}") - #print(f"Password: {opt_password}") - print(f"Port: {opt_port}") - print(f"Folder: {opt_folder}") - #print(f"Token: {opt_token}") - print(f"No HTTPS: {opt_no_https}") - print(f"No TLS Check: {opt_no_cert_check}") if DEBUG: home_path = os.getenv("HOME") tmp_path = f"{home_path}/tmp" help_file = f"{tmp_path}/nextcloud_{opt_hostname}_debug.txt" with open(help_file, "a") as file: - file.write(f"Hostname: {opt_hostname}, Port: {opt_port}, No HTTPS: {opt_no_https} \n") + file.write(f"Number of Arguments: {len(sys.argv)}, Argument List: {str(sys.argv)}\n") + +def showOptions(): + print(f"Hostname: {opt_hostname}") + print(f"Username: {opt_username}") + print(f"Password: {opt_password}") + print(f"Port: {opt_port}") + print(f"Folder: {opt_folder}") + print(f"Token: {opt_token}") + print(f"No HTTPS: {opt_no_https}") + print(f"No TLS Check: {opt_no_cert_check}") + home_path = os.getenv("HOME") + tmp_path = f"{home_path}/tmp" + help_file = f"{tmp_path}/nextcloud_{opt_hostname}_debug.txt" + with open(help_file, "a") as file: + file.write(f"Hostname: {opt_hostname}, Port: {opt_port}, No HTTPS: {opt_no_https}, No Cert Check: {opt_no_cert_check}\n") def createUrl(endpoint, hostname, protocol, port, folder): if folder == "": @@ -242,8 +255,6 @@ def doCmkOutputAllUsers(data, verify, hostname, protocol, port, folder): def main(): getOptions() - if DEBUG: - showOptions() if (opt_hostname == ""): sys.stderr.write(f"No hostname given.\n") showUsage() @@ -266,6 +277,8 @@ def main(): else: protocol = "https" port = opt_port + if DEBUG: + showOptions() if (protocol == "http" and port == "443"): sys.stderr.write(f"Combining HTTP with port 443 is not supported.\n") sys.exit(1) diff --git a/mkp/Nextcloud-2.3.1.mkp b/mkp/Nextcloud-2.3.1.mkp new file mode 100755 index 0000000000000000000000000000000000000000..0ac82cbf5c000da60efb4fdc9f000f31a14d4f7d GIT binary patch literal 9907 zcmZvAV{jz^w`7u;U}9&IOl&6;Ol;en*tTukw(W^++qQFK-Fx?|SG!yLcK2V``PWr_ zPWNe|XgE0Q6cQ6Cu)L{&clsNzZnnO7RG z_f$a4>Fkj#VXM@2Y;taAlP5PcnuvWW7_xleB&@X8K?{4I%k!!e1#Ma>A!!sU-% ztoYH1hcUQo4pBFtCzs#@ApzLcymaTgwzYBL+U^b9z2ykGyScgb8|&QTgPa~3M-Dh~ z_m}&()pWKnjM9d@z6!fV(CohLnw!8LwsiGUdiS0V^4}2R%=ruZ_1oriK+U;Y%~*$w z5c!)qHdk-B)ZTj@#=FqC-E}|UjHG!8mq?uCaqOB8%!=0u@)`bx0>6d-kkB#9Zhnsj zz}~8AM6?02ypm;a>_)`q+-J>*d`6McY`Go;!x~0=K3-6uP&;rSY}8`NMNx13X*=3X zXEcA@fLj-melynJBrzB9<~*=D6r~UNX@v7J{knOk2U)5yiv(vEFOF=s=|=L$SRiBb zZ3N2C6qanP%jgd=K}dOCGE68114uW61nhTmyh zfu9oInSzk%K6ENFJg!8R2!Fnkj4a^xmvFUOqnUO?kBM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