Zabbix 自定义 key 监控 apache

一、环境

Ubuntu14.04 LTS  zabbix 2.4.5  Apache/2.4.7

二、配置apache监控

  1、 开启apache的server-status

    添加下面的内容到apache的配置文件中

sudo vim /etc/apache2/apache2.conf
<Location /server-status>
    SetHandler server-status
    Allow from 127.0.0.1
    Order deny,allow
    Deny from all
</Location>
ExtendedStatus On # Optional. Must be in global scope and not in a virtual host

#Restart/reload Apache or use ```kill -USR1 `cat /var/run/httpd.pid ```` for zero downtime.

    

三、配置zabbix server

  1、     Import the template file *Template_App_Apache_Status.xml* into Zabbix

  2、   Link the *Template_App_Apache_Status* template to the hosts to be monitored

四、配置zabbix agent

  1、     在/etc/zabbix/zabbix_agent.d/目录下新建check_apache.conf,并且添加以下内容;

# returns a single integer, but uses zabbix_sender to populate trapper items
UserParameter=apache.status,/etc/zabbix/scripts/check_apache --config /etc/zabbix/zabbix_agentd.conf

  2、     编写脚本check_apache在/etc/zabbix/scripts/目录下;

#!/usr/bin/python
#
import urllib
from optparse import OptionParser
import os
import StringIO
import csv
import sys
import logging, logging.handlers
from subprocess import Popen, PIPE, STDOUT

def setLogLevel(loglevel):
    """
    Setup logging.
    """

    numeric_loglevel = getattr(logging, loglevel.upper(), None)
    if not isinstance(numeric_loglevel, int):
        raise ValueError(‘Invalid log level: "%s"\n Try: "debug", "info", "warning", "critical".‘ % loglevel)

    program = os.path.basename( __file__ )
    logger = logging.getLogger( program )
    logger.setLevel(numeric_loglevel)

    log_handler = logging.handlers.SysLogHandler( address = ‘/dev/log‘ )
    #log_handler = logging.StreamHandler(sys.stdout)
    logger.addHandler( log_handler )

    return logger

def zbx_fail(err):
    logger.critical("%s", err)
    print "ZBX_NOTSUPPORTED"
    sys.exit(1)

