Varnish plugin: Added SM Monitor
authorJérôme Renard <jerome.renard@gmail.com>
Sun, 6 Jun 2010 07:23:25 +0000 (09:23 +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 80643e5..8cb3fce 100644 (file)
 #  - SMS bytes freed
 #  MonitorSMS yes
 #
+#  Will monitor:
+#  - allocator requests
+#  - outstanding allocations
+#  - bytes allocated
+#  - bytes free
+#  MonitorSM yes
+#
 #</Plugin>
 
 #<Plugin vmem>
index 6bdb774..2fe5f4f 100644 (file)
@@ -169,6 +169,7 @@ varnish_hcb         value:GAUGE:0:U
 varnish_shm         value:GAUGE:0:U
 varnish_sma         value:GAUGE:0:U
 varnish_sms         value:GAUGE:0:U
+varnish_sm          value:GAUGE:0:U
 virt_cpu_total         ns:COUNTER:0:256000000000
 virt_vcpu              ns:COUNTER:0:1000000000
 vmpage_action          value:COUNTER:0:4294967295
index 80c6d37..1d07945 100644 (file)
  * 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
- * sm_bfree             bytes free                                N
+ * sm_nreq              allocator requests                        Y
+ * sm_nobj              outstanding allocations                   Y
+ * sm_balloc            bytes allocated                           Y
+ * sm_bfree             bytes free                                Y
  * sma_nreq             SMA allocator requests                    Y
  * sma_nobj             SMA outstanding allocations               Y
  * sma_nbytes           SMA outstanding bytes                     Y
 
 #include <varnish/varnishapi.h>
 
-#define USER_CONFIG_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0}
+#define USER_CONFIG_INIT {0, 0, 0, 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 */
@@ -142,6 +142,7 @@ struct user_config_s {
        int monitor_shm;
        int monitor_sma;
        int monitor_sms;
+       int monitor_sm;
 };
 
 typedef struct user_config_s user_config_t; /* }}} */
@@ -159,7 +160,8 @@ static const char *config_keys[] =
   "MonitorHCB",
   "MonitorSHM",
   "MonitorSMA",
-  "MonitorSMS"
+  "MonitorSMS",
+  "MonitorSM"
 };
 
 static int config_keys_num = STATIC_ARRAY_SIZE (config_keys); /* }}} */
@@ -175,6 +177,7 @@ static int varnish_config(const char *key, const char *value) /* {{{ */
        SET_MONITOR_FLAG("MonitorSHM"        , monitor_shm        , value);
        SET_MONITOR_FLAG("MonitorSMA"        , monitor_sma        , value);
        SET_MONITOR_FLAG("MonitorSMS"        , monitor_sms        , value);
+       SET_MONITOR_FLAG("MonitorSM"         , monitor_sm         , value);
 
        return (0);
 } /* }}} */
@@ -276,6 +279,14 @@ static void varnish_monitor(struct varnish_stats *VSL_stats) /* {{{ */
                varnish_submit("varnish_sms", "sms_balloc", VSL_stats->sms_balloc); /* SMS bytes allocated         */
                varnish_submit("varnish_sms", "sms_bfree" , VSL_stats->sms_bfree);  /* SMS bytes freed             */
        }
+
+       if(user_config.monitor_sm == 1)
+       {
+               varnish_submit("varnish_sm", "sm_nreq"  , VSL_stats->sm_nreq);   /* allocator requests      */
+               varnish_submit("varnish_sm", "sm_nobj"  , VSL_stats->sm_nobj);   /* outstanding allocations */
+               varnish_submit("varnish_sm", "sm_balloc", VSL_stats->sm_balloc); /* bytes allocated         */
+               varnish_submit("varnish_sm", "sm_bfree" , VSL_stats->sm_bfree);  /* bytes free              */
+       }
 } /* }}} */
 
 static int varnish_read(void) /* {{{ */