Varnish plugin: Added SMS monitor
authorJérôme Renard <jerome.renard@gmail.com>
Sun, 6 Jun 2010 07:10:12 +0000 (09:10 +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 2e31ea3..80643e5 100644 (file)
 #  - SMA bytes allocated
 #  - SMA bytes free
 #  MonitorSMA yes
+#
+#  Will monitor:
+#  - SMS allocator requests
+#  - SMS outstanding allocations
+#  - SMS outstanding bytes
+#  - SMS bytes allocated
+#  - SMS bytes freed
+#  MonitorSMS yes
+#
 #</Plugin>
 
 #<Plugin vmem>
index 3444e45..6bdb774 100644 (file)
@@ -168,6 +168,7 @@ varnish_fetch       value:GAUGE:0:U
 varnish_hcb         value:GAUGE:0:U
 varnish_shm         value:GAUGE:0:U
 varnish_sma         value:GAUGE:0:U
+varnish_sms         value:GAUGE:0:U
 virt_cpu_total         ns:COUNTER:0:256000000000
 virt_vcpu              ns:COUNTER:0:1000000000
 vmpage_action          value:COUNTER:0:4294967295
index 88fd58d..80c6d37 100644 (file)
  * sma_nbytes           SMA outstanding bytes                     Y
  * sma_balloc           SMA bytes allocated                       Y
  * sma_bfree            SMA bytes free                            Y
- * sms_nreq             SMS allocator requests                    N
- * sms_nobj             SMS outstanding allocations               N
- * sms_nbytes           SMS outstanding bytes                     N
- * sms_balloc           SMS bytes allocated                       N
- * sms_bfree            SMS bytes freed                           N
+ * sms_nreq             SMS allocator requests                    Y
+ * sms_nobj             SMS outstanding allocations               Y
+ * sms_nbytes           SMS outstanding bytes                     Y
+ * sms_balloc           SMS bytes allocated                       Y
+ * sms_bfree            SMS bytes freed                           Y
  * backend_req          Backend requests made                     N
  * n_vcl                N vcl total                               N
  * n_vcl_avail          N vcl available                           N
 
 #include <varnish/varnishapi.h>
 
-#define USER_CONFIG_INIT {0, 0, 0, 0, 0, 0, 0, 0}
+#define USER_CONFIG_INIT {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 */
@@ -141,6 +141,7 @@ struct user_config_s {
        int monitor_hcb;
        int monitor_shm;
        int monitor_sma;
+       int monitor_sms;
 };
 
 typedef struct user_config_s user_config_t; /* }}} */
@@ -157,7 +158,8 @@ static const char *config_keys[] =
   "MonitorFetch",
   "MonitorHCB",
   "MonitorSHM",
-  "MonitorSMA"
+  "MonitorSMA",
+  "MonitorSMS"
 };
 
 static int config_keys_num = STATIC_ARRAY_SIZE (config_keys); /* }}} */
@@ -172,6 +174,7 @@ static int varnish_config(const char *key, const char *value) /* {{{ */
        SET_MONITOR_FLAG("MonitorHCB"        , monitor_hcb        , value);
        SET_MONITOR_FLAG("MonitorSHM"        , monitor_shm        , value);
        SET_MONITOR_FLAG("MonitorSMA"        , monitor_sma        , value);
+       SET_MONITOR_FLAG("MonitorSMS"        , monitor_sms        , value);
 
        return (0);
 } /* }}} */
@@ -264,6 +267,15 @@ static void varnish_monitor(struct varnish_stats *VSL_stats) /* {{{ */
                varnish_submit("varnish_sma", "sma_balloc", VSL_stats->sma_balloc); /* SMA bytes allocated         */
                varnish_submit("varnish_sma", "sma_bfree" , VSL_stats->sma_bfree);  /* SMA bytes free              */
        }
+
+       if(user_config.monitor_sms == 1)
+       {
+               varnish_submit("varnish_sms", "sms_nreq"  , VSL_stats->sms_nreq);   /* SMS allocator requests      */
+               varnish_submit("varnish_sms", "sms_nobj"  , VSL_stats->sms_nobj);   /* SMS outstanding allocations */
+               varnish_submit("varnish_sms", "sms_nbytes", VSL_stats->sms_nbytes); /* SMS outstanding bytes       */
+               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             */
+       }
 } /* }}} */
 
 static int varnish_read(void) /* {{{ */