Adding an Application#

The applications system is quite simple, and just involves including files based on entries in the database.

  • Applications are 'polled' by scripts in includes/polling/applications/<app_type>.inc.php
  • RRD formats are defiend in includes/definitions/rrdtypes.inc.php
  • Applications are 'displayed' by scripts in html/pages/device/apps/<app_type>.inc.php
  • Graph types can be created in html/includes/graphs/application/<app_type>_<graph_type>.inc.php
  • The application name corresponds to the app_type field in the applications database table
  • Add the correct graph_type in includes/definitions/apps.inc.php in order to see the correct graphs in application overview

Examples#

  • Unix agent is contacted, header is <<<app-apache>>>
<<<app-apache>>>
19427252
636202073088
.000530668
4224866
4.59831
150585
32747.9
U
U
4
0
1
1
7
0
0
0
0
0
137
  • Its results are passed to includes/polling/applications/apache.inc.php
if (!empty($agent_data['app']['apache']))
{
  $app_id = discover_app($device, 'apache');

  list ($total_access, $total_kbyte, $cpuload, $uptime, $reqpersec, $bytespersec, $bytesperreq, $busyworkers, $idleworkers,
        $score_wait, $score_start, $score_reading, $score_writing, $score_keepalive, $score_dns, $score_closing, $score_logging,
        $score_graceful, $score_idle, $score_open) = explode("\n", $agent_data['app']['apache']);

  update_application($app_id, array(
    'access'       => $total_access,
    'kbyte'        => $total_kbyte,
    'cpu'          => $cpuload,
    'uptime'       => $uptime,
    'reqpersec'    => $reqpersec,
    'bytespersec'  => $bytespersec,
    'byesperreq'   => $bytesperreq,
    'busyworkers'  => $busyworkers,
    'idleworkers'  => $idleworkers,
    'sb_wait'      => $score_wait,
    'sb_start'     => $score_start,
    'sb_reading'   => $score_reading,
    'sb_writing'   => $score_writing,
    'sb_keepalive' => $score_keepalive,
    'sb_dns'       => $score_dns,
    'sb_closing'   => $score_closing,
    'sb_logging'   => $score_logging,
    'sb_graceful'  => $score_graceful,
    'sb_idle'      => $score_idle,
    'sb_open'      => $score_open,
  ));

  rrdtool_update_ng($device, 'apache', array(
    'access'       => $total_access,
    'kbyte'        => $total_kbyte,
    'cpu'          => $cpuload,
    'uptime'       => $uptime,
    'reqpersec'    => $reqpersec,
    'bytespersec'  => $bytespersec,
    'byesperreq'   => $bytesperreq,
    'busyworkers'  => $busyworkers,
    'idleworkers'  => $idleworkers,
    'sb_wait'      => $score_wait,
    'sb_start'     => $score_start,
    'sb_reading'   => $score_reading,
    'sb_writing'   => $score_writing,
    'sb_keepalive' => $score_keepalive,
    'sb_dns'       => $score_dns,
    'sb_closing'   => $score_closing,
    'sb_logging'   => $score_logging,
    'sb_graceful'  => $score_graceful,
    'sb_idle'      => $score_idle,
    'sb_open'      => $score_open,
  ), $app_id);
}
  • This populates an rrd file with data received via the UNIX agent as defined in includes/definitions/rrdtypes.inc.php
$config['rrd_types']['apache'] = array(
  'file'  => 'app-apache-%index%.rrd',
  'ds'    => array(
    'access'       => array('type' => 'DERIVE', 'min' => 0, 'max' => 125000000000),
    'kbyte'        => array('type' => 'DERIVE', 'min' => 0, 'max' => 125000000000),
    'cpu'          => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
    'uptime'       => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
    'reqpersec'    => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
    'bytespersec'  => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
    'byesperreq'   => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
    'busyworkers'  => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
    'idleworkers'  => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
    'sb_wait'      => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
    'sb_start'     => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
    'sb_reading'   => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
    'sb_writing'   => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
    'sb_keepalive' => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
    'sb_dns'       => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
    'sb_closing'   => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
    'sb_logging'   => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
    'sb_graceful'  => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
    'sb_idle'      => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
    'sb_open'      => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
  ),
);
  • The graph types have been defined as html/includes/graphs/application/apache_*.inc.php

html/includes/graphs/application/apache_bits.inc.php

$scale_min = 0;

include_once($config['html_dir']."/includes/graphs/common.inc.php");

$apache_rrd = get_rrd_path($device, "app-apache-".$app['app_id'].".rrd");

if (is_file($apache_rrd))
{
  $rrd_filename = $apache_rrd;
}

$ds = "kbyte";

$colour_area = "CDEB8B";
$colour_line = "006600";

$colour_area_max = "FFEE99";

$graph_max = 1;
$multiplier = 8;

$unit_text = "Kbps";

include($config['html_dir']."/includes/graphs/generic_simplex.inc.php");
  • Overview graphs are defined by an array in includes/definitions/apps.inc.php
$config['app']['apache']['top']            = array('bits', 'hits', 'scoreboard', 'cpu');
  • The graphs are loaded with a bit of descriptive text by html/pages/device/apps/apache.inc.php
$app_graphs['default'] = array('apache_bits' => 'Traffic',
                'apache_hits' => 'Hits',
                'apache_cpu'  => 'CPU Utilisation',
                'apache_scoreboard' => 'Scoreboard Statistics');