lausser / check_logfiles

A plugin (monitoring-plugin, not nagios-plugin, see also http://is.gd/PP1330) which scans logfiles for patterns.
https://omd.consol.de/docs/plugins/check_logfiles/
GNU General Public License v2.0
46 stars 27 forks source link

Use both command line parameter and config file #39

Closed jbeaujour closed 6 years ago

jbeaujour commented 6 years ago

Hello, I would use check_logfiles with command line parameter --logfile both with --config, and use a var in the config file for re-use the logfile name. I don't find documentation for what kind of var in @searches :

lausser commented 6 years ago

Sorry, you cant't mix config file and cmdline Parameter.

lausser commented 6 years ago

What you can do: ` @searches = ( { template => 'test', logfile => '/var/log/$CL_TAG$.log', criticalpattern => '4097.*generated an application error', },

` (it's template instead of tag). Then, run check_logfiles --config ... --tag myapplication

$CL_TAG$ will be replaced in the logfile attribute as well as in critical/warningpatterns. So you can use this to modify one configfile at runtime.

jbeaujour commented 6 years ago

Thank's It Work's !!! But i have a postcript who's wrong: $postscript = sub {

Gestion du state et du message pour NAGIOS

    if ($ENV{CHECK_LOGFILES_SERVICESTATEID} == 2) {
            printf "$ENV{CHECK_LOGFILES_SERVICEOUTPUT}, controler $ENV{CHECK_LOGFILES_TAG}";
            return 2;
    } elsif ($ENV{CHECK_LOGFILES_SERVICESTATEID} == 0) {
            printf "$ENV{CHECK_LOGFILES_SERVICEOUTPUT}, statut de $ENV{CHECK_LOGFILES_TAG} OK";
            return 0;
    } else
    {
            printf "ESB : Statut inconnu, consulter le fichier de log $ENV{CHECK_LOGFILES_TAG}";
            return 3;
    }

};

It return "postcript" instead of "$tag" in all state: "... controler postscript ...." In the past, we use $ENV{CHECK_LOGFILES_LOGDIR}/$ENV{CHECK_LOGFILES_LOGFILE} who works fine Is there a bug in my code ?

jbeaujour commented 6 years ago

In fact, we use $ENV{CHECK_LOGFILES_MY_LOGDIR}/$ENV{CHECK_LOGFILES_MY_LOGFILE} who works fine MY_LOGDIR and MY_LOGFILE was personnal macros with static data in config files Is there a bug in the new code of my config file ?