<?php
$time = isset($_GET['time']) ? $_GET['time'] : 5 ;
$ramal = $_GET['ramal'];
$monit = trim(shell_exec('sudo asterisk -rx "core show channels verbose" | grep '.$ramal));
$calls = shell_exec('sudo asterisk -rx "core show channels verbose"');
$agents = shell_exec('sudo asterisk -rx "agent show online"');
$serverdata = shell_exec('ifconfig');
?>
<html>
<head>
<meta http-equiv="refresh" content="<?php echo $time ?>" >
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://bootswatch.com/3/paper/bootstrap.css" media="screen">
<link rel="stylesheet" href="https://bootswatch.com/3/assets/css/custom.min.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="panel panel-success">
<div class="panel-heading">
Agentes
</div>
<div class="panel-body">
<pre style="font-size: 12px;"><?php echo trim($agents) ?></pre>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">
Monitorando Ligações do ramal / agente: <?php echo $ramal ?>
</div>
<div class="panel-body">
<form action="index.php" method="GET" class="form-inline">
<input type="text" value="<?php echo $ramal ?>" name="ramal" class="form-control" placeholder="Ramal / ex: 6219"/>
<select name="time" class="form-control">
<option value="2" <?php echo ($time == '2') ? selected : ''?>>2 Segundos</option>
<option value="5" <?php echo ($time == '5') ? selected : ''?>>5 Segundos</option>
<option value="10" <?php echo ($time == '10') ? selected : ''?>>10 Segundos</option>
<option value="15" <?php echo ($time == '15') ? selected : ''?>>15 Segundos</option>
<option value="20" <?php echo ($time == '20') ? selected : ''?>>20 Segundos</option>
</select>
<input type="submit" value="Enviar" class="btn btn-sm"/>
</form>
<pre style="font-size: 12px;"><?php echo $monit ?></pre>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">
Ligações
</div>
<div class="panel-body">
<pre style="font-size: 12px;"><?php echo trim($calls) ?></pre>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">
Servidor
</div>
<div class="panel-body">
<pre style="font-size: 12px;"><?php echo trim($serverdata) ?></pre>
</div>
</div>
</div>
</div>
</div>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
</body>
</html>