Hello, I would like to be able to build a powershell script that would allow me to interface with APIs on a server and get the values from prtg.
when I use the query:
Invoke-WebRequest -Uri "http://192.168.168.101/xmlapi/?token=GyeC3sfAMPZojC..." -UsersOutBody \ text-xml Admin \ "-MethodBody \ text \ body \ xml Administrator \" -MethodutB \ body \ $ xmlAdmin \ "-UsersOutBody \ $ xml
$ body = @ "
<? xml version = "1.0"?>
<xml>
<object> controllerstaterx </object>
<action> select </action>
<id> 4 </id>
</xml>
"@
I have the following result:
<? xml version = "1.0"?>
<xml>
<result>
<type> success </type>
<message> </message>
<errno> 0 </errno>
<id> 4 </id>
</result>
<data>
<bdrf> 65.6 </bdrf>
<cn> 25 </cn>
<rfl> 56.8 </rfl>
<cn_sta_avg> 12.9 </cn_sta_avg>
<cn_con_avg> 8.8 </cn_con_avg>
<id> 4 </id>
<hub_network_id> 1 </hub_network_id>
<controller_id> 4 </controller_id>
<packets> 0 </packets>
<bad_state> 2021-11-19 07:29:10 </bad_state>
<good_state> 2021-11-19 10:18:10 </good_state>
<updated> 2021-11-19 10:18:05 </updated>
<state> 17 </state>
<channel> 4 </channel>
<frlen> 256 </frlen>
<rqsl> 3 </rqsl>
<guarq> 3 </guarq>
<totrq> 3 </totrq>
<rtrq> 0 </rtrq>
<upst> 5 </upst>
<actst> 3 </actst>
<hblow> 5 </hblow>
<stlow> 0 </stlow>
<rxspd> 10128 </rxspd>
<platform> 34 </platform>
<hardware> 1466715 </hardware>
<hardware_errors> 0 </hardware_errors>
<config_errors> 0 </config_errors>
<license> 6146 </license>
<configurable_profiles> 2147483647 </configurable_profiles>
<licensed_profiles> 2147000307 </licensed_profiles>
<faults> 0 </faults>
</data>
</xml>
My question: how to be able to create a power shell script to retrieve this result in the "form requested by the PRTG system
Thanks for your help jérémy
Add comment