- Joined
- Feb 10, 2015
- Messages
- 8
- Reaction score
- 0
I'm write on PHP simply show GSM and SIP Channel Status (I have OpenVoxG400 GSM card)
Placed in /var/www/html/showstatus.php and exec attr
and open in browser https://you_ip_elastix/showstatus.php
Placed in /var/www/html/showstatus.php and exec attr
Code:
<html>
<title>GSM and SIP Channel Status</title>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script type="text/JavaScript">
function timedRefresh(timeoutPeriod) {
setTimeout("location.reload(true);",timeoutPeriod);
}
</script>
</head>
<body onload="JavaScript:timedRefresh(2000);">
<?php
/* Here I am setting up the variables for the commands to pass down through to the shell */
$uptime = (shell_exec("uptime | awk '{print $1;}'|sed 's/,//g'"));
$span2 = (shell_exec("asterisk -rx \"gsm show span 2\" 2>/dev/null |grep \"Network Status\" | awk '{print;}'|sed 's/,//g'"));
$span3 = (shell_exec("asterisk -rx \"gsm show span 3\" 2>/dev/null |grep \"Network Status\" | awk '{print;}'|sed 's/,//g'"));
$span4 = (shell_exec("asterisk -rx \"gsm show span 4\" 2>/dev/null |grep \"Network Status\" | awk '{print;}'|sed 's/,//g'"));
$span2level = (shell_exec("asterisk -rx \"gsm show span 2\" 2>/dev/null |grep \"Signal Quality (0,31):\" | awk '{print $4;}'|sed 's/,//g'"));
$span3level = (shell_exec("asterisk -rx \"gsm show span 3\" 2>/dev/null |grep \"Signal Quality (0,31):\" | awk '{print $4;}'|sed 's/,//g'"));
$span4level = (shell_exec("asterisk -rx \"gsm show span 4\" 2>/dev/null |grep \"Signal Quality (0,31):\" | awk '{print $4;}'|sed 's/,//g'"));
/* Here I am outputting to the screen the commands I have specified above*/
//echo "<pre><font color=black>$uptime</font></pre>";
//echo "<pre><font color=black>LIFE span 2 $span2</font></pre>";
//echo "<pre><font color=black>KYIVSTAR span 3 $span3</font></pre>";
//echo "<pre><font color=black>MTS span 4 $span4</font></pre>";
echo "<center><h4>Status SIM card on $uptime</h4><table width=100% border=0 cellspacing=1 cellpadding=1 bgcolor=000000>";
echo "<tr bgcolor=whitesmoke>
<td align=center bgcolor=FFCC99>Operator</td>
<td align=center bgcolor=FFCC99>Status</td>
<td align=center bgcolor=FFCC99>Signal Level (0,31)</td>
</tr>";
echo "<tr bgcolor=whitesmoke>";
echo "<td width=100 valign=top>";
echo "LIFE";
echo "</td>";
echo "<td valign=top>";
echo "span2 - ".$span2;
echo "</td>";
echo "<td align=center width=140 valign=top>";
echo $span2level;
echo "</td>";
echo "</tr>";
echo "<tr bgcolor=whitesmoke>";
echo "<td width=100 valign=top>";
echo "KYIVSTAR";
echo "</td>";
echo "<td valign=top>";
echo "span3 - ".$span3;
echo "</td>";
echo "<td align=center width=140 valign=top>";
echo $span3level;
echo "</td>";
echo "</tr>";
echo "<tr bgcolor=whitesmoke>";
echo "<td width=100 valign=top>";
echo "MTS";
echo "</td>";
echo "<td valign=top>";
echo "span4 - ".$span4;
echo "</td>";
echo "<td align=center width=140 valign=top>";
echo $span4level;
echo "</td>";
echo "</tr>";
echo "</table></center>";
/* sip show channelstats */
$channelstats = (shell_exec("asterisk -rx \"sip show channelstats\""));
echo "<pre><font color=black>$channelstats</font></pre>";
/* sip show channelstats */
?>
</body>
</html>
and open in browser https://you_ip_elastix/showstatus.php