def fetchURL(url, user = None, passwd = None):
    """ Return the data from a URL """
    if user and passwd:
        parts = url.split(‘://‘)
        url = parts[0] + "://" + user + ":" + passwd + "@" + parts[1]

    try:
        conn = urllib.urlopen(url)
        data = conn.read()
    except:
        raise

    conn.close()
    return data

def zabbix_sender(payload, agentconfig = None, zabbixserver = None, zabbixport = 10051, senderloc = ‘/usr/bin/zabbix_sender‘ ):
    logger.debug(‘sendValues: %s‘ % payload)
    sender_command = []
    result = 0
    err = ‘‘

    if not (os.path.exists(senderloc)) or not (os.access(senderloc, os.X_OK)):
        logger.error("%s not exists or not executable" %(senderloc))
        raise

    else:
        # must have a config file OR have hostname, and server name
        if agentconfig is not None:
            logger.debug(‘sending to server in agent config %s‘ % agentconfig)
            sender_command = [ senderloc, ‘-vv‘, ‘--config‘, agentconfig, ‘--input-file‘, ‘-‘ ]
        else:
            if zabbixserver is not None:
                logger.debug(‘sending to server %s:%s‘ % (zabbixserver, zabbixport))
                sender_command = [ senderloc, ‘-vv‘, ‘--zabbix-server‘, zabbixserver, ‘--port‘, str(zabbixport), ‘--input-file‘, ‘-‘ ]
            else:
                logger.error(‘must specify agent configuration or server name to call zabbix_sender with‘)

        try:
            p = Popen(sender_command, stdout = PIPE, stdin = PIPE, stderr = PIPE)
            out, err = p.communicate( input = payload )
            ret = p.wait()
            result = 1

        except Exception, e:
          err = "%s\nFailed to execute: ‘%s‘" % (e, " ".join(sender_command))

        finally:
            if ret != 0:
              raise Exception("error returned from %s! ret: %d, out: ‘%s‘, err: ‘%s‘" % (sender_command[0], ret, out.strip(‘\n‘), err.strip(‘\n‘)))

    return result

def clean(string, chars):
    for i in chars:
        string = string.replace(i, ‘‘)
    return string

def parse(data):
    """ Parse the CSV file into a dict of data
    """
    mapping = {
        "_":"Waiting for Connection",
        "S":"Starting up",
        "R":"Reading Request",
        "W":"Sending Reply",
        "K":"Keepalive (read)",
        "D":"DNS Lookup",
        "C":"Closing connection",
        "L":"Logging",
        "G":"Gracefully finishing",
        "I":"Idle cleanup of worker",
        ".":"Open slot with no current process",
        }
    # Clean out certian chars
    replace = ‘() ‘
    csvobj = csv.reader(StringIO.StringIO(data), delimiter = ":", skipinitialspace = True)
    ret = {}
    for (key, val) in csvobj:
        if key == ‘Scoreboard‘:
            sb = {
                "Waiting for Connection":0,
                "Starting up":0,
                "Reading Request":0,
                "Sending Reply":0,
                "Keepalive (read)":0,
                "DNS Lookup":0,
                "Closing connection":0,
                "Logging":0,
                "Gracefully finishing":0,
                "Idle cleanup of worker":0,
                "Open slot with no current process":0,
                }
            for i in val:
                sb[mapping[i]] += 1
            ret[key] = sb
        else:
            ret[key] = val
    ret2 = {}
    for (key, val) in ret.items():
        if key == "Scoreboard":
            for (key, val) in val.items():
                ret2[clean(key, replace)] = val
        else:
            ret2[clean(key, replace)] = val

    return ret2

def get_opts():
    parser = OptionParser(
                        usage = "%prog [-z <Zabbix hostname or IP>] [-o <Apache hostname or IP>]",
                        version = "%prog $Revision: 173 $",
                        prog = "ApacheStatsForZabbix",
                        description = """This program gathers data from Apache‘s
built-in status page and sends it to
Zabbix. The data is sent via zabbix_sender.
Author: Paulson McIntyre (GpMidi)
License: GPLv2
                        """,
                        )
    parser.add_option(
                      "-l",
                      "--url",
                      action = "store",
                      type = "string",
                      dest = "url",
                      default = None,
                      help = "Override the automatically generated URL with one of your own",
                      )
    parser.add_option(
                      "-o",
                      "--host",
                      action = "store",
                      type = "string",
                      dest = "host",
                      default = "localhost",
                      help = "Host to connect to. [default: %default]",
                      )
    parser.add_option(
                      "-p",
                      "--port",
                      action = "store",
                      type = "int",
                      dest = "port",
                      default = 80,
                      help = "Port to connect on. [default: %default]",
                      )
    parser.add_option(
                      "-r",
                      "--proto",
                      action = "store",
                      type = "string",
                      dest = "proto",
                      default = "http",
                      help = "Protocol to connect on. Can be http or https. [default: %default]",
                      )
    parser.add_option(
                      "-z",
                      "--zabbixserver",
                      action = "store",
                      type = "string",
                      dest = "zabbixserver",
                      default = "localhost",
                      )
    parser.add_option(
                      "-u",
                      "--user",
                      action = "store",
                      type = "string",
                      dest = "user",
                      default = None,
                      help = "HTTP authentication user to use when connection. [default: None]",
                      )
    parser.add_option(
                      "-a",
                      "--passwd",
                      action = "store",
                      type = "string",
                      dest = "passwd",
                      default = None,
                      help = "HTTP authentication password to use when connecting. [default: None]",
                      )
    parser.add_option(
                      "-s",
                      "--sender",
                      action = "store",
                      type = "string",
                      dest = "senderloc",
                      default = "/usr/bin/zabbix_sender",
                      help = "Location to the zabbix_sender executable. [default: %default]",
                      )
    parser.add_option(
                      "-q",
                      "--zabbixport",
                      action = "store",
                      type = "int",
                      dest = "zabbixport",
                      default = 10051,
                      help = "Zabbix port to connect to. [default: %default]",
                      )
    parser.add_option(
                      "-c",
                      "--zabbixsource",
                      action = "store",
                      type = "string",
                      dest = "zabbixsource",
                      default = "localhost",
                      help = "Zabbix host to use when sending values. [default: %default]",
                      )
    parser.add_option(
                      "--config",
                      action = "store",
                      type = "string",
                      dest = "agentconfig",
                      default = "",
                      help = "Zabbix agent config to derive Hostname and ServerActive from. [default: %default]",
                      )

    (opts, args) = parser.parse_args()
    if opts.url and (opts.port != 80 or opts.proto != "http"):
        parser.error("Can‘t specify -u with  -p or -r")
    if not opts.url:
        opts.url = "%s://%s:%s/server-status?auto" % (opts.proto, opts.host, opts.port)

    return opts, args

def main():
    opts, args = get_opts()

    result = 0

    try:
        server_status = fetchURL(opts.url, user = opts.user, passwd = opts.passwd)
    except Exception as e:
        zbx_fail(‘failed to read server-status: %s‘ % e)

    try:
        data = parse( data = server_status )
    except Exception as e:
        zbx_fail(‘failed to parse server-status: %s‘ % e)

    payload = ""

    if opts.agentconfig:
        # agent check; assume hostname from zabbix agent config
        for key, val in data.items():
            payload += "-\tapache[%s]\t%s\n" % (key, val)

        try:
            result = zabbix_sender(
                payload     = payload,
                agentconfig = opts.agentconfig,
                senderloc   = opts.senderloc )
        except Exception as e:
            zbx_fail(‘failed to send parsed data: %s‘ % e)
        else:
            # return value for apache.status item
            print result

    else:
        # cron or remote check; hostname may be distinct from host running the check
        for key, val in data.items():
            payload += "%s apache[%s] %s\n" % (opts.zabbixsource, key, val)

        try:
            result = zabbix_sender(
                payload      = payload,
                zabbixserver = opts.zabbixserver,
                zabbixport   = opts.zabbixport,
                senderloc    = opts.senderloc )
        except Exception as e:
            zbx_fail(‘failed to send parsed data: %s‘ % e)

if __name__ == "__main__":
    loglevel = ‘debug‘
    logger   = setLogLevel(loglevel)
    main()

  3、 添加执行权限;

sudo chmod +x  check_apach
sudo chown zabbix:zabbix check_apach

4、  重启zabbix agent;

sudo service zabbix-agent restart

  5、 apach模板;

  

<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
    <version>2.0</version>
    <date>2015-05-07T21:49:53Z</date>
    <groups>
        <group>
            <name>App Templates</name>
        </group>
        <group>
            <name>Templates</name>
        </group>
    </groups>
    <templates>
        <template>
            <template>Template_App_Apache_Status</template>
            <name>Template_App_Apache_Status</name>
            <groups>
                <group>
                    <name>App Templates</name>
                </group>
                <group>
                    <name>Templates</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Apache Stats</name>
                </application>
                <application>
                    <name>Apache Worker</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Apache - Bytes Per Request</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[BytesPerReq]</key>
                    <delay>0</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units>B</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Stats</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache - Bytes Per Second</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[BytesPerSec]</key>
                    <delay>0</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units>Bps</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Stats</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache - CPU Load</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[CPULoad]</key>
                    <delay>0</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Stats</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache - Requests Per Second</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[ReqPerSec]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units>r/s</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Stats</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache - Total Accesses</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[TotalAccesses]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Stats</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache - Total Data Transfer</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>1</multiplier>
                    <snmp_oid/>
                    <key>apache[TotalkBytes]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units>b</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1024</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Stats</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache - Uptime</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[Uptime]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units>s</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Stats</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache Status</name>
                    <type>0</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache.status</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description>Item used to trigger zabbix trapper submission by agent.</description>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Stats</name>
                        </application>
                    </applications>
                    <valuemap>
                        <name>Host status</name>
                    </valuemap>
                </item>
                <item>
                    <name>Apache Workers - Busy</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[BusyWorkers]</key>
                    <delay>0</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units>Workers</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Worker</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache Workers - Closing Connection</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[Closingconnection]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units>Workers</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Worker</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache Workers - DNS Lookup</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[DNSLookup]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units>Workers</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Worker</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache Workers - Gracefully Finishing</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[Gracefullyfinishing]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units>Workers</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Worker</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache Workers - Idle</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[IdleWorkers]</key>
                    <delay>0</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units>Workers</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Stats</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache Workers - Idle cleanup of worker</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[Idlecleanupofworker]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units>Workers</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Worker</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache Workers - Keepalive (read)</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[Keepaliveread]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units>Workers</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Worker</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache Workers - Logging</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[Logging]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units>Workers</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Worker</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache Workers - Open slot with no current process</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[Openslotwithnocurrentprocess]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units>Workers</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Worker</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache Workers - Reading Request</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[ReadingRequest]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units>Workers</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Worker</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache Workers - Sending Reply</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[SendingReply]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units>Workers</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Worker</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache Workers - Starting up</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[Startingup]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units>Workers</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Worker</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Apache Workers - Waiting for Connection</name>
                    <type>2</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>apache[WaitingforConnection]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units>s</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Apache Worker</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
            </items>
            <discovery_rules/>
            <macros/>
            <templates/>
            <screens/>
        </template>
    </templates>
    <graphs>
        <graph>
            <name>Apache Stats</name>
            <width>900</width>
            <height>200</height>
            <yaxismin>0.0000</yaxismin>
            <yaxismax>100.0000</yaxismax>
            <show_work_period>1</show_work_period>
            <show_triggers>1</show_triggers>
            <type>0</type>
            <show_legend>1</show_legend>
            <show_3d>0</show_3d>
            <percent_left>0.0000</percent_left>
            <percent_right>0.0000</percent_right>
            <ymin_type_1>0</ymin_type_1>
            <ymax_type_1>0</ymax_type_1>
            <ymin_item_1>0</ymin_item_1>
            <ymax_item_1>0</ymax_item_1>
            <graph_items>
                <graph_item>
                    <sortorder>2</sortorder>
                    <drawtype>0</drawtype>
                    <color>0000C8</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_App_Apache_Status</host>
                        <key>apache[BytesPerSec]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>3</sortorder>
                    <drawtype>0</drawtype>
                    <color>C800C8</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_App_Apache_Status</host>
                        <key>apache[CPULoad]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>0</sortorder>
                    <drawtype>0</drawtype>
                    <color>C80000</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_App_Apache_Status</host>
                        <key>apache[BusyWorkers]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>4</sortorder>
                    <drawtype>0</drawtype>
                    <color>00C8C8</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_App_Apache_Status</host>
                        <key>apache[ReqPerSec]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <drawtype>0</drawtype>
                    <color>00C800</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_App_Apache_Status</host>
                        <key>apache[BytesPerReq]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Apache Workers</name>
            <width>900</width>
            <height>200</height>
            <yaxismin>0.0000</yaxismin>
            <yaxismax>100.0000</yaxismax>
            <show_work_period>1</show_work_period>
            <show_triggers>1</show_triggers>
            <type>1</type>
            <show_legend>1</show_legend>
            <show_3d>0</show_3d>
            <percent_left>0.0000</percent_left>
            <percent_right>0.0000</percent_right>
            <ymin_type_1>0</ymin_type_1>
            <ymax_type_1>0</ymax_type_1>
            <ymin_item_1>0</ymin_item_1>
            <ymax_item_1>0</ymax_item_1>
            <graph_items>
                <graph_item>
                    <sortorder>2</sortorder>
                    <drawtype>0</drawtype>
                    <color>0000C8</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_App_Apache_Status</host>
                        <key>apache[Gracefullyfinishing]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <drawtype>0</drawtype>
                    <color>00C800</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_App_Apache_Status</host>
                        <key>apache[DNSLookup]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>3</sortorder>
                    <drawtype>0</drawtype>
                    <color>C800C8</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_App_Apache_Status</host>
                        <key>apache[Idlecleanupofworker]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>11</sortorder>
                    <drawtype>0</drawtype>
                    <color>009696</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_App_Apache_Status</host>
                        <key>apache[IdleWorkers]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>0</sortorder>
                    <drawtype>0</drawtype>
                    <color>C80000</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_App_Apache_Status</host>
                        <key>apache[Closingconnection]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>9</sortorder>
                    <drawtype>0</drawtype>
                    <color>000096</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_App_Apache_Status</host>
                        <key>apache[Startingup]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>4</sortorder>
                    <drawtype>0</drawtype>
                    <color>00C8C8</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_App_Apache_Status</host>
                        <key>apache[Keepaliveread]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>5</sortorder>
                    <drawtype>0</drawtype>
                    <color>C8C800</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_App_Apache_Status</host>
                        <key>apache[Logging]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>10</sortorder>
                    <drawtype>0</drawtype>
                    <color>960096</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_App_Apache_Status</host>
                        <key>apache[WaitingforConnection]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>8</sortorder>
                    <drawtype>0</drawtype>
                    <color>009600</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_App_Apache_Status</host>
                        <key>apache[SendingReply]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>7</sortorder>
                    <drawtype>0</drawtype>
                    <color>960000</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_App_Apache_Status</host>
                        <key>apache[ReadingRequest]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>6</sortorder>
                    <drawtype>0</drawtype>
                    <color>C8C8C8</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>2</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_App_Apache_Status</host>
                        <key>apache[Openslotwithnocurrentprocess]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
    </graphs>
</zabbix_export>

参考资料

  https://github.com/gpmidi/zabbix-apache-stats

时间: 2024-10-29 15:01:55

Zabbix 自定义 key 监控 apache的相关文章

zabbix自定义KEY监控服务状态[不需要端口]

zabbix监控Windows下的服务并实现告警和重启服务 首先 创建获取服务状态的脚本 一.Windows脚本 @echo off set srvname=%1 for /f "skip=3 tokens=4" %%i in ('sc query %srvname%') do set "zt=%%i" &goto :next :next if /i "%zt%"=="RUNNING" ( :服务运行正常,返回1. e

Zabbix自定义key监控docker

一.需求场景在某些docker容器中运行着java,容器提供API供监控调用.需要监控服务运行是否正常和容器内JVM使用情况. 二.想法编写监控脚本,使用自定义key的方式添加到Zabbix中. 三.实践1.编写服务监控脚本 #!/bin/bash interval_time=600 service_port_file=/script/tmp/service_port.txt #Gener_service_port tee > ${service_port_file} << EOF ap

zabbix 自定义key 监控mysql增删查改

1.先熟悉一下zabb自定义key的使用格式 vim /etc/zabbix/zabbix_agentd.d/mysql.conf##zabbix_agentd.d在这个文件夹下的.conf,都会被agent读取,我们这里新建的一个配置文件方便使用,这样就不需要去动主配置文件了 UserParameter=echo[*],echo "$1" #要传递参数要带[*],且key键必须全局唯一 UserParameter=ifconfig,ifconfig|awk NR==2'{print

zabbix 自定义key监控redis

一.环境 ubuntu 14.04 LTS zabbix 2.4.5 redis-2.8.7 二.配置redis监控 1.在/etc/zabbix/zabbix_agentd.d/目录下新建userparameter_redis.conf文件,添加以下内容: UserParameter=redis.stat[*],cat /tmp/redisstat | grep "$1:" | cut -d":" -f2 2.在/etc/crontab文件下添加以下内容 sudo

zabbix自定义key监控mysql主从同步超简单!

1.在zabbix客户端配置文件中加入: 首先要对mysql提供一个查询主从状态的账号!(当然用root也可以.) UserParameter=mysql.replicate_error,if test `mysql -uxxx -pxxx -h127.0.0.1 -e 'show slave status\G' | awk -F: '{if($1~/Slave_IO_Running/) print$2}' ` = "Yes" -a `mysql -uxxx -pxxx -h127.0

zabbix 自定义key 监控 网站关键字

http://www.tuicool.com/articles/3Q7R3y http://www.tuicool.com/articles/fYjQ7j 监控磁盘 配置客户端 vim /usr/local/zabbix-2.2.2/etc/zabbix_agentd.conf Include=/usr/local/etc/zabbix_agentd.conf.d/ #此行去掉注释 编写脚本 vim /usr/local/zabbix-2.2.2/scripts/jfedu.sh #!/bin/

zabbix开源监控系列三(自定义key监控nginx_status)

需求场景 lnmp环境 3台nginx 每台nginx服务上有几个虚拟主机,分别跑了不同的域名,准备对主站做nginx status 状态做监控,监控每一台nginx的活动链接数,和总的连接数. 解决方案1 每台nginx server的主配置文件 都配置status模块  代码端如下 location /ngst{   stub_status on;   access_log off;   allow 127.0.0.1;   allow xxx.xxx.xxx.xxx;   deny all

zabbix 自定义 key (转)

转自:http://www.cnblogs.com/miclesvic/p/6164303.html 1.在zabbix_agent端zabbix_agentd.conf配置文件中增加自定义Key(/usr/local/zabbix_agent/etc/zabbix_agentd.conf) ### Option: UserParameter # User-defined parameter to monitor. There can be several user-defined parame

zabbix 自定义key值监控

1.zabbix一般监控使用zabbix即可,如果自定义的监控的话也是可以的,现看下zabbix.agentd.conf里面的介绍 UnsafeUserParameters 默认参数是0,0表示不启用UserParameter,1表示启用. 2. UserParameter=<key>,<shell command> 这个就是自定义监控的命令,key加上监控的选项,如下监控http的连接数 3.改完配置以后一定要重启下,之后再服务端测试下 这里可以看到有输出的,但是没访问所以很少