Code

Varnish plugin: Added SHM monitoring
authorJérôme Renard <jerome.renard@gmail.com>
Fri, 4 Jun 2010 16:59:05 +0000 (18:59 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 7 Jun 2010 12:40:47 +0000 (14:40 +0200)
src/collectd.conf.in
src/types.db
src/varnish.c

index 2ca0561f6d56349db2f0c10ef5bc375f0c20760f..b04eb28c0b629f8f4565452ba90dc931d5d4c216 100644 (file)
 #  MonitorBackend yes
 #  MonitorFetch yes
 #  MonitorHCB yes
+#  MonitorSHM yes
 #</Plugin>
 
 #<Plugin vmem>
index 10a7ff2d8dee829ebaa391bb77d593ac1f5f4bda..7df495c5c7fd444c8840f83cafb3f2899e2b597b 100644 (file)
@@ -166,6 +166,7 @@ varnish_esi         value:GAUGE:0:U
 varnish_backend_connections     value:GAUGE:0:U
 varnish_fetch       value:GAUGE:0:U
 varnish_hcb         value:GAUGE:0:U
+varnish_shm         value:GAUGE:0:U
 virt_cpu_total         ns:COUNTER:0:256000000000
 virt_vcpu              ns:COUNTER:0:1000000000
 vmpage_action          value:COUNTER:0:4294967295
index ea510e17423d999cb1daf2ef53d87ad5d3447b88..f4b36bf9dc48f7d0d520678d80c8c1c1a749a345 100644 (file)
  * sess_readahead       Session Read Ahead                        N
  * sess_linger          Session Linger                            N
  * sess_herd            Session herd                              N
- * shm_records          SHM records                               N
- * shm_writes           SHM writes                                N
- * shm_flushes          SHM flushes due to overflow               N
- * shm_cont             SHM MTX contention                        N
- * shm_cycles           SHM cycles through buffer                 N
+ * shm_records          SHM records                               Y
+ * shm_writes           SHM writes                                Y
+ * shm_flushes          SHM flushes due to overflow               Y
+ * shm_cont             SHM MTX contention                        Y
+ * shm_cycles           SHM cycles through buffer                 Y
  * sm_nreq              allocator requests                        N
  * sm_nobj              outstanding allocations                   N
  * sm_balloc            bytes allocated                           N
 
 #include <varnish/varnishapi.h>
 
-#define USER_CONFIG_INIT {0, 0, 0, 0, 0,0}
+#define USER_CONFIG_INIT {0, 0, 0, 0, 0, 0, 0}
 #define SET_MONITOR_FLAG(name, flag, value) if((strcasecmp(name, key) == 0) && IS_TRUE(value)) user_config.flag = 1
 
 /* {{{ user_config_s */
@@ -139,6 +139,7 @@ struct user_config_s {
        int monitor_backend;
        int monitor_fetch;
        int monitor_hcb;
+       int monitor_shm;
 };
 
 typedef struct user_config_s user_config_t; /* }}} */
@@ -153,7 +154,8 @@ static const char *config_keys[] =
   "MonitorESI",
   "MonitorBackend",
   "MonitorFetch",
-  "MonitorHCB"
+  "MonitorHCB",
+  "MonitorSHM"
 };
 
 static int config_keys_num = STATIC_ARRAY_SIZE (config_keys); /* }}} */
@@ -166,6 +168,7 @@ static int varnish_config(const char *key, const char *value) /* {{{ */
        SET_MONITOR_FLAG("MonitorBackend", monitor_backend, value);
        SET_MONITOR_FLAG("MonitorFetch", monitor_fetch, value);
        SET_MONITOR_FLAG("MonitorHCB", monitor_hcb, value);
+       SET_MONITOR_FLAG("MonitorSHM", monitor_shm, value);
 
        return (0);
 } /* }}} */
@@ -240,6 +243,15 @@ static void varnish_monitor(struct varnish_stats *VSL_stats) /* {{{ */
                varnish_submit("varnish_hcb", "hcb_lock"  , VSL_stats->hcb_lock);   /* HCB Lookups with lock    */
                varnish_submit("varnish_hcb", "hcb_insert", VSL_stats->hcb_insert); /* HCB Inserts              */
        }
+
+       if(user_config.monitor_shm == 1)
+       {
+               varnish_submit("varnish_shm", "shm_records"   , VSL_stats->shm_records); /* SHM records                 */
+               varnish_submit("varnish_shm", "shm_writes"    , VSL_stats->shm_writes);  /* SHM writes                  */
+               varnish_submit("varnish_shm", "shm_flushes"   , VSL_stats->shm_flushes); /* SHM flushes due to overflow */
+               varnish_submit("varnish_shm", "shm_contention", VSL_stats->shm_cont);    /* SHM MTX contention          */
+               varnish_submit("varnish_shm", "shm_cycles"    , VSL_stats->shm_cycles);  /* SHM cycles through buffer   */
+       }
 } /* }}} */
 
 static int varnish_read(void) /* {{{ */