forked from dtouzeau/artica
/
services.status.php
72 lines (52 loc) · 1.5 KB
/
services.status.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
<?php
include_once('ressources/class.templates.inc');
include_once('ressources/class.mailboxes.inc');
include_once('ressources/class.main_cf.inc');
Status();
function status(){
$sock=new sockets();
$datas=explode("\n",$sock->getfile('?psprocesses'));
while (list ($num, $ligne) = each ($datas) ){
if(preg_match('#([0-9]+)\s+([0-9]+)\s+([a-zA-Z\-\.0-9]+)#',$ligne,$regs)){
$proc=$regs[3];
$mem1=$regs[1]+ $regs[2];
$follow_arr[$proc]["MEM"]=$follow_arr[$proc]["MEM"]+$mem1;
$follow_arr[$proc]["PROC"]=$follow_arr[$proc]["PROC"]+1;
}
}
if(!is_array($follow_arr)){
$tpl=new templates('{global_services_status}','{error_no_socks}');
echo $tpl->web_page;
exit;
}
$html="<h2>{services_status}</h2>
<table >
<tr class=rowA>
<td><strong>{service_name}</td>
<td><strong>{global_memory}</td>
<td><strong>{process_number}</td>
</tr>";
while (list ($num, $ligne) = each ($follow_arr) ){
if(array_stats($num)){
if($class=='rowA'){$class='rowB';}else{$class="rowA";}
$mem=round($ligne["MEM"]/1024);
$html=$html . "
<tr class=$class>
<td>$num</td>
<td>$mem mb</td>
<td>{$ligne["PROC"]}</td>
</tr>";
}
}
$html=$html . "</table>";
$tpl=new templates('{global_services_status}',$html);
echo $tpl->web_page;
}
function array_stats($service){
$array_process=array("saslauthd","apache2","master","qmgr","artica-postfix","cyrmaster","slapd","aveserver");
while (list ($num, $ligne) = each ($array_process) ){
if($ligne==$service){return true;}
}
return false;
}
?>