Ejemplo n.º 1
0
function update_all_vps_status()
{
    global $db;
    $vps_list = get_vps_array(false, SERVER_ID);
    if (is_array($vps_list)) {
        foreach ($vps_list as $vps) {
            if ($vps->exists) {
                if (DEMO_MODE) {
                    $out["ve_id"] = $vps->veid;
                    $out["ve_nproc"] = '42';
                    $out["ve_status"] = 'running';
                    $out["ve_hostname"] = $vps->ve["ve_hostname"];
                    $memusage = '1234';
                    $diskusage = '1234';
                } else {
                    $vzlist = NULL;
                    exec(BIN_VZLIST . ' ' . $vps->veid . ' | tr -s " "', $vzlist);
                    $tds = explode(' ', trim($vzlist[1]));
                    $out["ve_id"] = $tds[0];
                    $out["ve_nproc"] = $tds[1];
                    $out["ve_status"] = $tds[2];
                    $out["ve_hostname"] = $tds[4];
                    $memusage = get_mem_usage($vps->veid);
                    $diskusage = get_disk_usage($vps->veid);
                }
            }
            (int) ($up = (int) ($out["ve_status"] == 'running'));
            $sql = 'INSERT INTO vps_status
			SET vps_id = "' . $db->check($vps->veid) . '",
			    timestamp = "' . time() . '",
			    vps_up = "' . $up . '",
			    vps_nproc = "' . $db->check($out["ve_nproc"]) . '",
			    vps_vm_used_mb = "' . $memusage['used'] . '",
			    vps_disk_used_mb = "' . $db->check($diskusage) . '",
			    vps_admin_ver ="' . VERSION . '"';
            $db->query($sql);
        }
    }
}
Ejemplo n.º 2
0
        }
    } elseif ($table === "jobs") {
        $jobids = get_user_jobs($user);
        if (count($jobids) > 0) {
            foreach ($jobids as $jobid) {
                $jobinfo = get_temp_job_info($user, $jobid);
                $status = JobStatus::$RUNNING;
                if ($jobinfo === false) {
                    // if $jobinfo is false, the nc_jobinfo.json file does not exist, because the results dir was deleted from the files section
                    $status = JobStatus::$UNKNOWN;
                } elseif (is_array($jobinfo) && isset($jobinfo['status'])) {
                    $status = $jobinfo['status'];
                } else {
                    $status = get_job_status($jobinfo);
                }
                $usage = get_disk_usage($user, $jobid);
                ?>
            <tr>
                <td><?php 
                echo $user;
                ?>
</td> 
                <td><?php 
                echo $jobid;
                ?>
</td>
                <td><?php 
                echo $status;
                ?>
</td>
                <td><?php