forked from HPCNow/PHPQstat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qstat_job.php
140 lines (114 loc) · 4.1 KB
/
qstat_job.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<html>
<head>
<title>PHPQstat</title>
<meta name="AUTHOR" content="Jordi Blasco Pallares ">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="KEYWORDS" content="gridengine sge sun hpc supercomputing batch queue linux xml qstat qhost jordi blasco solnu">
<link rel="stylesheet" href="phpqstat.css" type="text/css" />
</head>
<?php
require('time_duration.php');
$owner = isset($_GET['owner']) ? $_GET['owner'] : null;
$jobid = isset($_GET['jobid']) ? $_GET['jobid'] : null;
$jobstat = isset($_GET['jobstat']) ? $_GET['jobstat'] : null;
echo "<body><table align=center width=95% border=\"1\" cellpadding=\"0\" cellspacing=\"0\"><tbody>";
include("header.php");
echo "<tr><td><h1>PHPQstat</h1></td></tr>
<tr><td CLASS=\"header\" align=center>
<a href=\"qstat.php?owner=$owner\">Queue status</a> •
<a href=\"qhost.php?owner=$owner\">Hosts status</a> •
<a href=\"qstat_user.php?owner=$owner\">Jobs status ($owner)</a> •
<a href=\"about.php?owner=$owner\">About PHPQstat</a>
</td></tr>";
?>
<td>
<br>
<?php
$password_length = 20;
function make_seed() {
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
srand(make_seed());
$token = uniqid('phpqstat_');
$tokenfile = "/tmp/$token.xml";
if($jobstat){$jobstatflag="-s $jobstat";}else{$jobstatflag="";}
$out = exec("./gexml -j $jobid $jobstatflag -u all -o $tokenfile");
$qstat = simplexml_load_file($tokenfile);
//foreach ($qstat->xpath('detailed_job_info->djob_info->element') as $element) {
//foreach ($qstat->element[0] as $element) {
$job_name=$qstat->djob_info->element[0]->JB_job_name;
$job_owner=$qstat->djob_info->element[0]->JB_owner;
$job_group=$qstat->djob_info->element[0]->JB_group;
$job_project=$qstat->djob_info->element[0]->JB_project;
$job_ust=$qstat->djob_info->element[0]->JB_submission_time;
$job_st=date('r', date($job_ust * 1 ) );
$job_qn=$qstat->djob_info->element[0]->JB_ja_tasks->ulong_sublist->JAT_grandted_destin_identifier_list->JG_qname;
$job_pe=$qstat->djob_info->element[0]->JB_pe;
$job_slots=$qstat->djob_info->element[0]->JB_pe_range->ranges->RN_min;
echo " <table align=center width=95% border=\"1\" cellpadding=\"0\" cellspacing=\"0\">
<tbody>
<tr CLASS=\"header\">
<td>JobID</td>
<td>Name</td>
<td>Owner</td>
<td>Group</td>
<td>Project</td>
<td>SubmitTime</td>
<td>Queue</td>
<td>PE</td>
<td>Slots</td>
</tr>
<tr>
<td>$jobid</td>
<td>$job_name</td>
<td>$job_owner</td>
<td>$job_group</td>
<td>$job_project</td>
<td>$job_st</td>
<td>$job_qn</td>
<td>$job_pe</td>
<td>$job_slots</td>
</tr>
</tbody>
</table><br>";
$i=0;
$usage_stats = array();
foreach ($qstat->xpath('//scaled') as $usage) {
$key=strval($usage->UA_name);
$val=strval($usage->UA_value);
$usage_stats[$key]=$val;
}
$cputime = ($usage_stats['cpu'] > 0) ? $cputime = time_duration($usage_stats['cpu'], 'dhms') : 0;
echo " <table align=center width=95% border=\"1\" cellpadding=\"0\" cellspacing=\"0\">
<tbody>
<tr CLASS=\"header\">
<td>CPUTime (s)</td>
<td>Mem (GB)</td>
<td>io</td>
<td>iow</td>
<td>VMem (M)</td>
<td>MaxVMem (M)</td>
</tr>
<tr>
<td>$cputime</td>
<td>".number_format($usage_stats['mem'], 2, '.', '')."</td>
<td>".number_format($usage_stats['io'], 2, '.', '')."</td>
<td>".number_format($usage_stats['iow'], 2, '.', '')."</td>
<td>".number_format($usage_stats['vmem']/1024/1024, 2, '.', '')."</td>
<td>".number_format($usage_stats['maxvmem']/1024/1024, 2, '.', '')."</td>
</tr>
</tbody>
</table><br>";
unlink($tokenfile);
?>
<br>
</td>
</tr>
<?php
include("bottom.php");
?>
</tbody>
</table>
</body>
</html>