problem getting json 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
menno
Posts: 157
Joined: Fri May 21, 2010 1:27 am

problem getting json value

Post by menno »

Hi support

I am builing a test that gets the info from a json reply

The http request result in this output

http get command gives :

Code: Select all

{"code":0,"msg":"success","time":"1683896070","data":{"degrees":{"celsius":{"time":"1683892112","unit":"","value":"6"}}}}
readable output is:

Code: Select all

 {
    "code":0,
    "msg":"success",
    "time":"1683892176",
    "data":
    {
        "degrees":
        {
            "celsius":
            {
                "time":"1683892112",
                "unit":"",
                "value":"6"
            }
        }
    }
 }
i am interessted only in the "value":"6" line and then in this case / example the 6
We just want to check is the value is not below 1 and not higher as 10

i tried to use this help but i did not manage to get it working
https://www.ks-soft.net/cgi-bin/phpBB/v ... light=json

i played with the Tune up reply value but didn't succeed.
i tried : [('%data%' getword 1 == 'value') and ('%data%' getnumber 1 >= 9)]

I hope you can help me out here.
many thanks in advance

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

Post by KS-Soft »

1) HostMonitor version?
2) Test method? URL?

3) Where did you find %data% variable?
There is %HttpPage% variable, %SuggestedReply% variable.
{"code":0,"msg":"success","time":"1683896070","data":{"degrees":{"celsius":{"time":"1683892112","unit":"","value":"6"}}}}
i am interessted only in the "value":"6" line and then in this case / example the 6
[('%data%' getword 1 == 'value') and ('%data%' getnumber 1 >= 9)]
4) There are no spaces, no CR, LF characters in this JSON string so entire string looks to "getword" operator as just 1 word

5) getnumber may help. But why did you set "getnumber 1"? I though you want to get 4th number, not first.

So if you want to set Warning or Normal test status you may try expression like
("%HttpPage%" getnumber 4 > 0) and ("%HttpPage%" getnumber 4 < 11)
i played with the Tune up reply value but didn't succeed.
i tried : [('%data%' getword 1 == 'value') and ('%data%' getnumber 1 >= 9)]
I am confised. If you want to check value, then you want to do something depending on the value, right? Then I should ask why do you use this expression in TuneUpReply option?
Either you should use different expression and set some reply... or you should use different options like "Set Warning status if ...".

Regards
Alex
menno
Posts: 157
Joined: Fri May 21, 2010 1:27 am

Post by menno »

Thx Alex !
for your info :
-HM version 13.50
-Test method : URL test ( also tried HTTP )

The solution you provided is good enough so i will use that.

Again many Thanks
m
KS-Soft
Posts: 12846
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

You are welcome

Regards
Alex
Post Reply