Hi , i still get this error when i built a custom sensor to get Data from KlimaLogg Service
Does somebody know what is this error for ?
param ( [string]$inputfile = "C:\ProgramData\KlimaLogg.dat1" ) set-psdebug -strict $ErrorActionPreference="SilentlyContinue" $error.clear() write-host "Start PRTG Sensor" write-host "Inputfile:" $Inputfile $inifile = get-content $inputfile [string]$resultxml="<inifile>" [string]$inisection="" foreach ($line in $inifile) { write-host "Processing $line" if ($line[0] -eq "[") { if ($inisection -ne "") { write-host "Closing old inisection: $inisection" $resultxml+=("</$inisection>`r`n") } $inisection = $line.replace("[","").replace("]","") write-host "Found new inisection: $inisection" $resultxml+=("<$inisection>`r`n") } elseif ($line -like "*=*") { $key=($line.split("=")[0]) $value=($line.split("=")[1]) write-host "Found parameterline Key: $key Value:$value" $resultxml+=("<$key>$value</$key>`r`n") } else { write-host "Skip line" } } $resultxml+=("</$inisection>`r`n") $resultxml+="</inifile>" [xml]$inixml= $resultxml [string]$result="<prtg>`r`n" $lastactualization = [long]($inixml.inifile.time.last_actualisation.replace("""","")) write-host "Timestamp lastactualization: $lastactualization" $timestampageseconds = [long](((Get-Date).touniversaltime().addseconds(-$lastactualization) - (get-date 1.1.1900)).totalseconds) write-host "Timestamp age in minutes $timestampageseconds" if ($timestampageseconds -gt 120) { $result+="<error>1</error>`r`n" $result+="<text>Data to old. last update $timestampageseconds Seconds. Check Klimalogger-Service</text>`r`n" } else { foreach ($count in (0..8)) { write-host "Processing Channel $count" $result+=" <result>`r`n" $result+=" <channel>Temperature("+$count+")</channel>`r`n" $result+=" <value>"+$inixml.inifile.("temperature_channel_"+$count).deg_c.replace("""","")+"</value>`r`n" $result+=" <unit>Temperature</unit>`r`n" $result+=" <CustomUnit>Celsius</CustomUnit>`r`n" $result+=" <mode>Absolute</mode>`r`n" $result+=" <float>1</float>`r`n" $result+=" </result>`r`n" $result+=" <result>`r`n" $result+=" <channel>Humidy("+$count+")</channel>`r`n" $result+=" <value>"+$inixml.inifile.("humidity_channel_"+$count).percent.replace("""","")+"</value>`r`n" $result+=" <unit>Percent</unit>`r`n" $result+=" <mode>Absolute</mode>`r`n" $result+=" </result>`r`n" } $result+="<text>No errors found</text>`r`n" } $result+="</prtg>" write-host "End: ExitCode "$error.count Write-host "Sending Result to output pipeline" $result if ($error) { #write-host "Found Errors" EXIT 1 }
Add comment