[go: up one dir, main page]

Menu

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

Download this file

41 lines (39 with data), 932 Bytes

 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
<?php
include 'functions.php';
$service=getService($_GET['service']);
$proto=$service['protocol'];
$host=$service['machine']['host'];
$port=$service['port'];
$sleep=$service['interval'];
$count=$service['count'];
$extra=isset($_GET['manuall']);
if($extra){
sleep(30);
}
$chk_return=false;
if($proto=="html") {
$cmd = "cat html.txt | nc $host $port 2>/dev/null";
$chk_return=true;
}
else {
if ($proto=="sip") {
$cmd = "cat opt.txt | 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();
?>