View previous topic :: View next topic |
Author |
Message |
gorisdean
Joined: 20 Jun 2012 Posts: 22
|
Posted: Fri Nov 27, 2020 1:53 am Post subject: Inspecting json reply to get Reply value |
|
|
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! |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Fri Nov 27, 2020 4:50 am Post subject: |
|
|
Quote: | one of the elements contains the actual Reply value I'm interested in |
Which one?
Quote: | Ideally I'm getting a percentage out of this test calculated out of two elements in the json |
free / total *100?
Regards
Alex |
|
Back to top |
|
|
gorisdean
Joined: 20 Jun 2012 Posts: 22
|
Posted: Fri Nov 27, 2020 5:10 am Post subject: |
|
|
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 |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Fri Nov 27, 2020 5:57 am Post subject: |
|
|
Use optional status processing options
https://www.ks-soft.net/hostmon.eng/mframe.htm#tests.htm#usrstatusprocessing
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 |
|
Back to top |
|
|
gorisdean
Joined: 20 Jun 2012 Posts: 22
|
Posted: Fri Nov 27, 2020 7:38 am Post subject: |
|
|
Super, thx.
I wasn't familiar with those "Tune Up Reply" option, but that brings a lot of possibilities... |
|
Back to top |
|
|
gorisdean
Joined: 20 Jun 2012 Posts: 22
|
Posted: Fri Nov 27, 2020 2:45 pm Post subject: |
|
|
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? |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Fri Nov 27, 2020 3:13 pm Post subject: |
|
|
Yes, I think square brackets lead to the error.
Not sure how to fix this yet..
Regards
Alex |
|
Back to top |
|
|
gorisdean
Joined: 20 Jun 2012 Posts: 22
|
Posted: Mon Nov 30, 2020 5:16 am Post subject: |
|
|
ok, thx for the feedback.
Should I post this somewhere on this forum as feature request? |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Mon Nov 30, 2020 2:46 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
gorisdean
Joined: 20 Jun 2012 Posts: 22
|
Posted: Tue Dec 01, 2020 10:14 am Post subject: |
|
|
Fix works and proposed calculations work as expected.
Thanks for your quick assistance! |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Tue Dec 01, 2020 10:16 am Post subject: |
|
|
You are welcome
Regards
Alex |
|
Back to top |
|
|
|