Giter VIP home page Giter VIP logo

zabbix-apache-stats's Introduction

zabbix-apache-status

Overview

This program gathers data from Apache's built-in status page and sends it to Zabbix. The data is sent via the CLI tool zabbix_sender.

*** See http://www.zabbix.com/wiki/templates/apache for a detailed install guide ***

Author(s)

Install

Enable Apache server-status

  1. Add this to your Apache config file:

    <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
  2. Restart/reload Apache or use ```kill -USR1 `cat /var/run/httpd.pid ```` for zero downtime

Configure 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

Now continue with either Zabbix Agent Mode mode or Cron mode.

Zabbix Agent Mode Install

This method relies on your polling interval for an item called apache.status, and will honor any maintenance windows. The check will run on the host being monitored everytime time apache.status is polled. This item is defined as a UserParameter like this:

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

Install on apache server to be monitored and connect to status page on localhost. Assumes zabbix-agent is installed.

  1. Copy bin/check_apache to , such as /var/lib/zabbix/bin/check_apache
  2. Run chmod +x on the file
  3. Copy conf/check_apache.conf to your zabbix agent include dir. Probably /etc/zabbix_agentd.conf.d/
  • Tip Check to make sure your include directory is enabled.

grep Include /etc/zabbix_agentd.conf

  1. Tip Make sure you have ServerActive and Hostname filled in your config file.
  2. Restart zabbix-agent.

Cron or Remote Mode Install

This method can run remotely or locally via cron. This method relies on your cron scheduler to set the polling interval, and is unaware of any maintenance windows.

Install on Zabbix server or the host to monitor:

  1. Copy bin/check_apache to , such as /usr/bin/check_apache
  2. Run chmod +x on the file
  3. Add this to crontab to run every minute: * * * * * /usr/bin/check_apache --zabbixsource myhostname -z myzabbixserver &> /dev/null
  4. Replace "myhostname" with the hostname (or name in the Zabbix GUI) of the host that the values should be stored with. Replace "myzqbbixserver" with the hostname/IP of your Zabbix server.

Repeat above cron lines to monitor multiple hosts. Use the -o option if these URL differs from the hostname.

Notes

License

GPLv2 - See LICENSE file

zabbix-apache-stats's People

Contributors

dlbewley avatar galindro avatar gpmidi avatar rogersk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zabbix-apache-stats's Issues

need more than 1 value to unpack

When I run /usr/lib/zabbix/check_apache --config /etc/zabbix/zabbix_agentd.conf

I get

"failed to parse server-status: need more than 1 value to unpack"

RHEL 7.1
Server version: Apache/2.4.6 (Red Hat Enterprise Linux)

Can confirm I can access /server-status from localhost.

ValueError: need more than 1 value to unpack. (old script)

I tried to run this script from our monitoring server for a remote host running Apache 2.4.16, but when I excecute cron, it returns the following error.

Traceback (most recent call last):
File "/usr/local/plugin/fetch.py", line 225, in
data = parse(data = data)
File "/usr/local/plugin/fetch.py", line 78, in parse
for (key, val) in csvobj:
ValueError: need more than 1 value to unpack

I have added hostname before each item key in the template.

When I add print data in 77th line in the script it shows correct data from apache server along with the error above. I also checked with 'print repr(csvobj)' but it shows the following.

<_csv.reader object at 0x7f04feca5a60>
Traceback (most recent call last):
File "/usr/local/plugin/fetch.py", line 225, in
data = parse(data = data)
File "/usr/local/plugin/fetch.py", line 78, in parse
for (key, val) in csvobj:
ValueError: need more than 1 value to unpack

remote host is an amazon ec2 instance.

failed to send parsed data

Trying to send data to a zabbix 2.4.7 instance I get this error:

/var/lib/zabbix/bin/check_apache --config /etc/zabbix/zabbix_agentd.conf 
sendValues: -   apache[ReadingRequest]  9
-   apache[Uptime]  578838
-   apache[Logging] 0
-   apache[TotalAccesses]   200095
-   apache[SendingReply]    1
-   apache[Startingup]  0
-   apache[Idlecleanupofworker] 0
-   apache[Gracefullyfinishing] 0
-   apache[DNSLookup]   0
-   apache[BytesPerReq] 59830.6
-   apache[WaitingforConnection]    63
-   apache[CPULoad] .0917372
-   apache[BytesPerSec] 20682.5
-   apache[Keepaliveread]   2
-   apache[ReqPerSec]   .345684
-   apache[TotalkBytes] 11691207
-   apache[IdleWorkers] 63
-   apache[BusyWorkers] 12
-   apache[Closingconnection]   0
-   apache[Openslotwithnocurrentprocess]    75

