summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile.am2
-rw-r--r--NEWS90
-rw-r--r--README34
-rw-r--r--configure.ac12
-rw-r--r--lib/VarnishMib/HashTable.pm16
-rw-r--r--lib/VarnishMib/MIBTable.pm16
-rw-r--r--src/Makefile.am2
-rw-r--r--src/VARNISH-MIB.txt6
-rw-r--r--src/auth.c2
-rw-r--r--src/backend.h3
-rw-r--r--src/ban.c2
-rw-r--r--src/belex.l17
-rw-r--r--src/modconf.c17
-rw-r--r--src/varnish-mib.885
-rw-r--r--src/vcli.c2
15 files changed, 254 insertions, 52 deletions
diff --git a/Makefile.am b/Makefile.am
index 30060d5..cea3646 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,26 +1,26 @@
1# This file is part of varnish-mib -*- automake -*- 1# This file is part of varnish-mib -*- automake -*-
2# Copyright (C) 2014-2015 Sergey Poznyakoff 2# Copyright (C) 2014-2018 Sergey Poznyakoff
3# 3#
4# varnish-mib is free software; you can redistribute it and/or modify 4# varnish-mib is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by 5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option) 6# the Free Software Foundation; either version 3, or (at your option)
7# any later version. 7# any later version.
8# 8#
9# varnish-mib is distributed in the hope that it will be useful, 9# varnish-mib is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details. 12# GNU General Public License for more details.
13# 13#
14# You should have received a copy of the GNU General Public License 14# You should have received a copy of the GNU General Public License
15# along with varnish-mib. If not, see <http://www.gnu.org/licenses/>. 15# along with varnish-mib. If not, see <http://www.gnu.org/licenses/>.
16ACLOCAL_AMFLAGS = -I m4 16ACLOCAL_AMFLAGS = -I m4
17SUBDIRS = src 17SUBDIRS = src
18EXTRA_DIST=\ 18EXTRA_DIST=\
19 git2chg.awk\ 19 git2chg.awk\
20 lib/prereq.pl\ 20 lib/prereq.pl\
21 lib/VarnishMib/HashTable.pm\ 21 lib/VarnishMib/HashTable.pm\
22 lib/VarnishMib/MIBTable.pm 22 lib/VarnishMib/MIBTable.pm
23 23
24.PHONY: ChangeLog 24.PHONY: ChangeLog
25ChangeLog: 25ChangeLog:
26 $(AM_V_GEN)if test -d .git; then \ 26 $(AM_V_GEN)if test -d .git; then \
diff --git a/NEWS b/NEWS
index f12c539..e447533 100644
--- a/NEWS
+++ b/NEWS
@@ -1,43 +1,127 @@
1Varnish-mib NEWS -- history of user-visible changes. 2016-04-27 1Varnish-mib NEWS -- history of user-visible changes. 2018-02-05
2Copyright (C) 2014-2016 Sergey Poznyakoff
3See the end of file for copying conditions. 2See the end of file for copying conditions.
4 3
5Please send Varnish-mib bug reports to <gray@gnu.org> 4Please send Varnish-mib bug reports to <gray@gnu.org>
6 5
6Version 2.0, 2018-02-05
7
8This version is written for Varnish 5.2.0. It will definitely not
9compile with Varnish 5.2.1 and later. You'll have to use version 3.0
10for that.
11
12Most important changes:
13
14New OIDs:
15
16** VarnishMIB::objects branch
17
18 objectsCount
19
20 Approximate number of HTTP objects (headers + body,
21 if present) in the cache.
22 [Varnish variable MAIN.n_object]
23
24 objectsVampire
25 Number of unresurrected objects.
26 [MAIN.n_vampireobject]
27
28 objectsCore
29 Approximate number of object metadata elements in the cache. Each
30 object needs an objectcore, extra objectcores are for
31 hit-for-miss, hit-for-pass and busy objects.
32 [MAIN.n_objectcore]
33
34 objectsHead
35 Approximate number of different hash entries in the cache.
36 [MAIN.n_objecthead]
37
38 objectsExpired
39 Number of objects that expired from cache because of old age.
40 [MAIN.n_expired]
41
42 objectsLRUNuked
43 How many objects have been forcefully evicted from
44 storage to make room for a new object.
45 [MAIN.n_lru_nuked]
46
47 objectsLRUMoved
48 Number of move operations done on the LRU list.
49 [MAIN.n_lru_moved]
50
51 objectsPurges
52 Number of purge operations executed.
53 [MAIN.n_purges]
54
55 objectsObjPurged
56 Number of purged objects.
57 [MAIN.n_obj_purged]
58
59 objectsGzip
60 Number of gzip operations.
61 [MAIN.n_gzip]
62
63 objectsGunzip
64 Number of gunzip operations.
65 [MAIN.n_gunzip]
66
67** VarnishMIB::vcl branch
68
69 vclTotal
70 Number of loaded VCLs in total.
71 [MAIN.n_vcl]
72
73 vclAvail
74 Number of VCLs available.
75 [MAIN.n_vcl_avail]
76
77 vclDiscard
78 Number of discarded VCLs.
79 [MAIN.n_vcl_discard]
80
81 vclFail
82 Number of VCL failures.
83 [MAIN.vcl_fail]
84
85* Removed OIDs
86
87Several OIDs have been withdrawn due to changes in the Varnish API.
88These are: clientRequests411, clientRequests413, and backendConnUnused.
89
90
7Version 1.1.90 (Git) 91Version 1.1.90 (Git)
8 92
9* Support for Varnish 4.1 93* Support for Varnish 4.1
10 94
11 95
12Version 1.1, 2015-02-25 96Version 1.1, 2015-02-25
13 97
14* Don't exit if unable to open Varnish memory file 98* Don't exit if unable to open Varnish memory file
15 99
16 100
17Version 1.0, 2014-11-28 101Version 1.0, 2014-11-28
18 102
19Initial release. 103Initial release.
20 104
21 105
22* Copyright information: 106* Copyright information:
23 107
24Copyright (C) 2014-2016 Sergey Poznyakoff 108Copyright (C) 2014-2018 Sergey Poznyakoff
25 109
26 Permission is granted to anyone to make or distribute verbatim copies 110 Permission is granted to anyone to make or distribute verbatim copies
27 of this document as received, in any medium, provided that the 111 of this document as received, in any medium, provided that the
28 copyright notice and this permission notice are preserved, 112 copyright notice and this permission notice are preserved,
29 thus giving the recipient permission to redistribute in turn. 113 thus giving the recipient permission to redistribute in turn.
30 114
31 Permission is granted to distribute modified versions 115 Permission is granted to distribute modified versions
32 of this document, or of portions of it, 116 of this document, or of portions of it,
33 under the above conditions, provided also that they 117 under the above conditions, provided also that they
34 carry prominent notices stating who last changed them. 118 carry prominent notices stating who last changed them.
35 119
36Local variables: 120Local variables:
37mode: outline 121mode: outline
38 paragraph-separate: "[ ]*$" 122 paragraph-separate: "[ ]*$"
39eval: (add-hook 'write-file-hooks 'time-stamp) 123eval: (add-hook 'write-file-hooks 'time-stamp)
40time-stamp-start: "changes. " 124time-stamp-start: "changes. "
41time-stamp-format: "%:y-%02m-%02d" 125time-stamp-format: "%:y-%02m-%02d"
42time-stamp-end: "\n" 126time-stamp-end: "\n"
43end: 127end:
diff --git a/README b/README
index 8e68d6a..1917254 100644
--- a/README
+++ b/README
@@ -1,67 +1,91 @@
1Varnish-mib README 1Varnish-mib README
2Copyright (C) 2014-2015 Sergey Poznyakoff
3See the end of file for copying conditions. 2See the end of file for copying conditions.
4 3
5* Introduction 4* Introduction
6 5
7This file contains brief information about configuring, testing 6This file contains brief information about configuring, testing
8and using Varnish-mib. It is *not* intended as a replacement 7and using Varnish-mib. It is *not* intended as a replacement
9for the documentation, and is provided as a brief reference only. 8for the documentation, and is provided as a brief reference only.
10For a detailed documentation, please see the varnish-mib(8) 9For a detailed documentation, please see the varnish-mib(8)
11manpage. 10manpage.
12 11
12If you are building varnish-mib from Git repository, jump to
13the section GIT SOURCES, below.
14
13* Overview 15* Overview
14 16
15Varnish-mib is a dynamically loadable object module for net-snmp 17Varnish-mib is a dynamically loadable object module for net-snmp
16snmpd, that provides access to Varnish Cache statistics. It uses 18snmpd, that provides access to Varnish Cache statistics. It uses
17MIBs from varnishsnmp project (http://varnishsnmp.sourceforge.net). 19MIBs from varnishsnmp project (http://varnishsnmp.sourceforge.net).
18 20
21This and other versions of Varnish-mib is available for download from
22<http://download.gnu.org.ua/release/varnish-mib>. The following table
23describes the relation between the release number and the version
24of Varnish API version it is written for:
25
26 1.0 and up to 2.0 Varnish 4.0 and 4.1
27 2.0 (this release) Varnish 5.2.0
28 3.0 Varnish 5.2.1
29
19* Installation 30* Installation
20 31
21In order to compile the package you need to have Net-snmp and Varnish 32In order to compile the package you need to have Net-SNMP and Varnish
22installed. Only Varnish 4.x is supported. The installation sequence 33installed. The installation sequence is as usual:
23is as usual:
24 34
25 ./configure [options] 35 ./configure [options]
26 make 36 make
27 make install 37 make install
28 38
29(the last step normally requires root privileges). For generic 39(the last step normally requires root privileges). For generic
30options to configure, please see the file INSTALL. Package-specific 40options to configure, please see the file INSTALL. Package-specific
31options are: 41options are:
32 42
33** --with-dlmoddir=DIR 43** --with-dlmoddir=DIR
34 44
35Install varnish_mod.so in DIR. By default it is installed in 45Install varnish_mod.so in DIR. By default it is installed in
36$PREFIX/lib/snmp, where $PREFIX stands for the installation prefix. 46$PREFIX/lib/snmp, where $PREFIX stands for the installation prefix.
37 47
38** --with-mibdir=DIR 48** --with-mibdir=DIR
39 49
40Install MIBs (the file VARNISH-MIB.txt in DIR. By default it is 50Install MIBs (the file VARNISH-MIB.txt in DIR. By default it is
41installed in $prefix/share/snmp. 51installed in $prefix/share/snmp.
42 52
53* GIT SOURCES
54
55If you cloned the sources from GIT, you will need the following
56additional tools in order to bootstrap the package:
57
58 + Perl
59 + mib2c
60 + Perl module Inline::C
61 + Flex
62
63Make sure to check out the branch corresponding to the version of
64Varnish you are using. Run ./bootstrap. Then, proceed as discussed
65above.
66
43* Bug reporting 67* Bug reporting
44 68
45Send bug reports and suggestions to <gray@gnu.org> 69Send bug reports and suggestions to <gray@gnu.org>
46 70
47 71
48* Copyright information: 72* Copyright information:
49 73
50Copyright (C) 2014 Sergey Poznyakoff 74Copyright (C) 2014-2018 Sergey Poznyakoff
51 75
52 Permission is granted to anyone to make or distribute verbatim copies 76 Permission is granted to anyone to make or distribute verbatim copies
53 of this document as received, in any medium, provided that the 77 of this document as received, in any medium, provided that the
54 copyright notice and this permission notice are preserved, 78 copyright notice and this permission notice are preserved,
55 thus giving the recipient permission to redistribute in turn. 79 thus giving the recipient permission to redistribute in turn.
56 80
57 Permission is granted to distribute modified versions 81 Permission is granted to distribute modified versions
58 of this document, or of portions of it, 82 of this document, or of portions of it,
59 under the above conditions, provided also that they 83 under the above conditions, provided also that they
60 carry prominent notices stating who last changed them. 84 carry prominent notices stating who last changed them.
61 85
62 86
63Local Variables: 87Local Variables:
64mode: outline 88mode: outline
65 paragraph-separate: "[ ]*$" 89 paragraph-separate: "[ ]*$"
66version-control: never 90version-control: never
67End: 91End:
diff --git a/configure.ac b/configure.ac
index 84544b2..917bab5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,82 +1,82 @@
1# This file is part of Varnish-mib -*- autoconf -*- 1# This file is part of Varnish-mib -*- autoconf -*-
2# Copyright (C) 2014-2018 Sergey Poznyakoff 2# Copyright (C) 2014-2018 Sergey Poznyakoff
3# 3#
4# Varnish-mib is free software; you can redistribute it and/or modify 4# Varnish-mib is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by 5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option) 6# the Free Software Foundation; either version 3, or (at your option)
7# any later version. 7# any later version.
8# 8#
9# Varnish-mib is distributed in the hope that it will be useful, 9# Varnish-mib is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details. 12# GNU General Public License for more details.
13# 13#
14# You should have received a copy of the GNU General Public License 14# You should have received a copy of the GNU General Public License
15# along with Varnish-mib. If not, see <http://www.gnu.org/licenses/>. 15# along with Varnish-mib. If not, see <http://www.gnu.org/licenses/>.
16 16
17AC_PREREQ(2.69) 17AC_PREREQ(2.69)
18AC_INIT([varnish-mib], 1.1.90, [gray@gnu.org]) 18AC_INIT([varnish-mib], 2.0, [gray@gnu.org])
19AC_CONFIG_SRCDIR(src/varnish_mib.mib2c) 19AC_CONFIG_SRCDIR(src/varnish_mib.mib2c)
20AM_CONFIG_HEADER(config.h) 20AM_CONFIG_HEADER(config.h)
21AC_CONFIG_AUX_DIR([build-aux]) 21AC_CONFIG_AUX_DIR([build-aux])
22AC_CONFIG_MACRO_DIR([m4]) 22AC_CONFIG_MACRO_DIR([m4])
23 23
24AC_CANONICAL_SYSTEM 24AC_CANONICAL_SYSTEM
25AC_LANG(C) 25AC_LANG(C)
26AM_INIT_AUTOMAKE([gnu tar-ustar silent-rules]) 26AM_INIT_AUTOMAKE([gnu tar-ustar silent-rules])
27AM_SILENT_RULES([yes]) 27AM_SILENT_RULES([yes])
28 28
29AC_GNU_SOURCE 29AC_GNU_SOURCE
30AC_PROG_CC 30AC_PROG_CC
31AC_PROG_CC_STDC 31AC_PROG_CC_STDC
32if test "x$ac_cv_prog_cc_c99" = xno; then 32if test "x$ac_cv_prog_cc_c99" = xno; then
33 AC_MSG_ERROR([could not find a C99 compatible compiler]) 33 AC_MSG_ERROR([could not find a C99 compatible compiler])
34fi 34fi
35AC_PROG_CPP 35AC_PROG_CPP
36AM_PROG_LEX 36AM_PROG_LEX
37 37
38AC_PROG_INSTALL 38AC_PROG_INSTALL
39AC_PROG_LIBTOOL 39AC_PROG_LIBTOOL
40AC_PROG_MAKE_SET 40AC_PROG_MAKE_SET
41 41
42# Check for pkg-config 42# Check for pkg-config
43PKG_PROG_PKG_CONFIG 43PKG_PROG_PKG_CONFIG
44 44
45# Checks for Varnish 45# Checks for Varnish
46PKG_CHECK_MODULES([VARNISHAPI], [varnishapi >= 5.0]) 46PKG_CHECK_MODULES([VARNISHAPI], [varnishapi >= 5.0])
47 47
48varnishapi_version() { 48check_minor_number() {
49 AC_DEFINE_UNQUOTED([VARNISHAPI_MAJOR],[$1],[Varnish API major version number]) 49 if [ "$2" -gt 1 ]; then
50 AC_DEFINE_UNQUOTED([VARNISHAPI_MINOR],[$2],[Varnish API minor version number]) 50 AC_MSG_ERROR([Unsupported Varnish API version; please try varnish_mib 3.0 or newer])
51 AC_DEFINE_UNQUOTED([VARNISHAPI_PATCH],[$3],[Varnish API patchlevel]) 51 fi
52} 52}
53 53
54v=$($PKG_CONFIG --modversion varnishapi) 54v=$($PKG_CONFIG --modversion varnishapi)
55if test -n "$v"; then 55if test -n "$v"; then
56 save_IFS=$IFS 56 save_IFS=$IFS
57 IFS='.' 57 IFS='.'
58 varnishapi_version $v 58 check_minor_number $v
59 IFS=$save_IFS 59 IFS=$save_IFS
60fi 60fi
61 61
62# Check for Net-SNMP 62# Check for Net-SNMP
63AC_PATH_PROG([NET_SNMP_CONFIG], net-snmp-config, none, $PATH) 63AC_PATH_PROG([NET_SNMP_CONFIG], net-snmp-config, none, $PATH)
64if test "$NET_SNMP_CONFIG" = "none"; then 64if test "$NET_SNMP_CONFIG" = "none"; then
65 AC_MSG_ERROR([cannot find Net-SNMP (net-snmp-config not found)]) 65 AC_MSG_ERROR([cannot find Net-SNMP (net-snmp-config not found)])
66fi 66fi
67AC_SUBST(NET_SNMP_CONFIG) 67AC_SUBST(NET_SNMP_CONFIG)
68 68
69# Checks for header files. 69# Checks for header files.
70AC_HEADER_STDC 70AC_HEADER_STDC
71 71
72# Checks for typedefs, structures, and compiler characteristics. 72# Checks for typedefs, structures, and compiler characteristics.
73AC_C_CONST 73AC_C_CONST
74AC_TYPE_SIZE_T 74AC_TYPE_SIZE_T
75 75
76# Directories 76# Directories
77AC_SUBST([DLMODDIR],['$(libdir)/snmp']) 77AC_SUBST([DLMODDIR],['$(libdir)/snmp'])
78AC_ARG_WITH([dlmoddir], 78AC_ARG_WITH([dlmoddir],
79 [AC_HELP_STRING([--with-dlmoddir=DIR], 79 [AC_HELP_STRING([--with-dlmoddir=DIR],
80 [installation directory for net-snmp loadable agents])], 80 [installation directory for net-snmp loadable agents])],
81 [case $withval in 81 [case $withval in
82 /*) DLMODDIR=$withval;; 82 /*) DLMODDIR=$withval;;
diff --git a/lib/VarnishMib/HashTable.pm b/lib/VarnishMib/HashTable.pm
index 1faef96..00224ac 100644
--- a/lib/VarnishMib/HashTable.pm
+++ b/lib/VarnishMib/HashTable.pm
@@ -1,24 +1,40 @@
1# This file is part of varnish-mib -*- automake -*-
2# Copyright (C) 2018 Sergey Poznyakoff
3#
4# varnish-mib is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option)
7# any later version.
8#
9# varnish-mib is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with varnish-mib. If not, see <http://www.gnu.org/licenses/>.
16
1package VarnishMib::HashTable; 17package VarnishMib::HashTable;
2use strict; 18use strict;
3use warnings; 19use warnings;
4use Carp; 20use Carp;
5use Inline 'C'; 21use Inline 'C';
6use Pod::Usage; 22use Pod::Usage;
7use Pod::Man; 23use Pod::Man;
8 24
9=head1 NAME 25=head1 NAME
10 26
11VarnishMib::HashTable - Create a hash table implementation in C 27VarnishMib::HashTable - Create a hash table implementation in C
12 28
13=head1 DESCRIPTION 29=head1 DESCRIPTION
14 30
15Given a list of unique strings, creates a C code for fast look ups of 31Given a list of unique strings, creates a C code for fast look ups of
16data associated with them. 32data associated with them.
17 33
18=head1 CONSTRUCTOR 34=head1 CONSTRUCTOR
19 35
20 $ht = new VarnishMib::HashTable([KW => VAL,...]); 36 $ht = new VarnishMib::HashTable([KW => VAL,...]);
21 37
22Returns a new instance of the hash table generator. Allowed arguments are: 38Returns a new instance of the hash table generator. Allowed arguments are:
23 39
24=over 4 40=over 4
diff --git a/lib/VarnishMib/MIBTable.pm b/lib/VarnishMib/MIBTable.pm
index 6aa959f..da0ca19 100644
--- a/lib/VarnishMib/MIBTable.pm
+++ b/lib/VarnishMib/MIBTable.pm
@@ -1,24 +1,40 @@
1# This file is part of varnish-mib -*- automake -*-
2# Copyright (C) 2018 Sergey Poznyakoff
3#
4# varnish-mib is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option)
7# any later version.
8#
9# varnish-mib is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with varnish-mib. If not, see <http://www.gnu.org/licenses/>.
16
1package VarnishMib::MIBTable; 17package VarnishMib::MIBTable;
2use strict; 18use strict;
3use warnings; 19use warnings;
4use parent 'VarnishMib::HashTable'; 20use parent 'VarnishMib::HashTable';
5use Carp; 21use Carp;
6 22
7sub new { 23sub new {
8 my ($class, $type, $table, %args) = @_; 24 my ($class, $type, $table, %args) = @_;
9 my @oids = 25 my @oids =
10 sort { $table->{$a}[1] cmp $table->{$b}[1] } 26 sort { $table->{$a}[1] cmp $table->{$b}[1] }
11 grep { $table->{$_}[0] eq 'DICT' } keys %{$table}; 27 grep { $table->{$_}[0] eq 'DICT' } keys %{$table};
12 28
13 my @equiv; 29 my @equiv;
14 my @uniq_oids; 30 my @uniq_oids;
15 for (my $i = 0; $i <= $#oids; $i++) { 31 for (my $i = 0; $i <= $#oids; $i++) {
16 unless ($i > 0 32 unless ($i > 0
17 && $table->{$uniq_oids[-1]}[1] eq $table->{$oids[$i]}[1]) { 33 && $table->{$uniq_oids[-1]}[1] eq $table->{$oids[$i]}[1]) {
18 push @uniq_oids, $oids[$i]; 34 push @uniq_oids, $oids[$i];
19 } 35 }
20 push @equiv, $#uniq_oids; 36 push @equiv, $#uniq_oids;
21 } 37 }
22 my $self = bless $class->SUPER::new(%args), $class; 38 my $self = bless $class->SUPER::new(%args), $class;
23 $self->{oids_all} = \@oids; 39 $self->{oids_all} = \@oids;
24 $self->{oids_uniq} = \@uniq_oids; 40 $self->{oids_uniq} = \@uniq_oids;
diff --git a/src/Makefile.am b/src/Makefile.am
index 55cdb85..5c79dfc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,26 +1,26 @@
1# This file is part of varnish-mib -*- automake -*- 1# This file is part of varnish-mib -*- automake -*-
2# Copyright (C) 2014-2015 Sergey Poznyakoff 2# Copyright (C) 2014-2018 Sergey Poznyakoff
3# 3#
4# varnish-mib is free software; you can redistribute it and/or modify 4# varnish-mib is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by 5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option) 6# the Free Software Foundation; either version 3, or (at your option)
7# any later version. 7# any later version.
8# 8#
9# varnish-mib is distributed in the hope that it will be useful, 9# varnish-mib is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details. 12# GNU General Public License for more details.
13# 13#
14# You should have received a copy of the GNU General Public License 14# You should have received a copy of the GNU General Public License
15# along with varnish-mib. If not, see <http://www.gnu.org/licenses/>. 15# along with varnish-mib. If not, see <http://www.gnu.org/licenses/>.
16 16
17dlmoddir=@DLMODDIR@ 17dlmoddir=@DLMODDIR@
18dlmod_LTLIBRARIES = varnish-mib.la 18dlmod_LTLIBRARIES = varnish-mib.la
19 19
20varnish_mib_la_SOURCES = \ 20varnish_mib_la_SOURCES = \
21 auth.c\ 21 auth.c\
22 ban.c\ 22 ban.c\
23 backend.h\ 23 backend.h\
24 belex.l\ 24 belex.l\
25 betab.c\ 25 betab.c\
26 modconf.h\ 26 modconf.h\
diff --git a/src/VARNISH-MIB.txt b/src/VARNISH-MIB.txt
index 6b03f21..b7e77f1 100644
--- a/src/VARNISH-MIB.txt
+++ b/src/VARNISH-MIB.txt
@@ -1,54 +1,54 @@
1VARNISH-MIB DEFINITIONS ::= BEGIN 1VARNISH-MIB DEFINITIONS ::= BEGIN
2 2
3-- ************************************************************* 3-- *************************************************************
4-- $Id: VARNISH-MIB.txt 8 2014-11-24 14:38:24Z graygnuorg $ 4-- $Id: VARNISH-MIB.txt 8 2014-11-24 14:38:24Z graygnuorg $
5-- 5--
6-- Varnish reverse proxy MIB 6-- Varnish reverse proxy MIB
7-- by Shared Autonomous sYstems 7-- by Shared Autonomous sYstems
8-- 8--
9-- ************************************************************* 9-- *************************************************************
10 10
11IMPORTS 11IMPORTS
12 MODULE-IDENTITY, OBJECT-TYPE, enterprises, Counter64, TimeTicks, 12 MODULE-IDENTITY, OBJECT-TYPE, enterprises, Counter64, TimeTicks,
13 Counter32, Integer32 13 Counter32, Integer32
14 FROM SNMPv2-SMI 14 FROM SNMPv2-SMI
15 TEXTUAL-CONVENTION, DateAndTime 15 TEXTUAL-CONVENTION, DateAndTime
16 FROM SNMPv2-TC 16 FROM SNMPv2-TC
17 InetAddressIPv4, InetAddressIPv6, InetPortNumber 17 InetAddressIPv4, InetAddressIPv6, InetPortNumber
18 FROM INET-ADDRESS-MIB 18 FROM INET-ADDRESS-MIB
19 OBJECT-GROUP, MODULE-COMPLIANCE 19 OBJECT-GROUP, MODULE-COMPLIANCE
20 FROM SNMPv2-CONF; 20 FROM SNMPv2-CONF;
21 21
22varnishMIB MODULE-IDENTITY 22varnishMIB MODULE-IDENTITY
23 LAST-UPDATED "201802020845Z" 23 LAST-UPDATED "201802052024Z"
24 ORGANIZATION "Shared Autonomous sYstems" 24 ORGANIZATION "Shared Autonomous sYstems"
25 CONTACT-INFO "Morten Hermanrud <mhe@say.no> 25 CONTACT-INFO "Morten Hermanrud <mhe@say.no>
26 Sergey Poznyakoff <gray@gnu.org> 26 Sergey Poznyakoff <gray@gnu.org>
27 " 27 "
28 DESCRIPTION 28 DESCRIPTION
29 "This MIB module defines objects for Varnish reverse web proxy." 29 "This MIB module defines objects for Varnish reverse web proxy."
30 REVISION "201802020845Z" 30 REVISION "201802052024Z"
31 DESCRIPTION 31 DESCRIPTION
32 "Second revision." 32 "Second revision."
33 ::= { varnish 0 } 33 ::= { varnish 0 }
34 34
35 varnish OBJECT IDENTIFIER::= { enterprises 33043 6 1 } 35 varnish OBJECT IDENTIFIER::= { enterprises 33043 6 1 }
36 client OBJECT IDENTIFIER::= { varnish 1 } 36 client OBJECT IDENTIFIER::= { varnish 1 }
37 backend OBJECT IDENTIFIER::= { varnish 2 } 37 backend OBJECT IDENTIFIER::= { varnish 2 }
38 total OBJECT IDENTIFIER::= { varnish 3 } 38 total OBJECT IDENTIFIER::= { varnish 3 }
39 master OBJECT IDENTIFIER::= { varnish 4 } 39 master OBJECT IDENTIFIER::= { varnish 4 }
40 session OBJECT IDENTIFIER::= { varnish 5 } 40 session OBJECT IDENTIFIER::= { varnish 5 }
41 threads OBJECT IDENTIFIER::= { varnish 6 } 41 threads OBJECT IDENTIFIER::= { varnish 6 }
42 bans OBJECT IDENTIFIER::= { varnish 7 } 42 bans OBJECT IDENTIFIER::= { varnish 7 }
43 agent OBJECT IDENTIFIER::= { varnish 8 } 43 agent OBJECT IDENTIFIER::= { varnish 8 }
44objects OBJECT IDENTIFIER ::= { varnish 9 } 44objects OBJECT IDENTIFIER ::= { varnish 9 }
45vcl OBJECT IDENTIFIER ::= { varnish 10 } 45vcl OBJECT IDENTIFIER ::= { varnish 10 }
46 46
47clientAcceptedConnections OBJECT-TYPE 47clientAcceptedConnections OBJECT-TYPE
48 SYNTAX Counter64 48 SYNTAX Counter64
49 MAX-ACCESS read-only 49 MAX-ACCESS read-only
50 STATUS current 50 STATUS current
51 DESCRIPTION 51 DESCRIPTION
52 "Client connections accepted." 52 "Client connections accepted."
53 ::= { client 1 } 53 ::= { client 1 }
54 54
@@ -833,49 +833,49 @@ objectsExpired OBJECT-TYPE
833 ::= { objects 5 } 833 ::= { objects 5 }
834 834
835objectsLRUNuked OBJECT-TYPE 835objectsLRUNuked OBJECT-TYPE
836 SYNTAX Counter64 836 SYNTAX Counter64
837 MAX-ACCESS read-only 837 MAX-ACCESS read-only
838 STATUS current 838 STATUS current
839 DESCRIPTION 839 DESCRIPTION
840 "How many objects have been forcefully evicted from 840 "How many objects have been forcefully evicted from
841 storage to make room for a new object." 841 storage to make room for a new object."
842 ::= { objects 6 } 842 ::= { objects 6 }
843 843
844objectsLRUMoved OBJECT-TYPE 844objectsLRUMoved OBJECT-TYPE
845 SYNTAX Counter64 845 SYNTAX Counter64
846 MAX-ACCESS read-only 846 MAX-ACCESS read-only
847 STATUS current 847 STATUS current
848 DESCRIPTION 848 DESCRIPTION
849 "Number of move operations done on the LRU list." 849 "Number of move operations done on the LRU list."
850 ::= { objects 7 } 850 ::= { objects 7 }
851 851
852objectsPurges OBJECT-TYPE 852objectsPurges OBJECT-TYPE
853 SYNTAX Counter64 853 SYNTAX Counter64
854 MAX-ACCESS read-only 854 MAX-ACCESS read-only
855 STATUS current 855 STATUS current
856 DESCRIPTION 856 DESCRIPTION
857 "Number of purge operations executed" 857 "Number of purge operations executed."
858 ::= { objects 8 } 858 ::= { objects 8 }
859 859
860objectsObjPurged OBJECT-TYPE 860objectsObjPurged OBJECT-TYPE
861 SYNTAX Counter64 861 SYNTAX Counter64
862 MAX-ACCESS read-only 862 MAX-ACCESS read-only
863 STATUS current 863 STATUS current
864 DESCRIPTION 864 DESCRIPTION
865 "Number of purged objects." 865 "Number of purged objects."
866 ::= { objects 9 } 866 ::= { objects 9 }
867 867
868objectsGzip OBJECT-TYPE 868objectsGzip OBJECT-TYPE
869 SYNTAX Counter64 869 SYNTAX Counter64
870 MAX-ACCESS read-only 870 MAX-ACCESS read-only
871 STATUS current 871 STATUS current
872 DESCRIPTION 872 DESCRIPTION
873 "Number of gzip operations." 873 "Number of gzip operations."
874 ::= { objects 10 } 874 ::= { objects 10 }
875 875
876objectsGunzip OBJECT-TYPE 876objectsGunzip OBJECT-TYPE
877 SYNTAX Counter64 877 SYNTAX Counter64
878 MAX-ACCESS read-only 878 MAX-ACCESS read-only
879 STATUS current 879 STATUS current
880 DESCRIPTION 880 DESCRIPTION
881 "Number of gunzip operations." 881 "Number of gunzip operations."
diff --git a/src/auth.c b/src/auth.c
index e9abbe4..2ff6aba 100644
--- a/src/auth.c
+++ b/src/auth.c
@@ -1,26 +1,26 @@
1/* This file is part of varnish-mib -*- c -*- 1/* This file is part of varnish-mib -*- c -*-
2 Copyright (C) 2014-2015 Sergey Poznyakoff 2 Copyright (C) 2014-2018 Sergey Poznyakoff
3 3
4 Varnish-mib is free software; you can redistribute it and/or modify 4 Varnish-mib is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option) 6 the Free Software Foundation; either version 3, or (at your option)
7 any later version. 7 any later version.
8 8
9 Varnish-mib is distributed in the hope that it will be useful, 9 Varnish-mib is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with varnish-mib. If not, see <http://www.gnu.org/licenses/>. 15 along with varnish-mib. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17 17
18#include "varnish_mib.h" 18#include "varnish_mib.h"
19#include "sha256.h" 19#include "sha256.h"
20#include <unistd.h> 20#include <unistd.h>
21#include <fcntl.h> 21#include <fcntl.h>
22#include <assert.h> 22#include <assert.h>
23#include <errno.h> 23#include <errno.h>
24 24
25void 25void
26varnish_auth_response_fd(int fd, const char *challenge, 26varnish_auth_response_fd(int fd, const char *challenge,
diff --git a/src/backend.h b/src/backend.h
index d60f613..b13e644 100644
--- a/src/backend.h
+++ b/src/backend.h
@@ -1,16 +1,15 @@
1typedef struct be_string { 1typedef struct be_string {
2 char const *start; 2 char const *start;
3 size_t len; 3 size_t len;
4} be_string_t; 4} be_string_t;
5 5
6typedef void (*regfun_t)(be_string_t *, be_string_t *, be_string_t *, void *); 6typedef void (*regfun_t)(be_string_t *, be_string_t *, be_string_t *, void *);
7 7
8void read_defs(const char *str, size_t len, regfun_t regfun, void *d); 8struct vsm;
9void varnish_backend_table_timeout_parser(const char *token, char *line);
10struct VSC_point; 9struct VSC_point;
11void backend_register(char const *name, size_t len, char const *param, 10void backend_register(char const *name, size_t len, char const *param,
12 const struct VSC_point *vpt); 11 const struct VSC_point *vpt);
13void backend_clear(void); 12void backend_clear(void);
14int backend_collect_addr(struct vsm *vsm); 13int backend_collect_addr(struct vsm *vsm);
15void backend_parser(const char *str, size_t len, regfun_t regfun, void *d); 14void backend_parser(const char *str, size_t len, regfun_t regfun, void *d);
16 15
diff --git a/src/ban.c b/src/ban.c
index 1f4583b..a50b5a3 100644
--- a/src/ban.c
+++ b/src/ban.c
@@ -1,26 +1,26 @@
1/* This file is part of varnish-mib -*- c -*- 1/* This file is part of varnish-mib -*- c -*-
2 Copyright (C) 2014-2015 Sergey Poznyakoff 2 Copyright (C) 2014-2018 Sergey Poznyakoff
3 3
4 Varnish-mib is free software; you can redistribute it and/or modify 4 Varnish-mib is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option) 6 the Free Software Foundation; either version 3, or (at your option)
7 any later version. 7 any later version.
8 8
9 Varnish-mib is distributed in the hope that it will be useful, 9 Varnish-mib is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with varnish-mib. If not, see <http://www.gnu.org/licenses/>. 15 along with varnish-mib. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17 17
18#include "varnish_mib.h" 18#include "varnish_mib.h"
19#include <ctype.h> 19#include <ctype.h>
20 20
21static int 21static int
22send_ban_cmd(vcli_conn_t *conn, const char *expr) 22send_ban_cmd(vcli_conn_t *conn, const char *expr)
23{ 23{
24 if (vcli_asprintf(conn, "ban %s\n", expr) || vcli_write(conn)) 24 if (vcli_asprintf(conn, "ban %s\n", expr) || vcli_write(conn))
25 return 1; 25 return 1;
26 26
diff --git a/src/belex.l b/src/belex.l
index f35f114..bc0bfc0 100644
--- a/src/belex.l
+++ b/src/belex.l
@@ -1,24 +1,41 @@
1/* This file is part of varnish-mib
2 Copyright (C) 2018 Sergey Poznyakoff
3
4 Varnish-mib is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 Varnish-mib is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with varnish-mib. If not, see <http://www.gnu.org/licenses/>.
16*/
17
1%option nounput 18%option nounput
2%option noinput 19%option noinput
3 20
4%{ 21%{
5#include "backend.h" 22#include "backend.h"
6 23
7enum { 24enum {
8 T_BOGUS = 256, 25 T_BOGUS = 256,
9 T_IDENT, 26 T_IDENT,
10 T_NUMBER, 27 T_NUMBER,
11 T_STRING, 28 T_STRING,
12 T_BACKEND, 29 T_BACKEND,
13 T_HOST, 30 T_HOST,
14 T_PORT 31 T_PORT
15}; 32};
16 33
17static char const *input_string; 34static char const *input_string;
18static size_t input_len; 35static size_t input_len;
19static size_t input_pos; 36static size_t input_pos;
20static char const *string_start; 37static char const *string_start;
21static size_t current_pos; 38static size_t current_pos;
22 39
23#define YY_INPUT(buf,result,max_size) \ 40#define YY_INPUT(buf,result,max_size) \
24 do { \ 41 do { \
diff --git a/src/modconf.c b/src/modconf.c
index 85b2582..64177c1 100644
--- a/src/modconf.c
+++ b/src/modconf.c
@@ -1,24 +1,41 @@
1/* This file is part of varnish-mib
2 Copyright (C) 2018 Sergey Poznyakoff
3
4 Varnish-mib is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 Varnish-mib is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with varnish-mib. If not, see <http://www.gnu.org/licenses/>.
16*/
17
1#include "varnish_mib.h" 18#include "varnish_mib.h"
2#include <ctype.h> 19#include <ctype.h>
3 20
4static int 21static int
5timeout_parser(const char *token, char *line, unsigned *retval) 22timeout_parser(const char *token, char *line, unsigned *retval)
6{ 23{
7 char *p; 24 char *p;
8 unsigned long n = strtoul(line, &p, 10); 25 unsigned long n = strtoul(line, &p, 10);
9 26
10 if (*p) { 27 if (*p) {
11 if (isspace(*p)) { 28 if (isspace(*p)) {
12 while (*p && isspace(*p)) 29 while (*p && isspace(*p))
13 ++p; 30 ++p;
14 if (*p) { 31 if (*p) {
15 config_perror("too many arguments"); 32 config_perror("too many arguments");
16 return 1; 33 return 1;
17 } 34 }
18 } else { 35 } else {
19 config_perror("invalid timeout value"); 36 config_perror("invalid timeout value");
20 return 1; 37 return 1;
21 } 38 }
22 } 39 }
23 40
24 if (n > UINT_MAX) { 41 if (n > UINT_MAX) {
diff --git a/src/varnish-mib.8 b/src/varnish-mib.8
index 8d86f18..77912af 100644
--- a/src/varnish-mib.8
+++ b/src/varnish-mib.8
@@ -1,151 +1,179 @@
1.\" This file is part of Varnish-mib -*- nroff -*- 1.\" This file is part of Varnish-mib -*- nroff -*-
2.\" Copyright (C) 2014-2016 Sergey Poznyakoff 2.\" Copyright (C) 2014-2018 Sergey Poznyakoff
3.\" 3.\"
4.\" Varnish-mib is free software; you can redistribute it and/or modify 4.\" Varnish-mib is free software; you can redistribute it and/or modify
5.\" it under the terms of the GNU General Public License as published by 5.\" it under the terms of the GNU General Public License as published by
6.\" the Free Software Foundation; either version 3, or (at your option) 6.\" the Free Software Foundation; either version 3, or (at your option)
7.\" any later version. 7.\" any later version.
8.\" 8.\"
9.\" Varnish-mib is distributed in the hope that it will be useful, 9.\" Varnish-mib is distributed in the hope that it will be useful,
10.\" but WITHOUT ANY WARRANTY; without even the implied warranty of 10.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12.\" GNU General Public License for more details. 12.\" GNU General Public License for more details.
13.\" 13.\"
14.\" You should have received a copy of the GNU General Public License 14.\" You should have received a copy of the GNU General Public License
15.\" along with Varnish-mib. If not, see <http://www.gnu.org/licenses/>. 15.\" along with Varnish-mib. If not, see <http://www.gnu.org/licenses/>.
16.TH VARNISH-MIB 8 "February 2, 2018" "varnish-mib" 16.TH VARNISH-MIB 8 "February 5, 2018" "varnish-mib"
17.SH NAME 17.SH NAME
18varnish\-mib \- net-snmp module for obtaining Varnish Cache statistics 18varnish\-mib \- Net-SNMP module for Varnish Cache monitoring
19.SH SYNOPSIS 19.SH SYNOPSIS
20In \fBsnmpd.conf\fR(5): 20In \fBsnmpd.conf\fR(5):
21.PP 21.PP
22.B dlmod varnish_mib /usr/lib/snmp/varnish\-mib.so 22.B dlmod varnish_mib /usr/lib/snmp/varnish\-mib.so
23.SH DESCRIPTION 23.SH DESCRIPTION
24Dynamically loadable object module for 24Dynamically loadable object module for
25.B net-snmp 25.B net-snmp
26that provides access to Varnish Cache statistics. The module is 26that provides access to Varnish Cache statistics. The module is
27loaded into 27loaded into
28.BR snmpd (8) 28.BR snmpd (8)
29as shown above (actual path can of course differ, depending on how 29as shown above (actual path can of course differ, depending on how
30the package was configured). The module is written for Varnish 30the package was configured). This version is written for Varnish
31version \fB5.\fIX\fR. 31\fB5.2.0\fR.
32.PP 32.PP
33The module obtains most of the data using Varnish API, and \fBvarnishd\fR 33The values in the OID branches
34administrative interface. You should make sure that \fBsnmpd\fR is 34.BR client ,
35able to access both data sources. 35.BR total ,
36.BR master ,
37.BR session ,
38.BR threads ", and "
39.B objects
40are obtained from Varnish API.
36.PP 41.PP
37The user \fBsnmpd\fR runs as should be able to read contents of the 42The OID branches
38\fB/var/lib/varnish/\fIHOSTNAME\fB/_.vsm_mgt\fR directory and read 43.BR backend ,
39files located in it. It must also have read permission on the varnish 44.BR bans ", and "
40secret file. 45.B vcl
46are obtained using \fBvarnishd\fR administrative interface (similar
47to
48.BR varnishadm (8)).
49.PP
50To retrieve this information, the module must
51have enough permissions to scan the Varnish management directory and
52read files located in it. This directory is normally named
53\fB/var/lib/varnish/\fIHOSTNAME\fB/_.vsm_mgt\fR, where \fIHOSTNAME\fR
54stands for the server's hostname. Unless
55.BR snmpd (8)
56is run as root, special measures should be undertaken in order to
57grant access rights. For example, if the daemon runs as user
58\fBsnmp\fR, running the following two commands after starting
59\fBvarnishd\fR will do the trick:
60
61.EX
62 setfacl -m u:snmp:rx /var/lib/varnish/$(hostname)/_.vsm_mgt
63 setfacl -m u:snmp:r /var/lib/varnish/$(hostname)/_.vsm_mgt/*
64.EE
65.PP
66
41.SH CONFIGURATION OPTIONS 67.SH CONFIGURATION OPTIONS
42Configuration statements specific to 68Configuration statements specific to
43.B varnish\-mib 69.B varnish\-mib
44must appear in the 70must appear in the
45.B snmpd.conf 71.B snmpd.conf
46file below the 72file, after the
47.B dlmod 73.B dlmod
48statement that loads the module. 74statement that loads the module.
49.PP 75.PP
50The following configuration statements are available: 76The following configuration statements are available:
51.TP 77.TP
52\fBvarnishBanTableTimeout\fR \fINUMBER\fR 78\fBvarnishBanTableTimeout\fR \fINUMBER\fR
53To create \fBbanTable\fR (see below), \fBvarnish_mib\fR connects to 79To create \fBbanTable\fR (see below), \fBvarnish_mib\fR connects to
54\fBvarnish\fR administration port and issues the \fBban.list\fR 80\fBvarnish\fR administration port and issues the \fBban.list\fR
55command. To minimize the performance impact, the information obtained 81command. To minimize the performance impact, the information obtained
56is cached for a predefined amount of time (60 seconds by default). 82is cached for a predefined amount of time (60 seconds by default).
57This amount (in seconds) is configured by \fBvarnishBanTableTimeout\fR 83This amount (in seconds) is configured by \fBvarnishBanTableTimeout\fR
58statement. 84statement.
59.TP 85.TP
60\fBvarnishBackendTableTimeout\fR \fINUMBER\fR 86\fBvarnishBackendTableTimeout\fR \fINUMBER\fR
61Update interval for \fBbackendTable\fR. Default is 5 seconds. 87Update interval for \fBbackendTable\fR. Default is 5 seconds.
62.TP 88.TP
63\fBvarnishCLIPortTimeout\fR \fINUMBER\fR 89\fBvarnishCLIPortTimeout\fR \fINUMBER\fR
64Sets timeout for I/O operations with Varnish administrative port. 90Sets timeout for I/O operations with Varnish administrative port.
65Default is 5 seconds. 91Default is 5 seconds.
66.PP 92.PP
67The following two statements are not normally needed, since 93The following two statements are not normally needed, but are
68\fBvarnish-mib\fR obtains this information automatically. 94provided for completeness sake:
69.TP 95.TP
70\fBvarnishCLISocket\fR \fIADDRESS\fR[:\fIPORT\fR] 96\fBvarnishCLISocket\fR \fIADDRESS\fR[:\fIPORT\fR]
71Sets the address of Varnish administrative interface 97Sets the address of Varnish administrative interface
72socket. 98socket.
73.TP 99.TP
74\fBvarnishCLISecretFile\fR \fIFILE\fR 100\fBvarnishCLISecretFile\fR \fIFILE\fR
75Pathname of the Varnish secret file. 101Sets the pathname of the Varnish secret file.
76.SH DEBUGGING 102.SH DEBUGGING
77The module defines the following debugging tokens: 103The module defines the following debugging tokens:
78.TP 104.TP
79.B varnish_mib 105.B varnish_mib
80General debugging information. 106Produces general debugging information.
81.TP 107.TP
82.B varnish_mib:ban 108.B varnish_mib:ban
83Debug ban table loading. 109Outputs verbose report about loading th ban table.
84.TP 110.TP
85.B varnish_mib:vcli 111.B varnish_mib:vcli
86Varnish 112Displays additional information regarding varnish
87.B CLI 113.B CLI
88interaction. 114interaction.
89.TP 115.TP
90.B varnish_mib:vcli:transcript 116.B varnish_mib:vcli:transcript
91Enables full transcript of CLI interaction. 117Enables full transcript of varnish CLI session.
92.TP 118.TP
93.B varnish_mib:backend 119.B varnish_mib:backend
94Debug loading the backend information. 120Outputs verbose information about loading the backend information.
95.SH OIDS 121.SH OIDS
96The following OIDs are defined: 122The following OIDs are defined in the
123.B VARNISH-MIB.txt
124file:
97.SS Branch \(dqclient\(dq 125.SS Branch \(dqclient\(dq
98.TP 126.TP
99.B clientAcceptedConnections 127.B clientAcceptedConnections
100Number of accepted connections. 128Number of accepted connections.
101.TP 129.TP
102.B clientRequestsReceived 130.B clientRequestsReceived
103Number of received HTTP requests. 131Number of received HTTP requests.
104.TP 132.TP
105.B clientCacheHits 133.B clientCacheHits
106Number of cache hits. A cache hit indicates that an object has been 134Number of cache hits. A cache hit indicates that an object has been
107delivered to a client without fetching it from a backend server. 135delivered to a client without fetching it from a backend server.
108.TP 136.TP
109.B clientCacheHitsPass 137.B clientCacheHitsPass
110Number of hits for pass. A cache hit for pass indicates that Varnish 138Number of hits for pass. A cache hit for pass indicates that Varnish
111passes the request to the backend and this decision itself has been cached. 139passes the request to the backend and this decision itself has been cached.
112.TP 140.TP
113.B clientCacheMisses 141.B clientCacheMisses
114Number of misses. A cache miss indicates the object was fetched from 142Number of misses. A cache miss indicates the object was fetched from
115the backend before delivering it to the client. 143the backend before delivering it to the client.
116.TP 144.TP
117.B clientRequests400 145.B clientRequests400
118Client requests received, subject to 400 errors. 146Client requests received, subject to 400 errors.
119.TP 147.TP
120.B clientBan 148.B clientBan
121A write-only OID. When set, invalidates the cache using the supplied 149A write-only OID. When set, invalidates the cache using the supplied
122value as argument to ban. When read, returns an empty string. E.g., 150value as argument to ban. When read, returns an empty string. E.g.,
123to invalidate caches of all \fBpng\fR images: 151to invalidate caches of all \fBpng\fR images:
124 152
125.EE
126snmpset \fBhostname\fR VARNISH\-MIB::clientBan.0 s 'req.url ~ \(dq\\.png$\(dq'
127.EX 153.EX
154snmpset \fIhostname\fR VARNISH\-MIB::clientBan.0 s 'req.url ~ \(dq\\.png$\(dq'
155.EE
128.SS Branch \(dqbackend\(dq 156.SS Branch \(dqbackend\(dq
129.TP 157.TP
130.B backendConnSuccess 158.B backendConnSuccess
131Number of successful connections to the backend. 159Number of successful connections to the backend.
132.TP 160.TP
133.B backendConnNotAttempted 161.B backendConnNotAttempted
134Number of backend connections not attempted, because of the unhealthy 162Number of backend connections not attempted, because of the unhealthy
135status of the backend. 163status of the backend.
136.TP 164.TP
137.B backendConnToMany 165.B backendConnToMany
138Number of backend connections failed because there were too many 166Number of backend connections failed because there were too many
139connections open. 167connections open.
140.TP 168.TP
141.B backendConnFailures 169.B backendConnFailures
142Number of failed backend connections. 170Number of failed backend connections.
143.TP 171.TP
144.B backendConnReuses 172.B backendConnReuses
145Number of reused backend connections. This counter is increased 173Number of reused backend connections. This counter is increased
146whenever Varnish reuses a recycled connection. 174whenever Varnish reuses a recycled connection.
147.TP 175.TP
148.B backendConnRecycled 176.B backendConnRecycled
149Number of backend connection recycles. This counter is increased 177Number of backend connection recycles. This counter is increased
150whenever Varnish has keep-alive connection that is put back into 178whenever Varnish has keep-alive connection that is put back into
151the pool of connections. It has not yet been used, but it might be, 179the pool of connections. It has not yet been used, but it might be,
@@ -237,65 +265,66 @@ Total request header bytes received for piped sessions.
237.B totalPipeIn 265.B totalPipeIn
238Total number of bytes forwarded from clients in pipe sessions. 266Total number of bytes forwarded from clients in pipe sessions.
239.TP 267.TP
240.B totalPipeOut 268.B totalPipeOut
241Total number of bytes forwarded to clients in pipe sessions. 269Total number of bytes forwarded to clients in pipe sessions.
242.SS Branch \(dqmaster\(dq 270.SS Branch \(dqmaster\(dq
243.TP 271.TP
244.B uptime 272.B uptime
245Master daemon uptime, in hundredths of a second. 273Master daemon uptime, in hundredths of a second.
246.SS Branch \(dqsession\(dq 274.SS Branch \(dqsession\(dq
247.TP 275.TP
248.B sessAccepted 276.B sessAccepted
249Number of sessions succesfully accepted. 277Number of sessions succesfully accepted.
250.TP 278.TP
251.B sessQueued 279.B sessQueued
252Number of times session was queued waiting for a thread. 280Number of times session was queued waiting for a thread.
253.TP 281.TP
254.B sessDropped 282.B sessDropped
255Number of sessions dropped because session queue was full. 283Number of sessions dropped because session queue was full.
256.TP 284.TP
257.B sessClosed 285.B sessClosed
258Number of sessions closed. 286Number of sessions closed.
259.TP 287.TP
260.B sessPipeline 288.B sessPipeline
261Session pipeline. This variable is available only in Varnish version \fR4.0\fR. 289This OID was used in Varnish \fR4.1\fR, but disappeared from version
290\fB5.0\fR.
262.TP 291.TP
263.B sessReadAhead 292.B sessReadAhead
264Session read-ahead. 293Session read-ahead.
265.TP 294.TP
266.B sessHerd 295.B sessHerd
267Session herd. 296Session herd.
268.TP 297.TP
269.B sessDrop 298.B sessDrop
270Number of sessions dropped for thread. 299Number of sessions dropped for thread.
271.TP 300.TP
272.B sessFail 301.B sessFail
273Number of session accept failures. 302Number of session accept failures.
274.TP 303.TP
275.B sessPipeOverflow 304.B sessPipeOverflow
276Number of session pipe overflows. This variable is available only in 305This OID was used in Varnish \fR4.1\fR, but disappeared in version
277Varnish version \fR4.0\fR. 306\fB5.0\fR.
278.SS Branch \(dqthreads\(dq 307.SS Branch \(dqthreads\(dq
279.TP 308.TP
280.B threadsPools 309.B threadsPools
281Number of thread pools. 310Number of thread pools.
282.TP 311.TP
283.B threadsTotal 312.B threadsTotal
284Number of thread pools. 313Number of thread pools.
285.TP 314.TP
286.B threadsLimitHits 315.B threadsLimitHits
287Number of times more threads were needed, but limit was reached in a 316Number of times more threads were needed, but limit was reached in a
288thread pool. 317thread pool.
289.TP 318.TP
290.B threadsCreated 319.B threadsCreated
291Total number of threads created in all pools. 320Total number of threads created in all pools.
292.TP 321.TP
293.B threadsDestroyed 322.B threadsDestroyed
294Total number of threads destroyed in all pools. 323Total number of threads destroyed in all pools.
295.TP 324.TP
296.B threadsFailed 325.B threadsFailed
297Number of times creating a thread failed. 326Number of times creating a thread failed.
298.SS Branch \(dqbans\(dq 327.SS Branch \(dqbans\(dq
299.TP 328.TP
300.B bansTotal 329.B bansTotal
301Total number of bans. 330Total number of bans.
@@ -346,49 +375,49 @@ Number of bytes used by the persisted ban lists.
346Extra bytes in persisted ban lists due to fragmentation. 375Extra bytes in persisted ban lists due to fragmentation.
347.TP 376.TP
348.B banTable 377.B banTable
349A table of configured varnish bans. It is indexed by the 378A table of configured varnish bans. It is indexed by the
350\fBbanIndex\fR OID. Each row has the following elements: 379\fBbanIndex\fR OID. Each row has the following elements:
351.RS 380.RS
352.TP 381.TP
353.B banTime 382.B banTime
354Time when the ban was set. 383Time when the ban was set.
355.TP 384.TP
356.B banRefCount 385.B banRefCount
357Number of references to that ban. This equals to the number of objects 386Number of references to that ban. This equals to the number of objects
358in the varnish cache affected by that ban. 387in the varnish cache affected by that ban.
359.TP 388.TP
360.B banExpression 389.B banExpression
361VCL expression of the ban. 390VCL expression of the ban.
362.RE 391.RE
363 392
364Notice that for performance reasons, the ban table is cached, so the 393Notice that for performance reasons, the ban table is cached, so the
365total number of rows in the \fBbanTable\fR may diverge from the value 394total number of rows in the \fBbanTable\fR may diverge from the value
366of \fBbansTotal\fR variable. The default update interval is 60 395of \fBbansTotal\fR variable. The default update interval is 60
367seconds. It can be configured in the \fBsnmpd.conf\fR file 396seconds. It can be configured in the \fBsnmpd.conf\fR file
368(see the \fBvarnishBanTableTimeout\fR statement above). 397(see the \fBvarnishBanTableTimeout\fR statement above).
369.SS Branch \(dqagent\(dq 398.SS Branch \(dqagent\(dq
370The \fBagent\fR branch is reserved for OIDs for 399The \fBagent\fR branch is reserved for
371implementation-specific management. It is not used currently. 400implementation-specific management. It is not used currently.
372.SH NOTES 401.SH NOTES
373The following OIDs were used in Varnish 4. They are no longer 402The following OIDs were used in Varnish 4. They are no longer
374available in Varnish 5: 403available in Varnish 5:
375.TP 404.TP
376.B clientRequests411 405.B clientRequests411
377Client requests received, subject to 411 errors. This variable is 406Client requests received, subject to 411 errors. This variable is
378available only in Varnish version \fR4.0\fR. 407available only in Varnish version \fR4.0\fR.
379.TP 408.TP
380.B clientRequests413 409.B clientRequests413
381Client requests received, subject to 413 errors. This variable is 410Client requests received, subject to 413 errors. This variable is
382available only in Varnish version \fR4.0\fR. 411available only in Varnish version \fR4.0\fR.
383.TP 412.TP
384.B backendConnUnused 413.B backendConnUnused
385Number of unused backend connections. This variable is available only 414Number of unused backend connections. This variable is available only
386in Varnish version \fR4.0\fR. 415in Varnish version \fR4.0\fR.
387.PP 416.PP
388The OIDs 417The OIDs
389.B clientRequestsReceived 418.B clientRequestsReceived
390and 419and
391.B totalRequests 420.B totalRequests
392return the same value. 421return the same value.
393.SH "SEE ALSO" 422.SH "SEE ALSO"
394.BR snmpd.conf (5), 423.BR snmpd.conf (5),
diff --git a/src/vcli.c b/src/vcli.c
index 7d6c2b9..94f0eef 100644
--- a/src/vcli.c
+++ b/src/vcli.c
@@ -1,26 +1,26 @@
1/* This file is part of varnish-mib -*- c -*- 1/* This file is part of varnish-mib -*- c -*-
2 Copyright (C) 2014-2015 Sergey Poznyakoff 2 Copyright (C) 2014-2018 Sergey Poznyakoff
3 3
4 Varnish-mib is free software; you can redistribute it and/or modify 4 Varnish-mib is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option) 6 the Free Software Foundation; either version 3, or (at your option)
7 any later version. 7 any later version.
8 8
9 Varnish-mib is distributed in the hope that it will be useful, 9 Varnish-mib is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with varnish-mib. If not, see <http://www.gnu.org/licenses/>. 15 along with varnish-mib. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17 17
18#include "varnish_mib.h" 18#include "varnish_mib.h"
19#include <sys/types.h> 19#include <sys/types.h>
20#include <sys/socket.h> 20#include <sys/socket.h>
21#include <sys/time.h> 21#include <sys/time.h>
22#include <sys/ioctl.h> 22#include <sys/ioctl.h>
23#include <netinet/in.h> 23#include <netinet/in.h>
24#include <netdb.h> 24#include <netdb.h>
25#include <arpa/inet.h> 25#include <arpa/inet.h>
26#include <errno.h> 26#include <errno.h>

Return to:

Send suggestions and report system problems to the System administrator.