예제 #1
0
 private function _sampler_CallsMemoryCPU()
 {
     $arrayResult = array();
     $oSampler = new paloSampler();
     //retorna
     //Array ( [0] => Array ( [id] => 1 [name] => Sim. calls [color] => #00cc00 [line_type] => 1 )
     $arrLines = $oSampler->getGraphLinesById(1);
     //retorna
     //Array ( [name] => Simultaneous calls, memory and CPU )
     $arrGraph = $oSampler->getGraphById(1);
     $endtime = time();
     $starttime = $endtime - 26 * 60 * 60;
     $oSampler->deleteDataBeforeThisTimestamp($starttime);
     $arrayResult['ATTRIBUTES'] = array('TITLE' => utf8_decode(_tr($arrGraph['name'])), 'TYPE' => 'lineplot_multiaxis', 'LABEL_X' => 'Etiqueta X', 'LABEL_Y' => 'Etiqueta Y', 'SHADOW' => false, 'SIZE' => "450,260", 'MARGIN' => "50,110,30,120", 'COLOR' => "#fafafa", 'POS_LEYEND' => "0.35,0.85");
     $arrayResult['MESSAGES'] = array('ERROR' => 'Error', 'NOTHING_SHOW' => _tr('Nothing to show yet'));
     //$oSampler->getSamplesByLineId(1)
     //retorna
     //Array ( [0] => Array ( [timestamp] => 1230562202 [value] => 2 ), .......
     $i = 1;
     $arrData = array();
     foreach ($arrLines as $num => $line) {
         $arraySample = $oSampler->getSamplesByLineId($line['id']);
         $arrDat_N = array();
         $arrValues = array();
         foreach ($arraySample as $num => $time_value) {
             $arrValues[$time_value['timestamp']] = (int) $time_value['value'];
         }
         $arrStyle = array();
         $arrStyle['COLOR'] = $line['color'];
         $arrStyle['LEYEND'] = utf8_decode(_tr($line['name']));
         $arrStyle['STYLE_STEP'] = true;
         $arrStyle['FILL_COLOR'] = $i == 1 ? true : false;
         $arrDat_N["VALUES"] = $arrValues;
         $arrDat_N["STYLE"] = $arrStyle;
         if (count($arrValues) > 1) {
             $arrData["DAT_{$i}"] = $arrDat_N;
         } else {
             $arrData["DAT_{$i}"] = array();
         }
         $i++;
     }
     $arrayResult['DATA'] = $arrData;
     $arrayResult['FORMAT_CALLBACK'] = array($this, 'functionCallback');
     return $arrayResult;
 }
 function channelsUsage($id)
 {
     $arrayResult = array();
     $oSampler = new paloSampler();
     //retorna
     //Array ( [0] => Array ( [id] => 1 [name] => Sim. calls [color] => #00cc00 [line_type] => 1 )
     $arrLines = $oSampler->getGraphLinesById($id);
     //retorna
     //Array ( [name] => Simultaneous calls, memory and CPU )
     $arrGraph = $oSampler->getGraphById($id);
     $endtime = time();
     $starttime = $endtime - 26 * 60 * 60;
     $oSampler->deleteDataBeforeThisTimestamp($starttime);
     $arrayResult['ATTRIBUTES'] = array('TITLE' => str_ireplace('zap', 'DAHDI', $arrGraph['name']), 'TYPE' => 'lineplot', 'LABEL_X' => "", 'LABEL_Y' => '', 'SHADOW' => false, 'SIZE' => "570,170", 'MARGIN' => "50,140,30,50", 'COLOR' => "#fafafa", 'POS_LEYEND' => "0.02,0.5");
     $arrayResult['MESSAGES'] = array('ERROR' => 'Error', 'NOTHING_SHOW' => _tr('Nothing to show yet'));
     //$oSampler->getSamplesByLineId(1)
     //retorna
     //Array ( [0] => Array ( [timestamp] => 1230562202 [value] => 2 ), .......
     $i = 1;
     $arrData = array();
     foreach ($arrLines as $num => $line) {
         $arraySample = $oSampler->getSamplesByLineId($line['id']);
         $arrDat_N = array();
         $arrValues = array();
         foreach ($arraySample as $num => $time_value) {
             $arrValues[$time_value['timestamp']] = (int) $time_value['value'];
         }
         $arrStyle = array();
         $arrStyle['COLOR'] = $line['color'];
         $arrStyle['LEYEND'] = str_ireplace('zap', 'DAHDI', $line['name']);
         $arrStyle['STYLE_STEP'] = true;
         $arrStyle['FILL_COLOR'] = false;
         $arrDat_N["VALUES"] = $arrValues;
         $arrDat_N["STYLE"] = $arrStyle;
         if (count($arrValues) > 1) {
             $arrData["DAT_{$i}"] = $arrDat_N;
         } else {
             $arrData["DAT_{$i}"] = array();
         }
         $i++;
     }
     $arrayResult['DATA'] = $arrData;
     return $arrayResult;
 }
예제 #3
0
  | the License for the specific language governing rights and           |
  | limitations under the License.                                       |
  +----------------------------------------------------------------------+
  | The Original Code is: Elastix Open Source.                           |
  | The Initial Developer of the Original Code is PaloSanto Solutions    |
  +----------------------------------------------------------------------+
  $Id: sampler.php,v 1.2 2007/07/07 22:50:40 admin Exp $ */
$elxPath = "/usr/share/elastix";
// /usr/share/elastix/ directorio que contiene las librerias del sistema
//
ini_set('include_path', dirname($_SERVER['SCRIPT_FILENAME']) . ":{$elxPath}:" . ini_get('include_path'));
require_once "libs/misc.lib.php";
require_once "configs/default.conf.php";
require_once "libs/paloSantoSampler.class.php";
require_once "libs/paloSantoDB.class.php";
$oSampler = new paloSampler();
// NUMERO DE LLAMADAS SIMULTANEAS
$simCalls = 0;
$comando = "/usr/sbin/asterisk -r -x \"core show channels\"";
exec($comando, $arrSalida, $varSalida);
$counter_channels_dahdi = 0;
$counter_channels_sip = 0;
$counter_channels_iax = 0;
$counter_channels_h323 = 0;
$counter_channels_local = 0;
foreach ($arrSalida as $linea) {
    if (eregi("^DAHDI/", $linea)) {
        $counter_channels_dahdi++;
    } else {
        if (eregi("SIP", $linea)) {
            $counter_channels_sip++;