matoH12 / checkmk-nextcloud

checkmk plugin for nextcloud.
6 stars 0 forks source link

MKFetcherError #4

Open LordWurstebrot opened 2 years ago

LordWurstebrot commented 2 years ago

Hi @matoH12

first of all thanks for providing this plugin!

When I try to use the special agent I get the following error:

Fetching 'agent'... Failed: Failed to fetch data from subdomain.domain.de: Error(MKFetcherError('Agent exited with code 1: Traceback (most recent call last):\n File "/omd/sites/monitoring/local/share/check_mk/agents/special/agent_nextcloud_data", line 129, in <module>\n print("Version: %s" % data[\'ocs\'][\'data\'][\'nextcloud\'][\'system\'][\'version\'])\nTypeError: list indices must be integers or slices, not str'))

Would be awesome when you could help me fix this error.

matoH12 commented 2 years ago

Can you send me output json from API ? https://my.nextcloud.com/ocs/v2.php/apps/serverinfo/api/v1/info Im interest version section. For example: `

24.0.6.1`
LordWurstebrot commented 2 years ago

Hi, thanks for your help.

nextcloud_api.zip

I noticed the following error, when viewing the api output:

`Parse error on line 1:

matoH12 commented 2 years ago

Im see error on first message with "system version" and second is with "status" ? You use latest version of plugins ? If you can try run check plugin manualy: /omd/sites/h12/local/share/check_mk/agents/special/agent_nextcloud_data -u admin -p pass --no-cert-check data.mhasin.sk you use RAW or enterprice version ?

LordWurstebrot commented 2 years ago

Version of plugin cmk_version_plugin

CMK (free / enterprice) version cmk_version

Output of your comand output_comand

Hope this helps.

matoH12 commented 2 years ago

Yes im see you dont have installed python module requests. Can you try install this via pip and run special agent again? command: pip3 install requests

LordWurstebrot commented 2 years ago

Now I get the following output:

<<<check_mk>>> Traceback (most recent call last): File "/omd/sites/monitoring/local/share/check_mk/agents/special/agent_nextcloud_data", line 129, in <module> print ("Version: %s" % data['ocs']['data']['nextcloud']['system']['version']) KeyError: 'nextcloud'

matoH12 commented 2 years ago

Interesting bug. If you open "download agent output" you see correct data from nextcloud ? Example:

data1 data2

LordWurstebrot commented 2 years ago

Output:

Fetching 'agent'... Failed: Failed to fetch data from sub.domain.de: Error(MKFetcherError('Agent exited with code 1: Traceback (most recent call last):\n File "/omd/sites/monitoring/local/share/check_mk/agents/special/agent_nextcloud_data", line 129, in \n print("Version: %s" % data[\'ocs\'][\'data\'][\'nextcloud\'][\'system\'][\'version\'])\nKeyError: \'nextcloud\''))

Job finished.

LordWurstebrot commented 2 years ago

Are those setting right?

1 2
matoH12 commented 2 years ago

Can you run special agent manualy again ? get good output ? So im thing the problem is in username and password ? can you try this commant too: curl -u admin:"password" https://data.mhasin.sk/ocs/v2.php/apps/serverinfo/api/v1/info

matoH12 commented 2 years ago

Ok im know where is problem.... Can you specify URL address in DNS hostname or IP address. In the default the URL address is read from name of host and you can specify custom URL address for nextcloud.

LordWurstebrot commented 2 years ago

Can you run special agent manualy again ? get good output ? So im thing the problem is in username and password ? can you try this commant too: curl -u admin:"password" https://data.mhasin.sk/ocs/v2.php/apps/serverinfo/api/v1/info

grafik

matoH12 commented 2 years ago

can you specify this option. Its URL address or IP address of nexcloud server

obrázok

LordWurstebrot commented 2 years ago

Okay I changed it

3

but I get the same error: Failed: Failed to fetch data from sub.domain.de: Error(MKFetcherError('Agent exited with code 1: Traceback (most recent call last):\n File "/omd/sites/monitoring/local/share/check_mk/agents/special/agent_nextcloud_data", line 129, in \n print("Version: %s" % data['ocs']['data']['nextcloud']['system']['version'])\nKeyError: 'nextcloud''))

matoH12 commented 2 years ago

