• Zabbix 2.4.5 自定义 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"
     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
    Failed 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('
    '), err.strip('
    ')))
    
        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 += "-	apache[%s]	%s
    " % (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
    " % (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

  • 相关阅读:
    幸福必读
    JAVA程序员之路
    编写数据库操作类,使ASP.NET 中的数据库操作变得简单
    Duwamish 7.0 系列分析文章
    Visual Studio .NET加密技术剖析系列课程
    做为一个Tester,你为Testing付出了多少?
    程序员分成几种不同的境界
    深度探索C++对象模型(2).txt
    Eclipse快速上手指南之使用JUnit
    Eclipse使用技巧
  • 原文地址:https://www.cnblogs.com/chrisDuan/p/4599592.html
Copyright © 2020-2023  润新知