Hello,
Thank you for your message.
Regarding JSON, the property name should effectively start with a letter, an underscore (_) or a dollar sign($) as indicated here: https://google.github.io/styleguide/jsoncstyleguide.xml
If you can't change the property name, then I recommend to use the EXE/Script or EXE/Script Advanced sensor with a custom script such as the following:
Param (
#[Parameter(Mandatory)]
[string]$url = ""
)
function Invoke-Request {
Param(
$url = $script:url
)
Invoke-RestMethod $url -Method Get
}
try {
$r = Invoke-Request
write-host @"
<prtg>
<result>
<channel>24h reward</channel>
<value>$($r."24hreward")</value>
</result>
<result>
<channel>Hash rate</channel>
<value>$($r.hashrate)</value>
</result>
</prtg>
"@
} catch {
write-host "<prtg>"
write-host "<error>1</error>"
write-host "<text>$($_.exception.message) At line : $($_.InvocationInfo.ScriptLineNumber)</text>"
write-host "</prtg>"
Exit 1
}
Regards.
Add comment