Skip to content

Instantly share code, notes, and snippets.

@freemed
Created June 27, 2011 19:25
Show Gist options
  • Save freemed/1049599 to your computer and use it in GitHub Desktop.
Save freemed/1049599 to your computer and use it in GitHub Desktop.
gmond tags support
Index: monitor-core/gmetad/xml_hash.c
===================================================================
--- monitor-core/gmetad/xml_hash.c (revision 2618)
+++ monitor-core/gmetad/xml_hash.c (working copy)
@@ -35,12 +35,12 @@
#line 5 "xml_hash.gperf"
struct xml_tag;
-#define TOTAL_KEYWORDS 32
+#define TOTAL_KEYWORDS 33
#define MIN_WORD_LENGTH 2
#define MAX_WORD_LENGTH 13
-#define MIN_HASH_VALUE 3
-#define MAX_HASH_VALUE 44
-/* maximum key range = 42, duplicates = 0 */
+#define MIN_HASH_VALUE 4
+#define MAX_HASH_VALUE 49
+/* maximum key range = 46, duplicates = 0 */
#ifdef __GNUC__
__inline
@@ -56,32 +56,32 @@
{
static unsigned char asso_values[] =
{
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 5, 45, 0, 15, 0,
- 45, 0, 30, 10, 45, 45, 0, 20, 10, 0,
- 25, 45, 15, 0, 0, 5, 0, 45, 20, 30,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 0, 50, 5, 25, 5,
+ 50, 0, 35, 25, 50, 50, 10, 5, 5, 5,
+ 10, 50, 10, 0, 0, 20, 15, 50, 15, 40,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50, 50, 50, 50, 50
};
return len + asso_values[(unsigned char)str[len - 1]] + asso_values[(unsigned char)str[0]];
}
@@ -99,83 +99,85 @@
{
static unsigned char lengthtable[] =
{
- 0, 0, 0, 3, 4, 5, 6, 7, 3, 9, 5, 11, 2, 13,
- 4, 10, 0, 7, 8, 4, 5, 0, 7, 3, 4, 0, 6, 7,
- 13, 4, 0, 0, 2, 3, 4, 5, 0, 2, 8, 4, 0, 0,
- 0, 0, 9
+ 0, 0, 0, 0, 4, 0, 0, 2, 3, 4, 5, 6, 7, 3,
+ 4, 10, 6, 7, 13, 4, 5, 11, 7, 8, 9, 5, 0, 7,
+ 3, 4, 0, 0, 2, 3, 4, 0, 0, 2, 13, 4, 5, 0,
+ 0, 8, 4, 0, 0, 0, 0, 9
};
static struct xml_tag xml_tags[] =
{
- {"", 0}, {"", 0}, {"", 0},
-#line 33 "xml_hash.gperf"
- {"VAL", VAL_TAG},
-#line 34 "xml_hash.gperf"
+ {"", 0}, {"", 0}, {"", 0}, {"", 0},
+#line 11 "xml_hash.gperf"
+ {"TAGS", TAGS_TAG},
+ {"", 0}, {"", 0},
+#line 31 "xml_hash.gperf"
+ {"TN", TN_TAG},
+#line 28 "xml_hash.gperf"
+ {"SUM", SUM_TAG,},
+#line 35 "xml_hash.gperf"
{"TYPE", TYPE_TAG},
-#line 35 "xml_hash.gperf"
+#line 36 "xml_hash.gperf"
{"SLOPE", SLOPE_TAG},
-#line 36 "xml_hash.gperf"
+#line 37 "xml_hash.gperf"
{"SOURCE", SOURCE_TAG},
+#line 27 "xml_hash.gperf"
+ {"METRICS", METRICS_TAG},
+#line 29 "xml_hash.gperf"
+ {"NUM", NUM_TAG,},
+#line 10 "xml_hash.gperf"
+ {"NAME", NAME_TAG},
+#line 38 "xml_hash.gperf"
+ {"EXTRA_DATA", EXTRA_DATA_TAG},
+#line 26 "xml_hash.gperf"
+ {"METRIC", METRIC_TAG},
+#line 16 "xml_hash.gperf"
+ {"LATLONG", LATLONG_TAG,},
+#line 39 "xml_hash.gperf"
+ {"EXTRA_ELEMENT", EXTRA_ELEMENT_TAG},
+#line 32 "xml_hash.gperf"
+ {"TMAX", TMAX_TAG},
#line 15 "xml_hash.gperf"
- {"LATLONG", LATLONG_TAG,},
-#line 16 "xml_hash.gperf"
- {"URL", URL_TAG,},
+ {"OWNER", OWNER_TAG,},
+#line 7 "xml_hash.gperf"
+ {"GANGLIA_XML", GANGLIA_XML_TAG},
#line 13 "xml_hash.gperf"
+ {"CLUSTER", CLUSTER_TAG},
+#line 23 "xml_hash.gperf"
+ {"LOCATION", LOCATION_TAG},
+#line 14 "xml_hash.gperf"
{"LOCALTIME", LOCALTIME_TAG},
-#line 29 "xml_hash.gperf"
+#line 30 "xml_hash.gperf"
{"UNITS", UNITS_TAG},
-#line 7 "xml_hash.gperf"
- {"GANGLIA_XML", GANGLIA_XML_TAG},
-#line 30 "xml_hash.gperf"
- {"TN", TN_TAG},
-#line 38 "xml_hash.gperf"
- {"EXTRA_ELEMENT", EXTRA_ELEMENT_TAG},
-#line 10 "xml_hash.gperf"
- {"NAME", NAME_TAG},
-#line 37 "xml_hash.gperf"
- {"EXTRA_DATA", EXTRA_DATA_TAG},
{"", 0},
#line 8 "xml_hash.gperf"
{"VERSION", VERSION_TAG},
-#line 22 "xml_hash.gperf"
- {"LOCATION", LOCATION_TAG},
+#line 34 "xml_hash.gperf"
+ {"VAL", VAL_TAG},
#line 9 "xml_hash.gperf"
{"GRID", GRID_TAG},
-#line 14 "xml_hash.gperf"
- {"OWNER", OWNER_TAG,},
- {"", 0},
-#line 12 "xml_hash.gperf"
- {"CLUSTER", CLUSTER_TAG},
-#line 27 "xml_hash.gperf"
- {"SUM", SUM_TAG,},
-#line 31 "xml_hash.gperf"
- {"TMAX", TMAX_TAG},
- {"", 0},
-#line 25 "xml_hash.gperf"
- {"METRIC", METRIC_TAG},
-#line 26 "xml_hash.gperf"
- {"METRICS", METRICS_TAG},
-#line 24 "xml_hash.gperf"
- {"GMOND_STARTED", STARTED_TAG},
+ {"", 0}, {"", 0},
#line 20 "xml_hash.gperf"
+ {"UP", UP_TAG,},
+#line 17 "xml_hash.gperf"
+ {"URL", URL_TAG,},
+#line 21 "xml_hash.gperf"
{"DOWN", DOWN_TAG,},
{"", 0}, {"", 0},
+#line 22 "xml_hash.gperf"
+ {"IP", IP_TAG},
+#line 25 "xml_hash.gperf"
+ {"GMOND_STARTED", STARTED_TAG},
+#line 18 "xml_hash.gperf"
+ {"HOST", HOST_TAG},
#line 19 "xml_hash.gperf"
- {"UP", UP_TAG,},
-#line 28 "xml_hash.gperf"
- {"NUM", NUM_TAG,},
-#line 17 "xml_hash.gperf"
- {"HOST", HOST_TAG},
-#line 18 "xml_hash.gperf"
{"HOSTS", HOSTS_TAG,},
- {"", 0},
-#line 21 "xml_hash.gperf"
- {"IP", IP_TAG},
-#line 23 "xml_hash.gperf"
+ {"", 0}, {"", 0},
+#line 24 "xml_hash.gperf"
{"REPORTED", REPORTED_TAG},
-#line 32 "xml_hash.gperf"
+#line 33 "xml_hash.gperf"
{"DMAX", DMAX_TAG},
{"", 0}, {"", 0}, {"", 0}, {"", 0},
-#line 11 "xml_hash.gperf"
+#line 12 "xml_hash.gperf"
{"AUTHORITY", AUTHORITY_TAG}
};
Index: monitor-core/gmetad/gmetad.h
===================================================================
--- monitor-core/gmetad/gmetad.h (revision 2618)
+++ monitor-core/gmetad/gmetad.h (working copy)
@@ -69,7 +69,8 @@
SUM_TAG,
NUM_TAG,
EXTRA_DATA_TAG,
- EXTRA_ELEMENT_TAG
+ EXTRA_ELEMENT_TAG,
+ TAGS_TAG
}
xml_tag_t;
Index: monitor-core/gmetad/xml_hash.gperf
===================================================================
--- monitor-core/gmetad/xml_hash.gperf (revision 2618)
+++ monitor-core/gmetad/xml_hash.gperf (working copy)
@@ -8,6 +8,7 @@
VERSION, VERSION_TAG
GRID, GRID_TAG
NAME, NAME_TAG
+TAGS, TAGS_TAG
AUTHORITY, AUTHORITY_TAG
CLUSTER, CLUSTER_TAG
LOCALTIME, LOCALTIME_TAG
Index: monitor-core/lib/libgmond.c
===================================================================
--- monitor-core/lib/libgmond.c (revision 2618)
+++ monitor-core/lib/libgmond.c (working copy)
@@ -68,6 +68,7 @@
CFG_STR("module_dir", NULL, CFGF_NONE),
CFG_STR("override_hostname", NULL, CFGF_NONE),
CFG_STR("override_ip", NULL, CFGF_NONE),
+ CFG_STR("tags", NULL, CFGF_NONE),
CFG_END()
};
Index: monitor-core/gmond/gmond.c
===================================================================
--- monitor-core/gmond/gmond.c (revision 2618)
+++ monitor-core/gmond/gmond.c (working copy)
@@ -84,6 +84,8 @@
char *override_hostname = NULL;
/* This host ip, spoofed */
char *override_ip = NULL;
+/* Tags */
+char *tags = NULL;
/* Boolean. Will this host received gexec requests? */
int gexec_on = 0;
/* This is tweakable by globals{max_udp_msg_len=...} */
@@ -300,6 +302,9 @@
override_hostname = cfg_getstr(tmp, "override_hostname");
override_ip = cfg_getstr(tmp, "override_ip");
+ /* Any tags for this host */
+ tags = cfg_getstr(tmp, "tags");
+
/* Commandline for debug_level trumps configuration file behaviour ... */
if (args_info.debug_given)
{
@@ -1475,9 +1480,10 @@
int tn = (now - hostinfo->last_heard_from) / APR_USEC_PER_SEC;
len = apr_snprintf(hostxml, 1024,
- "<HOST NAME=\"%s\" IP=\"%s\" REPORTED=\"%d\" TN=\"%d\" TMAX=\"%d\" DMAX=\"%d\" LOCATION=\"%s\" GMOND_STARTED=\"%d\">\n",
+ "<HOST NAME=\"%s\" IP=\"%s\" TAGS=\"%s\" REPORTED=\"%d\" TN=\"%d\" TMAX=\"%d\" DMAX=\"%d\" LOCATION=\"%s\" GMOND_STARTED=\"%d\">\n",
hostinfo->hostname,
- hostinfo->ip,
+ hostinfo->ip,
+ tags ? tags : "",
(int)(hostinfo->last_heard_from / APR_USEC_PER_SEC),
tn,
host_tmax,
Index: monitor-core/gmond/dtd.h
===================================================================
--- monitor-core/gmond/dtd.h (revision 2618)
+++ monitor-core/gmond/dtd.h (working copy)
@@ -14,6 +14,7 @@
<!ELEMENT CLUSTER (HOST | HOSTS | METRICS)*>\n\
<!ATTLIST CLUSTER NAME CDATA #REQUIRED>\n\
<!ATTLIST CLUSTER OWNER CDATA #IMPLIED>\n\
+ <!ATTLIST CLUSTER TAGS CDATA #IMPLIED>\n\
<!ATTLIST CLUSTER LATLONG CDATA #IMPLIED>\n\
<!ATTLIST CLUSTER URL CDATA #IMPLIED>\n\
<!ATTLIST CLUSTER LOCALTIME CDATA #REQUIRED>\n\
@freemed
Copy link
Author

freemed commented Jun 30, 2011

This patch has been imported into upstream Subversion as of rev 2619.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment