function graphs_from_plugin($host, $plugin)
{
    global $CONFIG;
    $plugindata = collectd_plugindata($host, $plugin);
    $plugindata = group_plugindata($plugindata);
    foreach ($plugindata as $items) {
        $items['h'] = $host;
        $time = array_key_exists($plugin, $CONFIG['time_range']) ? $CONFIG['time_range'][$plugin] : $CONFIG['time_range']['default'];
        printf('<a href="%s%s"><img src="%s%s"></a>' . "\n", $CONFIG['weburl'], build_url('detail', $items, $time), $CONFIG['weburl'], build_url('graph', $items, $time));
    }
}
Beispiel #2
0
function graphs_from_plugin($host, $plugin, $overview = false)
{
    global $CONFIG;
    if (!($plugindata = collectd_plugindata($host, $plugin))) {
        return false;
    }
    if (!($plugindata = group_plugindata($plugindata))) {
        return false;
    }
    if (!($plugindata = plugin_sort($plugindata))) {
        return false;
    }
    foreach ($plugindata as $items) {
        if ($overview && isset($CONFIG['overview_filter'][$plugin]) && $CONFIG['overview_filter'][$plugin] !== array_intersect_assoc($CONFIG['overview_filter'][$plugin], $items)) {
            continue;
        }
        $items['h'] = $host;
        $time = array_key_exists($plugin, $CONFIG['time_range']) ? $CONFIG['time_range'][$plugin] : $CONFIG['time_range']['default'];
        if ($CONFIG['graph_type'] == 'canvas') {
            chdir($CONFIG['webdir']);
            isset($items['p']) ? $_GET['p'] = $items['p'] : ($_GET['p'] = '');
            isset($items['pi']) ? $_GET['pi'] = $items['pi'] : ($_GET['pi'] = '');
            isset($items['t']) ? $_GET['t'] = $items['t'] : ($_GET['t'] = '');
            isset($items['ti']) ? $_GET['ti'] = $items['ti'] : ($_GET['ti'] = '');
            $_GET['s'] = $time;
            include $CONFIG['webdir'] . '/graph.php';
        } else {
            printf('<a href="%1$s%2$s"><img src="%1$s%3$s"></a>' . "\n", htmlentities($CONFIG['weburl']), htmlentities(build_url('detail.php', $items, $time)), htmlentities(build_url('graph.php', $items, $time)));
        }
    }
}
function collectd_plugindetail($host, $plugin, $detail, $where = NULL)
{
    $details = array('pi', 'c', 't', 'ti');
    if (!in_array($detail, $details)) {
        return false;
    }
    if (!($plugindata = collectd_plugindata($host))) {
        return false;
    }
    $return = array();
    foreach ($plugindata as $item) {
        if ($item['p'] == $plugin && !in_array($item[$detail], $return) && isset($item[$detail])) {
            if ($where) {
                $add = true;
                # add detail to returnvalue if all where is true
                foreach ($where as $key => $value) {
                    if ($item[$key] != $value) {
                        $add = false;
                    }
                }
                if ($add) {
                    $return[] = $item[$detail];
                }
            } else {
                $return[] = $item[$detail];
            }
        }
    }
    return $return ? $return : false;
}