ismvru / zbx-tmplt-pbs

Zabbix template for Proxmox backup server
GNU Affero General Public License v3.0
27 stars 6 forks source link

Question about permissions - Response code "403" did not match any of the required status codes "200" #1

Closed greavette closed 1 year ago

greavette commented 2 years ago

Hello,

Thanks very much for making this template available for all to use. I very much appreciate your work! This template along with your PVE by HTTP are a game changer to help manage Proxmox...Great work!

I'm having an issue with some of the items from the PBS template. I'm receiving two types of errors:

Response code "400" did not match any of the required status codes "200" and Response code "403" did not match any of the required status codes "200"

In fact most of the items for this template are empty while some have an error. I'm thinking I have a permission problem. I've followed your ReadMe and added the necessary permissions. Can you provide any feedback for me on why most of the items from this template are empty and what added permissions would I need to add to get these errors resolved?

image

Thank you.

ismvru commented 2 years ago

Hello!

Please send me a screenshot of the Configuraion -> Access Control -> Permissions menu

Most likely, the user under which the template goes to the PBS API does not have enough permissions...

Minimal needed permissions for user:

/datastore - Audit /system/status - Audit /system/tasks - Audit

greavette commented 2 years ago

Hello @vashvampir ,

Thanks very much for your reply to my post and github post...I really appreciate your input and for providing this template for all to use.

I've added more than what was required to the permissions on my PBS server. I've added Admin in fact to each of the 3 Path's you've mentioned and even added Admin to "/" for my API Token user I created.

image

Unfortunately my Zabbix still has the same issues with authentication errors. For example item "PBS: Node status" still has the following error: Response code "403" did not match any of the required status codes "200"

I've confirmed that the PBS.Node.Name and PBS.Token.ID, PBS.Token.Secret and Host.Conn are all correct. But when I test I see the above error:

image

I do receive some values from the PBS template so my token must be working in some respects. But for example if I look at the item "PBS Datastore: pbs-ds-01 total" does return a value for me but there is no way to Test and see what macro's are being used?

Do you know what in the Template enables the Test button on an item from Latest Data?

image

Or another example, the item "PBS: Datastores usage" does return data from my PBS server when I test:

I've confirmed that the values in PBS.Token.ID, PBS.Token.Secret and Host.Code are the same in this Item test to the above item test. I notice in the above screenshot there is an extra macro used PBS.Node.Name. Not sure why one item test works and the other has an error.

image

Thank you!

ismvru commented 2 years ago

Hello! Testing items in this template is possible only for items with the HTTP Agent type:

The remaining items are taken from them by parsing the above items.

If it's not difficult, can you throw off the exact text of the errors from the Zabbix server log, the version of Zabbix itself and the PBS version? I'll test it and see what could go wrong.

greavette commented 2 years ago

Hello,

Thank you for your explanation as to why some of the items are testable from the latest data > configuration of the item. I think another reason is because of the error I'm receiving on some items and there is a dependency from an item where I'm receiving the access error.

I'd be happy to share the information you requested. Hopefully this is what you are looking for.

From my /var/log/zabbix/zabbix_server.log.1 file I see the following error when Zabbix is trying to connect to my PBS server swaspbs1:

677:20221025:125915.340 error reason for "swaspbs1:pve.cluster.status" changed: Response code "403" did not match any of the required status codes "200"

My Zabbix server is version 6.0.9

My PBS Server is version 2.2-6

Thank you!

jcz1 commented 1 year ago

Hello.

I think problem is in the {$PBS.NODE.NAME} macro. Because API URL for tasks is /api2/json/nodes/{node}/tasks you must have exact node name in macro (same as name in PBS dashboard).

Fix is very easy because API knows "localhost":

  1. Change template default for {$PBS.NODE.NAME} to "localhost" (i made a pull request)
  2. REMOVE {$PBS.NODE.NAME} from monitored host

Anyway thanks for this great template! :-)

jcz1 commented 1 year ago

P.S. API docs: https://pbs.proxmox.com/docs/api-viewer/index.html#/nodes/{node}/tasks

ismvru commented 1 year ago

I'm sorry, didn't have time to do this project. MR accepted, thanks! @greavette Try to test please.