ach :( So im dont know becouse im saw the variable nextcloud in you CSV you have... So can you coment the line Version: %s" % data['ocs']['data']['nextcloud']['system']['version'] in the special agent file /omd/sites/monitoring/local/share/check_mk/agents/special/agent_nextcloud_data and then run again. In my instalation everything work. So im saw you use version 1.2.2 can you try 1.2.3 version ?

LordWurstebrot commented 2 years ago

I did the update to 1.2.3 and comment line Version: ...

Now I get this error: Failed: Failed to fetch data from cloud.domain.de: Error(MKFetcherError("Program '/omd/sites/monitoring/local/share/check_mk/agents/special/agent_nextcloud_data' not found (exit code 127)"))

matoH12 commented 2 years ago

Hi sorry for delay. Im try install clear version och checkmk and nextcloud plugin version 1.2.3 and everything work great. So you try detelete the plugin detele everything files from plugins from system and then install the plugins again.

LordWurstebrot commented 2 years ago

Hi no problem. I will do it later today. How is you CMK setup?

I am running CMK in a Ubuntu 22.04 LXD Container on a QNAP NAS.

Dose the Plugin need any special ports open maybe?

matoH12 commented 2 years ago

So im try docker version, clear ubuntu virtual and plugin work. So you need:

  1. HTTPS connect to nextcloud server (check if you have connect from checkmk to nextcloud via CURL. )
  2. admin account what have permission to read data from API on nextcloud
  3. in checkmk you need configure admin account as parameter for plugin nextcloud
  4. if dont have SSL certificate you can disable certificate verification.
  5. check if you have installed python requests library

If you can try manualy check if everything work run this command with you parameter (username, password, URL): /omd/sites/h12/local/share/check_mk/agents/special/agent_nextcloud_data -u admin -p pass --no-cert-check data.mhasin.sk

LordWurstebrot commented 2 years ago

Hi, sorry for the late answer:

I think the problem is with my nextcloud setup. Because if I load up the serverinfo api in my browser I works fine and I get the values as json output. But if I use CURL (HTTPS) with user and password option I get the following error:

1) {"ocs":{"meta":{"status":"failure","statuscode":401,"message":null},"data":{"mes

2) Yes as I can see it from the browser

3) Yes I did. Its the same user I use in the browser

4) Nextcloud has a SSL certificate but CMK has none because I only access it from my internal network

5) Yes reinstall it to be sure

LordWurstebrot commented 2 years ago

I have now reinstalled everything and run the command with my data /omd/sites/h12/local/share/check_mk/agents/special/agent_nextcloud_data -u admin -p pass --no-cert-check data.mhasin.sk

Output: /usr/bin/env: ‘python1’: No such file or directory

I tried to install python-is-python3 but I get the same Error

matoH12 commented 2 years ago

interesting because the plugin use python3 no python1 or python2.... Its define in header of file #!/usr/bin/env python3 Im develop version 1.2.4 where is bug for RAW version of checkmk... Can you try it ? The problem report @nate386

LordWurstebrot commented 2 years ago

I updated the plugin to 1.2.4. Now I get the following error:

Error shown on terminal:

<<<check_mk>>> Traceback (most recent call last): File "/omd/sites/monitoring/local/share/check_mk/agents/special/agent_nextclou d_data", line 133, in <module> print("Version: %s" % data['ocs']['data']['nextcloud']['system']['version']) KeyError: 'nextcloud'

Error shown on CMK:

Error(MKFetcherError('Agent exited with code 1: Traceback (most recent call last):\n File "/omd/sites/monitoring/local/share/check_mk/agents/special/agent_nextcloud_data", line 133, in <module>\n print("Version: %s" % data[\'ocs\'][\'data\'][\'nextcloud\'][\'system\'][\'version\'])\nTypeError: list indices must be integers or slices, not str'))

I got 2FA enabled for my nextcloud instance. Coud this be a Problem?

matoH12 commented 2 years ago

Yes the 2FA is not support but in new version im add support for TOKEN authorization. Install version https://github.com/matoH12/checkmk-nextcloud/blob/main/nextcloud-1.3.mkp and set token on nextcloud server occ config:app:set serverinfo token --value yourtoken

LordWurstebrot commented 1 year ago

Hi, sorry for the late answer. I did as you said but I only get the ping status:

nextcloud_host

I use this config:

nextcloud_config

Job status:

nextcloud_job
matoH12 commented 1 year ago

Hi, interesting what you see after click download output data ? You see nextcloud data plugin output

LordWurstebrot commented 1 year ago

No, it's just a empty .txt file.