Esempio n. 1
0
if (!mysql_select_db('gts')) {
    die("Cannot select GTS db");
}
// Query Broadband Devices from GTS Database
$res = mysql_query("SELECT deviceID,ipAddressCurrent FROM Device WHERE isActive=1 AND deviceID like 'BBW%';");
if (!$res) {
    die("Error cannot select devices");
}
// Build Device Status Insert Array
$index = 0;
// Update timestamp on broadband locations to stop it falling off the end during cleanup
$insertquery[$index] = "UPDATE EventData SET timestamp=" . time() . " WHERE statusCode=61472 and deviceID like 'BBW%';";
$index++;
// Loop though devices getting status information and building inserts
while ($ar = mysql_fetch_array($res, MYSQL_BOTH)) {
    list($curstat, $latency, $pl) = statusping($ar['ipAddressCurrent']);
    $pubip = mtPublicIP($ar['ipAddressCurrent']);
    $avail24h = Avail($ar['deviceID'], 144);
    $avail7d = Avail($ar['deviceID'], 1008);
    $avail30d = Avail($ar['deviceID'], 4320);
    $insertquery[$index] = "REPLACE INTO EventData SET accountID='gtg',deviceID='" . $ar['deviceID'] . "',timestamp=" . time() . ",statusCode=" . $curstat . ",rawData='Latency:" . $latency . " Packet Loss:" . $pl . "% Public IP:" . $pubip . "';";
    $index++;
    $insertquery[$index] = "UPDATE Device SET lastInputState=" . $curstat . ",lastRtt=" . $latency . ",notes='<br>24 Hour Availability: " . $avail24h . "%<br>7 Day Availability: " . $avail7d . "%<br>30 Day Availability: " . $avail30d . "%<br>Packet Loss: " . $pl . "%<br>Current Public IP: " . $pubip . "<br>' WHERE deviceID='" . $ar['deviceID'] . "';";
    $index++;
}
// Perform Status and Location inserts
foreach ($insertquery as $querytext) {
    $res = mysql_query($querytext);
}
// Free GTS database connection
mysql_close($link);
Esempio n. 2
0
$index++;
// Loop though devices getting status information and building inserts
while ($ar = mysql_fetch_array($res, MYSQL_BOTH)) {
    list($curstat, $latency, $pl, $pubip) = mtStatusPing($ar['ipAddressCurrent']);
    if ($pl != 100) {
        list($uptime, $rawuptime) = mtUptime($ar['ipAddressCurrent']);
    }
    if ($ar['ipAddressCurrent'] == '0.0.0.0') {
        $curstat = 39999;
    }
    $date24h = date("Y-m-d H:i:s", time() - 24 * 60 * 60);
    $date7d = date("Y-m-d H:i:s", time() - 7 * 24 * 60 * 60);
    $date30d = date("Y-m-d H:i:s", time() - 30 * 24 * 60 * 60);
    $avail24h = Avail($ar['ipAddressCurrent'], $date24h);
    $avail7d = Avail($ar['ipAddressCurrent'], $date7d);
    $avail30d = Avail($ar['ipAddressCurrent'], $date30d);
    $latency24h = Latency($ar['ipAddressCurrent'], $date24h);
    $latency7d = Latency($ar['ipAddressCurrent'], $date7d);
    $latency30d = Latency($ar['ipAddressCurrent'], $date30d);
    $insertquery[$index] = "REPLACE INTO EventData SET accountID='gtg',deviceID='" . $ar['deviceID'] . "',timestamp=" . time() . ",statusCode=" . $curstat . ",rawData='Latency:" . $latency . " Packet Loss:" . $pl . "% Public IP:" . $pubip . " Uptime:" . $uptime . "';";
    $index++;
    $insertquery[$index] = "UPDATE Device SET lastInputState=" . $curstat . ",lastRtt=" . $latency . ",notes='<br>24 Hour Availability: " . $avail24h . "%<br>7 Day Availability: " . $avail7d . "%<br>30 Day Availability: " . $avail30d . "%<br>Packet Loss: " . $pl . "%<br>24 Hour Latency: " . $latency24h . " ms<br>7 Day Latency: " . $latency7d . " ms<br>30 Day Latency: " . $latency30d . " ms<br>Current Public IP: " . $pubip . "<br>Uptime: " . $rawuptime . "s<br>' WHERE deviceID='" . $ar['deviceID'] . "';";
    $index++;
}
// Perform Status and Location inserts
foreach ($insertquery as $querytext) {
    // Added for debug
    //echo "SQL:".$querytext."\n";
    $res = mysql_query($querytext);
}
// Free GTS database connection