Commit 35cb50d1 authored by Clemens John's avatar Clemens John

Add multiinsert for router offline data

Signed-off-by: Clemens John's avatarClemens John <clemens.john@floh1111.de>
parent a0e1a8fc
......@@ -39,11 +39,39 @@
echo $e->getMessage();
echo $e->getTraceAsString();
}
//Use custom multiinsert statement instead of RouterStatus class
echo " Prepare insertion of offline data for router\n";
$placeholders = array();
$values = array();
foreach($result as $router) {
echo " Inserting offline data for router ".$router['hostname']."\n";
//store offline crawl for offline router
$router_status = New RouterStatus(false, (int)$actual_crawl_cycle['id'], (int)$router['id'], "offline");
$router_status->store();
$placeholders[] = "(?, ?, NOW(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
array_push($values, (int)$router['id'], (int)$actual_crawl_cycle['id'], "offline",
"", "", "", "",
"", 0, 0, 0,
0, "", "", "", "",
"", "", "",
"", "",
"", "",
"", "",
"", 0);
}
echo " Insert offline Data for interfaces in one big statement\n";
try {
$stmt = DB::getInstance()->prepare("INSERT INTO crawl_routers (router_id, crawl_cycle_id, crawl_date, status,
hostname, distname, distversion, chipset,
cpu, memory_total, memory_caching, memory_buffering,
memory_free, loadavg, processes, uptime, idletime,
local_time, batman_advanced_version, fastd_version,
kernel_version, configurator_version,
nodewatcher_version, firmware_version,
firmware_revision, openwrt_core_revision,
openwrt_feeds_packages_revision, client_count)
VALUES ".implode(", ", $placeholders));
$stmt->execute($values);
} catch(PDOException $e) {
echo $e->getMessage();
echo $e->getTraceAsString();
}
echo "Create crawl data for offline interfaces\n";
......@@ -60,11 +88,12 @@
echo $e->getMessage();
echo $e->getTraceAsString();
}
//Use custom multiinsert statement instead of InterfaceStatus class
echo " Prepare insertion of offline data for interfaces\n";
$placeholders = array();
$values = array();
foreach($result as $interface) {
echo " Prepare insertion of offline data for interface ".$interface['name']."\n";
$placeholders[] = "(?, ?, ?, NOW(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
array_push($values, (int)$interface['router_id'], (int)$actual_crawl_cycle['id'], (int)$interface['id'], "", "", 0, 0, 0, 0, "", "", "", "", 0, 0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment