Beispiel #1
0
        if ($farminfo['clientid'] != 0) {
            define("SCALR_SERVER_TZ", date("T"));
            $env = Scalr_Model::init(Scalr_Model::ENVIRONMENT)->loadById($farminfo['env_id']);
            $tz = $env->getPlatformConfigValue(ENVIRONMENT_SETTINGS::TIMEZONE);
            if ($tz) {
                date_default_timezone_set($tz);
            }
        }
        $graph_info = GetGraphicInfo($graph_type);
        $image_path = APPPATH . "/cache/stats/{$farmid}/{$role_name}.{$watchername}.{$graph_type}.gif";
        $farm_rrddb_dir = CONFIG::$RRD_DB_DIR . "/{$farminfo['id']}";
        $rrddbpath = "{$farm_rrddb_dir}/{$role_name}/{$watchername}/db.rrd";
        CONFIG::$RRD_GRAPH_STORAGE_TYPE = RRD_STORAGE_TYPE::LOCAL_FS;
        if (file_exists($rrddbpath)) {
            try {
                GenerateGraph($farmid, $role_name, $rrddbpath, $watchername, $graph_type, $image_path);
                $url = str_replace(array("%fid%", "%rn%", "%wn%"), array($farmid, $role_name, $watchername), CONFIG::$RRD_STATS_URL);
                $url = "{$url}{$graph_type}.gif";
                $result = array("success" => true, "msg" => $url);
            } catch (Exception $e) {
                $result = array("success" => false, "msg" => $e->getMessage());
            }
        } else {
            $result = array("success" => false, "msg" => _("Statistics not available yet"));
        }
    }
}
print json_encode($result);
function GenerateGraph($farmid, $role_name, $rrddbpath, $watchername, $graph_type)
{
    if (CONFIG::$RRD_GRAPH_STORAGE_TYPE == RRD_STORAGE_TYPE::AMAZON_S3) {
Beispiel #2
0
    exit;
}
if (isset($_GET["main"])) {
    echo mysql_main_switch();
    exit;
}
if (isset($_GET["instance_choose"])) {
    echo collectd_selector_instance();
    exit;
}
if (isset($_GET["type_choose"])) {
    echo collectd_selector_type_data();
    exit;
}
if (isset($_GET["GenerateGraph"])) {
    echo GenerateGraph();
    exit;
}
if (isset($_GET["SaveEnableCollectdDaemon"])) {
    EnableCollectdDaemonSave();
    exit;
}
if ($_GET["script"] == "plugin_choose") {
    echo collectd_selector_plugin();
    exit;
}
if ($_GET["script"] == "type_choose") {
    echo collectd_selector_type();
    exit;
}
if ($_GET["script"] == "buildgraph") {
Beispiel #3
0
function CHECK_DNS_SYSTEMS()
{
    $unix = new unix();
    include_once dirname(__FILE__) . "/ressources/class.influx.inc";
    $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pidFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $BigTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".week.time";
    if (!is_file("/etc/artica-postfix/settings/Daemons/EnableDNSPerfs")) {
        @file_put_contents("/etc/artica-postfix/settings/Daemons/EnableDNSPerfs", 1);
    }
    $EnableDNSPerfs = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableDNSPerfs"));
    if ($EnableDNSPerfs == 0) {
        echo "EnableDNSPerfs -> Disabled\n";
        die;
    }
    $unix = new unix();
    $GLOBALS["MYHOSTNAME"] = $unix->hostname_g();
    $pid = $unix->get_pid_from_file($pidFile);
    if ($unix->process_exists($pid)) {
        if ($unix->PROCCESS_TIME_MIN($pid, 10) < 2) {
            return;
        }
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "pidtime ={$pidtime}\n";
    }
    @file_put_contents($pidFile, getmypid());
    $time = $unix->file_time_min($pidtime);
    if (!$GLOBALS["FORCE"]) {
        if ($time < 5) {
            Events("{$time}mn < 5mn ( use --force to bypass)");
            if ($GLOBALS["VERBOSE"]) {
                echo "{$time}mn < 5mn ( use --force to bypass)\n";
            }
            return;
        }
    }
    @unlink($pidtime);
    @file_put_contents($pidtime, time());
    $BigTimeEx = $unix->file_time_min($BigTime);
    $resolv = new resolv_conf();
    $q = new mysql_squid_builder();
    $sock = new sockets();
    if ($resolv->MainArray["DNS1"] != null) {
        $DNS[] = $resolv->MainArray["DNS1"];
    }
    if ($resolv->MainArray["DNS2"] != null) {
        $DNS[] = $resolv->MainArray["DNS2"];
    }
    if (isset($resolv->MainArray["DNS3"])) {
        if ($resolv->MainArray["DNS3"] != null) {
            $DNS[] = $resolv->MainArray["DNS3"];
        }
    }
    $sql = "SELECT * FROM dns_servers";
    $q = new mysql_squid_builder();
    $results = $q->QUERY_SQL($sql);
    while ($ligne = mysql_fetch_assoc($results)) {
        $DNS[] = $ligne["dnsserver"];
    }
    $type = "A";
    $ipClass = new IP();
    $minperf = $sock->GET_INFO("DNSPerfsPointer");
    if (!is_numeric($minperf)) {
        $minperf = 301450;
    }
    while (list($index, $dnsA) = each($DNS)) {
        $COMP[$dnsA] = true;
    }
    while (list($dnsA, $none) = each($COMP)) {
        Events("Checks DNS {$dnsA}");
        if (!$ipClass->isIPAddress($dnsA)) {
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "{$dnsA}\n";
        }
        $t['start'] = microtime(true);
        $rs = new Net_DNS2_Resolver(array('nameservers' => array($dnsA)));
        $rs->timeout = 20;
        try {
            $date = date("Y-m-d H:i:s");
            $tA = rand("10000", "208460");
            $result = $rs->query("p4-cpsk2owex6nby-dwvedtapjla4ebei-{$tA}-i2-v6exp3-v4.metric.gstatic.com", "A");
            $t[$dnsA] = microtime(true);
            $time = mini_bench_to($t);
            $timeC = $time * 10000;
        } catch (Net_DNS2_Exception $e) {
            $error = $e->getMessage();
            squid_admin_mysql(1, "DNS benchmark failed on {$dnsA} {$error}", $error, __FILE__, __LINE__);
            continue;
        }
        $perc = $minperf / $timeC;
        $perc = round($perc * 100);
        Events("{$dnsA} Response Time:{$time} = {$timeC}/{$minperf} {$perc}%");
        foreach ($result->answer as $record) {
            if ($ipClass->isIPAddress($record->address)) {
                if ($perc > 100) {
                    $perc = 100;
                }
                $zDate = date("Y-m-d H:i:s");
                $q = new postgres_sql();
                $q->QUERY_SQL("INSERT INTO dnsperfs (zDate,PROXYNAME,DNS,PERCENT,RESPONSE)\n\t\t\t\tVALUES ('{$zDate}','{$GLOBALS["MYHOSTNAME"]}','{$dnsA}','{$perc}','{$time}');");
                break;
            }
        }
    }
    GenerateGraph(true);
}
Beispiel #4
0
    echo "</form>\n";
}
// end: if (isset($_GET['getdata']))
// dont continue if no nodeID selected
if (empty($SelectedNodes)) {
    _exit();
}
$SQL0 = "SELECT time,nodeID,place,supplyV,temp,hum,date(time,'unixepoch') AS Date FROM werte WHERE Date='" . $GetDATE . "' AND (";
$SQL1 = "";
foreach ($SelectedNodes as $NID) {
    if (empty($SQL1)) {
        $SQL1 = "nodeID='" . $NID . "'";
    } else {
        $SQL1 .= " OR nodeID='" . $NID . "'";
    }
    GenerateGraph($NID);
    if (!isset($_GET['getdata'])) {
        echo "<img src='" . $GRAPH['DIR'] . "/" . $NID . "." . $GRAPH['SetImgFormat'] . "' /> <br/>\n";
    }
}
$SQL2 = ") ORDER BY time DESC";
echo "<div id='SensorDetails'>\n";
echo "<table class='Sensors' border=1 cellpadding=2 cellspacing=0 bordercolorlight>\n";
echo "<tr>\n";
echo "<th class='tab'>Date</th>\n";
echo "<th class='tab'>Sensor</th>\n";
echo "<th class='tab'>Supply Voltage</th>\n";
echo "<th class='tab'>Temperature</th>\n";
echo "<th class='tab'>Humidity</th>\n";
echo "</tr>\n";
// get Added Entries