Example #1
0
function graph_incident_sla_compliance($id_incident, $width = 200, $height = 200, $ttl = 1)
{
    global $config;
    if (!(require_once "include/functions_incidents.php")) {
        require_once "functions_incidents.php";
    }
    $seconds = incidents_get_incident_sla_graph_seconds($id_incident);
    $total = $seconds["OK"] + $seconds["FAIL"];
    if ($total == 0) {
        $percent_fail = 0;
        $percent_ok = 100;
    } else {
        $percent_fail = $seconds["FAIL"] / $total * 100;
        $percent_ok = $seconds["OK"] / $total * 100;
    }
    $data = array();
    if ($config["flash_charts"]) {
        $data["FAIL"] = $percent_fail;
        $data["OK"] = $percent_ok;
    } else {
        $data["OK"] = $percent_ok;
        $data["FAIL"] = $percent_fail;
    }
    if (isset($data)) {
        return pie3d_graph($config['flash_charts'], $data, $width, $height, "", "", "", $config['font'], $config['fontsize'], $ttl);
    } else {
        graphic_error();
    }
}
function incidents_get_sla_graph_percentages($incidents)
{
    $slas = array();
    foreach ($incidents as $incident) {
        if ($incident['sla_disabled'] != 1) {
            $seconds = incidents_get_incident_sla_graph_seconds($incident["id_incidencia"]);
            $seconds_ok = $seconds["OK"];
            $seconds_fail = $seconds["FAIL"];
            $seconds_total = $seconds_ok + $seconds_fail;
            $slas[$incident['id_incidencia']] = $seconds_ok / $seconds_total * 100;
        }
    }
    return $slas;
}