sensu-plugins / sensu-plugins-graphite

This plugin provides native Graphite instrumentation for monitoring, including: replication status, various Graphite data queries, mutators, and handlers
http://sensu-plugins.io
MIT License
22 stars 45 forks source link

check-graphite-data, Incorrect behavior if WARN is greater than CRIT #47

Closed rayderua closed 6 years ago

rayderua commented 7 years ago

Hi!

I found that if the WARNING is greater than CRITICAL, then we get the wrong answers.

[/opt/sensu/embedded/bin] ./check-graphite-data.rb -s <SERVER> -t '<TAGGET>' -w 80 -c 70 
TARGET has passed critical threshold (83.468116493418)

should be - OK

[/opt/sensu/embedded/bin] ./check-graphite-data.rb -s <SERVER> -t '<TAGGET>' -w 85 -c 80 
TARGET has passed critical threshold (83.468116493418)

should be - WARNING

[/opt/sensu/embedded/bin] ./check-graphite-data.rb -s <SERVER> -t '<TAGGET>' -w 90 -c 85 
CheckGraphiteData OK: graphite check value OK

should be - CRITICAL

majormoses commented 7 years ago

From the output you show me It is acting as intended for the first two for sure and assuming the numbers from the above this also looks right to me. Critical is a higher level of event type than warning. How would you expect this to work? Maybe I am missing something.

rayderua commented 7 years ago

For example monitoring free space somwhere: 20% free space -warning 10% free space - critical

so 25% - ok, 15% - warning, 5% critical

sometimes impossible to get the metric in another form (% of used instead % free)

Just compare WARN and CRITICAL as in the example below:

if ( CRIT > WARN )
  if ( VALUE  >= CRIT )
    echo "CRITICAL"
  elsif ( VALUE  >= WARN )
    echo "WARNING"
  else
    echo "OK"
  fi
else
  if ( VALUE <= CRIT )
    echo "CRITICAL"
  elsif ( VALUE <= WARN )
    echo "WARNING"
  else
    echo "OK"
  fi
fi

example: check_graphite fro nagios on ruby: https://github.com/obfuscurity/nagios-scripts/blob/master/check_graphite

majormoses commented 7 years ago

I think what you might be looking for something like this:

majormoses commented 7 years ago

or is there something else I am missing

majormoses commented 6 years ago

closing due to inactivity feel free to respond back and we can re-open.