GitXplorerGitXplorer
a

zbx_nginx_template

public
126 stars
93 forks
13 issues

Commits

List of commits on branch master.
Unverified
a340653051e5058328a3b972776d6af88f0f1458

add IPv6 support

committed 9 years ago
Unverified
008be39dc9dd6c961c4d49a16cecece4350d45dd

Merge pull request #3 from junwei-wang/master

aadubkov committed 10 years ago
Unverified
4ad103db15cf3846175e9d25b16cdb47eab505a3

update the document

jjunwei-wang committed 10 years ago
Unverified
342022c15fa3694de0be146d74e4a4a526e74f5b

Merge pull request #1 from geekpete/patch-1

aadubkov committed 11 years ago
Unverified
9da92402195b9aba838addc71d67d0583e0a3700

Fixing copy/paste typo from zbx_redis_template

ggeekpete committed 11 years ago
Unverified
355af8b064443d6d0819325e1826db3a661fb268

readme typo

aadubkov committed 11 years ago

README

The README file for this repository.

zbx_nginx_template

Zabbix template for Nginx (python)

It's accumulate nginx stats and parse the access.log (just pice of log at once) and push result in Zabbix through trap-messages

System requirements

  • python
  • nginx with configured http_stub_status_module and access.log

What's logging:

  • Request\sec
  • Response codes (200,301,302,403,404,500,503)\min
  • Active\Keepalive connections
  • Header and body reading
  • Accepted, handled connections

Install

  1. Put zbx_nginx_stats.py into your scripts path (like: /etc/zabbix/script/nginx/) on your Zabbix agent hosts.

  2. Change next section in zbx_nginx_stats.py, to your configuration:

zabbix_host = '127.0.0.1'   # Zabbix server IP
zabbix_port = 10051         # Zabbix server port
hostname = 'Zabbix Agent'   # Name of monitored host, like it shows in zabbix web ui
time_delta = 1              # grep interval in minutes

# URL to nginx stat (http_stub_status_module)
stat_url = 'https://nginx.server/nginx_stat'

# Nginx log file path
nginx_log_file_path = '/var/log/nginx/access.log'

# Optional Basic Auth
username = 'user'
password = 'pass'

# Temp file, with log file cursor position
seek_file = '/tmp/nginx_log_stat'
  1. In script path (/etc/zabbix/script/nginx/) do:
chmod +x zbx_nginx_stats.py
  1. Configure cron to run script every one minute:
$ sudo crontab -e

*/1 * * * * /etc/zabbix/script/nginx/zbx_nginx_stats.py
  1. Import zbx_nginx_template.xml into zabbix in Tepmplate section web gui.

  2. Add the following configurations to you Nginx configuration file.

location /nginx_stat {
  stub_status on;       # Turn on nginx stats
  access_log   off;     # We do not need logs for stats
  allow 127.0.0.1;      # Security: Only allow access from IP
  allow ::1;            # Security IPv6: allow only from localhost
  deny all;             # Deny requests from the other of the world
}

That is all :)