Parsing curl output

I am trying to build a simple curl script to update bigfix with Solarwinds node number so that i can later use the node number to issue commands to put monitoring in maintenance mode, etc.

The curl command will use the client IP and Name to try to match a pre-existing registered client on the orion server.

curl -k -u user:passmwword https://solarserver:17778/SolarWinds/InformationService/v3/Json/Query?query=“SELECT+NodeID+FROM+Orion.Nodes+WHERE+IP_Address=’$IP’+OR+Caption=’$ComputerName’”

The output is like:
{“results”:[{“NodeID”:665}]}

I really have issues trying to parse in action script, give me sed and awk any day.
I am looking to just get the ### and nothing else out of the return so i can use it to set a client setting for a node for future reference.

thank you

1 Like

I’ve not tested this, but what about something like:

setting "NodeID"="{preceding text of first "}" of following text of last ":" of lines of file "R:\curloutput.txt"}" on "{parameter "action issue date" of action}" for client

1 Like

We have JSON inspectors…will post back shortly.

With this output in c:\temp\test.txt, we can retrieve that using the JSON inspectors via

q: values of keys "NodeID" of elements 0 of values of keys "results" of jsons of file "c:\temp\test.txt"
A: 665
T: 0.313 ms
I: plural json value

4 Likes

Jason, your information was awesome.

I was able to get this working however can you provide a hint on how to collect the curl output from stdout and have it in a parameter? and then parse the parameter with the jsons function?

It would be nice to not have the file i/o even if it is short lived on the clients.

Thank you

I’m not sure you’d be able to avoid file i/o in that case. Relevance evaluation is handled separately from the file execution, so you wouldn’t be able to capture the process output directly into a parameter.

1 Like