KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Inspecting json reply to get Reply value

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting
View previous topic :: View next topic  
Author Message
gorisdean



Joined: 20 Jun 2012
Posts: 14

PostPosted: Fri Nov 27, 2020 1:53 am    Post subject: Inspecting json reply to get Reply value Reply with quote

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
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12431
Location: USA

PostPosted: Fri Nov 27, 2020 4:50 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
gorisdean



Joined: 20 Jun 2012
Posts: 14

PostPosted: Fri Nov 27, 2020 5:10 am    Post subject: Reply with quote

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
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12431
Location: USA

PostPosted: Fri Nov 27, 2020 5:57 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
gorisdean



Joined: 20 Jun 2012
Posts: 14

PostPosted: Fri Nov 27, 2020 7:38 am    Post subject: Reply with quote

Super, thx.
I wasn't familiar with those "Tune Up Reply" option, but that brings a lot of possibilities...
Back to top
View user's profile Send private message
gorisdean



Joined: 20 Jun 2012
Posts: 14

PostPosted: Fri Nov 27, 2020 2:45 pm    Post subject: Reply with quote

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
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12431
Location: USA

PostPosted: Fri Nov 27, 2020 3:13 pm    Post subject: Reply with quote

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

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
gorisdean



Joined: 20 Jun 2012
Posts: 14

PostPosted: Mon Nov 30, 2020 5:16 am    Post subject: Reply with quote

ok, thx for the feedback.
Should I post this somewhere on this forum as feature request?
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12431
Location: USA

PostPosted: Mon Nov 30, 2020 2:46 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
gorisdean



Joined: 20 Jun 2012
Posts: 14

PostPosted: Tue Dec 01, 2020 10:14 am    Post subject: Reply with quote

Fix works and proposed calculations work as expected.
Thanks for your quick assistance!
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12431
Location: USA

PostPosted: Tue Dec 01, 2020 10:16 am    Post subject: Reply with quote

You are welcome

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index