diff --git a/modules/varnish/files/varnishreqstats b/modules/varnish/files/varnishreqstats index 9ed812d..e717f22 100755 --- a/modules/varnish/files/varnishreqstats +++ b/modules/varnish/files/varnishreqstats @@ -33,7 +33,7 @@ import sys import time import unittest -from varnishlog import varnishlog +from varnishlog4 import varnishlog valid_http_methods = ( 'get', @@ -154,11 +154,11 @@ def count_vsl_entries( return # Count the http request method - if tag in ['TxRequest', 'RxRequest'] and is_valid_http_method(value): + if tag in ['BereqMethod', 'ReqMethod'] and is_valid_http_method(value): counts[remote_party + '.method.' + value.lower()] += 1 # Count the http response status - elif tag in ['RxStatus', 'TxStatus'] and is_valid_http_status(value): + elif tag in ['BerespStatus', 'RespStatus'] and is_valid_http_status(value): key_prefix = remote_party + '.status.' counts[key_prefix + value[0] + 'xx'] += 1 @@ -173,7 +173,11 @@ def count_vsl_entries( counts[key_prefix + 'error'] += 1 # Thesee indicates we completed a request, count it. - elif tag in ['ReqEnd', 'BackendClose', 'BackendReuse']: + elif tag in ['BackendClose', 'BackendReuse']: + counts[remote_party + '.total'] += 1 + + # There is no ReqEnd in v4, let's use Timestamp for Resp + elif tag == 'Timestamp' and 'Resp' in value: counts[remote_party + '.total'] += 1 # If interval seconds have passed, publish counts @@ -204,11 +208,11 @@ if __name__ == '__main__': arguments = parser.parse_args() vsl_args = [ - ('i', 'TxRequest'), - ('i', 'RxStatus'), - ('i', 'RxRequest'), - ('i', 'TxStatus'), - ('i', 'ReqEnd'), + ('i', 'BereqMethod'), + ('i', 'BerespStatus'), + ('i', 'ReqMethod'), + ('i', 'RespStatus'), + ('i', 'Timestamp'), ('i', 'BackendClose'), ('i', 'BackendReuse') ]