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
      }
      

    ]
  }
}

Article Comments

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.


May, 2021 - Permalink

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

May, 2021 - Permalink

Thank you for sharing your script with the community.

Have a nice day.


May, 2021 - Permalink