sending to server in agent config /etc/zabbix/zabbix_agentd.conf
failed to send parsed data: error returned from /usr/bin/zabbix_sender! ret: 2, out: 'info from server: "processed: 0; failed: 20; total: 20; seconds spent: 0.000141"
sent: 20; skipped: 0; total: 20', err: 'zabbix_sender [7050]: DEBUG: answer [{"response":"success","info":"processed: 0; failed: 20; total: 20; seconds spent: 0.000141"}]'
ZBX_NOTSUPPORTED

Could you help me to solve the problem?

Thanks
Paolo

import template failure :

Here the error I receive when importing the template:
Cannot read XML: (41) Specification mandate value for attribute data-pjax-transient [Line: 45 | Column: 42].

Any suggestion?

thx

running Zabbix 3.0.4

ValueError: need more than 1 value to unpack

Attempting to run fetch.py on a CentOS 5.10 system returns the following error:

Traceback (most recent call last):
  File "/etc/zabbix/bin/fetch.py", line 224, in <module>
    data = parse(data = data)
  File "/etc/zabbix/bin/fetch.py", line 77, in parse
    for (key, val) in csvobj:
ValueError: need more than 1 value to unpack

This is very strange code. It works perfectly on my Debian and Ubuntu systems; this is the first CentOS box I have tried to run it on.

I threw in a print data just before line 77 to verify that it was actually seeing the Apache server status, and the status appeared to be present and valid.

The only other change I made to the script was in line 1, which I changed to:

#!/usr/bin/python26

to try to rule out any problem with Python 2.4.

The box is running:

CentOS 5.10
python26-2.6.8-2.el5

My command line was:

/etc/zabbix/bin/fetch.py -c $(hostname) -z monitor.example.com -l http://localhost/whm-server-status

ZBX 3 Import Template

The template can't be imported. Results on error.
...
Created: Application "Apache Worker" on "Template_App_Apache_Status".
Created: Application "Apache Stats" on "Template_App_Apache_Status".
Cannot find value map "Host status" used for item "Apache Status" on "Template_App_Apache_Status".

running on localhost

when running fetch.py on localhost with zabbix on localhost and apache on localhost, sender runs but no test pass. the instructions in the wiki were followed as well.

/usr/bin/python ZabbixApacheUpdater.py -s /usr/local/bin/zabbix_sender -z localhost -c 127.0.0.1
zabbix_sender [5946]: DEBUG: answer [{
"response":"success",
"info":"processed: 0; failed: 20; total: 20; seconds spent: 0.001798"}]
info from server: "processed: 0; failed: 20; total: 20; seconds spent: 0.001798"
sent: 20; skipped: 0; total: 20
Usage: ApacheStatsForZabbix [-z ] [-o ]

ApacheStatsForZabbix: error: An error occurred while sending values to the Zabbix server

ZBX_NOTSUPPORTED

After trying to run the executable i get that error.

Ubuntu 14.04, Zabbix 2.4

Question: Is this normal behavior of an Application ?

Apache stats:
screen shot 2017-03-05 at 4 30 47 pm

I am noticing a gradual increase in the yellow line and it seems like it hits a limit every sunday. And then app starts throwing 404s in between

Although, the graph clearly says bytes per second. But the graph is giving me a hard time understanding the gradual increase and sudden drop. I will be grateful if someone can share some thoughts on this. Thanks

apache[localhost,???]

I'm using Zabbix 2.2.1.

There's a conflict between zabbix_export.xml and fetch.py, zabbix_export.xml use apache[localhost,???] as the key while fetch.py use "%s apache[%s,%s] %s\n" % (opts.zabbixsource, opts.host, key, val).

When monitoring a remote webserver, opts.host is not set to localhost but something else. Then zabbix-sender pushs keys apache[notlocalhost,???] causing error: An error occurred while sending values to the Zabbix server.

I think we can change apache[localhost,???] to apache[???]. (Though I'm not quite familiar with Zabbix core)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.