监控系统 - check_mk_agent

本文介绍了check_mk_agent的安装及配置方法,并详细说明了如何通过编辑xinetd配置文件来启动监控服务。此外,还提供了插件示例,展示了如何设置插件以实现不同间隔的异步运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

系统级监控

cpu (system, user)
memory (cache, buffer, use)(MB)
load (cpu core)
diskspace (used, inode)(GB)
diskio (read, write, io)
traffic (in, out)(Mb)

应用级监控

tcp connection
nfs mount
web access user count
lvs
haproxy
install
yum -y install xinetd
yum -y install check-mk-agent-1.2.6p2-1.noarch.rpm 
/etc/xinetd.d/check_mk
service check_mk
{
    type           = UNLISTED
    port           = 6556
    socket_type    = stream
    protocol       = tcp
    wait           = no
    user           = root
    server         = /usr/bin/check_mk_agent

    # If you use fully redundant monitoring and poll the client
    # from more then one monitoring servers in parallel you might
    # want to use the agent cache wrapper:
    #server         = /usr/bin/check_mk_caching_agent

    # configure the IP address(es) of your Nagios server here:
    #only_from      = 127.0.0.1 10.0.20.1 10.0.20.2

    # Don't be too verbose. Don't log every check. This might be
    # commented out for debugging. If this option is commented out
    # the default options will be used for this service.
    log_on_success =

    disable        = no
}

/usr/lib/check_mk_agent/plugins

These plugins can be installed in the plugins directory of the Linux agent
in /usr/lib/check_mk_agent/plugins/. Please only install the plugins that
you really need.

If you want a plugin to be run asynchronously and also in
a larger interval then the normal check interval, then you can
copy it to a subdirectory named after a number of *minutes*,
e.g.:

/usr/lib/check_mk_agent/plugins/60/mk_zypper

In that case the agent will:

 - Run this plugin in the background and wait not for it to finish.
 - Store the result of the plugin in a cache file below /etc/check_mk/cache.
 - Use that file for one hour before running the script again.
plugins example
# Run and *send* only once every __ seconds
. $MK_CONFDIR/mk_inventory.cfg 2>/dev/null || true

# Default to four hours
INTERVAL=${INVENTORY_INTERVAL:-14400}

FLAGFILE=$MK_VARDIR/mk_inventory.last.$REMOTE
LAST_RUN=$(stat -c %Y $FLAGFILE)
NOW=$(date +%s)
UNTIL=$((NOW + INTERVAL + 600))

if [ $(( NOW - LAST_RUN )) -ge $INTERVAL ]
then
    touch $FLAGFILE

    # List of DEB packages
    if type dpkg-query >/dev/null; then
        echo "<<<lnx_packages:sep(124):persist($UNTIL)>>>"
        dpkg-query --show --showformat='${Package}|${Version}|${Architecture}|deb|${Summary}|${Status}\n'
    fi

    # List of RPM packages in same format
    if type rpm >/dev/null; then
        echo "<<<lnx_packages:sep(9):persist($UNTIL)>>>"
        rpm -qa --qf '%{NAME}\t%{VERSION}\t%{ARCH}\trpm\t%{SUMMARY}\t-\n'
    fi

    # Information about distribution
    echo "<<<lnx_distro:sep(124):persist($UNTIL)>>>"
    for f in /etc/{debian_version,lsb-release,redhat-release,SuSE-release} ; do
        if [ -e $f ] ; then
            echo -n "$f|" ; tr \\n \| < $f | sed 's/|$//' ; echo
        fi
    done

    # CPU Information. We need just the first one
    if [ -e /proc/cpuinfo ] ; then
        echo "<<<lnx_cpuinfo:sep(58):persist($UNTIL)>>>"
        sed 's/[[:space:]]*:[[:space:]]*/:/' < /proc/cpuinfo
    fi

    # Information about main board, memory, etc.
    if type dmidecode >/dev/null ; then
        echo "<<<dmidecode:sep(58):persist($UNTIL)>>>"
        dmidecode -q | sed 's/\t/:/g'
    fi

    # Information about kernel architecture
    if type uname >/dev/null ; then
        echo "<<<lnx_uname:persist($UNTIL)>>>"
        uname -m
        uname -r
    fi
    if type lspci > /dev/null ; then
        echo "<<<lnx_vga:sep(58):persist($UNTIL)>>>"
        lspci  -v -s  $(lspci | grep VGA | cut -d" " -f 1)
    fi

fi
posted on 2014-10-21 15:54 北京涛子 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/liujitao79/p/4040575.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值