neuralfraud / grafana-prtg

A PRTG Datasource plugin for Grafana
181 stars 75 forks source link

Passhash not getting set properly in API calls. #131

Closed edjeffreys closed 5 years ago

edjeffreys commented 5 years ago

Currently getting around by hard-coding the passhash in dist/datasource.js Line 56: this.passhash = instanceSettings.jsonData.prtgApiPasshash; to this.passhash = 123456;

neuralfraud commented 5 years ago

On what version of grafana and prtg does this appear to not work?

Sent from my iPhone

On Jul 12, 2019, at 10:03 AM, Ed Jeffreys notifications@github.com wrote:

Currently getting around by hard-coding the passhash in dist/datasource.js Line 56: this.passhash = instanceSettings.jsonData.prtgApiPasshash; to this.passhash = 123456;

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

edjeffreys commented 5 years ago

Grafana v6.2.5 PRTG v19.2 Grafana PRTG plugin v4.0.3

The passhash doesn't seem to populate correctly. According to the URL in chrome network tools; the passhash parameter in the URL populates with [object%20Object] instead of the actual passhash value.

Interestingly; the first call Grafana makes seems to fill the passhash correctly; but every subsequent one does not fill.

I have tried different cache timeouts etc. with no success.

SIM0N-F commented 5 years ago

Hello I have same problem on my grafana.

Grafana v6.2.1 PRTG 19.1.49.1966 Grafana PRTG v4.0.3

And many thanks @edjeffreys for the work around.

ray-haggerty commented 5 years ago

Having the same issue is there a work around?

edjeffreys commented 5 years ago

Currently getting around by hard-coding the passhash in dist/datasource.js Line 56: this.passhash = instanceSettings.jsonData.prtgApiPasshash; to this.passhash = 123456;

This did the trick for me.

ray-haggerty commented 5 years ago

Oh man I'm blind, thanks!

MIKI785 commented 5 years ago

That solution didn't work for me, the issue was on line 169 of dist/PRTGAPIService.js - it overrides the passhash with the response for some reason. Commenting it out fixed it for me.

//_this.passhash = response;

edjeffreys commented 5 years ago

@MIKI785 well spotted! That's a nicer fix.

neuralfraud commented 5 years ago

DO NOT HARD CODE A PASSWORD INTO THE SCRIPT!

Especially if you're using Direct/browser access!

  1. Get the latest version of Grafana
  2. Get the latest version of this plugin (Currently, clone the master branch)
  3. Use Server/Proxy access mode - NOT Browser!
  4. Enter your info and click Save & Test
markuman commented 2 years ago

Currently the same lines of code produces the same error in grafana 8.4.1

https://grafana.....de/api/datasources/proxy/1/table.json?username=prtgadmin&passhash=[object%20Object]&content=groups&count=9999&columns=objid,group,probe,tags,active,status,message,priority 

See &passhash=[object Object] in the request.

polarAli commented 1 year ago

The issue still exists in the plugin