On Tue, Aug 26, 2008 at 09:01:43AM -0600, Brad Nicholes wrote:

>   Thanks Rich.  This got me thinking a little about how the same thing
>   might be done only in a more generic way rather than just
>   sequentially numbered metrics.  I am wondering if, rather than
>   looping through numbers, we actually tried to do some pattern
>   matching over the known metrics.  For every known metric that
>   matches a metric pattern found in a collection_group, the metric
>   name is constructed and the metric is added using the
>   add_metric_series() function.  Of course it would also have to do
>   some kind of substitution for the metric title as well.  This could
>   simplify some of the metric configurations.

+1

Another option will be to have each module able to print some usable
configuration. I am attaching some patch from a quick hack that I wrote
for the multidisk plugin to output a usable .conf file. Maybe extending
the mudule api with a metric_autoconf function so you can do a gmond -t
modulename > modulename.conf (or something similar) is a good idea.
It can get you going for simple setups where you just need to collect
all available metrics.

Kostas
--- multidisk.py-orig   2008-07-14 23:28:12.000000000 +0100
+++ multidisk.py        2008-08-28 17:20:00.000000000 +0100
@@ -32,6 +32,7 @@
 
 import statvfs
 import os
+import sys
 
 descriptors = list()
     
@@ -123,9 +124,46 @@
     '''Clean up the metric module.'''
     pass
 
+def metric_autoconf():
+    '''Prints example config.'''
+    print """
+modules {
+  module {
+    name = "multidisk"
+    language = "python"
+  }
+}"""
+    print """
+collection_group {
+  collect_every = 10
+  time_threshold = 50
+"""
+    for d in descriptors:
+        if d['name'].endswith('-disk_used'):
+            print '  metric {'
+            print '    name = %s' % (d['name'])
+            print "    value_threshold = 1.0\n  }"
+    print "}"
+
+    print """
+collection_group {
+  collect_once = yes
+  time_threshold = 20
+"""
+    for d in descriptors:
+        if d['name'].endswith('-disk_total'):
+            print '  metric {'
+            print '    name = "%s"' % (d['name'])
+            print "    value_threshold = \"1.0\"\n  }"
+    print "}"
+
 #This code is for debugging and unit testing    
 if __name__ == '__main__':
     metric_init(None)
+    for o in sys.argv[1:]:
+        if o == "-t":
+          metric_autoconf()
+          sys.exit(0)
     for d in descriptors:
         v = d['call_back'](d['name'])
         print 'value for %s is %f' % (d['name'],  v)
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ganglia-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ganglia-developers

Reply via email to