You are here

function monitoring_munin_config in Monitoring 7

Returns the munin graphs definitions.

Return value

array Munin graphs definitions.

2 calls to monitoring_munin_config()
monitoring_munin_drush_callback in modules/monitoring_munin/monitoring_munin.drush.inc
Command callback for munin integration.
_monitoring_munin_result in modules/monitoring_munin/monitoring_munin.module
Returns the monitoring result.

File

modules/monitoring_munin/monitoring_munin.module, line 203
Monitoring Munin module bootstrap file.

Code

function monitoring_munin_config() {
  $host = monitoring_host();
  $config = array();

  // Collect all multigraphs and create their definitions.
  foreach (monitoring_munin_multigraphs() as $multigraph) {
    $config[monitoring_munin_multigraph_identifier($multigraph['title'])] = array(
      'graph_title' => $multigraph['title'],
      'graph_vlabel' => $multigraph['vlabel'],
      'graph_category' => $host,
    );
  }
  foreach (monitoring_sensor_manager()
    ->getEnabledSensorInfo() as $sensor_name => $info) {
    $munin_settings = $info
      ->getSetting('munin');

    // Skip in case sensor is disabled by munin.
    if (empty($munin_settings['munin_enabled'])) {
      continue;
    }
    $graph = array();
    $munin_sensor_name = monitoring_munin_sensor_identifier($sensor_name);

    // If a sensor belongs to one or more multigraphs add its definition to all
    // of the multigraphs.
    if (!empty($munin_settings['multigraphs'])) {
      foreach ($munin_settings['multigraphs'] as $multigraph) {
        $multigraph = monitoring_munin_multigraph_identifier($multigraph);
        $config[$multigraph][$munin_sensor_name . '.label'] = $info
          ->getLabel();
      }
    }
    else {
      $graph['graph_title'] = $info
        ->getDescription();
      $graph['graph_vlabel'] = $info
        ->getValueLabel() ? $info
        ->getValueLabel() : $info
        ->getLabel();
      $graph['graph_category'] = $host;
      $graph[$munin_sensor_name . '.label'] = $info
        ->getLabel();

      // @todo - deal with other threshold types.
      if ($info
        ->getThresholdsType() == 'exceeds') {
        foreach (array(
          'warning',
          'critical',
        ) as $key) {
          $graph[$munin_sensor_name . '.' . $key] = $info
            ->getThresholdValue($key);
        }
      }
      $config[$munin_sensor_name] = $graph;
    }
  }
  return $config;
}