zoukankan      html  css  js  c++  java
  • 监控系统

    系统级监控

    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}
    '
        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}	%{VERSION}	%{ARCH}	rpm	%{SUMMARY}	-
    '
        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/	/:/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
    
  • 相关阅读:
    中国大学排名爬虫
    基于bs4库的HTML内容查找方法和HTML格式化和编码
    自动化提取51啦数据的信息
    简单目录扫描工具
    一个简单音乐播放器
    【原创】C++中对象的序列化
    [android]android开发中的运行错误之:adb.exe
    [转载]十大编程算法助程序员走上高手之路
    [原创]二叉树相关笔试题代码
    [原创]VS2010中创建动态链接库及其调用
  • 原文地址:https://www.cnblogs.com/liujitao79/p/4040575.html
Copyright © 2011-2022 走看看