-
Notifications
You must be signed in to change notification settings - Fork 1
/
check.php
78 lines (57 loc) · 1.61 KB
/
check.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
<?php
include "config.php";
include "layout.class.php";
include "bartlby-ui.class.php";
$btl=new BartlbyUi($Bartlby_CONF);
$info=$btl->getInfo();
$layout= new Layout();
$layout->setTemplate("nonav.html");
$layout->Table("100%");
$lib=bartlby_lib_info($btl->RES);
$exi=-1;
$plugin_dir=bartlby_config($btl->CFG, "agent_plugin_dir");
$arges=str_replace("\\\"", "\"", $_GET[args]);
$arges=str_replace("\\\\", "\\", $arges);
$arges=str_replace("\n", "\\n", $arges);
$arges=str_replace("\r", "\\r", $arges);
$server=bartlby_get_server_by_id($btl->RES, $_GET[server]);
@$fp=fsockopen($server[server_ip], $server[server_port], $errno, $errstr, 10);
if(!$fp) {
$cmd_out = "$errstr ($errno)<br />\n";
} else {
$str=$_GET[plugin] . "| " . $arges . "|\n";
$estr=bartlby_encode($str);
$vers=fread($fp, 1024);
fwrite($fp, $estr);
$reply=fread($fp, 1024);
$dreply=bartlby_decode($reply);
if(strncmp($dreply, "PERF: ", 6) == 0) {
$reply=fread($fp, 1024);
$dreply=bartlby_decode($reply);
}
$ex=explode("|", $dreply);
$cmd_out = $ex[1];
$exi=$ex[0];
fclose($fp);
}
$layout->Tr(
$layout->Td(
Array(
0=>Array(
'colspan'=> 1,
'class'=>'header',
'show'=>"Check: <b>" . $server[server_name] . ":" . $server[client_port] . "/" . $server[service_name] . " Version: $vers</b>"
)
)
)
);
$layout->Tr(
$layout->Td(
Array(
0=>$cmd_out . "<br><br><hr noshade>Exited with: <font color='" . $btl->getColor($exi) . "'>" . $btl->getState($exi) . "</font>"
)
)
);
$layout->TableEnd();
$layout->display("no");
?>