What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

REST auth token

Votes:

0

Your Vote:

Up

Down

In order to use IBM flashsytem REST API I need to use username and password to get a token and then use the token for following requests

curl -k -X POST -H 'Content-Type:application/json' -H 'X-Auth-Username:prtgapi' -H 'X-Auth-Password:password' https://storage-device:7443/rest/auth
 curl -k -X POST -H 'Content-Type:application/json' -H 'X-Auth-Token:token'  https://st-tulsa:7443/rest/lssystemstats

I also created a REST template to get information from my system:

prtg": {
    "description" : {
      "device": "IBM flashsystem",
      "query": ":7443/rest/lssystemstats",
      "comment": "Documentation is on https://barrywhytestorage.blog/2020/08/03/tips-and-tricks-using-the-spectrum-virtualize-rest-api/"
    },
    "result": [
      {
        "channel": $[0].stat_name ,
        "unit": "%",
        "value": $[0].stat_current
      },
      {
        "channel": $[1].stat_name ,
        "unit": "%",
        "value": $[1].stat_current
      },
	  {
        "channel": $[6].stat_name ,
        "unit": "io",
        "value": $[6].stat_current
      },
	  {
        "channel": $[7].stat_name ,
        "unit": "Mb",
        "value": $[7].stat_current
      },
	  {
        "channel": $[10].stat_name ,
        "unit": "Mb",
        "value": $[10].stat_current
      },
	  {
        "channel": $[11].stat_name ,
        "unit": "io",
        "value": $[11].stat_current
      },
	  {
        "channel": $[12].stat_name ,
        "unit": "ms",
        "value": $[12].stat_current
      },
	  {
        "channel": $[37].stat_name ,
        "unit": "W",
        "value": $[37].stat_current
      },
	  {
        "channel": $[38].stat_name ,
        "unit": "c",
        "value": $[38].stat_current
      }
      

    ]
  }
}

flashsystem ibm rest rest-api rest-custom

Created on May 23, 2021 10:15:42 AM by  Omri (0) 1 1

Last change on May 24, 2021 6:16:36 AM by  Florian Lesage [Paessler Support]



3 Replies

Votes:

0

Your Vote:

Up

Down

Hallo Omri,

Thank you for your message as well as REST template.

Regarding the handling of the token, I'm afraid that the REST Custom sensor is not able to get it automatically. Therefore, in such case I recommend to use a custom script with the EXE/script Advanced sensor.

However, there is also the possibility to use the REST sensor by updating the token configured in its settings automatically, with the API of PRTG.

Here is the corresponding API call for it:

https://PRTGServer/api/setobjectproperty.htm?id=SensorID&name=resttoken&value=NewToken&username=PRTGUser&passhash=Passhash

Regards.

Created on May 24, 2021 6:37:59 AM by  Florian Lesage [Paessler Support]



Votes:

0

Your Vote:

Up

Down

I setup the PRTG REST custom sensor to use lssystemstats on IBM flashsystem 5200:

  • Request Method: POST
  • Request Protocol: HTTPS
  • Certificate Acceptance: Accept all
  • Authentication Method: No authentication (default)
  • HTTP Headers: Send custom HTTP headers
  • Custom HTTP Headers: X-Auth-Token:2c06d0bb6a4f9ac6f7a8dfdb9003b25ac0818a2dc6
  • REST Query: :7443/rest/lssystemstats
  • REST Configuration: As template file from above in customsensors REST

created a simple bash script in linux cron to update the token from the storage (can be called from PRTG)

#!/bin/bash -f
# PRTG token login for storwise REST API
# By Omri Kedem 05/2021
StorUSER="storewiseuser"
StorPASS="storwisepassword" 
STOR1="storewiseDNS.com"
PRTGUser="prtgadmin"
PRTGHASH="545345hash"
PRTGSENSORID="21984"

tokenJSON=`curl -k -X POST -H 'Content-Type:application/json' -H "X-Auth-Username:$StorUSER" -H "X-Auth-Password:$StorPASS" "https://$STOR1:7443/rest/auth"`

token=`echo $tokenJSON | cut -d : -f2 | awk -F \} '{print $1}' | awk -F \" '{print $2}'`

response=`curl -k -X GET  "https://prtg/api/setobjectproperty.htm?username=$PRTGUser&passhash=$PRTGHASH&id=$PRTGSENSORID&name=customheaders&value=X-Auth-Token%3A$token"`

echo $STOR1 : $response

Created on May 24, 2021 2:43:46 PM by  Omri (0) 1 1

Last change on May 25, 2021 5:18:06 AM by  Florian Lesage [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Thank you for sharing your script with the community.

Have a nice day.

Created on May 25, 2021 5:18:40 AM by  Florian Lesage [Paessler Support]



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.