-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfs-status.php
More file actions
73 lines (62 loc) · 2.48 KB
/
fs-status.php
File metadata and controls
73 lines (62 loc) · 2.48 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
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
<?php
// status proof of concept
include('lib/xmlrpc.inc');
$fsUser = "freeswitch";
$fsPass = "fs";
$fsHost = "thevoices.faith";
$fsPort = 9366;
$f=new xmlrpcmsg('freeswitch.api',
array(
new xmlrpcval("show", "string"),
new xmlrpcval("status", "string")
)
);
$c=new xmlrpc_client("/RPC2", $fsHost, $fsPort);
$c->setCredentials($fsUser,$fsPass,NULL);
echo "<PRE>";
$output = getFSstatus($c);
echo "</PRE>";
echo"<h2> OUTPUT </h2>";
echo "<PRE>";
var_dump($output);
echo "</PRE>";
echo "ARRR";
function getFSstatus(&$rpcClient) {
$uptimeRegex = "/^UP (\d{1,2}) years, (\d{1,3}) days, (\d{1,2}) hours, (\d{1,2}) minutes, (\d{1,2}) seconds, (\d{1,3}) milliseconds, (\d{1,3}) microseconds/";
$sessionRegex = "/^(\d{1,6}) session\(s\) since startup$/";
$sessionCountRegex = "/^(\d{1,3}) session\(s\) - peak (\d{1,6}), last 5min (\d{1,6}) $/";
$sessionLoadRegex = "/^(\d{1,6}) session\(s\) per Sec out of max (\d{1,4}), peak (\d{1,4}), last 5min (\d{1,4}) $/";
$sessionMaxRegex = "/^(\d{1,6}) session\(s\) max$/";
$rpcmsg=new xmlrpcmsg('freeswitch.api',
array(
new xmlrpcval("show", "string"),
new xmlrpcval("status", "string")
)
);
$result=&$rpcClient->send($rpcmsg);
if(!$result->faultCode())
{
$v=$result->value();
$foo = explode("\n" , $v->scalarval());
preg_match($uptimeRegex,$foo[0],$uptimeMatch);
preg_match($sessionRegex,$foo[2],$sessionCount);
preg_match($sessionCountRegex,$foo[3],$sessionLoad);
preg_match($sessionLoadRegex,$foo[4],$sessionSys);
preg_match($sessionMaxRegex,$foo[5],$sessionMax);
//var_dump($sessionLoad);
$returnResult = [
'uptime' => $uptimeMatch,
'version' => $foo[1],
'session-count' => $sessionCount[1],
'session-current' => $sessionLoad[1],
'session-load' => $sessionSys,
'session-max' => $sessionMax[1]
];
return $returnResult;
} else {
print "An error occurred: ";
print "Code: " . htmlspecialchars($r->faultCode())
. " Reason: '" . htmlspecialchars($r->faultString());
}
}
?>