function get_xfer_metrics($system, $dates, $date_step) { $metrics = array("tx_bytes", "rx_bytes", "vnc-tx_bytes", "vnc-rx_bytes"); $conn = cassandra_connect(KS_METRICS); $agg = new ColumnFamily($conn, CF_AGG); $keys = array(); $totals = array(); foreach($metrics as $metric) { $keys[] = "$system-$metric-$date_step"; $totals[$metric] = array(); } $result = $agg->multiget($keys, $dates); foreach($metrics as $metric) { $xfer = $result["$system-$metric-$date_step"]; foreach($dates as $date) { $v = array_key_exists($date, $xfer) ? $xfer[$date] : ""; $totals[$metric][$date] = $v; } } return $totals; }
} function get_current($period) { return date(get_date_format($period)); } $date_start = strtotime($_GET["date_start"]); $date_stop = strtotime($_GET["date_stop"]); $date_step = $_GET["date_step"]; $metric = $_GET["metric"]; $dates = get_date_span($date_start, $date_stop, $date_step); $dates = array_reverse($dates); $current = get_current($date_step); try { $sys = new ColumnFamily(cassandra_connect("fo"), "systems"); $agg = new ColumnFamily(cassandra_connect("metrics"), "agg"); $sys->read_consistency_level = cassandra_ConsistencyLevel::ONE; $agg->read_consistency_level = cassandra_ConsistencyLevel::ONE; if($_GET["load"] == "all") { $systems = array(); $r = $sys->get_range("", "", $row_count=200, $columns=array("status")); foreach($r as $system => $info) $systems[] = $system; } else { $systems = explode(",", $_GET["load"]); } $keys = array(); $totals = array(); foreach($systems as $system) { $totals[$system] = array(); $keys["$system-$metric-$date_step"] = $system; }
$system = $passwd = null; if(isset($_SESSION[$k_system]) && isset($_SESSION[$k_passwd])) { $system = $_SESSION[$k_system]; $passwd = $_SESSION[$k_passwd]; } if(isset($_POST[$k_system]) && isset($_POST[$k_passwd])) { $system = strtolower(trim($_POST[$k_system])); $passwd = trim($_POST[$k_passwd]); } if($system != null && $passwd != null) { require_once("/home/frozen/phpcassa.php"); $error = "Login failed. User does not exist or incorrect password."; try { $conn = cassandra_connect(KS_FO); $sys = new ColumnFamily($conn, CF_SYSTEMS); $system_info = $r = $sys->get($system); if($r["status"] == "assigned" && $r["subscription"] != "" && hash("sha256", ".:$system.$passwd:.") == $r["slogin_www"]) { $_SESSION[$k_system] = $system; $_SESSION[$k_passwd] = $passwd; unset($error); $logged_in = true; $sub = new ColumnFamily($conn, CF_SUBSCRIPTIONS); $sub_info = $sub->get($system_info["subscription"]); } } catch (Exception $e) { } } if($logged_in) {