Discussion:
[Check_mk (english)] local check - warning and critical if less than
Yves Pires Da Silva
2018-11-06 18:22:35 UTC
Permalink
Hey all

Where i can change this logic? I am writing some local scripts to read UPS battery, input, voltage and i need check_mk to notify me when numbers get low.


Sample script, this kinda works but the output is negative.

#!/bin/bash

bateria=-$(cat /dir/comercial/nobreak.bateria)
if [ $bateria -lt -11 ] ; then
status=0
statustxt=OK
elif [ $bateria -lt -10 ] ; then
status=1
statustxt=WARNING
else
status=2
statustxt=CRITICAL
fi
echo "$status Nobreak.Comercial.Bateria bateria=$bateria;-11;-10;0; $statustxt - $bateria"

[Loading Image...]<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon> Virus-free. www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
Andreas Döhler
2018-11-11 11:43:49 UTC
Permalink
Hi Yves,

you can write the output line like the following example.

echo "P Nobreak.Comercial.Bateria bateria=$bateria;-11.0;-9.0 $statustxt -
$bateria"

With the P status you can forget the complete if-elif logic. This status
calculate the correct value by itself.

A value of -10.9 for $bateria will give you an warning status and an value
greater then -9.0 will give a critical.
I see on problem in your check. If you only get integer values then you
will get a warning for an value of -10 and from -9 on critical.
If your value is the same as the warning or critical threshold then you
will get the better result --> -11 will produce an OK state.

Best regards
Andreas

Am Di., 6. Nov. 2018 um 19:23 Uhr schrieb Yves Pires Da Silva <
Post by Yves Pires Da Silva
Hey all
Where i can change this logic? I am writing some local scripts to read UPS
battery, input, voltage and i need check_mk to notify me when numbers get
low.
Sample script, this kinda works but the output is negative.
#!/bin/bash
bateria=-$(cat /dir/comercial/nobreak.bateria)
if [ $bateria -lt -11 ] ; then
status=0
statustxt=OK
elif [ $bateria -lt -10 ] ; then
status=1
statustxt=WARNING
else
status=2
statustxt=CRITICAL
fi
echo "$status Nobreak.Comercial.Bateria bateria=$bateria;-11;-10;0; $statustxt - $bateria"
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon> Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
<#m_-87361419742688928_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
_______________________________________________
checkmk-en mailing list
Manage your subscription or unsubscribe
http://lists.mathias-kettner.de/mailman/listinfo/checkmk-en
Loading...