Projet

Général

Profil

Révision 17f78427

ID17f784270ae966ee9a13e9f5104a5b8f925b639e
Parent ef851f0c
Enfant d4320aea, 5b2396a9

Ajouté par Lars Kruse il y a plus de 7 ans

Whitespace cleanup

  • remove trailing whitespace
  • remove empty lines at the end of files

Voir les différences:

plugins/nginx/nginx_vhost_traffic
1 1
#!/bin/sh
2 2
#
3 3
# Script for monitoring nginx Virtual host output traffic
4
# 
4
#
5 5
# Requierements: logtail awk
6 6
# one unique access log file with $bytes_sent value for more accuracy
7 7
# check http://wiki.nginx.org/NginxHttpLogModule
......
11 11
#
12 12
# Virtual host list
13 13
# env.vhosts "example.com example.net example.org"
14
# 
14
#
15 15
# Log path
16 16
# env.logdir = /var/log/nginx
17
# env.flogfile = access.log 
17
# env.flogfile = access.log
18 18
#
19 19
# Position of the $bytes_sent in the access.log file
20 20
# env.bparam 11
21 21
#
22 22
# Aggregate subdomains
23
# ex: example.com will match www.example.com, webmail.example.com and *example.com 
23
# ex: example.com will match www.example.com, webmail.example.com and *example.com
24 24
# BUG: will also match also www.bad-example.com
25
# env.aggregate true #change to false to disable aggregation 
25
# env.aggregate true #change to false to disable aggregation
26 26
#
27 27
# To report bugs, improvements or get updates
28 28
# see http://github.com/joanpc/nginix_vhost_traffic
29 29
#
30
# inspired in postfix_filtered_awk 
30
# inspired in postfix_filtered_awk
31 31
# Copyright (c) 2010, Joan Perez i Cauhe
32 32

  
33 33
LOGDIR=${logdir:-/var/log/nginx}
......
48 48
	echo 'graph_category webserver'
49 49

  
50 50
	i=0
51
	for vhost in $VHOSTS 
52
	do 
51
	for vhost in $VHOSTS
52
	do
53 53
		i=$(($i + 1))
54 54
		echo vhost$i.label $vhost
55 55
		echo vhost$i.type ABSOLUTE
......
57 57
		echo vhost$i.draw $DRAW
58 58
		DRAW=STACK
59 59
	done
60
	
60

  
61 61
	echo rest.label Rest
62 62
	echo rest.type ABSOLUTE
63 63
	echo rest.cdef rest,8,*
......
72 72
# Awk Script
73 73
$LOGTAIL ${ACCESS_LOG} -o $STATEFILE | awk '
74 74

  
75
BEGIN { 
75
BEGIN {
76 76
split(ENVIRON["VHOSTS"], hosts)
77 77
for (host in hosts) { track[hosts[host]] = host}
78
}        
78
}
79 79
{
80 80
		cn[$2]+=$ENVIRON["BPARAM"]
81 81
}
82
END { 
83
		for (host in cn) {		
84
		if (match(ENVIRON["AGGREGATE"], "true")) {	
82
END {
83
		for (host in cn) {
84
		if (match(ENVIRON["AGGREGATE"], "true")) {
85 85
			found = 0
86 86
			for (vhost in track) {
87 87
				if (index(host, vhost)) {
......
93 93
			if (! found) rest+=cn[host]
94 94
		} else {
95 95
			if (host in track) {
96
				res[host] += cn[host]	
96
				res[host] += cn[host]
97 97
			} else rest+=cn[host]
98 98
		}
99 99
		}

Formats disponibles : Unified diff