Ejemplo n.º 1
0
if ($_SERVER['SCRIPT_NAME'] != '/ossim/av_center/data/sections/main/real_time.php') {
    exit;
}
$system_id = POST('system_id');
ossim_valid($system_id, OSS_DIGIT, OSS_LETTER, '-', 'illegal:' . _('System ID'));
if (ossim_error()) {
    $data['status'] = 'error';
    $data['data'] = array('status' => NULL, 'ha_status' => NULL, 'can_be_removed' => TRUE, 'mem_used' => '0.00', 'swap_used' => '0.00', 'cpu_load' => '0.00', 'update' => array('is_updated' => NULL, 'release_type' => NULL, 'release_version' => NULL));
    echo json_encode($data);
    exit;
}
try {
    $data['status'] = 'success';
    $s_data = Av_center::get_system_status($system_id, 'general', TRUE);
    //Check if there are packages to install
    $is_updated = Av_center::is_system_updated($system_id);
    $release_type = NULL;
    $release_version = NULL;
    if ($is_updated == FALSE) {
        $release_info = Av_center::get_release_info($system_id);
        $release_type = $release_info['type'];
        $release_version = $release_info['version'];
    }
    $local_id = strtolower(Util::get_system_uuid());
    $can_be_removed = $system_id != $local_id && $s_data['ha_status'] == NULL ? TRUE : FALSE;
    $data['data'] = array('status' => 'up', 'ha_status' => $s_data['ha_status'], 'can_be_removed' => $can_be_removed, 'mem_used' => $s_data['memory']['ram']['percent_used'], 'swap_used' => $s_data['memory']['swap']['percent_used'], 'cpu_load' => $s_data['cpu']['load_average'], 'update' => array('is_updated' => $is_updated, 'release_type' => $release_type, 'release_version' => $release_version));
} catch (Exception $e) {
    $data['status'] = 'error';
    $data['data'] = array('status' => 'down', 'ha_status' => NULL, 'can_be_removed' => TRUE, 'mem_used' => '0.00', 'swap_used' => '0.00', 'cpu_load' => '0.00', 'update' => array('is_updated' => NULL, 'release_type' => NULL, 'release_version' => NULL));
}
echo json_encode($data);