示例#1
0
function meta_graph_tcp_connections($host, $plugin, $plugin_instance, $type, $type_instances, $opts = array())
{
    global $config;
    $sources = array();
    $title = "{$host}/{$plugin}" . (!is_null($plugin_instance) ? "-{$plugin_instance}" : '') . "/{$type}";
    if (!isset($opts['title'])) {
        $opts['title'] = $title;
    }
    $opts['number_format'] = '%5.1lf%s';
    #$opts['rrd_opts']      = array('-v', 'Connections');
    $opts['rrd_opts'] = array('COMMENT:Connections      Cur     Avg      Min     Max\\l');
    $opts['colors'] = array('ESTABLISHED' => '00e000', 'SYN_SENT' => '00e0ff', 'SYN_RECV' => '00e0a0', 'FIN_WAIT1' => 'f000f0', 'FIN_WAIT2' => 'f000a0', 'TIME_WAIT' => 'ffb000', 'CLOSE' => '0000f0', 'CLOSE_WAIT' => '0000a0', 'LAST_ACK' => '000080', 'LISTEN' => 'ff0000', 'CLOSING' => '000000');
    $type_instances = array('ESTABLISHED', 'SYN_SENT', 'SYN_RECV', 'FIN_WAIT1', 'FIN_WAIT2', 'TIME_WAIT', 'CLOSE', 'CLOSE_WAIT', 'LAST_ACK', 'CLOSING', 'LISTEN');
    while (list($k, $inst) = each($type_instances)) {
        $file = '';
        foreach ($config['datadirs'] as $datadir) {
            if (is_file($datadir . '/' . $title . '-' . $inst . '.rrd')) {
                $file = $datadir . '/' . $title . '-' . $inst . '.rrd';
                break;
            }
        }
        if ($file == '') {
            continue;
        }
        $sources[] = array('name' => $inst, 'file' => $file, 'ds' => 'value');
    }
    return collectd_draw_meta_stack($opts, $sources);
}
示例#2
0
function meta_graph_dns_event($host, $plugin, $plugin_instance, $type, $type_instances, $opts = array())
{
    global $config;
    $sources = array();
    $title = "{$host}/{$plugin}" . (!is_null($plugin_instance) ? "-{$plugin_instance}" : '') . "/{$type}";
    if (!isset($opts['title'])) {
        $opts['title'] = $title;
    }
    $opts['rrd_opts'] = array('-v', 'Events', '-r', '-l', '0');
    $files = array();
    //	$opts['colors'] = array(
    //	);
    //	$type_instances = array('IQUERY', 'NOTIFY');
    while (list($k, $inst) = each($type_instances)) {
        $file = '';
        $title = $opts['title'];
        foreach ($config['datadirs'] as $datadir) {
            if (is_file($datadir . '/' . $title . '-' . $inst . '.rrd')) {
                $file = $datadir . '/' . $title . '-' . $inst . '.rrd';
                break;
            }
        }
        if ($file == '') {
            continue;
        }
        $sources[] = array('name' => $inst, 'file' => $file);
    }
    return collectd_draw_meta_stack($opts, $sources);
}