Hi all,

please find attached a patch that adds two per-backend counters to
VSC_DO_VBE:
- conn : gauge which represents the number of concurrent connections to
backend.
- req : counter which represents the number of requests sent.

It has to be applied to the master branch.
The change has been driven by costumer demand, the aim is to improve the
backends' info and provide a better overview over backends performances.

-- 
Arianna Aondio
Software Developer | Varnish Software AS
Mobile: +47 980 62 619

 We Make Websites Fly
www.varnish-software.com
From b3f15efc5b161e2ee0bd47b860fad2b300e1fc29 Mon Sep 17 00:00:00 2001
From: Arianna Aondio <[email protected]>
Date: Wed, 5 Nov 2014 10:54:03 +0100
Subject: [PATCH] New counters for VBE.

---
 bin/varnishd/cache/cache_backend.c     | 3 +++
 bin/varnishd/cache/cache_backend_cfg.c | 1 +
 include/tbl/vsc_fields.h               | 8 ++++++++
 3 files changed, 12 insertions(+)

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 8454f56..4dda66b 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -151,6 +151,7 @@ bes_conn_try(struct busyobj *bo, struct vbc *vc, const struct vbe_dir *vs)
 	Lck_Lock(&bp->mtx);
 	bp->refcount++;
 	bp->n_conn++;		/* It mostly works */
+	bp->vsc->conn++;
 	Lck_Unlock(&bp->mtx);
 
 	s = -1;
@@ -175,6 +176,7 @@ bes_conn_try(struct busyobj *bo, struct vbc *vc, const struct vbe_dir *vs)
 	if (s < 0) {
 		Lck_Lock(&bp->mtx);
 		bp->n_conn--;
+		bp->vsc->conn--;
 		bp->refcount--;		/* Only keep ref on success */
 		Lck_Unlock(&bp->mtx);
 		vc->addr = NULL;
@@ -359,6 +361,7 @@ vbe_dir_getfd(const struct director *d, struct busyobj *bo)
 		return (-1);
 	}
 
+	vc->backend->vsc->req++;
 	if (bo->htc == NULL)
 		bo->htc = WS_Alloc(bo->ws, sizeof *bo->htc);
 	AN(bo->htc);
diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c
index 5cf077e..bc80ae5 100644
--- a/bin/varnishd/cache/cache_backend_cfg.c
+++ b/bin/varnishd/cache/cache_backend_cfg.c
@@ -150,6 +150,7 @@ VBE_DropRefConn(struct backend *b, const struct acct_bereq *acct_bereq)
 	Lck_Lock(&b->mtx);
 	assert(b->n_conn > 0);
 	b->n_conn--;
+	b->vsc->conn--;
 	VBE_DropRefLocked(b, acct_bereq);
 }
 
diff --git a/include/tbl/vsc_fields.h b/include/tbl/vsc_fields.h
index 64e63a3..0d646a2 100644
--- a/include/tbl/vsc_fields.h
+++ b/include/tbl/vsc_fields.h
@@ -214,6 +214,14 @@ VSC_F(pipe_in,			uint64_t, 0, 'a', info,
 	"Total number of bytes forwarded from backend in"
 	" pipe sessions"
 )
+VSC_F(conn,			uint64_t, 0, 'g', info,
+    "Concurrent connections to backend",
+	""
+)
+VSC_F(req,			uint64_t, 0, 'c', info,
+    "Backend requests sent",
+	""
+)
 
 #endif
 
-- 
1.9.1

_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to