gpt4 book ai didi

logfiles - 如何使用 Nagios 监控日志文件

转载 作者:行者123 更新时间:2023-12-03 11:15:47 26 4
gpt4 key购买 nike

我们正在使用 Nagios 来监控我们的网络并取得了巨大成功。但是,我们有一个用于关键应用程序错误的系统日志,当我设置 check_log 时,它似乎不像监控设备那样有效。

问题是:

  • 它只显示最后一个条目
  • 似乎没有办法承认严重错误并且
    将显示器恢复到良好状态

  • nagios 是错误的工具,还是我们只是没有正确设置服务监控?

    这是我的条目
    # log file
    define command{
    command_name check_log
    command_line $USER1$/check_log -F /var/log/applications/appcrit.log -O /tmp/appcrit.log -q ?
    }


    # Define the log monitering service
    define service{
    name logfile-check ;
    use generic-service ;
    check_period 24x7 ;
    max_check_attempts 1 ;
    normal_check_interval 5 ;
    retry_check_interval 1 ;
    contact_groups admins ;
    notification_options w,u,c,r ;
    notification_period 24x7 ;
    register 0 ;
    }

    define service{
    use logfile-check
    host_name localhost
    service_description CritLogFile
    check_command check_log
    }

    最佳答案

    由于有很多方法可以实现目标,因此 Consol 还提供了一个不错的插件:
    https://labs.consol.de/lang/en/nagios/check_logfiles/

  • 支持正则表达式
  • 支持日志轮换

  • 要使用它,你需要一个cfg文件,这是一个oracle数据库的例子
    @searches = ({
    tag => 'oraalerts',
    options => 'sticky=28800',
    logfile => '/u01/app/oracle/diag/rdbms/davmdkp/DAVMDKP1/trace/alert_DAVMDKP1.log',
    criticalpatterns => [
    'ORA\-0*204[^\d]', # error in reading control file
    'ORA\-0*206[^\d]', # error in writing control file
    'ORA\-0*210[^\d]', # cannot open control file
    'ORA\-0*257[^\d]', # archiver is stuck
    'ORA\-0*333[^\d]', # redo log read error
    'ORA\-0*345[^\d]', # redo log write error
    'ORA\-0*4[4-7][0-9][^\d]',# ORA-0440 - ORA-0485 background process failure
    'ORA\-0*48[0-5][^\d]',
    'ORA\-0*6[0-3][0-9][^\d]',# ORA-6000 - ORA-0639 internal errors
    'ORA\-0*1114[^\d]', # datafile I/O write error
    'ORA\-0*1115[^\d]', # datafile I/O read error
    'ORA\-0*1116[^\d]', # cannot open datafile
    'ORA\-0*1118[^\d]', # cannot add a data file
    'ORA\-0*1122[^\d]', # database file 16 failed verification check
    'ORA\-0*1171[^\d]', # datafile 16 going offline due to error advancing checkpoint
    'ORA\-0*1201[^\d]', # file 16 header failed to write correctly
    'ORA\-0*1208[^\d]', # data file is an old version - not accessing current version
    'ORA\-0*1578[^\d]', # data block corruption
    'ORA\-0*1135[^\d]', # file accessed for query is offline
    'ORA\-0*1547[^\d]', # tablespace is full
    'ORA\-0*1555[^\d]', # snapshot too old
    'ORA\-0*1562[^\d]', # failed to extend rollback segment
    'ORA\-0*162[89][^\d]', # ORA-1628 - ORA-1632 maximum extents exceeded
    'ORA\-0*163[0-2][^\d]',
    'ORA\-0*165[0-6][^\d]', # ORA-1650 - ORA-1656 tablespace is full
    'ORA\-16014[^\d]', # log cannot be archived, no available destinations
    'ORA\-16038[^\d]', # log cannot be archived
    'ORA\-19502[^\d]', # write error on datafile
    'ORA\-27063[^\d]', # number of bytes read/written is incorrect
    'ORA\-0*4031[^\d]', # out of shared memory.
    'No space left on device',
    'Archival Error',
    ],
    warningpatterns => [
    'ORA\-0*3113[^\d]', # end of file on communication channel
    'ORA\-0*6501[^\d]', # PL/SQL internal error
    'ORA\-0*1140[^\d]', # follows WARNING: datafile #20 was not in online backup mode
    'Archival stopped, error occurred. Will continue retrying',
    ]
    });

    关于logfiles - 如何使用 Nagios 监控日志文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2373212/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com