[go: up one dir, main page]

Menu

[r59]: / inc / check_service.php  Maximize  Restore  History

Download this file

44 lines (42 with data), 1.1 kB

 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
<?php
include '../config.php';
$service=getService($_GET['service']);
$machine=getMachine($service->machine_id);
$host=$machine->host;
$proto=$service->protocol;
$port=$service->port;
$sleep=$service->interval;
$count=$service->count;
$extra=isset($_GET['manuall']);
$html_file = dirname(__FILE__)."/../txt/html.txt";
$sip_file = dirname(__FILE__)."/../txt/opt.txt";
if($extra){
sleep(30);
}
$chk_return=false;
if($proto=="http") {
$cmd = "cat $html_file | nc $host $port 2>/dev/null";
$chk_return=true;
}
else {
if ($proto=="sip") {
$cmd = "cat $sip_file | nc -u $host $port -w2 2>/dev/null";
}
else {
die("unknown protocol $proto<br/>");
}
}
for($i=0; $i<$count; $i++){
exec ($cmd,$out,$return);
if(count($out)>0 || ($return==0 && $chk_return)){
echo "started ".$_GET['service'];
die();
}
sleep($sleep);
if($extra){
sleep(5);
}
}
echo "failed ".$_GET['service'];
die();
?>