ConSol-Monitoring / snclient

SNClient+ - Cross platform monitoring agent
MIT License
50 stars 8 forks source link

check process with template syntax #126

Closed kafos closed 2 months ago

kafos commented 3 months ago

I tried the template syntax with a check_process of VNC processes but it seems that the conditioning does not work properly:

command: check_nsc_web -k -p "PASSWORD" -u https://IP:PORT \ check_process process=tvnserver.exe warn="state=stoppped || count > 1 || count < 1" \ ok-syntax="%(status) - VNC running" 'empty-state=3' \ 'top-syntax=%(status) - %(count) - {{ IF count > 1 }} "active VNC session" {{ ELSIF count < 1 }} "VNC OK" {{ END }}'

the output looks like this: WARNING - 2 - "active VNC session" "VNC OK" |'count'=2;1:1;;0; 'rss'=77619200B;;;0; 'virtual'=9033150464B;;;0; 'cpu'=28.791498%;;;0;

documentation says: {{ IF }}...{{ ELSIF }}...{{ ELSE }}...{{ END }} "ELSIF" correct? -- anyway -tried with ELSEIF or ELIF - dont' get the correct output.

Tried it also with {{ IF %(count) > 1 }} "active VNC session" {{ ELSIF %(count) < 1 }}

sni commented 3 months ago

i cannot reproduce this, which snclient version is this?

kafos commented 2 months ago

It's version 0.25 here some screenshots: image

image

image

sni commented 2 months ago

so it does work now?

kafos commented 2 months ago

the value count is 2 and based on "top-syntax=%(status) - %(count) - {{ IF %(count) < 1 }} NO VNC PROCESS RUNNING {{ ELSIF %(count) > 1 }} RUNNING SESSION {{ END }}" the output should be "WARNING - 2 - RUNNING SESSION"

Seems that "IF %(count) < 1" gives TRUE back but it's FALSE.

sni commented 2 months ago

could you try {{ IF count < 1 }} the %() are not required in the if expression

kafos commented 2 months ago

same with: "top-syntax=%(status) - %(count) - {{ IF count < 1 }} NO VNC PROCESS RUNNING {{ ELSIF count > 1 }} RUNNING SESSION {{ END }}"

sni commented 2 months ago

finally found the issue, thanks for reporting this. Should be fine with the next release.