Ganglia
Architecture and Module Development
Ganglia
monitoring suite consists of three main parts: gmond, gmetad and
ganglia-web.
monitoring suite consists of three main parts: gmond, gmetad and
ganglia-web.
gmond | The ganglia monitoring daemon (gmond) is a lightweight service that is installed on every machine you'd like to monitor. This daemon uses a simple listen/announce protocol via XDR to collect monitoring state and then shares this information via XML over TCP. Gmond is portable and collects dozens of system metrics: CPU, memory, disk, network and process data. |
gmetad | The ganglia meta daemon (gmetad) is a service that collects data from other gmetad and gmond sources and stores their state to disk in indexed round-robin databases. Gmetad provides a simple query mechanism for collecting specific information about groups of machines. Gmetad supports hierarchical delegation for creating manageable monitoring domains. |
gmetric | The ganglia metric tool is a commandline application that you can use to inject custom made metrics about hosts that are being monitored by ganglia. It has the ability to spoof messages as coming from a different host in case you want to capture and report metrics from a device where you don't have gmond running (like a network or other embedded device). |
gstat | The ganglia stat tool is a commandline application that you can use to query a gmond for metric information directly. |
gweb | The ganglia web frontend expresses the data stored by gmetad in a graphical web interface using PHP. |

Fig. Ganglia
Architecture in Cluster Mode
Ganglia-web Extension
All
of the "graph handlers"
are stored in the ../ganglia/graph.d
directory, where "ganglia"
is the top-level directory used by the webserver to publish the
various Ganglia webpages. Ganglia ships with one
general handler for metrics,
five basic reports,
and one heavily commented sample
report.
of the "graph handlers"
are stored in the ../ganglia/graph.d
directory, where "ganglia"
is the top-level directory used by the webserver to publish the
various Ganglia webpages. Ganglia ships with one
general handler for metrics,
five basic reports,
and one heavily commented sample
report.
- The
default layout of ganglia-web and default view of graphs can be
modified according our need. For that we just need to modify some
PHP code. - Uses
presentation templates so that the web site “look
and feel” can be easily customized.
modify ../ganglia/templates/defaults/*.tpl
- Adding Custom Reports
It is possible to add new custom reports, without making any changes to the “Official” Ganglai PHP code. Adding new report is a four step process.
1. All reports should be contained in a single PHP file with the name "reportName_report.php" in the
graph.d/ directory. Obviously, replace "reportName" with something suitable.
2. The *_report function should return an associative array that contains a number of specifically named
variables example:$series,$title,$vertical_label etc.
3. Within this file, you must have a PHP function called "reportName_report" that takes a single array argument that is passed by reference (not by value!). The function definition for this will look something like this: function temperature_report ( &$rrdtool_graph ) { $rrdtool_graph['vertical_label'] = 'Temperature (C)'; $rrdtool_graph['title'] = 'CPU Temeratures'; $rrdtool_graph['series'] = "... very long set of RRD tool RPN commands..."; }
4. Edit the $optional_graphs variable in the conf.php file to include the base name of your new report.
Thus, if the function name is reportName_report, and the PHP file is "reportName_report.php", include
only "reportName" in the $optional_graphs array.
$optional_graphs = array('packets', 'reportName');
Sample report to view cpu user
<?php
<?php
function graph_demo_report ( &$rrdtool_graph ) {
global $cpu_user_color,
$rrd_dir;
$rrdtool_graph['title'] ='==Demo Report==';
$rrdtool_graph['vertical-label'] = '==Demo Report==';
$series ="DEF:'cpu_user'='${rrd_dir}/cpu_user.rrd':'sum':AVERAGE "
. "AREA:'cpu_user'#$cpu_user_color:'==CPU User==' ";
$rrdtool_graph['series'] = $series;
return $rrdtool_graph;
}
?>
Gmond Matrix Gathering Agent Extension
- Gmetric – Out-of-process utility capable of invoking command line based metric gathering scripts
- Loadable modules capable of gathering multiple metrics or using advanced metric gathering APIs
Gmond Pluggable Metric Modules Development
- Using C
- Using Python
Using Python
- Extends the available metrics that can be gathered by Gmond
- Provided as dynamically loadable modules
- Configured through the gmond.conf
- Scheduled through Gmond rather than an external scheduler
- Module development is similar to an Apache module
- Able to produce multiple metrics from a single module
Each module must contain three mandatory functions
metric_init()
- Called once at module initialization time
- Must return a metric description dictionary or list of dictionaries
- Any other module initialization can also take place here
metric_handler() –
- may have multiple handlers
- Metric gathering handler
- Must return a single data value of the same type as specified in the metric_init() function
metric_cleanup()
- Called once at module termination time
- Does
not return a valueExample
Module:
Curve_Max = 15
v = int(1)
inc = int(1)
count = 0
def metric_init(params):
global Curve_Max
if ‘CurveMax’ in params:
Curve_Max = int(params[‘CurveMax’])
d = {‘name’: ‘Curve_Metric’,
‘call_back’: curve_handler,
‘time_max': int(60),
‘value_type’: ‘uint’,
‘units’: ‘Seconds’,
‘slope’: ‘both’,
‘format’: ‘%u’,
‘description’:
‘Shows a uniform curve’}
return d
def curve_handler(name):
global v,count,inc,Curve_Max
v += inc
count += 1
if count > Curve_Max:
count = 0
inc = -inc
return int(v)
def metric_cleanup():
pass
Gmond Python Module Deployment
- Copy the .py file to python directory specified in gmond.conf file put in gmond.conf
modules {
module {
name = "python_module"
path = "/usr/lib/ganglia/modpython.so"
params = "/usr/lib/ganglia/python_modules"
}
}
- Define the metric to collection group for this module
- Restart gmond
1 comments:
This information which you provided is very much useful for us.It was very interesting and useful for Hadoop training Persons.We also providing ccna ccnp online training institute in worldwide.