Inspecting json reply to get Reply value

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
gorisdean
Posts: 22
Joined: Wed Jun 20, 2012 7:56 am

Inspecting json reply to get Reply value

Post by gorisdean »

Hi,

For monitoring one of our hardware appliances I'm looking into requesting some stats from the API.
The API returns a json document and one of the elements contains the actual Reply value I'm interested in.
An example reply:
{
"total": "3077.90",
"used": "432.28",
"free": "2645.62",
"label": "System Memory Stats"
...
}

I will probably be able to request this via an HTTP request, but I don't know how to extract one of the values and use it as the Reply value. Is that possible? Maybe by using an expression (not very faimiliar with that at the moment)?

Ideally I'm getting a percentage out of this test calculated out of two elements in the json, but getting one of the actual values in the json as Reply would already be a good step forward.

Otherwise I will need to create an external script (eg Powershell) in which I can easily interpret the results and use them as Reply value, but those kind of tests are much heavier for Hostmonitor to handle and we try to avoid it if possible.

Thanks!
KS-Soft
Posts: 12877
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

one of the elements contains the actual Reply value I'm interested in
Which one?
Ideally I'm getting a percentage out of this test calculated out of two elements in the json
free / total *100?

Regards
Alex
gorisdean
Posts: 22
Joined: Wed Jun 20, 2012 7:56 am

Post by gorisdean »

Ideally I want to check free/total*100 indeed. This should not drop below a certain value.
If a calculation is not possible, than extracting the "free" value only and comparing this with a static threshold is a possibility as well, although less dynamic.

Thanks
KS-Soft
Posts: 12877
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Use optional status processing options
https://www.ks-soft.net/hostmon.eng/mfr ... processing

E.g.
Tune up Reply value [('%SuggestedReply%' getnumberwithdot 3)*100 div ('%SuggestedReply%' getnumberwithdot 1)]

Set Warning status if ('%SuggestedReply%' getnumberwithdot 3)*100 div ('%SuggestedReply%' getnumberwithdot 1) < 50

Regards
Alex
gorisdean
Posts: 22
Joined: Wed Jun 20, 2012 7:56 am

Post by gorisdean »

Super, thx.
I wasn't familiar with those "Tune Up Reply" option, but that brings a lot of possibilities...
gorisdean
Posts: 22
Joined: Wed Jun 20, 2012 7:56 am

Post by gorisdean »

Ok, have been testing around a little further.
I'm doing a URL test right now and I'm trying to tune the reply value.

The entire response of the request is this:
{
"total": "3077.90",
"used": "430.42",
"free": "2647.48",
"label": "System Memory Stats",
"dateMinMaxDiff": 53,
"ymax": 100,
"items": [
{
"x": 1606509360,
"y": 14,
"id": "memoryused_1606509360",
"set": "memoryused"
}
]
}

When trying to tune this reply with this expression:
['%HttpPage%' getnumberwithdot 2]

I'm getting:
Error in expression ['{"total":"3077.90","used... Unterminated string: '{"total":"...
in my Reply value.

I think of two possible problems:
Maybe something with the square brackets in the response of the server causing the Tune expression to fail.
Or the httpPage response is to big and cut off.

Any idea?
KS-Soft
Posts: 12877
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Yes, I think square brackets lead to the error.
Not sure how to fix this yet..

Regards
Alex
gorisdean
Posts: 22
Joined: Wed Jun 20, 2012 7:56 am

Post by gorisdean »

ok, thx for the feedback.
Should I post this somewhere on this forum as feature request?
KS-Soft
Posts: 12877
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

We are testing update.
If you are using latest version (12.60), you may send request to support@ks-soft.net, we will finish testing and provide new version.

Regards
Alex
gorisdean
Posts: 22
Joined: Wed Jun 20, 2012 7:56 am

Post by gorisdean »

Fix works and proposed calculations work as expected.
Thanks for your quick assistance!
KS-Soft
Posts: 12877
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

You are welcome

Regards
Alex
Post Reply