mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Delete traffic_graph will move to fusionpbx-apps repo
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
//application details
|
||||
$apps[$x]['name'] = "Traffic Graph";
|
||||
$apps[$x]['uuid'] = "99932b6e-6560-a472-25dd-22e196262187";
|
||||
$apps[$x]['category'] = "System";
|
||||
$apps[$x]['subcategory'] = "";
|
||||
$apps[$x]['version'] = "1.0";
|
||||
$apps[$x]['license'] = "Mozilla Public License 1.1";
|
||||
$apps[$x]['url'] = "http://www.fusionpbx.com";
|
||||
$apps[$x]['description']['en-us'] = "Uses SVG to show the network traffic.";
|
||||
$apps[$x]['description']['ar-eg'] = "";
|
||||
$apps[$x]['description']['de-at'] = "Verwendet SVG um die Netzwerkauslastung anzuzeigen.";
|
||||
$apps[$x]['description']['de-ch'] = "";
|
||||
$apps[$x]['description']['de-de'] = "Verwendet SVG um die Netzwerkauslastung anzuzeigen.";
|
||||
$apps[$x]['description']['es-cl'] = "Utiliza SVG para mostrar el tráfico de red";
|
||||
$apps[$x]['description']['es-mx'] = "";
|
||||
$apps[$x]['description']['fr-ca'] = "";
|
||||
$apps[$x]['description']['fr-fr'] = "Affiche le traffique Réseau via SVG.";
|
||||
$apps[$x]['description']['he-il'] = "";
|
||||
$apps[$x]['description']['it-it'] = "";
|
||||
$apps[$x]['description']['nl-nl'] = "";
|
||||
$apps[$x]['description']['pl-pl'] = "";
|
||||
$apps[$x]['description']['pt-br'] = "";
|
||||
$apps[$x]['description']['pt-pt'] = "Utiliza SVG para mostrar o tráfego de rede.";
|
||||
$apps[$x]['description']['ro-ro'] = "";
|
||||
$apps[$x]['description']['ru-ru'] = "Использование SVG для отображения сетевого трафика.";
|
||||
$apps[$x]['description']['sv-se'] = "";
|
||||
$apps[$x]['description']['uk-ua'] = "";
|
||||
|
||||
//permission details
|
||||
$y=0;
|
||||
$apps[$x]['permissions'][$y]['name'] = "traffic_graph_view";
|
||||
$apps[$x]['permissions'][$y]['menu']['uuid'] = "05ac3828-dc2b-c0e2-282c-79920f5349e0";
|
||||
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
|
||||
|
||||
?>
|
||||
@@ -1,124 +0,0 @@
|
||||
<?php
|
||||
#This file was last reorganized on 19th of September 2017 08:54:24 AM UTC
|
||||
|
||||
$text['title-traffic_graph']['en-us'] = "Traffic Graph";
|
||||
$text['title-traffic_graph']['ar-eg'] = "";
|
||||
$text['title-traffic_graph']['de-at'] = "Netzauslastung"; //copied from de-de
|
||||
$text['title-traffic_graph']['de-ch'] = "Netzauslastung"; //copied from de-de
|
||||
$text['title-traffic_graph']['de-de'] = "Netzauslastung";
|
||||
$text['title-traffic_graph']['es-cl'] = "Gráfico de Tráfico";
|
||||
$text['title-traffic_graph']['es-mx'] = "Gráfico de Tráfico"; //copied from es-cl
|
||||
$text['title-traffic_graph']['fr-ca'] = "Graphique de Traffic"; //copied from fr-fr
|
||||
$text['title-traffic_graph']['fr-fr'] = "Graphique de Traffic";
|
||||
$text['title-traffic_graph']['he-il'] = "";
|
||||
$text['title-traffic_graph']['it-it'] = "Grafico Traffico Dati";
|
||||
$text['title-traffic_graph']['nl-nl'] = "";
|
||||
$text['title-traffic_graph']['pl-pl'] = "Wykres przesyłu danych";
|
||||
$text['title-traffic_graph']['pt-br'] = "Gráfico de tráfego";
|
||||
$text['title-traffic_graph']['pt-pt'] = "Gráfico do Tráfego";
|
||||
$text['title-traffic_graph']['ro-ro'] = "";
|
||||
$text['title-traffic_graph']['ru-ru'] = "График трафика";
|
||||
$text['title-traffic_graph']['sv-se'] = "Trafik Graf";
|
||||
$text['title-traffic_graph']['uk-ua'] = "Графік трафіку";
|
||||
|
||||
$text['message-no_interfaces_found']['en-us'] = "No interfaces found.";
|
||||
$text['message-no_interfaces_found']['ar-eg'] = "";
|
||||
$text['message-no_interfaces_found']['de-at'] = "Keine Netzwerkkarte gefunden."; //copied from de-de
|
||||
$text['message-no_interfaces_found']['de-ch'] = "Keine Netzwerkkarte gefunden."; //copied from de-de
|
||||
$text['message-no_interfaces_found']['de-de'] = "Keine Netzwerkkarte gefunden.";
|
||||
$text['message-no_interfaces_found']['es-cl'] = "Sin interfaces encontrados.";
|
||||
$text['message-no_interfaces_found']['es-mx'] = "Sin interfaces encontrados."; //copied from es-cl
|
||||
$text['message-no_interfaces_found']['fr-ca'] = "Aucune interface trouvé."; //copied from fr-fr
|
||||
$text['message-no_interfaces_found']['fr-fr'] = "Aucune interface trouvé.";
|
||||
$text['message-no_interfaces_found']['he-il'] = "";
|
||||
$text['message-no_interfaces_found']['it-it'] = "Nessuna interfaccia trovata.";
|
||||
$text['message-no_interfaces_found']['nl-nl'] = "";
|
||||
$text['message-no_interfaces_found']['pl-pl'] = "Nie znaleziono interfejsy.";
|
||||
$text['message-no_interfaces_found']['pt-br'] = "Sem interfaces encontrados."; //copied from pt-pt
|
||||
$text['message-no_interfaces_found']['pt-pt'] = "Sem interfaces encontrados.";
|
||||
$text['message-no_interfaces_found']['ro-ro'] = "";
|
||||
$text['message-no_interfaces_found']['ru-ru'] = "Интерфейсы не найдены.";
|
||||
$text['message-no_interfaces_found']['sv-se'] = "Inga gränssnitt hittades.";
|
||||
$text['message-no_interfaces_found']['uk-ua'] = "Не знайдено жодного інтерфейсу";
|
||||
|
||||
$text['label-interface']['en-us'] = "Interface";
|
||||
$text['label-interface']['ar-eg'] = "";
|
||||
$text['label-interface']['de-at'] = "Netzwerkkarte"; //copied from de-de
|
||||
$text['label-interface']['de-ch'] = "Netzwerkkarte"; //copied from de-de
|
||||
$text['label-interface']['de-de'] = "Netzwerkkarte";
|
||||
$text['label-interface']['es-cl'] = "Interfaz";
|
||||
$text['label-interface']['es-mx'] = "Interfaz"; //copied from es-cl
|
||||
$text['label-interface']['fr-ca'] = "Interface"; //copied from fr-fr
|
||||
$text['label-interface']['fr-fr'] = "Interface";
|
||||
$text['label-interface']['he-il'] = "";
|
||||
$text['label-interface']['it-it'] = "Interfaccia";
|
||||
$text['label-interface']['nl-nl'] = "";
|
||||
$text['label-interface']['pl-pl'] = "Wybierz interfejs";
|
||||
$text['label-interface']['pt-br'] = "Interface"; //copied from pt-pt
|
||||
$text['label-interface']['pt-pt'] = "Interface";
|
||||
$text['label-interface']['ro-ro'] = "";
|
||||
$text['label-interface']['ru-ru'] = "Интерфейсы";
|
||||
$text['label-interface']['sv-se'] = "Gränssnitt";
|
||||
$text['label-interface']['uk-ua'] = "Інтерфейс";
|
||||
|
||||
$text['header-traffic_graph']['en-us'] = "Traffic Graph";
|
||||
$text['header-traffic_graph']['ar-eg'] = "";
|
||||
$text['header-traffic_graph']['de-at'] = "Netzauslastung"; //copied from de-de
|
||||
$text['header-traffic_graph']['de-ch'] = "Netzauslastung"; //copied from de-de
|
||||
$text['header-traffic_graph']['de-de'] = "Netzauslastung";
|
||||
$text['header-traffic_graph']['es-cl'] = "Gráfico de Tráfico";
|
||||
$text['header-traffic_graph']['es-mx'] = "Gráfico de Tráfico"; //copied from es-cl
|
||||
$text['header-traffic_graph']['fr-ca'] = "Graphique de Traffic"; //copied from fr-fr
|
||||
$text['header-traffic_graph']['fr-fr'] = "Graphique de Traffic";
|
||||
$text['header-traffic_graph']['he-il'] = "";
|
||||
$text['header-traffic_graph']['it-it'] = "Grafico Traffico Dati";
|
||||
$text['header-traffic_graph']['nl-nl'] = "";
|
||||
$text['header-traffic_graph']['pl-pl'] = "Wykres przesyłu danych";
|
||||
$text['header-traffic_graph']['pt-br'] = "Gráfico de tráfego";
|
||||
$text['header-traffic_graph']['pt-pt'] = "Gráfico do Tráfego";
|
||||
$text['header-traffic_graph']['ro-ro'] = "";
|
||||
$text['header-traffic_graph']['ru-ru'] = "График трафика";
|
||||
$text['header-traffic_graph']['sv-se'] = "Trafik Graf";
|
||||
$text['header-traffic_graph']['uk-ua'] = "Графік трафіку";
|
||||
|
||||
$text['description-traffic_graph']['en-us'] = "A browser (or plugin) that supports Scalable Vector Graphics (SVG) is required to view the traffic graph below.";
|
||||
$text['description-traffic_graph']['ar-eg'] = "";
|
||||
$text['description-traffic_graph']['de-at'] = "Um die Netzauslastung anzuzeigen ist ein Browser (oder Plugin) erforderlich, das SVG Dateien (Scalable Vector Graphics) unterstützt."; //copied from de-de
|
||||
$text['description-traffic_graph']['de-ch'] = "Um die Netzauslastung anzuzeigen ist ein Browser (oder Plugin) erforderlich, das SVG Dateien (Scalable Vector Graphics) unterstützt."; //copied from de-de
|
||||
$text['description-traffic_graph']['de-de'] = "Um die Netzauslastung anzuzeigen ist ein Browser (oder Plugin) erforderlich, das SVG Dateien (Scalable Vector Graphics) unterstützt.";
|
||||
$text['description-traffic_graph']['es-cl'] = "Un navegador (o plugin) que soporte SVG (Scalable Vector Graphics) es necesario para ver el gráfico siguiente.";
|
||||
$text['description-traffic_graph']['es-mx'] = "Un navegador (o plugin) que soporte SVG (Scalable Vector Graphics) es necesario para ver el gráfico siguiente."; //copied from es-cl
|
||||
$text['description-traffic_graph']['fr-ca'] = "Un explorateur (ou plugin) qui support le Graphique Vectoriel Evolutif (SVG) est nécessaire pour afficher les graphique ci-dessous."; //copied from fr-fr
|
||||
$text['description-traffic_graph']['fr-fr'] = "Un explorateur (ou plugin) qui support le Graphique Vectoriel Evolutif (SVG) est nécessaire pour afficher les graphique ci-dessous.";
|
||||
$text['description-traffic_graph']['he-il'] = "";
|
||||
$text['description-traffic_graph']['it-it'] = "E' necessario un browser (o plugin) che supporti Scalable Vector Graphics (SVG) per vedere il grafico del traffico qui sotto.";
|
||||
$text['description-traffic_graph']['nl-nl'] = "";
|
||||
$text['description-traffic_graph']['pl-pl'] = "Aby zobaczyć przesytu danych wymagana jest przeglądarka (lub wtyczka), która obsługuje Scalable Vector Graphics (SVG). ";
|
||||
$text['description-traffic_graph']['pt-br'] = "Um browser (ou plugin) que suporte SVG (Scalable Vector Graphics) é necessário para ver o gráfico do tráfego abaixo. ";
|
||||
$text['description-traffic_graph']['pt-pt'] = "Um browser (ou plugin) que suporte SVG (Scalable Vector Graphics) é necessário para ver o gráfico do tráfego abaixo.";
|
||||
$text['description-traffic_graph']['ro-ro'] = "";
|
||||
$text['description-traffic_graph']['ru-ru'] = "Для просмотра графика трафика ниже требуется браузер (или плагин), который поддерживает масштабируемую векторную графику (SVG).";
|
||||
$text['description-traffic_graph']['sv-se'] = "En webbläsare (eller plugin) som stöder Scalable Vector Graphics (SVG) krävs för att visa trafik grafen nedan.";
|
||||
$text['description-traffic_graph']['uk-ua'] = "Браузер (або плагін), який підтримує Scalable Vector Graphics (SVG) необхідний для перегляду графіка руху нижче.";
|
||||
|
||||
$text['description-no_svg']['en-us'] = "Unfortunately your browser does not currently support Scalable Vector Graphics (SVG). To view the traffic graph, please use a browser (or plugin) that supports Scalable Vector Graphics (SVG).";
|
||||
$text['description-no_svg']['ar-eg'] = "";
|
||||
$text['description-no_svg']['de-at'] = "Offensichtlich unterstützt Ihr Browser keine SVG Dateien (Scalable Vector Graphics). Um die Netzauslastung anzuzeigen benutzen Sie bitte einen Browser (oder Plugin) welcher SVG Dateien unterstützt."; //copied from de-de
|
||||
$text['description-no_svg']['de-ch'] = "Offensichtlich unterstützt Ihr Browser keine SVG Dateien (Scalable Vector Graphics). Um die Netzauslastung anzuzeigen benutzen Sie bitte einen Browser (oder Plugin) welcher SVG Dateien unterstützt."; //copied from de-de
|
||||
$text['description-no_svg']['de-de'] = "Offensichtlich unterstützt Ihr Browser keine SVG Dateien (Scalable Vector Graphics). Um die Netzauslastung anzuzeigen benutzen Sie bitte einen Browser (oder Plugin) welcher SVG Dateien unterstützt.";
|
||||
$text['description-no_svg']['es-cl'] = "Su navegador no soporta SVG (Scalable Vector Graphics). Para ver el gráfico debe utilizar un navegador (o plugin) que soporte SVG.";
|
||||
$text['description-no_svg']['es-mx'] = "Su navegador no soporta SVG (Scalable Vector Graphics). Para ver el gráfico debe utilizar un navegador (o plugin) que soporte SVG."; //copied from es-cl
|
||||
$text['description-no_svg']['fr-ca'] = "Malheureusement votre explorateur ne ssupporte pas le Graphique Vectoriel Evolutif (SVG). Pour voir le graphique, merci d'utiliser un explorateur (ou plugin) qui le supporte."; //copied from fr-fr
|
||||
$text['description-no_svg']['fr-fr'] = "Malheureusement votre explorateur ne ssupporte pas le Graphique Vectoriel Evolutif (SVG). Pour voir le graphique, merci d'utiliser un explorateur (ou plugin) qui le supporte.";
|
||||
$text['description-no_svg']['he-il'] = "";
|
||||
$text['description-no_svg']['it-it'] = "Sfortunatamente il tuo browser non supporta al momento Scalable Vector Graphics (SVG). Per vedere il grafico del traffico, ti preghiamo di usare un browser (o plugin) che supporti grafica SVG.";
|
||||
$text['description-no_svg']['nl-nl'] = "";
|
||||
$text['description-no_svg']['pl-pl'] = "Niestety twoja przeglądarka nie obsługuje obecnie Scalable Vector Graphics (SVG). Aby wyświetlić wykres przesyłu danych, należy użyć przeglądarki (lub wtyczki), który obsługuje Scalable Vector Graphics (SVG).";
|
||||
$text['description-no_svg']['pt-br'] = "Infelizmente o seu browser não suporta SVG (Scalable Vector Graphics). Para ver o gráfico do tráfego por favor utilize um browser (ou plugin) que suporte SVG."; //copied from pt-pt
|
||||
$text['description-no_svg']['pt-pt'] = "Infelizmente o seu browser não suporta SVG (Scalable Vector Graphics). Para ver o gráfico do tráfego por favor utilize um browser (ou plugin) que suporte SVG.";
|
||||
$text['description-no_svg']['ro-ro'] = "";
|
||||
$text['description-no_svg']['ru-ru'] = "К сожалению, ваш браузер в настоящее время не поддерживает масштабируемую векторную графику (SVG). Чтобы просмотреть график трафика, используйте браузер (или плагин), который поддерживает масштабируемую векторную графику (SVG).";
|
||||
$text['description-no_svg']['sv-se'] = "Din webbläsare stödjer tyvärr inte Scalable Vector Graphics (SVG). Om du vill visa trafik grafen, vänligen använd en webbläsare (eller plugin) som stöder Scalable Vector Graphics (SVG) ";
|
||||
$text['description-no_svg']['uk-ua'] = "На жаль, браузер не підтримує Scalable Vector Graphics (SVG). Для перегляду графіка, будь ласка, використовуйте браузер (або плагін), який підтримує Scalable Vector Graphics (SVG).";
|
||||
|
||||
?>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
$y=0;
|
||||
$apps[$x]['menu'][$y]['title']['en-us'] = "Traffic Graph";
|
||||
$apps[$x]['menu'][$y]['title']['ar-eg'] = "";
|
||||
$apps[$x]['menu'][$y]['title']['de-at'] = "Netzauslastungsdiagramm";
|
||||
$apps[$x]['menu'][$y]['title']['de-de'] = "Netzauslastungsdiagramm";
|
||||
$apps[$x]['menu'][$y]['title']['es-cl'] = "Gráfico de Tráfico";
|
||||
$apps[$x]['menu'][$y]['title']['es-mx'] = "";
|
||||
$apps[$x]['menu'][$y]['title']['fr-ca'] = "";
|
||||
$apps[$x]['menu'][$y]['title']['fr-fr'] = "Traffic Graphe";
|
||||
$apps[$x]['menu'][$y]['title']['he-il'] = "";
|
||||
$apps[$x]['menu'][$y]['title']['it-it'] = "Grafico del Traffico";
|
||||
$apps[$x]['menu'][$y]['title']['nl-nl'] = "";
|
||||
$apps[$x]['menu'][$y]['title']['pl-pl'] = "Wykres przesyłu danych";
|
||||
$apps[$x]['menu'][$y]['title']['pt-br'] = "Gráfico de tráfego";
|
||||
$apps[$x]['menu'][$y]['title']['pt-pt'] = "Grafico de Trafego";
|
||||
$apps[$x]['menu'][$y]['title']['ro-ro'] = "";
|
||||
$apps[$x]['menu'][$y]['title']['ru-ru'] = "График трафика";
|
||||
$apps[$x]['menu'][$y]['title']['sv-se'] = "Trafik Graf";
|
||||
$apps[$x]['menu'][$y]['title']['uk-ua'] = "Трафік";
|
||||
$apps[$x]['menu'][$y]['uuid'] = "05ac3828-dc2b-c0e2-282c-79920f5349e0";
|
||||
$apps[$x]['menu'][$y]['parent_uuid'] = "0438b504-8613-7887-c420-c837ffb20cb1";
|
||||
$apps[$x]['menu'][$y]['category'] = "internal";
|
||||
$apps[$x]['menu'][$y]['path'] = "/app/traffic_graph/status_graph.php?width=660&height=330";
|
||||
$apps[$x]['menu'][$y]['groups'][] = "superadmin";
|
||||
|
||||
?>
|
||||
@@ -1,90 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2012
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
|
||||
// make sure the PATH_SEPARATOR is defined
|
||||
umask(2);
|
||||
if (!defined("PATH_SEPARATOR")) {
|
||||
if (strpos($_ENV["OS"], "Win") !== false) {
|
||||
define("PATH_SEPARATOR", ";");
|
||||
} else {
|
||||
define("PATH_SEPARATOR", ":");
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
|
||||
|
||||
// make sure the document_root is set
|
||||
$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
|
||||
if(PHP_SAPI == 'cli'){
|
||||
chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
|
||||
$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
|
||||
$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
|
||||
if (file_exists('/project_root.php')) {
|
||||
$path = '/';
|
||||
} else {
|
||||
$i = 1;
|
||||
$path = '';
|
||||
while ($i < count($dirs)) {
|
||||
$path .= '/' . $dirs[$i];
|
||||
if (file_exists($path. '/project_root.php')) {
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$_SERVER["DOCUMENT_ROOT"] = $path;
|
||||
}else{
|
||||
$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
|
||||
}
|
||||
$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
|
||||
// try to detect if a project path is being used
|
||||
if (!defined('PROJECT_PATH')) {
|
||||
if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) {
|
||||
define('PROJECT_PATH', '/fusionpbx');
|
||||
} elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) {
|
||||
define('PROJECT_PATH', '');
|
||||
} else {
|
||||
$dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME)));
|
||||
$i = 1;
|
||||
$path = $_SERVER["DOCUMENT_ROOT"];
|
||||
while ($i < count($dirs)) {
|
||||
$path .= '/' . $dirs[$i];
|
||||
if (file_exists($path. '/project_root.php')) {
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
if(!file_exists($path. '/project_root.php')){
|
||||
die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance");
|
||||
}
|
||||
$project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path);
|
||||
define('PROJECT_PATH', $project_path);
|
||||
}
|
||||
$_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH);
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,139 +0,0 @@
|
||||
<?php
|
||||
/* $Id$ */
|
||||
/*
|
||||
status_graph.php
|
||||
Part of pfSense
|
||||
Copyright (C) 2004 Scott Ullrich
|
||||
All rights reserved.
|
||||
|
||||
Originally part of m0n0wall (http://m0n0.ch/wall)
|
||||
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
include "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
if (permission_exists('traffic_graph_view')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
if ($_REQUEST['interface']) {
|
||||
$interface = $_REQUEST['interface'];
|
||||
}
|
||||
else {
|
||||
$interface = '';
|
||||
}
|
||||
if ($_REQUEST['width']) {
|
||||
$width = $_REQUEST['width'];
|
||||
}
|
||||
else {
|
||||
$width = "660"; //550 //660 //792
|
||||
}
|
||||
|
||||
if ($_REQUEST['height']) {
|
||||
$height = $_REQUEST['height'];
|
||||
}
|
||||
else {
|
||||
$height = "330"; //275 //330 //396
|
||||
}
|
||||
|
||||
require_once "resources/header.php";
|
||||
$document['title'] = $text['title-traffic_graph'];
|
||||
|
||||
?>
|
||||
<table cellpadding='0' cellspacing='0' border='0' align='right'>
|
||||
<tr>
|
||||
<td>
|
||||
<?php
|
||||
// run netstat to determine interface info
|
||||
exec("netstat -i", $result_array);
|
||||
//parse the data into a named array
|
||||
$x = 0;
|
||||
foreach ($result_array as $key => $value) {
|
||||
if ($value != "Kernel Interface table") {
|
||||
if ($x != 0) {
|
||||
//get the values
|
||||
$interface_info = preg_split("/\s+/", $result_array[$key]);
|
||||
//list all the interfaces
|
||||
$options[] = "<option value='".$interface_info[0]."' ".(($interface == $interface_info[0]) ? "selected='selected'" : null).">".htmlspecialchars($interface_info[0])."</option>";
|
||||
//auto-select first interface
|
||||
if ($interface == '') { $interface = $interface_info[0]; }
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
//output form, if interfaces exist'
|
||||
if (sizeof($options)) {
|
||||
?>
|
||||
<form name="form1" action="status_graph.php" method="get" style="">
|
||||
<strong><?php echo $text['label-interface']?></strong>
|
||||
<select name="interface" class="formfld" style="width: 100px; z-index: -10;" onchange="document.form1.submit()">
|
||||
<?php echo implode("\n", $options); ?>
|
||||
</select>
|
||||
<input type='hidden' name='width' value='<?php echo $width; ?>'>
|
||||
<input type='hidden' name='height' value='<?php echo $height; ?>'>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<b><?php echo $text['header-traffic_graph']?></b>
|
||||
<br><br>
|
||||
<?php echo $text['description-traffic_graph']?>
|
||||
<br><br>
|
||||
|
||||
<div align="center">
|
||||
<br><br>
|
||||
<?php
|
||||
if (sizeof($options) > 0) {
|
||||
?>
|
||||
<object data="svg_graph.php?interface=<?php echo $interface; ?>" type="image/svg+xml" width="<?php echo $width; ?>" height="<?php echo $height; ?>">
|
||||
<param name="src" value="svg_graph.php?interface=<?php echo $interface; ?>" />
|
||||
<?php echo $text['description-no_svg']?>
|
||||
</object>
|
||||
<?php
|
||||
}
|
||||
else {
|
||||
echo "<br><br><br><br><br>";
|
||||
echo $text['message-no_interfaces_found'];
|
||||
echo "<br><br><br><br><br>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<br><br><br>
|
||||
|
||||
<?php
|
||||
require_once "resources/footer.php";
|
||||
?>
|
||||
@@ -1,139 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2012
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
if (permission_exists('traffic_graph_view')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
//http get saved to a php variable
|
||||
$interface_name = $_GET['interface'];
|
||||
|
||||
//notes
|
||||
//links to get netstat working in a jail
|
||||
//http://ggeek.blogspot.com/2008/10/freebsd-jails-and-net-snmp.html
|
||||
//http://am-productions.biz/docs/devfs.rules.php
|
||||
//http://ggeek.blogspot.com/2008/10/freebsd-jails-and-net-snmp.html
|
||||
|
||||
//freebsd
|
||||
//netstat -i -nWb -f link
|
||||
//Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll
|
||||
//dc0 1500 <Link#1> 00:07:95:b3:e9:14 38081447 0 1267085007 10894865 0 1825820736 0
|
||||
//xl0 1500 <Link#2> 00:08:74:11:f8:44 10910693 0 1855752990 24502116 7466 459761069 4074482
|
||||
|
||||
//linux get the info need to parse it
|
||||
//list a single interface doesn't work on all versions of linux
|
||||
//netstat -I=eth0
|
||||
//list all interfaces
|
||||
//netstat -i
|
||||
//Kernel Interface table
|
||||
//Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
|
||||
//eth0 1500 0 25878419 0 0 0 32196826 0 0 0 BMRU
|
||||
//eth1 1500 0 17537 0 0 0 27819 0 0 0 BMRU
|
||||
//lo 16436 0 99683 0 0 0 99683 0 0 0 LRU
|
||||
|
||||
//osx
|
||||
//list all interfaces
|
||||
//netstat -i
|
||||
//Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll
|
||||
//lo0 16384 <Link#1> 2761841 0 2761840 0 0
|
||||
//lo0 16384 localhost ::1 2761841 - 2761840 - -
|
||||
//lo0 16384 localhost fe80:1::1 2761841 - 2761840 - -
|
||||
//lo0 16384 127 localhost 2761841 - 2761840 - -
|
||||
//gif0* 1280 <Link#2> 0 0 0 0 0
|
||||
//stf0* 1280 <Link#3> 0 0 0 0 0
|
||||
//en0 1500 <Link#4> c4:2c:03:0b:52:de 3242578 0 3286461 0 0
|
||||
//en0 1500 macolantern fe80:4::c62c:3ff: 3242578 - 3286461 - -
|
||||
//en0 1500 192.168.2 744.ssenn.net 3242578 - 3286461 - -
|
||||
|
||||
//example code
|
||||
//exec("/usr/bin/netstat -i", $result_array);
|
||||
//echo "<pre>\n";
|
||||
//print_r($result_array);
|
||||
//echo "</pre>\n";
|
||||
|
||||
//$interface_name_info = preg_split("/\s+/", $result_array[0]);
|
||||
//$interface_value_info = preg_split("/\s+/", $result_array[1]);
|
||||
//$netstat_array = array();
|
||||
//foreach ($interface_name_info as $key => $value) {
|
||||
// $netstat_array[$value] = $interface_value_info[$key];
|
||||
//}
|
||||
//echo "<pre>\n";
|
||||
//print_r($netstat_array);
|
||||
//echo "</pre>\n";
|
||||
|
||||
// run netstat to determine interface info
|
||||
exec("netstat -i -nWb -f link", $result_array);
|
||||
if (count($result_array) == 0) {
|
||||
exec("netstat -i", $result_array);
|
||||
}
|
||||
|
||||
//parse the data into a named array
|
||||
$x = 0;
|
||||
foreach ($result_array as $key => $value) {
|
||||
if ($value != "Kernel Interface table") {
|
||||
if ($x == 0) {
|
||||
//get the names of the values
|
||||
$interface_name_info = preg_split("/\s+/", $result_array[$key]);
|
||||
}
|
||||
else {
|
||||
//get the values
|
||||
$interface_value_info = preg_split("/\s+/", $result_array[$key]);
|
||||
//find data for the selected interface
|
||||
if ($interface_name == $interface_value_info[0]) {
|
||||
$netstat_array = array();
|
||||
foreach ($interface_name_info as $sub_key => $sub_value) {
|
||||
$netstat_array[$sub_value] = $interface_value_info[$sub_key];
|
||||
}
|
||||
}
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
|
||||
//set the correct tx and rx values
|
||||
if (strlen($netstat_array['Iface']) > 0) {
|
||||
$in_bytes = ($netstat_array['RX-OK']*1024);
|
||||
$out_bytes = ($netstat_array['TX-OK']*1024);
|
||||
}
|
||||
if (strlen($netstat_array['Name']) > 0) {
|
||||
$in_bytes = $netstat_array['Ibytes'];
|
||||
$out_bytes = $netstat_array['Obytes'];
|
||||
}
|
||||
|
||||
//get the timing
|
||||
$tmp_time = gettimeofday();
|
||||
$timing = (double)$tmp_time["sec"] + (double)$tmp_time["usec"] / 1000000.0;
|
||||
|
||||
//provide the timing, input bytes and output bytes
|
||||
echo "$timing|" . $in_bytes . "|" . $out_bytes . "\n";
|
||||
|
||||
?>
|
||||
@@ -1,372 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
graph.php
|
||||
part of m0n0wall (http://m0n0.ch/wall)
|
||||
|
||||
Copyright (C) 2004-2006 T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net>
|
||||
and Jonathan Watt <jwatt@jwatt.org>.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
include "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
if (permission_exists('traffic_graph_view')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
header("Last-Modified: " . gmdate( "D, j M Y H:i:s" ) . " GMT" );
|
||||
header("Expires: " . gmdate( "D, j M Y H:i:s", time() ) . " GMT" );
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1
|
||||
header("Cache-Control: post-check=0, pre-check=0", FALSE );
|
||||
header("Pragma: no-cache"); // HTTP/1.0
|
||||
header("Content-type: image/svg+xml");
|
||||
|
||||
//http get saved to a php variable
|
||||
$interface = $_GET['interface'];
|
||||
|
||||
/********** HTTP GET Based Conf ***********/
|
||||
//$ifnum=@$_GET["ifnum"]; // BSD / SNMP interface name / number
|
||||
$ifname=@$_GET["interface"]?$_GET["interface"]:"Interface $interface"; //Interface name that will be showed on top right of graph
|
||||
|
||||
/********* Other conf *******/
|
||||
$scale_type="up"; //Autoscale default setup : "up" = only increase scale; "follow" = increase and decrease scale according to current graphed datas
|
||||
$nb_plot=120; //NB plot in graph
|
||||
if ($_GET["timeint"])
|
||||
$time_interval = $_GET["timeint"]; //Refresh time Interval
|
||||
else
|
||||
$time_interval = 3;
|
||||
|
||||
$fetch_link = "status_interface.php?interface=".$interface;
|
||||
|
||||
//SVG attributes
|
||||
$attribs['axis']='fill="black" stroke="black"';
|
||||
$attribs['in']='fill="#FF0000" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="7"';
|
||||
$attribs['out']='fill="#000000" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="7"';
|
||||
$attribs['graph_in']='fill="none" stroke="#FF0000" stroke-opacity="0.8"';
|
||||
$attribs['graph_out']='fill="none" stroke="#000000" stroke-opacity="0.8"';
|
||||
$attribs['legend']='fill="black" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4"';
|
||||
$attribs['graphname']='fill="#FF0000" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="8"';
|
||||
$attribs['grid_txt']='fill="gray" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="6"';
|
||||
$attribs['grid']='stroke="gray" stroke-opacity="0.5"';
|
||||
$attribs['switch_unit']='fill="#FF0000" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4" text-decoration="underline"';
|
||||
$attribs['switch_scale']='fill="#FF0000" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4" text-decoration="underline"';
|
||||
$attribs['error']='fill="blue" font-family="Arial" font-size="4"';
|
||||
$attribs['collect_initial']='fill="gray" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4"';
|
||||
|
||||
//Error text if we cannot fetch data : depends on which method is used
|
||||
$error_text = "Cannot get data about interface $interface";
|
||||
|
||||
$height=100; //SVG internal height : do not modify
|
||||
$width=200; //SVG internal width : do not modify
|
||||
|
||||
/********* Graph DATA **************/
|
||||
print('<?xml version="1.0" encoding="iso-8859-1"?>' . "\n");?>
|
||||
<svg width="100%" height="100%" viewBox="0 0 <?php echo $width?> <?php echo $height?>" preserveAspectRatio="none" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" onload="init(evt)">
|
||||
<g id="graph">
|
||||
<rect id="bg" x1="0" y1="0" width="100%" height="100%" fill="white"/>
|
||||
<line id="axis_x" x1="0" y1="0" x2="0" y2="100%" <?php echo $attribs['axis']?>/>
|
||||
<line id="axis_y" x1="0" y1="100%" x2="100%" y2="100%" <?php echo $attribs['axis']?>/>
|
||||
<path id="graph_out" d="M0 <?php echo $height?> L 0 <?php echo $height?>" <?php echo $attribs['graph_out']?>/>
|
||||
<path id="graph_in" d="M0 <?php echo $height?> L 0 <?php echo $height?>" <?php echo $attribs['graph_in']?>/>
|
||||
<path id="grid" d="M0 <?php echo $height/4*1?> L <?php echo $width?> <?php echo $height/4*1?> M0 <?php echo $height/4*2?> L <?php echo $width?> <?php echo $height/4*2?> M0 <?php echo $height/4*3?> L <?php echo $width?> <?php echo $height/4*3?>" <?php echo $attribs['grid']?>/>
|
||||
<text id="grid_txt1" x="<?php echo $width?>" y="<?php echo $height/4*1?>" <?php echo $attribs['grid_txt']?> text-anchor="end"> </text>
|
||||
<text id="grid_txt2" x="<?php echo $width?>" y="<?php echo $height/4*2?>" <?php echo $attribs['grid_txt']?> text-anchor="end"> </text>
|
||||
<text id="grid_txt3" x="<?php echo $width?>" y="<?php echo $height/4*3?>" <?php echo $attribs['grid_txt']?> text-anchor="end"> </text>
|
||||
<text id="graph_in_lbl" x="5" y="8" <?php echo $attribs['in']?>>In</text>
|
||||
<text id="graph_out_lbl" x="5" y="16" <?php echo $attribs['out']?>>Out</text>
|
||||
<text id="graph_in_txt" x="20" y="8" <?php echo $attribs['in']?>> </text>
|
||||
<text id="graph_out_txt" x="20" y="16" <?php echo $attribs['out']?>> </text>
|
||||
<text id="ifname" x="<?php echo $width?>" y="8" <?php echo $attribs['graphname']?> text-anchor="end"><?php echo $ifname?></text>
|
||||
<text id="switch_unit" x="<?php echo $width*0.55?>" y="5" <?php echo $attribs['switch_unit']?>>Switch to bytes/s</text>
|
||||
<text id="switch_scale" x="<?php echo $width*0.55?>" y="11" <?php echo $attribs['switch_scale']?>>AutoScale (<?php echo $scale_type?>)</text>
|
||||
<text id="datetime" x="<?php echo $width*0.33?>" y="5" <?php echo $attribs['legend']?>> </text>
|
||||
<text id="graphlast" x="<?php echo $width*0.55?>" y="17" <?php echo $attribs['legend']?>>Graph shows last <?php echo $time_interval*$nb_plot?> seconds</text>
|
||||
<polygon id="axis_arrow_x" <?php echo $attribs['axis']?> points="<?php echo ($width) . "," . ($height)?> <?php echo ($width-2) . "," . ($height-2)?> <?php echo ($width-2) . "," . $height?>"/>
|
||||
<text id="error" x="<?php echo $width*0.5?>" y="<?php echo $height*0.5?>" visibility="hidden" <?php echo $attribs['error']?> text-anchor="middle"><?php echo $error_text?></text>
|
||||
<text id="collect_initial" x="<?php echo $width*0.5?>" y="<?php echo $height*0.5?>" visibility="hidden" <?php echo $attribs['collect_initial']?> text-anchor="middle">Collecting initial data, please wait...</text>
|
||||
</g>
|
||||
<script type="text/ecmascript">
|
||||
<![CDATA[
|
||||
|
||||
/**
|
||||
* getURL is a proprietary Adobe function, but it's simplicity has made it very
|
||||
* popular. If getURL is undefined we spin our own by wrapping XMLHttpRequest.
|
||||
*/
|
||||
if (typeof getURL == 'undefined') {
|
||||
getURL = function(url, callback) {
|
||||
if (!url)
|
||||
throw 'No URL for getURL';
|
||||
|
||||
try {
|
||||
if (typeof callback.operationComplete == 'function')
|
||||
callback = callback.operationComplete;
|
||||
} catch (e) {}
|
||||
if (typeof callback != 'function')
|
||||
throw 'No callback function for getURL';
|
||||
|
||||
var http_request = null;
|
||||
if (typeof XMLHttpRequest != 'undefined') {
|
||||
http_request = new XMLHttpRequest();
|
||||
}
|
||||
else if (typeof ActiveXObject != 'undefined') {
|
||||
try {
|
||||
http_request = new ActiveXObject('Msxml2.XMLHTTP');
|
||||
} catch (e) {
|
||||
try {
|
||||
http_request = new ActiveXObject('Microsoft.XMLHTTP');
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
if (!http_request)
|
||||
throw 'Both getURL and XMLHttpRequest are undefined';
|
||||
|
||||
http_request.onreadystatechange = function() {
|
||||
if (http_request.readyState == 4) {
|
||||
callback( { success : true,
|
||||
content : http_request.responseText,
|
||||
contentType : http_request.getResponseHeader("Content-Type") } );
|
||||
}
|
||||
}
|
||||
http_request.open('GET', url, true);
|
||||
http_request.send(null);
|
||||
}
|
||||
}
|
||||
|
||||
var SVGDoc = null;
|
||||
var last_ifin = 0;
|
||||
var last_ifout = 0;
|
||||
var last_ugmt = 0;
|
||||
var max = 0;
|
||||
var plot_in = new Array();
|
||||
var plot_out = new Array();
|
||||
|
||||
var max_num_points = <?php echo $nb_plot?>; // maximum number of plot data points
|
||||
var step = <?php echo $width?> / max_num_points ;
|
||||
var unit = 'bits';
|
||||
var scale_type = '<?php echo $scale_type?>';
|
||||
|
||||
function init(evt) {
|
||||
SVGDoc = evt.target.ownerDocument;
|
||||
SVGDoc.getElementById("switch_unit").addEventListener("mousedown", switch_unit, false);
|
||||
SVGDoc.getElementById("switch_scale").addEventListener("mousedown", switch_scale, false);
|
||||
|
||||
fetch_data();
|
||||
}
|
||||
|
||||
function switch_unit(event)
|
||||
{
|
||||
SVGDoc.getElementById('switch_unit').firstChild.data = 'Switch to ' + unit + '/s';
|
||||
unit = (unit == 'bits') ? 'bytes' : 'bits';
|
||||
}
|
||||
|
||||
function switch_scale(event)
|
||||
{
|
||||
scale_type = (scale_type == 'up') ? 'follow' : 'up';
|
||||
SVGDoc.getElementById('switch_scale').firstChild.data = 'AutoScale (' + scale_type + ')';
|
||||
}
|
||||
|
||||
function fetch_data() {
|
||||
getURL('<?php echo $fetch_link?>', plot_data);
|
||||
}
|
||||
|
||||
function plot_data(obj) {
|
||||
// Show datetimelegend
|
||||
var now = new Date();
|
||||
var datetime = (now.getMonth()+1) + "/" + now.getDate() + "/" + now.getFullYear() + ' ' +
|
||||
LZ(now.getHours()) + ":" + LZ(now.getMinutes()) + ":" + LZ(now.getSeconds());
|
||||
SVGDoc.getElementById('datetime').firstChild.data = datetime;
|
||||
|
||||
if (!obj.success)
|
||||
return handle_error(); // getURL failed to get data
|
||||
|
||||
var t = obj.content.split("|");
|
||||
var ugmt = parseFloat(t[0]); // ugmt is an unixtimestamp style
|
||||
var ifin = parseInt(t[1]); // number of bytes received by the interface
|
||||
var ifout = parseInt(t[2]); // number of bytes sent by the interface
|
||||
var scale;
|
||||
|
||||
if (!isNumber(ifin) || !isNumber(ifout))
|
||||
return handle_error();
|
||||
|
||||
var diff_ugmt = ugmt - last_ugmt;
|
||||
var diff_ifin = ifin - last_ifin;
|
||||
var diff_ifout = ifout - last_ifout;
|
||||
|
||||
if (diff_ugmt == 0)
|
||||
diff_ugmt = 1; /* avoid division by zero */
|
||||
|
||||
last_ugmt = ugmt;
|
||||
last_ifin = ifin;
|
||||
last_ifout = ifout;
|
||||
|
||||
switch (plot_in.length) {
|
||||
case 0:
|
||||
SVGDoc.getElementById("collect_initial").setAttributeNS(null, 'visibility', 'visible');
|
||||
plot_in[0] = diff_ifin / diff_ugmt;
|
||||
plot_out[0] = diff_ifout / diff_ugmt;
|
||||
setTimeout('fetch_data()',<?php echo 1000*$time_interval?>);
|
||||
return;
|
||||
case 1:
|
||||
SVGDoc.getElementById("collect_initial").setAttributeNS(null, 'visibility', 'hidden');
|
||||
break;
|
||||
case max_num_points:
|
||||
// shift plot to left if the maximum number of plot points has been reached
|
||||
var i = 0;
|
||||
while (i < max_num_points) {
|
||||
plot_in[i] = plot_in[i+1];
|
||||
plot_out[i] = plot_out[++i];
|
||||
}
|
||||
plot_in.length--;
|
||||
plot_out.length--;
|
||||
}
|
||||
|
||||
plot_in[plot_in.length] = diff_ifin / diff_ugmt;
|
||||
plot_out[plot_out.length]= diff_ifout / diff_ugmt;
|
||||
var index_plot = plot_in.length - 1;
|
||||
|
||||
SVGDoc.getElementById('graph_in_txt').firstChild.data = formatSpeed(plot_in[index_plot], unit);
|
||||
SVGDoc.getElementById('graph_out_txt').firstChild.data = formatSpeed(plot_out[index_plot], unit);
|
||||
|
||||
/* determine peak for sensible scaling */
|
||||
if (scale_type == 'up') {
|
||||
if (plot_in[index_plot] > max)
|
||||
max = plot_in[index_plot];
|
||||
if (plot_out[index_plot] > max)
|
||||
max = plot_out[index_plot];
|
||||
}
|
||||
else if (scale_type == 'follow') {
|
||||
i = 0;
|
||||
max = 0;
|
||||
while (i < plot_in.length) {
|
||||
if (plot_in[i] > max)
|
||||
max = plot_in[i];
|
||||
if (plot_out[i] > max)
|
||||
max = plot_out[i];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
var rmax; // max, rounded up
|
||||
|
||||
if (unit == 'bits') {
|
||||
/* round up max, such that
|
||||
100 kbps -> 200 kbps -> 400 kbps -> 800 kbps -> 1 Mbps -> 2 Mbps -> ... */
|
||||
rmax = 12500;
|
||||
i = 0;
|
||||
while (max > rmax) {
|
||||
i++;
|
||||
if (i && (i % 4 == 0))
|
||||
rmax *= 1.25;
|
||||
else
|
||||
rmax *= 2;
|
||||
}
|
||||
} else {
|
||||
/* round up max, such that
|
||||
10 KB/s -> 20 KB/s -> 40 KB/s -> 80 KB/s -> 100 KB/s -> 200 KB/s -> 400 KB/s -> 800 KB/s -> 1 MB/s ... */
|
||||
rmax = 10240;
|
||||
i = 0;
|
||||
while (max > rmax) {
|
||||
i++;
|
||||
if (i && (i % 4 == 0))
|
||||
rmax *= 1.25;
|
||||
else
|
||||
rmax *= 2;
|
||||
|
||||
if (i == 8)
|
||||
rmax *= 1.024;
|
||||
}
|
||||
}
|
||||
|
||||
scale = <?php echo $height?> / rmax;
|
||||
|
||||
/* change labels accordingly */
|
||||
SVGDoc.getElementById('grid_txt1').firstChild.data = formatSpeed(3*rmax/4,unit);
|
||||
SVGDoc.getElementById('grid_txt2').firstChild.data = formatSpeed(2*rmax/4,unit);
|
||||
SVGDoc.getElementById('grid_txt3').firstChild.data = formatSpeed(rmax/4,unit);
|
||||
|
||||
var path_in = "M 0 " + (<?php echo $height?> - (plot_in[0] * scale));
|
||||
var path_out = "M 0 " + (<?php echo $height?> - (plot_out[0] * scale));
|
||||
for (i = 1; i < plot_in.length; i++)
|
||||
{
|
||||
var x = step * i;
|
||||
var y_in = <?php echo $height?> - (plot_in[i] * scale);
|
||||
var y_out = <?php echo $height?> - (plot_out[i] * scale);
|
||||
path_in += " L" + x + " " + y_in;
|
||||
path_out += " L" + x + " " + y_out;
|
||||
}
|
||||
|
||||
SVGDoc.getElementById('error').setAttributeNS(null, 'visibility', 'hidden');
|
||||
SVGDoc.getElementById('graph_in').setAttributeNS(null, 'd', path_in);
|
||||
SVGDoc.getElementById('graph_out').setAttributeNS(null, 'd', path_out);
|
||||
|
||||
setTimeout('fetch_data()',<?php echo 1000*$time_interval?>);
|
||||
}
|
||||
|
||||
function handle_error() {
|
||||
SVGDoc.getElementById("error").setAttributeNS(null, 'visibility', 'visible');
|
||||
setTimeout('fetch_data()',<?php echo 1000*$time_interval?>);
|
||||
}
|
||||
|
||||
function isNumber(a) {
|
||||
return typeof a == 'number' && isFinite(a);
|
||||
}
|
||||
|
||||
function formatSpeed(speed, unit) {
|
||||
if (unit == 'bits')
|
||||
return formatSpeedBits(speed);
|
||||
if (unit == 'bytes')
|
||||
return formatSpeedBytes(speed);
|
||||
}
|
||||
|
||||
function formatSpeedBits(speed) {
|
||||
// format speed in bits/sec, input: bytes/sec
|
||||
if (speed < 125000)
|
||||
return Math.round(speed / 125) + " Kbps";
|
||||
if (speed < 125000000)
|
||||
return Math.round(speed / 1250)/100 + " Mbps";
|
||||
// else
|
||||
return Math.round(speed / 1250000)/100 + " Gbps"; /* wow! */
|
||||
}
|
||||
|
||||
function formatSpeedBytes(speed) {
|
||||
// format speed in bytes/sec, input: bytes/sec
|
||||
if (speed < 1048576)
|
||||
return Math.round(speed / 10.24)/100 + " KB/s";
|
||||
if (speed < 1073741824)
|
||||
return Math.round(speed / 10485.76)/100 + " MB/s";
|
||||
// else
|
||||
return Math.round(speed / 10737418.24)/100 + " GB/s"; /* wow! */
|
||||
}
|
||||
|
||||
function LZ(x) {
|
||||
return (x < 0 || x > 9 ? "" : "0") + x;
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</svg>
|
||||
Reference in New Issue
Block a user