Using check_mysql_health, how to verify that date returned from query is current

It’s late Friday and I figured I asked the question. Anyone might know how to check to make sure a dateandtime mysql result that is formatted like ‘20190823’ is the current time when using check_mysql_health?

So far this is what i’ve come up with. I realize the --warning and --critical are incorrect.

object CheckCommand “check-mysql-foxsite-floattable” {
import “plugin-check-command”

command = [ PluginDir + "/check_mysql_health" ]
arguments = {
    "--hostname" = "vmware-foxsite"
    "--database" = "erp"
    "--user" = "icinga2"
    "--password" = "password"
    "--mode" = "sql"
    "--name" = "SELECT DATE_FORMAT(dateandtime, '%Y%m%d%') FROM erp.floattable ORDER BY dateandtime DESC LIMIT$
    "--name2" = "erp.floattable.dateandtime"
    "--units" = " :yyyymmdd"
    "--warning" = "$$"
    "--critical" = "$$"


Comparing dates is always complicated.

Try with another operator and a query like:

select date_format(date(dateandtime),'%Y%m%d') from table
where date(dateandtime) >= date '2019-08-23';

Consider also adding time in the mix.


1 Like