r247 - in trunk/varnish-cache: . bin bin/varnishstat
phk at projects.linpro.no
phk at projects.linpro.no
Wed Jun 28 13:21:06 CEST 2006
Author: phk
Date: 2006-06-28 13:21:06 +0200 (Wed, 28 Jun 2006)
New Revision: 247
Added:
trunk/varnish-cache/bin/varnishstat/
trunk/varnish-cache/bin/varnishstat/Makefile.am
trunk/varnish-cache/bin/varnishstat/varnishstat.c
Modified:
trunk/varnish-cache/bin/Makefile.am
trunk/varnish-cache/configure.ac
Log:
Add varnishstat program
Modified: trunk/varnish-cache/bin/Makefile.am
===================================================================
--- trunk/varnish-cache/bin/Makefile.am 2006-06-28 10:31:29 UTC (rev 246)
+++ trunk/varnish-cache/bin/Makefile.am 2006-06-28 11:21:06 UTC (rev 247)
@@ -1,3 +1,3 @@
# $Id$
-SUBDIRS = varnishd varnishlog
+SUBDIRS = varnishd varnishlog varnishstat
Added: trunk/varnish-cache/bin/varnishstat/Makefile.am
===================================================================
--- trunk/varnish-cache/bin/varnishstat/Makefile.am 2006-06-28 10:31:29 UTC (rev 246)
+++ trunk/varnish-cache/bin/varnishstat/Makefile.am 2006-06-28 11:21:06 UTC (rev 247)
@@ -0,0 +1,9 @@
+# $Id: Makefile.am 133 2006-04-06 09:38:00Z phk $
+
+INCLUDES = -I$(top_srcdir)/include
+
+bin_PROGRAMS = varnishstat
+
+varnishlog_SOURCES = varnishstat.c
+
+# varnishlog_LDADD = $(top_builddir)/lib/libvarnishapi/libvarnishapi.la
Added: trunk/varnish-cache/bin/varnishstat/varnishstat.c
===================================================================
--- trunk/varnish-cache/bin/varnishstat/varnishstat.c 2006-06-28 10:31:29 UTC (rev 246)
+++ trunk/varnish-cache/bin/varnishstat/varnishstat.c 2006-06-28 11:21:06 UTC (rev 247)
@@ -0,0 +1,62 @@
+/*
+ * $Id: varnishlog.c 153 2006-04-25 08:17:43Z phk $
+ *
+ * Log tailer for Varnish
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#include <shmlog.h>
+
+static struct shmloghead *loghead;
+
+int
+main(int argc, char **argv)
+{
+ int fd;
+ int i;
+ struct shmloghead slh;
+ struct varnish_stats *VSL_stats;
+
+ fd = open(SHMLOG_FILENAME, O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "Cannot open %s: %s\n",
+ SHMLOG_FILENAME, strerror(errno));
+ exit (1);
+ }
+ i = read(fd, &slh, sizeof slh);
+ if (i != sizeof slh) {
+ fprintf(stderr, "Cannot read %s: %s\n",
+ SHMLOG_FILENAME, strerror(errno));
+ exit (1);
+ }
+ if (slh.magic != SHMLOGHEAD_MAGIC) {
+ fprintf(stderr, "Wrong magic number in file %s\n",
+ SHMLOG_FILENAME);
+ exit (1);
+ }
+
+ loghead = mmap(NULL, slh.size + sizeof slh,
+ PROT_READ, MAP_HASSEMAPHORE, fd, 0);
+ if (loghead == MAP_FAILED) {
+ fprintf(stderr, "Cannot mmap %s: %s\n",
+ SHMLOG_FILENAME, strerror(errno));
+ exit (1);
+ }
+
+ VSL_stats = &loghead->stats;
+
+#define MAC_STAT(n,t,f,d) \
+ printf("%12ju " d "\n", (VSL_stats->n));
+#include "stat_field.h"
+#undef MAC_STAT
+
+ exit (0);
+
+}
Modified: trunk/varnish-cache/configure.ac
===================================================================
--- trunk/varnish-cache/configure.ac 2006-06-28 10:31:29 UTC (rev 246)
+++ trunk/varnish-cache/configure.ac 2006-06-28 11:21:06 UTC (rev 247)
@@ -68,6 +68,7 @@
bin/Makefile
bin/varnishd/Makefile
bin/varnishlog/Makefile
+ bin/varnishstat/Makefile
contrib/Makefile
include/Makefile
lib/Makefile
More information about the varnish-commit
mailing list