-
Notifications
You must be signed in to change notification settings - Fork 0
/
statistics.inc.php
84 lines (79 loc) · 2.41 KB
/
statistics.inc.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
<?php
// compute some statistics from VRE.log file
// OBSOLETE
function get_statistics_tool($toolId,$user="all"){
// short statistics output
$statistics = array("Total Jobs" => 0,
" - Finished succsessfully" => 0,
" - Finished with errors" => 0
);
// statistics outfile
if ($user=="all"){
$logFile = $GLOBALS['logFile'];
$logFile ="/orozco/services/MuG/VRE.log.1";
// Total jobs
$cmd = "grep 'TOOL:$toolId' $logFile";
exec($cmd, $matchs);
if (count($matchs) == 0){
return $statistics;
}
$statistics['Total Jobs']=count($matchs);
// Parse total jobs
$jobs=array();
foreach($matchs as $jobLine){
if (preg_match('/(.*) \| USER:(.*), ID:(.*), LAUNCHER:(.*), TOOL:(.*), PID:(.*)/',$jobLine,$m)){
if ($m[6] == 0 ){
$jobs[$m[5]]["NO_PID_".rand()]= array(
"start" => $m[1],
"login" => $m[2],
"user_id" => $m[3],
"launcher"=> $m[4],
"finished"=> $m[1],
"success" => false,
"error" => true
);
$statistics[' - Finished with errors']+=1;
}else{
$jobs[$m[5]][$m[6]]= array(
"start" => $m[1],
"login" => $m[2],
"user_id" => $m[3],
"launcher"=> $m[4],
"finished"=> "-",
"success" => "-",
"error" => "-"
);
}
}else{
$_SESSION['errorData']['Warning'][]="Statistics for tool $toolId not correctly computed. LOG file has bad format";
return $statistics;
}
}
// Search for FINISHED
$pids = "JOB ".implode("|JOB ",array_keys($jobs[$toolId]));
$cmd = "grep -P '$pids' $logFile | sort -u";
exec($cmd, $matchs1);
if (count($matchs1) == 0){
//$_SESSION['errorData']['Warning'][]="Statistics for tool $toolId not correctly computed. LOG file has bad format.";
}
foreach($matchs1 as $jobLine){
if (preg_match('/(.*) \| JOB (.*) FINISHED SUCCESSFULLY/',$jobLine,$m)){
$statistics[' - Finished succsessfully']+=1;
if ($jobs[$toolId][$m[2]]){
$jobs[$toolId][$m[1]]['finished']= $m[1];
$jobs[$toolId][$m[1]]['success'] = true;
$jobs[$toolId][$m[1]]['success'] = false;
}
}elseif (preg_match('/(.*) \| JOB (.*) FINISHED but with error/',$jobLine,$m)){
$statistics[' - Finished with errors']+=1;
if ($jobs[$toolId][$m[2]]){
$jobs[$toolId][$m[1]]['finished']= $m[1];
$jobs[$toolId][$m[1]]['success'] = false;
$jobs[$toolId][$m[1]]['success'] = true;
}
}
}
}
return $statistics;
}
?>