Closed parosio closed 3 years ago
The behaviour is that anything after the |
will be treated as perfdata; at which point nscp will try and parse it into the perfdata format (i..e name_of_thing=value_of_thing;;
- http://docs.pnp4nagios.org/pnp-0.6/perfdata_format) and put it back together again. If you change from |
to something else it should leave the output unmolested
Thank you @mintsoft, that explains it, and seems quite fair. Only I didn't expect nscp to try an interpretation of the output of a custom script.
In the example above, supposing I wanted nagios to receive
'mail_uploaded'=25ml
as perfdata, what I should output from the ps script?
You should output something like:
write-host "Mail: everything is OK | mail_uploaded=25;;"
Powershell script: problem with perfdata
Hello, I have a ps1 script that receive 3 params: a filename FN, a number N, a string S. Check last line of FN to search for S, and check the filetime is less than N minutes old. Depending on results, outputs a resultstring and exit with the corresponding code. Ex: "OK: file is less than N minutes old" 0.
I'd also want to pass back the lastline as perfdata.
The problem is each "token" of perfdata string is handled separately and sort of null-terminated: a string like
"additional information here"
becomes"'additional'=0 'information'=0 'here'=0"
.Details follow:
from
nsclient.ini
:from
check_file_last_line.ps1
:Expected Behavior
I'd expect nscp to return to nagios the last line of file, as seen when running the script from the command line:
Actual Behavior
Perfdata get messed up: each whitespace separated token is embedded within single quotes, and terminated by "=0 ":
from nscp test output:
Details
Additional Details
NSClient++ log: