1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

varnish: rename, use perlpod and minor changes

This commit is contained in:
Kim B. Heino 2021-04-06 10:12:01 +03:00 committed by Lars Kruse
parent b2a11780b3
commit a92c9a9b67

View file

@ -1,19 +1,43 @@
#!/usr/bin/python3 -tt #!/usr/bin/env python3
# -*- coding: utf-8 -*- # pylint: disable=invalid-name
# pylint: enable=invalid-name
""" Munin plugin to monitor Varnish 4 status. """Munin plugin to monitor Varnish status.
Copyright 2016, Kim B. Heino, b@bbbs.net, Foobar Oy =head1 NAME
License GPLv2+
varnish - monitor Varnish status
=head1 APPLICABLE SYSTEMS
Systems running Varnish cache.
=head1 CONFIGURATION
No configuration is required for this plugin.
=head1 NOTES
This plugin is tested on Varnish 4 but it should also work with v5 and v6.
=head1 AUTHOR
Kim B. Heino <b@bbbs.net>
This is based heavily on varnish4_ plugin from Munin contrib This is based heavily on varnish4_ plugin from Munin contrib
by Kristian Lyngstol <kristian@bohemians.org> / Redpill Linpro AS. by Kristian Lyngstol <kristian@bohemians.org> / Redpill Linpro AS.
#%# capabilities=autoconf =head1 LICENSE
#%# family=auto
GPLv2
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
""" """
# pylint: disable=invalid-name
# pylint: enable=invalid-name
import json import json
import subprocess import subprocess
@ -41,12 +65,6 @@ def get_values():
return {} return {}
def autoconf():
"""Print "yes" or "no"."""
status = 'yes' if get_values() else 'no'
print(status)
def config(): def config():
"""Print plugin config.""" """Print plugin config."""
# pylint: disable=too-many-statements # pylint: disable=too-many-statements
@ -192,18 +210,16 @@ def config():
print('n_objectcore.label Number of object cores') print('n_objectcore.label Number of object cores')
print('n_objectcore.type GAUGE') print('n_objectcore.type GAUGE')
print('n_objecthead.label Number of object heads') print('n_objecthead.label Number of object heads')
print( print('n_objecthead.info Each object head can have one or more object '
'n_objecthead.info Each object head can have one or more object ' 'attached, typically based on the Vary: header')
'attached, typically based on the Vary: header')
print('n_objecthead.type GAUGE') print('n_objecthead.type GAUGE')
# request_rate # request_rate
print('multigraph varnish_request_rate') print('multigraph varnish_request_rate')
print('graph_category webserver') print('graph_category webserver')
print('graph_title Request rates') print('graph_title Request rates')
print( print('graph_order cache_hit cache_hitpass cache_miss backend_conn '
'graph_order cache_hit cache_hitpass cache_miss backend_conn ' 'backend_unhealthy client_req client_conn')
'backend_unhealthy client_req client_conn')
print('client_req.label Good client requests received') print('client_req.label Good client requests received')
print('client_req.min 0') print('client_req.min 0')
print('client_req.colour 111111') print('client_req.colour 111111')
@ -238,10 +254,9 @@ def config():
print('cache_hitpass.min 0') print('cache_hitpass.min 0')
print('cache_hitpass.draw STACK') print('cache_hitpass.draw STACK')
print('cache_hitpass.colour FFFF00') print('cache_hitpass.colour FFFF00')
print( print('cache_hitpass.info Hitpass are cached passes: An entry in the '
'cache_hitpass.info Hitpass are cached passes: An entry in the ' 'cache instructing Varnish to pass. Typically achieved after a '
'cache instructing Varnish to pass. Typically achieved after a ' 'pass in vcl_fetch.')
'pass in vcl_fetch.')
print('cache_hitpass.type DERIVE') print('cache_hitpass.type DERIVE')
print('cache_hit.label Cache hits') print('cache_hit.label Cache hits')
print('cache_hit.min 0') print('cache_hit.min 0')
@ -288,9 +303,8 @@ def config():
print('s_resp_hdrbytes.min 0') print('s_resp_hdrbytes.min 0')
print('s_resp_hdrbytes.draw STACK') print('s_resp_hdrbytes.draw STACK')
print('s_resp_hdrbytes.cdef s_resp_hdrbytes,8,*') print('s_resp_hdrbytes.cdef s_resp_hdrbytes,8,*')
print( print('s_resp_hdrbytes.info HTTP Header traffic. TCP/IP overhead is not '
's_resp_hdrbytes.info HTTP Header traffic. TCP/IP overhead is not ' 'included.')
'included.')
print('s_resp_hdrbytes.type DERIVE') print('s_resp_hdrbytes.type DERIVE')
# uptime # uptime
@ -324,8 +338,7 @@ def fetch():
'backend_reuse', 'backend_reuse',
'backend_req', 'backend_req',
): ):
print('{0}.value {1}'.format( print('{0}.value {1}'.format(key, data['MAIN.' + key]['value']))
key, data['MAIN.' + key]['value']))
# bad # bad
print('multigraph varnish_bad') print('multigraph varnish_bad')
@ -344,12 +357,10 @@ def fetch():
'threads_limited', 'threads_limited',
'fetch_failed', 'fetch_failed',
): ):
print('{0}.value {1}'.format( print('{0}.value {1}'.format(key, data['MAIN.' + key]['value']))
key, data['MAIN.' + key]['value']))
print('SMA_Transient_c_fail.value {0}'.format( print('SMA_Transient_c_fail.value {0}'.format(
data['SMA.Transient.c_fail']['value'])) data['SMA.Transient.c_fail']['value']))
print('SMF_s0_c_fail.value {0}'.format( print('SMF_s0_c_fail.value {0}'.format(data['SMF.s0.c_fail']['value']))
data['SMF.s0.c_fail']['value']))
# expunge # expunge
print('multigraph varnish_expunge') print('multigraph varnish_expunge')
@ -357,8 +368,7 @@ def fetch():
'n_lru_nuked', 'n_lru_nuked',
'n_expired', 'n_expired',
): ):
print('{0}.value {1}'.format( print('{0}.value {1}'.format(key, data['MAIN.' + key]['value']))
key, data['MAIN.' + key]['value']))
# hit_rate # hit_rate
print('multigraph varnish_hit_rate') print('multigraph varnish_hit_rate')
@ -380,14 +390,10 @@ def fetch():
data['SMA.Transient.g_bytes']['value'])) data['SMA.Transient.g_bytes']['value']))
print('SMA_Transient_g_space.value {0}'.format( print('SMA_Transient_g_space.value {0}'.format(
data['SMA.Transient.g_space']['value'])) data['SMA.Transient.g_space']['value']))
print('SMF_s0_g_bytes.value {0}'.format( print('SMF_s0_g_bytes.value {0}'.format(data['SMF.s0.g_bytes']['value']))
data['SMF.s0.g_bytes']['value'])) print('sms_nbytes.value {0}'.format(data['MAIN.sms_nbytes']['value']))
print('sms_nbytes.value {0}'.format( print('sms_balloc.value {0}'.format(data['MAIN.sms_balloc']['value']))
data['MAIN.sms_nbytes']['value'])) print('SMF_s0_g_space.value {0}'.format(data['SMF.s0.g_space']['value']))
print('sms_balloc.value {0}'.format(
data['MAIN.sms_balloc']['value']))
print('SMF_s0_g_space.value {0}'.format(
data['SMF.s0.g_space']['value']))
print('SMA_Transient_c_bytes.value {0}'.format( print('SMA_Transient_c_bytes.value {0}'.format(
data['SMA.Transient.c_bytes']['value'])) data['SMA.Transient.c_bytes']['value']))
@ -399,8 +405,7 @@ def fetch():
'n_objectcore', 'n_objectcore',
'n_objecthead', 'n_objecthead',
): ):
print('{0}.value {1}'.format( print('{0}.value {1}'.format(key, data['MAIN.' + key]['value']))
key, data['MAIN.' + key]['value']))
# request_rate # request_rate
print('multigraph varnish_request_rate') print('multigraph varnish_request_rate')
@ -415,8 +420,7 @@ def fetch():
'cache_hitpass', 'cache_hitpass',
'cache_hit', 'cache_hit',
): ):
print('{0}.value {1}'.format( print('{0}.value {1}'.format(key, data['MAIN.' + key]['value']))
key, data['MAIN.' + key]['value']))
# threads # threads
print('multigraph varnish_threads') print('multigraph varnish_threads')
@ -427,8 +431,7 @@ def fetch():
'threads_limited', 'threads_limited',
'threads', 'threads',
): ):
print('{0}.value {1}'.format( print('{0}.value {1}'.format(key, data['MAIN.' + key]['value']))
key, data['MAIN.' + key]['value']))
# transfer_rates # transfer_rates
print('multigraph varnish_transfer_rates') print('multigraph varnish_transfer_rates')
@ -436,8 +439,7 @@ def fetch():
's_resp_bodybytes', 's_resp_bodybytes',
's_resp_hdrbytes', 's_resp_hdrbytes',
): ):
print('{0}.value {1}'.format( print('{0}.value {1}'.format(key, data['MAIN.' + key]['value']))
key, data['MAIN.' + key]['value']))
# uptime # uptime
print('multigraph varnish_uptime') print('multigraph varnish_uptime')
@ -446,7 +448,7 @@ def fetch():
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) > 1 and sys.argv[1] == 'autoconf': if len(sys.argv) > 1 and sys.argv[1] == 'autoconf':
autoconf() print('yes' if get_values() else 'no (varnish is not running)')
elif len(sys.argv) > 1 and sys.argv[1] == 'config': elif len(sys.argv) > 1 and sys.argv[1] == 'config':
config() config()
else: else: