aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2014-11-15 10:18:08 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2014-11-15 19:24:19 +0200
commitdb3812f4b4c5e4650671ca53bf1068ee25725078 (patch)
treec0e7fa12d27694902ece914dfc9fce94ad1a0e33 /src
downloadvarnish-mib-db3812f4b4c5e4650671ca53bf1068ee25725078.tar.gz
varnish-mib-db3812f4b4c5e4650671ca53bf1068ee25725078.tar.bz2
Initial commit
Diffstat (limited to 'src')
-rw-r--r--src/.gitignore1
-rw-r--r--src/Makefile.am54
-rw-r--r--src/VARNISH-MIB.txt237
-rw-r--r--src/varnish-mib.8126
-rw-r--r--src/varnish_mib.mib2c155
5 files changed, 573 insertions, 0 deletions
diff --git a/src/.gitignore b/src/.gitignore
new file mode 100644
index 0000000..49f397c
--- /dev/null
+++ b/src/.gitignore
@@ -0,0 +1 @@
+varnish_mib.c
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..b56c252
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,54 @@
+# This file is part of varnish-mib -*- automake -*-
+# Copyright (C) 2014 Sergey Poznyakoff
+#
+# varnish-mib is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# varnish-mib is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with varnish-mib. If not, see <http://www.gnu.org/licenses/>.
+
+dlmoddir=@DLMODDIR@
+dlmod_LTLIBRARIES = varnish-mib.la
+
+varnish_mib_la_SOURCES = \
+ varnish_mib.c
+
+BUILT_SOURCES = \
+ varnish_mib.c
+
+varnish_mib.c: varnish_mib.mib2c
+
+.mib2c.c:
+ MIBDIRS=${abs_srcdir}:${NET_SNMP_MIBDIRS} MIBS="+VARNISH-MIB" \
+ mib2c -c $< -f $@ varnish
+
+#NET_SNMP_INCLUDES = `$(NET_SNMP_CONFIG) --cflags`
+NET_SNMP_INCLUDES =
+NET_SNMP_LIBS = `$(NET_SNMP_CONFIG) --libs`
+NET_SNMP_EXLIBS = `$(NET_SNMP_CONFIG) --external-libs`
+NET_SNMP_MIBDIRS = `net-snmp-config --mibdirs`
+
+AM_LDFLAGS = \
+ -module \
+ -export-dynamic\
+ -avoid-version \
+ -rpath '$(dlmoddir)'\
+ ${VARNISHAPI_LIBS}\
+ $(NET_SNMP_LIBS)\
+ $(NET_SNMP_EXLIBS)
+
+AM_CPPFLAGS=-I. ${VARNISHAPI_CFLAGS} -I$NET_SNMP_INCLUDES
+
+mibdir=@MIBDIR@
+mib_DATA = varnish_mib.mib2c
+
+dist_man_MANS = varnish-mib.8
+
+EXTRA_DIST = VARNISH-MIB.txt varnish_mib.mib2c
diff --git a/src/VARNISH-MIB.txt b/src/VARNISH-MIB.txt
new file mode 100644
index 0000000..0ec5dac
--- /dev/null
+++ b/src/VARNISH-MIB.txt
@@ -0,0 +1,237 @@
+VARNISH-MIB DEFINITIONS ::= BEGIN
+
+-- *************************************************************
+-- $Id: VARNISH-MIB.txt,v 1.5 2009/03/07 09:44:10 mhe Exp $
+--
+-- Varnish reverse proxy MIB
+-- by Shared Autonomous sYstems
+--
+-- *************************************************************
+
+IMPORTS
+ MODULE-IDENTITY, OBJECT-TYPE, enterprises, Counter32
+ FROM SNMPv2-SMI
+ OBJECT-GROUP, MODULE-COMPLIANCE
+ FROM SNMPv2-CONF;
+
+varnishMIB MODULE-IDENTITY
+ LAST-UPDATED "200903050000Z"
+ ORGANIZATION "Shared Autonomous sYstems"
+ CONTACT-INFO "mhe@say.no"
+ DESCRIPTION
+ "This MIB module defines objects for Varnish reverse web proxy."
+ REVISION "200903050000Z"
+ DESCRIPTION
+ "Initial version."
+ ::= { varnish 0 }
+
+varnish OBJECT IDENTIFIER ::= { enterprises 33043 6 1 }
+client OBJECT IDENTIFIER ::= { varnish 1 }
+backend OBJECT IDENTIFIER ::= { varnish 2 }
+total OBJECT IDENTIFIER ::= { varnish 3 }
+
+clientAcceptedConnections OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Client connections accepted"
+ ::= { client 1 }
+
+clientRequestsReceived OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Client requests received"
+ ::= { client 2 }
+
+clientCacheHits OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Cache hits"
+ ::= { client 3 }
+
+clientCacheHitsPass OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Cache hits for pass"
+ ::= { client 4 }
+
+clientCacheMisses OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Cache misses"
+ ::= { client 5 }
+
+connections OBJECT IDENTIFIER ::= { backend 1 }
+
+backendConnSuccess OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Backend connections success"
+ ::= { connections 1 }
+
+backendConnNotAttempted OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Backend connections not attempted"
+ ::= { connections 2 }
+
+backendConnToMany OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Backend connections too many"
+ ::= { connections 3 }
+
+backendConnFailures OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Backend connections failures"
+ ::= { connections 4 }
+
+backendConnReuses OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Backend connections reuses"
+ ::= { connections 5 }
+
+backendConnRecycled OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Backend connections recycles"
+ ::= { connections 6 }
+
+backendConnUnused OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Backend connections unused"
+ ::= { connections 7 }
+
+totalSessions OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Total Sessions"
+ ::= { total 1 }
+
+totalRequests OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Total Requests"
+ ::= { total 2 }
+
+totalPipe OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Total pipe"
+ ::= { total 3 }
+
+totalPass OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Total pass"
+ ::= { total 4 }
+
+totalFetch OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Total fetch"
+ ::= { total 5 }
+
+totalHeaderBytes OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Total header bytes"
+ ::= { total 6 }
+
+totalBodyBytes OBJECT-TYPE
+ SYNTAX Counter32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Total body bytes"
+ ::= { total 7 }
+
+--
+-- Groups and Compliance
+--
+varnishConfs OBJECT IDENTIFIER ::= { varnish 100 }
+varnishGroups OBJECT IDENTIFIER ::= { varnishConfs 1 }
+varnishCompl OBJECT IDENTIFIER ::= { varnishConfs 2 }
+
+--
+-- Groups
+--
+varnishGroup OBJECT-GROUP
+ OBJECTS {
+ clientAcceptedConnections,
+ clientRequestsReceived,
+ clientCacheHits,
+ clientCacheHitsPass,
+ clientCacheMisses,
+ backendConnSuccess,
+ backendConnNotAttempted,
+ backendConnToMany,
+ backendConnFailures,
+ backendConnReuses,
+ backendConnRecycled,
+ backendConnUnused,
+ totalSessions,
+ totalRequests,
+ totalPipe,
+ totalPass,
+ totalFetch,
+ totalHeaderBytes,
+ totalBodyBytes}
+
+ STATUS current
+ DESCRIPTION "Group of Varnish objects"
+ ::= { varnishGroups 1 }
+
+--
+-- Compliance
+--
+varnishStandardComplianceV1 MODULE-COMPLIANCE
+ STATUS current
+ DESCRIPTION
+ "Compliance for an Varnish agent"
+
+ MODULE
+ MANDATORY-GROUPS {
+ varnishGroup}
+
+ ::= { varnishCompl 1 }
+
+END
diff --git a/src/varnish-mib.8 b/src/varnish-mib.8
new file mode 100644
index 0000000..452fc0b
--- /dev/null
+++ b/src/varnish-mib.8
@@ -0,0 +1,126 @@
+.\" This file is part of Varnish-mib -*- nroff -*-
+.\" Copyright (C) 2014 Sergey Poznyakoff
+.\"
+.\" Varnish-mib is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 3, or (at your option)
+.\" any later version.
+.\"
+.\" Varnish-mib is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.\" GNU General Public License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public License
+.\" along with Varnish-mib. If not, see <http://www.gnu.org/licenses/>.
+.TH VARNISH-MIB 8 "November 15, 2014" "varnish-mib"
+.SH NAME
+varnish\-mib \- net\-snmp module for obtaining Varnish Cache statistics
+.SH SYNOPSIS
+In \fBsnmpd.conf\fR(5):
+.br
+.B dlmod varnish_mib /usr/lib/snmp/varnish-mib.so
+.SH DESCRIPTION
+Dynamically loadable object module for
+.B net-snmp
+.BR snmpd (8),
+that provides access to Varnish Cache statistics. The module is
+loaded into
+.B snmpd
+as shown above (actual path can of course differ, depending on how
+the package was configured).
+.PP
+The following OIDs are defined:
+.TP
+.B VARNISH-MIB::clientAcceptedConnections.0
+Number of accepted connections.
+.TP
+.B VARNISH-MIB::clientRequestsReceived.0
+Number of received HTTP requests.
+.TP
+.B VARNISH-MIB::clientCacheHits.0
+Number of cache hits. A cache hit indicates that an object has been
+delivered to a client without fetching it from a backend server.
+.TP
+.B VARNISH-MIB::clientCacheHitsPass.0
+Number of hits for pass. A cache hit for pass indicates that Varnish
+passes the request to the backend and this decision itself has been cached.
+.TP
+.B VARNISH-MIB::clientCacheMisses.0
+Number of misses. A cache miss indicates the object was fetched from
+the backend before delivering it to the client.
+.TP
+.B VARNISH-MIB::backendConnSuccess.0
+Number of successful connections to the backend.
+.TP
+.B VARNISH-MIB::backendConnNotAttempted.0
+Number of backend connections not attempted, because of the unhealthy
+status of the backend.
+.TP
+.B VARNISH-MIB::backendConnToMany.0
+Number of backend connections failed because there were too many
+connections open.
+.TP
+.B VARNISH-MIB::backendConnFailures.0
+Number of failed backend connections.
+.TP
+.B VARNISH-MIB::backendConnReuses.0
+Number of reused backend connections. This counter is increased
+whenever Varnish reuses a recycled connection.
+.TP
+.B VARNISH-MIB::backendConnRecycled.0
+Number of backend connection recycles. This counter is increased
+whenever Varnish has keep-alive connection that is put back into
+the pool of connections. It has not yet been used, but it might be,
+unless the backend closes it.
+.TP
+.B VARNISH-MIB::backendConnUnused.0
+Number of unused backend connections.
+.TP
+.B VARNISH-MIB::totalSessions.0
+Total number of sessions served since the startup.
+.TP
+.B VARNISH-MIB::totalRequests.0
+Total number of requests received since the startup.
+.TP
+.B VARNISH-MIB::totalPipe.0
+Total number of requests piped to the backend.
+.TP
+.B VARNISH-MIB::totalPass.0
+Total number of requests passed to the backend.
+.TP
+.B VARNISH-MIB::totalFetch.0
+Total number of fetches.
+.TP
+.B VARNISH-MIB::totalHeaderBytes.0
+Total request header bytes received.
+.TP
+.B VARNISH-MIB::totalBodyBytes.0
+Total request body bytes received.
+.SH "SEE ALSO"
+.BR snmpd.conf (5),
+.BR snmpd (8),
+.BR varnish (7),
+.BR varnishstat (1).
+.SH AUTHORS
+Sergey Poznyakoff
+.SH "BUG REPORTS"
+Report bugs to <gray@gnu.org>.
+.SH COPYRIGHT
+Copyright \(co 2013-2014 Sergey Poznyakoff
+.br
+.na
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+.br
+.ad
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.
+.\" Local variables:
+.\" eval: (add-hook 'write-file-hooks 'time-stamp)
+.\" time-stamp-start: ".TH [A-Z_][A-Z0-9_.-]* [0-9] \""
+.\" time-stamp-format: "%:B %:d, %:y"
+.\" time-stamp-end: "\""
+.\" time-stamp-line-limit: 20
+.\" end:
+
+
diff --git a/src/varnish_mib.mib2c b/src/varnish_mib.mib2c
new file mode 100644
index 0000000..55b57e5
--- /dev/null
+++ b/src/varnish_mib.mib2c
@@ -0,0 +1,155 @@
+# This file is part of varnish-mib -*- c -*-
+# Copyright (C) 2014 Sergey Poznyakoff
+#
+# Varnish-mib is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# Varnish-mib is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with varnish-mib. If not, see <http://www.gnu.org/licenses/>.
+@open ${name}@
+/*
+ * Note: this file originally auto-generated by mib2c using
+ * mib2c.varnish.conf
+ */
+
+#include <config.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+#include "vapi/vsc.h"
+#include "vapi/vsm.h"
+
+#include <net-snmp/net-snmp-config.h>
+#include <net-snmp/net-snmp-includes.h>
+#include <net-snmp/agent/net-snmp-agent-includes.h>
+
+static struct VSM_data *vd;
+
+void
+varnish_snmp_init(void)
+{
+ vd = VSM_New();
+
+ if (VSM_Open(vd))
+ exit(1);
+}
+
+void
+varnish_snmp_deinit(void)
+{
+ VSM_Close(vd);
+}
+
+@startperl@
+$vars{'varnish_translate'} = sub {
+ my $name = shift;
+ my %trans = (
+ clientAcceptedConnections => 'sess_conn',
+ clientRequestsReceived => 'client_req',
+ clientCacheHits => 'cache_hit',
+ clientCacheHitsPass => 'cache_hitpass',
+ clientCacheMisses => 'cache_miss',
+ backendConnSuccess => 'backend_conn',
+ backendConnNotAttempted => 'backend_unhealthy',
+ backendConnToMany => 'backend_busy ',
+ backendConnFailures => 'backend_fail',
+ backendConnReuses => 'backend_reuse',
+ backendConnRecycled => 'backend_recycle',
+ backendConnUnused => 'backend_toolate',
+ totalSessions => 's_sess ',
+ totalRequests => 's_req ',
+ totalPipe => 's_pipe',
+ totalPass => 's_pass',
+ totalFetch => 's_fetch',
+ totalHeaderBytes => 's_req_hdrbytes',
+ totalBodyBytes => 's_req_bodybytes'
+ );
+
+ my $r = $trans{$name};
+ if (!defined($r)) {
+ print STDERR "no translation for $name!\n";
+ exit(1);
+ }
+ $vars{'varnish_member'} = $r;
+ return 0;
+};
+
+$vars{'modulename'} = $vars{'name'};
+$vars{'modulename'} =~ s#.*/##;
+$vars{'modulename'} =~ s/\.c$//;
+print "$vars{'modulename'}\n";
+
+0;
+@endperl@
+
+@foreach $i scalar@
+static int
+handle_$i(netsnmp_mib_handler *handler,
+ netsnmp_handler_registration *reginfo,
+ netsnmp_agent_request_info *reqinfo,
+ netsnmp_request_info *requests)
+{
+ uint32_t val;
+ /* We are never called for a GETNEXT if it's registered as a
+ "instance", as it's "magically" handled for us. */
+
+ /* an instance handler also only hands us one request at a time, so
+ we don't need to loop over a list of requests; we'll only get one.
+ */
+ @startperl@
+ &{$vars{'varnish_translate'}}($vars{'i'});
+ @endperl@
+ if (reqinfo->mode == MODE_GET) {
+ struct VSC_C_main const *st = VSC_Main(vd, NULL);
+ if (!st)
+ return SNMP_ERR_NOSUCHNAME;
+ snmp_set_var_typed_value(requests->requestvb, $i.type,
+ &st->$varnish_member,
+ sizeof(st->$varnish_member));
+ } else {
+ snmp_log(LOG_ERR, "unknown mode (%d) in handle_${i}\n",
+ reqinfo->mode );
+ return SNMP_ERR_GENERR;
+ }
+
+ return SNMP_ERR_NOERROR;
+}
+@end@
+
+/** Initializes the $name module */
+void
+init_$modulename(void)
+{
+ @foreach $i scalar@
+ const oid ${i}_oid[] = { $i.commaoid };
+ @end@
+
+ DEBUGMSGTL(("$name", "Initializing\n"));
+
+ @foreach $i scalar@
+ netsnmp_register_scalar(
+ netsnmp_create_handler_registration("$i", handle_$i,
+ ${i}_oid, OID_LENGTH(${i}_oid),
+ @if !$i.settable@
+ HANDLER_CAN_RONLY
+ @end@
+ @if $i.settable@
+ HANDLER_CAN_RWRITE
+ @end@
+ ));
+ @end@
+ varnish_snmp_init();
+}
+
+void
+deinit_$modulename(void)
+{
+ varnish_snmp_deinit();
+}

Return to:

Send suggestions and report system problems to the System administrator.