├── collector ├── data │ ├── .htaccess │ └── _README_ └── index.php ├── img ├── exit.png ├── favicon.ico ├── globus.png ├── butn-del.png ├── butn-edit.png ├── icon-info.gif └── ajax-loader.gif ├── README.md ├── plugins ├── logout.php ├── collector_check.php ├── login.php └── dashboard.php ├── CHANGELOG ├── INSTALL.md ├── config.php ├── const.php ├── css ├── megaModal.css └── monit.css ├── index.php ├── js ├── md5.js └── main.js.php ├── LICENSE └── func.php /collector/data/.htaccess: -------------------------------------------------------------------------------- 1 | Order allow,deny 2 | Deny from all -------------------------------------------------------------------------------- /collector/data/_README_: -------------------------------------------------------------------------------- 1 | Directory for saving hosts data 2 | 3 | -------------------------------------------------------------------------------- /img/exit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subnetsRU/mMonit-free/HEAD/img/exit.png -------------------------------------------------------------------------------- /img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subnetsRU/mMonit-free/HEAD/img/favicon.ico -------------------------------------------------------------------------------- /img/globus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subnetsRU/mMonit-free/HEAD/img/globus.png -------------------------------------------------------------------------------- /img/butn-del.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subnetsRU/mMonit-free/HEAD/img/butn-del.png -------------------------------------------------------------------------------- /img/butn-edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subnetsRU/mMonit-free/HEAD/img/butn-edit.png -------------------------------------------------------------------------------- /img/icon-info.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subnetsRU/mMonit-free/HEAD/img/icon-info.gif -------------------------------------------------------------------------------- /img/ajax-loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subnetsRU/mMonit-free/HEAD/img/ajax-loader.gif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mMonit-free 2 | ----------------------------------- 3 | 4 | Бесплатная и простая альтернатива M/Monit (https://mmonit.com/), который расширяет возможности Monit (http://mmonit.com/monit/). 5 | 6 | Обеспечивает отображение информации по всем вашим серверам с установленным Monit в одном web-интерфейсе без использования базы данных. 7 | 8 | Протестирован на Monit версии 5.25.0 9 | -------------------------------------------------------------------------------- /plugins/logout.php: -------------------------------------------------------------------------------- 1 | 5 | */ 6 | $pathinfo = dirname(__FILE__); 7 | require_once(realpath(sprintf("%s/../func.php",$pathinfo))); 8 | 9 | @session_destroy(); 10 | print ""; 13 | 14 | ?> -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | =========== 2 | 06.07.2021 3 | =========== 4 | Version 1.1.2 5 | 6 | What`s new: 7 | * fix collector for work with php 7.2 8 | 9 | =========== 10 | 16.02.2018 11 | =========== 12 | Version 1.1.1 13 | 14 | What`s new: 15 | * bug fixes 16 | * added host group based on FQDN of the host 17 | * some other improvements 18 | 19 | =========== 20 | 14.02.2018 21 | =========== 22 | Version 1.0.0 23 | 24 | First stable version 25 | -------------------------------------------------------------------------------- /INSTALL.md: -------------------------------------------------------------------------------- 1 | #INSTALL 2 | --------- 3 | 4 | 1. Скопируйте файлы проекта в директорию вашего HTTP сервера. 5 | ``` 6 | # cd /usr/local/www 7 | # git clone https://github.com/subnetsRU/mMonit-free.git 8 | ``` 9 | 10 | 2. Установите права на запись для папки collector/data для пользователя, от которого запущен HTTP сервер. 11 | ``` 12 | # chown www:www mMonit-free/collector/data 13 | ``` 14 | 15 | 3. Отредактируйте файл config.php 16 | 17 | 4. В конфигурации monit (https://mmonit.com/monit/documentation/monit.html#MANAGE-YOUR-MONIT-INSTANCES) укажите путь для отправки данных: 18 | 19 | `set mmonit http://ip-or-hostname-of-the-web-server/mMonit-free/collector/index.php` 20 | Например: 21 | ``` 22 | set mmonit http://192.168.1.1/mMonit-free/collector/index.php 23 | with timeout 15 seconds 24 | ``` 25 | 26 | 5. Запускайте демон monit и пользуйтесь. 27 | Для того, чтобы видеть процесс отладки запускайте демон с ключём -v: 28 | ``` 29 | # monit -v 30 | ``` 31 | Или -l logfile _(Print log information to this file)_: 32 | 33 | ``` 34 | monit -v -l /tmp/mmonit_verbose.log 35 | ``` 36 | -------------------------------------------------------------------------------- /plugins/collector_check.php: -------------------------------------------------------------------------------- 1 | 5 | */ 6 | $pathinfo = dirname(__FILE__); 7 | require_once(realpath(sprintf("%s/../func.php",$pathinfo))); 8 | //deb("Request: ".print_r($param,true)); 9 | 10 | if (chk_auth(1)){ 11 | $location=preg_replace("/^\//","",$_SERVER['REQUEST_URI']); 12 | $check=collector_check_4_errors(); 13 | //deb($check); 14 | if ($check){ 15 | print "\n
"; 16 | print "
"; 17 | print "
";
18 | 		    print $check;
19 | 		print "
"; 20 | print "
"; 21 | print "
\n"; 22 | 23 | $tmp=explode("\n",$check); 24 | printf("Обнаружены ошибки при сборе данных [%d]",count($tmp)-1); 25 | unset($tmp); 26 | 27 | print "\n\n"; 34 | } 35 | } 36 | 37 | ?> -------------------------------------------------------------------------------- /config.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | date_default_timezone_set('Europe/Moscow'); 9 | 10 | define('LOGIN','admin'); 11 | define('PASSWORD','pass_4_monit'); 12 | // 13 | define('CHECK_4_NEW_VERSION',true); //check if new version is avail, value is true or false, default true 14 | define('REFRESH_PAGE',60); //default page refresh in seconds, default 60 15 | define('NETWORK_ERRORS_AS_ALARM',false); //treat network errors as a problem, value is true or false, default false 16 | // 17 | define('COLLECTOR_DATA_DIR',"collector/data"); //dir write collector data to 18 | define('COLLECTOR_LOG_REQUEST',false); //log all requests to collector, value is true or false, default false 19 | define('COLLECTOR_CHECK_TIMER',300); //check and show collector errors if exist, seconds, default is 300 20 | // 21 | $developer_ips=array( 22 | "127.0.0.1", 23 | "172.16.10.39", 24 | "192.168.0.0/255.255.255.0", 25 | ); 26 | 27 | //Hosts that allowed to send data to collector 28 | $allowedHosts=array( 29 | 'test.example.ru' => array( 30 | '1.1.1.1', 31 | '2.2.2.2', 32 | ), 33 | 'test2.example.ru' => array( 34 | '1.1.1.1', 35 | '3.3.3.3', 36 | ), 37 | 'test3.example.ru' => '1.2.3.4', 38 | ); 39 | // 40 | $sysUsers = array( 41 | '0' => 'root', 42 | '22' => 'ssh', 43 | '53' => 'bind', 44 | '80' => 'www', 45 | '88' => 'mysql', 46 | '931' => 'asterisk', 47 | '65534' => 'nobody', 48 | ); 49 | 50 | $sysGroups = array( 51 | '0' => 'wheel', 52 | '22' => 'ssh', 53 | '53' => 'bind', 54 | '69' => 'network', 55 | '80' => 'www', 56 | '88' => 'mysql', 57 | '931' => 'asterisk', 58 | '65533' => 'nogroup', 59 | '65534' => 'nobody', 60 | ); 61 | 62 | ?> -------------------------------------------------------------------------------- /const.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | setlocale(LC_TIME, "ru_RU.UTF-8"); 11 | setlocale(LC_ALL, array("ru_RU.UTF-8")); 12 | ini_set('default_charset','UTF-8'); 13 | 14 | define('VERSION','1.1.2'); 15 | define('SYSTEM_NAME','mMonit-free'); 16 | // 17 | define('HOST',isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : "localhost"); 18 | $proto = "http"; 19 | if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO']){ 20 | $proto = $_SERVER['HTTP_X_FORWARDED_PROTO']; 21 | }elseif(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on"){ 22 | $proto = "https"; 23 | } 24 | define('PROTO',$proto); 25 | define('URL',sprintf("%s://%s/",PROTO,HOST)); 26 | define('REMOTE_ADDR',(isset($_SERVER['HTTP_X_REAL_IP']) && $_SERVER['HTTP_X_REAL_IP']) ? $_SERVER['HTTP_X_REAL_IP'] : (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : "")); 27 | // 28 | define('LOC',dirname(__FILE__)); 29 | // 30 | define('CHARSET','utf8'); 31 | define('REPLACE_FLAGS', ENT_COMPAT | ENT_XHTML); 32 | // 33 | $services=array( 34 | '5' => array( 35 | 'name' => "Система", 36 | 'key' => 'system', 37 | ), 38 | '0' => array( 39 | 'name' => "Файловая система", 40 | 'key' => 'filesystem', 41 | ), 42 | '3' => array( 43 | 'name' => "Процессы", 44 | 'key' => 'process', 45 | ), 46 | '8' => array( 47 | 'name' => "Сеть", 48 | 'key' => 'net', 49 | ), 50 | '1' => array( 51 | 'name' => "Проверка директорий", 52 | 'key' => 'directory', 53 | ), 54 | '2' => array( 55 | 'name' => "Проверка файлов", 56 | 'key' => 'file', 57 | ), 58 | '4' => array( 59 | 'name' => 'Проверка хостов', 60 | 'key' => 'host', 61 | ), 62 | '7' => array( 63 | 'name' => 'Проверка скриптов', 64 | 'key' => 'program', 65 | ), 66 | '-1' => array( 67 | 'name' => "Неизвестные", 68 | 'key' => 'unknown', 69 | ), 70 | ); 71 | 72 | ?> -------------------------------------------------------------------------------- /collector/index.php: -------------------------------------------------------------------------------- 1 | 5 | */ 6 | require_once(realpath("../func.php")); 7 | global $allowedHosts; 8 | 9 | if (COLLECTOR_LOG_REQUEST === true && !defined('LOG')){ 10 | define( 'LOG',@fopen(sprintf("%s/%s/%s_request.log",LOC,COLLECTOR_DATA_DIR,date("Y-m-d",time())),'a+')); 11 | } 12 | 13 | $params=array(); 14 | if ($_GET){ 15 | $params=$_GET; 16 | }elseif($_POST){ 17 | $params=$_POST; 18 | } 19 | $err=array(); 20 | 21 | $request = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : file_get_contents("php://input"); 22 | $requestID = mtime( ); 23 | logg(sprintf("<%s> Connect from: %s method %s",$requestID,REMOTE_ADDR != "0.0.0.0" ? REMOTE_ADDR : "unknown",isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : "unknown")); 24 | if (count($params) > 0){ 25 | logg(sprintf("<%s> Method data: %s",$requestID,count($params) > 0 ? print_r($params,true) : "none")); 26 | } 27 | logg(sprintf("<%s> REQUEST: %s",$requestID,$request)); 28 | 29 | if (!$request){ 30 | $err[]="You dont send any data"; 31 | }else{ 32 | if (!isset($allowedHostsIps[REMOTE_ADDR])){ 33 | $err[]="Access denied"; 34 | } 35 | } 36 | 37 | $data=unserialize_xml($request); 38 | if (count($err) == 0){ 39 | if (is_array($data) && count($data) > 0){ 40 | if (!isset($data['@attributes']['id']) || !isset($data['server']['localhostname'])){ 41 | $err[]="Identification failed"; 42 | } 43 | }else{ 44 | $err[]="Cant read your data"; 45 | } 46 | } 47 | 48 | if (count($err) == 0){ 49 | $host_name=trim($data['server']['localhostname']); 50 | if (!isset($allowedHosts[$host_name])){ 51 | $err[]="is not allowed here"; 52 | } 53 | } 54 | 55 | if (count($err) == 0){ 56 | $data['host_header']=$data['@attributes']; 57 | unset($data['@attributes']); 58 | $host = array( 59 | 'ip' => REMOTE_ADDR, 60 | 'name' => $host_name, 61 | 'id' => trim($data['host_header']['id']), 62 | ); 63 | $host['file']=sprintf("%s/%s/host_%s_%s.json",LOC,COLLECTOR_DATA_DIR,$host['name'],$host['id']); 64 | } 65 | 66 | if (count($err) == 0){ 67 | logg($host); 68 | $write=write_file( 69 | array( 70 | 'file' => $host['file'], 71 | 'mode' => 'w', 72 | 'data' => jsonEncode($data), 73 | ) 74 | ); 75 | if (isset($write['error'])){ 76 | $err=$write['error']; 77 | } 78 | } 79 | 80 | if (count($err) > 0){ 81 | $result = sprintf("<%s> ERROR:\n\t* %s",$requestID,implode("\n\t* ",$err)); 82 | logg($result); 83 | print $result; 84 | 85 | //Log errors for show up in iface 86 | write_file( 87 | array( 88 | 'file' => sprintf("%s/%s/errors.log",LOC,COLLECTOR_DATA_DIR), 89 | 'mode' => 'a+', 90 | 'data' => sprintf("[%s] Host %s (%s)%s\n",date("d.m.Y H:i:s",time()),REMOTE_ADDR,isset($data['server']['localhostname']) ? $data['server']['localhostname'] : "hostname unknown",sprintf(" %s",implode("; ",$err))), 91 | ) 92 | ); 93 | // 94 | }else{ 95 | $result = sprintf("<%s> OK\n",$requestID); 96 | logg($result); 97 | print $result; 98 | } 99 | 100 | //Clean up error file 101 | collector_check_4_errors( 1 ); 102 | 103 | ?> -------------------------------------------------------------------------------- /css/megaModal.css: -------------------------------------------------------------------------------- 1 | /* Контейнер */ 2 | div.modal { 3 | /* Слой перекрытия */ 4 | position: fixed; 5 | top: 0; 6 | left: 0; 7 | right: 0; 8 | bottom: 0; 9 | background: rgba(0,0,0,0.5); 10 | z-index: 10000; 11 | 12 | /* Трансформации прозрачности при открытии */ 13 | -webkit-transition: opacity 500ms ease-in; 14 | -moz-transition: opacity 500ms ease-in; 15 | transition: opacity 500ms ease-in; 16 | 17 | /* Скрываем изначально */ 18 | opacity: 0; 19 | pointer-events: none; 20 | } 21 | 22 | /* Показываем модальное окно */ 23 | div.modalShow { 24 | opacity: 1; 25 | pointer-events: auto; 26 | } 27 | 28 | /* Окно */ 29 | div.modal-window { 30 | width: 750px; 31 | min-height: 300px; 32 | /* Позиционируем окно посередине */ 33 | position: absolute; 34 | width: 50%; 35 | top: 50%; 36 | left: 50%; 37 | margin: -15% 0 0 -25%; 38 | 39 | /* По умолчанию минимизируем анимацию */ 40 | -webkit-animation: minimise 500ms linear; 41 | 42 | /* Вид */ 43 | background: #fff; 44 | padding: 30px; 45 | -moz-border-radius: 7px; 46 | border-radius: 7px; 47 | -webkit-box-shadow: 0 3px 20px rgba(0,0,0,0.9); 48 | -moz-box-shadow: 0 3px 20px rgba(0,0,0,0.9); 49 | box-shadow: 0 3px 20px rgba(0,0,0,0.9); 50 | background: -moz-linear-gradient(#fff, #ccc); 51 | background: -webkit-gradient(linear, right bottom, right top, color-stop(1, rgb(255,255,255)), color-stop(0.57, rgb(230,230,230))); 52 | text-shadow: 0 1px 0 #fff; 53 | } 54 | 55 | /* Внутренности модалки */ 56 | div.modal-header{ 57 | position: absolute; 58 | top: 0px; 59 | width: 100%; 60 | height: 30px; 61 | padding-top: 5px; 62 | background-image: linear-gradient(to right, transparent 0%, #339cff 100%); 63 | margin-left: -30px; 64 | font-weight: bold; 65 | font-size: 18px; 66 | color: #333; 67 | text-align: center; 68 | text-shadow: 1px 1px 1px rgba(255,255,255,.8); 69 | } 70 | 71 | div.modal-content{ 72 | overflow: auto; 73 | max-height: 510px; 74 | padding-top: 20px; 75 | } 76 | 77 | /* Создаем кнопку Закрыть */ 78 | div.modal span.modal-close { 79 | position: absolute; 80 | right: 0; 81 | top: 0; 82 | color: transparent; 83 | } 84 | 85 | div.modal span.modal-close:after { 86 | content: 'X'; 87 | display: block; 88 | 89 | /* Позиционируем */ 90 | position: absolute; 91 | right: -10px; 92 | top: -10px; 93 | width: 1.5em; 94 | padding: 1px 1px 1px 2px; 95 | 96 | /* Стили */ 97 | text-decoration: none; 98 | text-shadow: none; 99 | text-align: center; 100 | font-weight: bold; 101 | background: #000; 102 | color: #fff; 103 | border: 3px solid #fff; 104 | -moz-border-radius: 20px; 105 | border-radius: 20px; 106 | -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.5); 107 | -moz-box-shadow: 0 1px 3px rgba(0,0,0,0.5); 108 | box-shadow: 0 1px 3px rgba(0,0,0,0.5); 109 | } 110 | 111 | div.modal span.modal-close:focus:after,.modal span.modal-close:hover:after { 112 | -webkit-transform: scale(1.1,1.1); 113 | -moz-transform: scale(1.1,1.1); 114 | } 115 | 116 | div.modal span.modal-close:focus:after { 117 | outline: 1px solid #000; 118 | } 119 | 120 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 5 | */ 6 | require_once("func.php"); 7 | print head(); 8 | 9 | $location="dashboard.php"; 10 | if (!chk_auth()){ 11 | $location="login.php"; 12 | } 13 | print "\n
"; 14 | print ""; 15 | print "
"; 16 | print "
"; 17 | printf("%s%s",(defined('SYSTEM_NAME') && SYSTEM_NAME) ? SYSTEM_NAME : "",(defined('VERSION') && VERSION) ? sprintf(" v%s",VERSION) : ""); 18 | if (defined('CHECK_4_NEW_VERSION') && CHECK_4_NEW_VERSION === true){ 19 | if (chk_auth(0)){ 20 | $check_version=check_version( ); 21 | if (isset($check_version['error'])){ 22 | printf("Проверка наличия новой версии неудалась: %s",implode("; ",$check_version['error'])); 23 | }else{ 24 | if (isset($check_version['version'])){ 25 | printf(":: %s :: ",$check_version['version']); 26 | } 27 | } 28 | } 29 | } 30 | print "
"; 31 | printf("© Меганет-2003, %s%s",date("Y",time()) !="2018" ? "2018-": "",date("Y",time())); 32 | print "
"; 33 | print ""; 34 | 35 | print "\n\n"; 36 | print "
"; 37 | print ""; 45 | print "
"; 46 | print ""; 47 | 48 | print ""; 49 | print "
"; 50 | print "
"; 51 | print "
"; 52 | print ""; 53 | print "
"; 54 | print "
"; 55 | 56 | print "
"; 57 | print "
"; 58 | print "
Заголовок
"; 59 | print "
"; 60 | print ""; 61 | print "
"; 62 | print "
"; 63 | 64 | print "\n\n"; 95 | 96 | print foot(); 97 | 98 | ?> -------------------------------------------------------------------------------- /plugins/login.php: -------------------------------------------------------------------------------- 1 | 5 | */ 6 | $pathinfo = dirname(__FILE__); 7 | require_once(realpath(sprintf("%s/../func.php",$pathinfo))); 8 | $location=preg_replace("/^\//","",$_SERVER['REQUEST_URI']); 9 | //deb("Request: ".print_r($param,true)); 10 | 11 | if (isset($param['data']) && $param['data']){ 12 | $err=array(); 13 | $request_params=get_request_params($param['data']); 14 | if (isset($request_params['error'])){ 15 | $err=$request_params['error']; 16 | }else{ 17 | $param = $request_params['data']; 18 | $param['location'] = $location; 19 | } 20 | 21 | //deb($param); 22 | 23 | if (count($err) == 0){ 24 | if (!defined('AUTH') || !AUTH){ 25 | $err[]="Невозможно невозможно выполнить проверку данных"; 26 | } 27 | if (!isset($param['act']) || !$param['act']){ 28 | $err[]="Действие неизвестно"; 29 | } 30 | } 31 | 32 | if (isset($param['act'])){ 33 | if ($param['act'] =="auth"){ 34 | if (!isset($param['data']) || AUTH != $param['data']){ 35 | $err[]="Неправильный логин или пароль"; 36 | }else{ 37 | $_SESSION['auth'] = "1"; 38 | print "

Добро пожаловать

"; 39 | login_logedin(); 40 | } 41 | }else{ 42 | $err[]=sprintf("Действие%s не найдено",is_developer() ? " ".$param['act'] : ""); 43 | } 44 | } 45 | 46 | if (count($err) > 0){ 47 | print error($err); 48 | unset($param['act']); 49 | print goback($param,array("update"=>"workArea")); 50 | } 51 | }else{ 52 | if (isset($_SESSION['auth']) && $_SESSION['auth'] == 1){ 53 | login_logedin(); 54 | }else{ 55 | print ""; 56 | print ""; 57 | print ""; 58 | print ""; 59 | print ""; 60 | print ""; 61 | print ""; 62 | print ""; 63 | print ""; 64 | print ""; 65 | print ""; 68 | print ""; 69 | print "
Логин
Пароль
"; 66 | print "
Войти
"; 67 | print "
"; 70 | 71 | print ""; 79 | 80 | print "\n\n"; 115 | } 116 | } 117 | 118 | function login_logedin(){ 119 | printf("\n\n",URL); 120 | } 121 | ?> -------------------------------------------------------------------------------- /js/md5.js: -------------------------------------------------------------------------------- 1 | var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ 2 | var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ 3 | function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));} 4 | 5 | function core_md5(x, len){ 6 | x[len >> 5] |= 0x80 << ((len) % 32); 7 | x[(((len + 64) >>> 9) << 4) + 14] = len; 8 | 9 | var a = 1732584193; 10 | var b = -271733879; 11 | var c = -1732584194; 12 | var d = 271733878; 13 | 14 | for(var i = 0; i < x.length; i += 16) 15 | { 16 | var olda = a; 17 | var oldb = b; 18 | var oldc = c; 19 | var oldd = d; 20 | 21 | a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); 22 | d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); 23 | c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); 24 | b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); 25 | a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); 26 | d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); 27 | c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); 28 | b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); 29 | a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); 30 | d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); 31 | c = md5_ff(c, d, a, b, x[i+10], 17, -42063); 32 | b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); 33 | a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); 34 | d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); 35 | c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); 36 | b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); 37 | 38 | a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); 39 | d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); 40 | c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); 41 | b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); 42 | a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); 43 | d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); 44 | c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); 45 | b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); 46 | a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); 47 | d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); 48 | c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); 49 | b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); 50 | a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); 51 | d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); 52 | c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); 53 | b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); 54 | 55 | a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); 56 | d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); 57 | c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); 58 | b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); 59 | a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); 60 | d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); 61 | c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); 62 | b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); 63 | a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); 64 | d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); 65 | c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); 66 | b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); 67 | a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); 68 | d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); 69 | c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); 70 | b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); 71 | 72 | a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); 73 | d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); 74 | c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); 75 | b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); 76 | a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); 77 | d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); 78 | c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); 79 | b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); 80 | a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); 81 | d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); 82 | c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); 83 | b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); 84 | a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); 85 | d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); 86 | c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); 87 | b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); 88 | 89 | a = safe_add(a, olda); 90 | b = safe_add(b, oldb); 91 | c = safe_add(c, oldc); 92 | d = safe_add(d, oldd); 93 | } 94 | return Array(a, b, c, d); 95 | } 96 | function md5_cmn(q, a, b, x, s, t){ 97 | return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); 98 | } 99 | function md5_ff(a, b, c, d, x, s, t){ 100 | return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); 101 | } 102 | function md5_gg(a, b, c, d, x, s, t){ 103 | return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); 104 | } 105 | function md5_hh(a, b, c, d, x, s, t){ 106 | return md5_cmn(b ^ c ^ d, a, b, x, s, t); 107 | } 108 | function md5_ii(a, b, c, d, x, s, t) 109 | { 110 | return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); 111 | } 112 | function safe_add(x, y) 113 | { 114 | var lsw = (x & 0xFFFF) + (y & 0xFFFF); 115 | var msw = (x >> 16) + (y >> 16) + (lsw >> 16); 116 | return (msw << 16) | (lsw & 0xFFFF); 117 | } 118 | function bit_rol(num, cnt) 119 | { 120 | return (num << cnt) | (num >>> (32 - cnt)); 121 | } 122 | function str2binl(str) 123 | { 124 | var bin = Array(); 125 | var mask = (1 << chrsz) - 1; 126 | for(var i = 0; i < str.length * chrsz; i += chrsz) 127 | bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32); 128 | return bin; 129 | } 130 | function binl2hex(binarray) 131 | { 132 | var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; 133 | var str = ""; 134 | for(var i = 0; i < binarray.length * 4; i++) 135 | { 136 | str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + 137 | hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); 138 | } 139 | return str; 140 | } 141 | -------------------------------------------------------------------------------- /plugins/dashboard.php: -------------------------------------------------------------------------------- 1 | 5 | */ 6 | $pathinfo = dirname(__FILE__); 7 | require_once(realpath(sprintf("%s/../func.php",$pathinfo))); 8 | //deb("Request: ".print_r($param,true)); 9 | 10 | if (chk_auth(1)){ 11 | global $services; 12 | $location=preg_replace("/^\//","",$_SERVER['REQUEST_URI']); 13 | 14 | $err=array(); 15 | if (isset($param['data']) && $param['data']){ 16 | $request_params=get_request_params($param['data']); 17 | if (isset($request_params['error'])){ 18 | $err=$request_params['error']; 19 | }else{ 20 | $param = $request_params['data']; 21 | $param['location'] = $location; 22 | } 23 | //deb($param); 24 | 25 | if (count($err) == 0){ 26 | if (!isset($param['act']) || !$param['act']){ 27 | $err[]="Действие неизвестно"; 28 | } 29 | } 30 | 31 | if (count($err) > 0){ 32 | print error($err); 33 | unset($param['act']); 34 | print goback($param,array("update"=>"workArea")); 35 | } 36 | }else{ 37 | $refresh = (int)REFRESH_PAGE; 38 | if ((int)REFRESH_PAGE <= 59){ 39 | $refresh=60; 40 | } 41 | $get_hosts=get_hosts(); 42 | if (isset($get_hosts['error'])){ 43 | $err=$get_hosts['error']; 44 | } 45 | 46 | if (count($err) == 0){ 47 | $hosts_div=array(); 48 | foreach ($get_hosts['hosts'] as $group => $hostsData){ 49 | printf("

Группа %s
найдено хостов: %d

",$group == "z_noname_group" ? "общая" : mb_strtoupper($group),count($hostsData)); 50 | print ""; 51 | print ""; 52 | print ""; 53 | print ""; 54 | print ""; 55 | print ""; 56 | print ""; 57 | print ""; 58 | print ""; 59 | print ""; 60 | print ""; 61 | print ""; 62 | print ""; 63 | print ""; 64 | print ""; 65 | print ""; 66 | print ""; 67 | print ""; 68 | print ""; 69 | print ""; 70 | $nn=1; 71 | foreach($hostsData as $k=>$v){ 72 | $data = isset($v['data']) ? $v['data'] : array(); 73 | 74 | $class = ""; 75 | $poll = isset($data['server']['poll']) ? (int)$data['server']['poll'] : 0; 76 | if (!$poll){ 77 | $class="gray"; 78 | }elseif (time() > ($data['fdate']+$poll*2)){ 79 | $class="warn"; 80 | if (time() > ($data['fdate']+$poll*4)){ 81 | $class="alarm"; 82 | } 83 | } 84 | if ( ( (int)$poll > REFRESH_PAGE ) && ( (int)$refresh > (int)$poll) ){ 85 | $refresh = $poll; 86 | } 87 | 88 | //Host detail div 89 | $host_div=array(); 90 | $host_div[]=sprintf("
",$k); 91 | if (isset($v['error'])){ 92 | $host_div[]=error($v['error']); 93 | }else{ 94 | if (!$poll){ 95 | $host_div[]=error("Таймер обновления данных отсутствует или равен нулю"); 96 | }elseif (time() > ($data['fdate']+$poll*2)){ 97 | $tmp=sprintf("Хост не прислал данных в течение %s секунд",$poll*2); 98 | if (time() > ($data['fdate']+$poll*4)){ 99 | $tmp=sprintf("Хост не прислал данных в течение %s секунд",$poll*4); 100 | } 101 | $host_div[]=error($tmp); 102 | unset($tmp); 103 | } 104 | if(isset($data['services']) && is_array($data['services'])){ 105 | $hs=parse_services($data['services']); 106 | foreach ($services as $sk=>$sv){ 107 | if (isset($hs[$sv['key']])){ 108 | $host_div[]=sprintf("

%s

",$sv['name']); 109 | $host_div[]=$hs[$sv['key']]; 110 | $host_div[]="
"; 111 | } 112 | } 113 | if (is_developer()){ 114 | $host_div[]=sprintf("
DEBUG INFO:\n%s",print_r($data,true)); 115 | } 116 | }else{ 117 | $host_div[]=error("Нет данных по сервисам..."); 118 | if (is_developer()){ 119 | $host_div[]=sprintf("

DEBUG INFO:\n%s",print_r($data,true)); 120 | } 121 | } 122 | } 123 | $host_div[]="
"; 124 | $hosts_div[]=implode("\n",$host_div); 125 | // 126 | 127 | $host_url = ""; 128 | if (isset($data['server']['httpd']) && is_array($data['server']['httpd'])){ 129 | $httpd = $data['server']['httpd']; 130 | if (count($httpd) == 3){ 131 | $host_url=sprintf("", 132 | (isset($httpd['ssl']) && $httpd['ssl']) ? "https" : "http", 133 | (isset($data['server']['credentials']['username']) && $data['server']['credentials']['username']) ? $data['server']['credentials']['username'] : "", 134 | (isset($data['server']['credentials']['password']) && $data['server']['credentials']['password']) ? ":".$data['server']['credentials']['password']."@" : "", 135 | isset($httpd['address']) ? $httpd['address'] : "unknown", 136 | isset($httpd['port']) ? $httpd['port'] : 0 137 | ); 138 | } 139 | } 140 | printf("",$class ? " ".$class : ""); 141 | printf("",$nn++); 142 | $title=sprintf("ID хоста: %s",$k); 143 | printf("",$k,$title,$title,$k,isset($v['name']) ? $v['name'] : "отсутствует",$host_url ? " ".$host_url : ""); 144 | printf("%s",(isset($hs['alarm']) && $hs['alarm'] > 0) ? " class=warn" : "",(isset($hs['alarm']) && $hs['alarm'] >= 0) ? $hs['alarm'] : "n/a"); 145 | printf("",isset($data['fdate']) ? date("d.m.Y H:i:s",$data['fdate']) : "неизвестна"); 146 | 147 | printf("",isset($data['platform']['name']) ? $data['platform']['name'] : "n/a",isset($data['platform']['release']) ? $data['platform']['release'] : "",isset($data['platform']['machine']) ? $data['platform']['machine'] : ""); 148 | printf("",isset($data['platform']['cpu']) ? $data['platform']['cpu'] : "n/a"); 149 | printf("",(isset($data['platform']['memory']) && $data['platform']['memory'] > 0) ? get_bwk($data['platform']['memory']*1024) : "n/a"); 150 | printf("",(isset($data['platform']['swap']) && $data['platform']['swap'] > 0) ? get_bwk($data['platform']['swap']*1024) : "n/a"); 151 | 152 | printf("",$poll ? uptime($poll,"string") : "n/a"); 153 | $title=sprintf("Дата старта monit: %s",isset($data['host_header']['incarnation']) ? date("d.m.Y H:i:s",$data['host_header']['incarnation']) : "неизвестна"); 154 | printf("",$title,$title,(isset($data['server']['uptime']) && $data['server']['uptime'] > 0) ? uptime($data['server']['uptime'],"string") : "n/a"); 155 | printf("",isset($data['host_header']['version']) ? $data['host_header']['version'] : "n/a"); 156 | print ""; 157 | } 158 | print "
#ХостПроблемДата обновленияОписание хостаMonit
OSCPUsMEMSwapИнтервал обновленияUptimeВерсия
%d%s%s%s%s %s %s%s%s%s%s%s%s
"; 159 | print "
"; 160 | } 161 | print implode("\n",$hosts_div); 162 | 163 | //deb($get_hosts); 164 | ?> 165 | 192 | 0){ 196 | print error($err); 197 | } 198 | } 199 | } 200 | 201 | ?> -------------------------------------------------------------------------------- /js/main.js.php: -------------------------------------------------------------------------------- 1 | /* 2 | main js functions 3 | 4 | Copyright (c) Aug 2017 MEGA-NET.RU (Moscow, Russia) 5 | Authors: Panfilov Alexey, Nikolaev Dmitry 6 | */ 7 | 20 | 21 | (function (window) { 22 | window.MONIT||(window.MONIT = {}); 23 | MONIT.url = HOST; 24 | MONIT.mJson = function( obj ){ 25 | if (!MONIT.is_null(obj.request)){ 26 | obj.id = 'workArea'; 27 | } 28 | if (MONIT.is_null(obj.request)){ 29 | obj.request = ''; 30 | } 31 | if (!MONIT.is_null(obj.location)){ 32 | new Request.HTML( { 33 | url: URL+obj.location, 34 | update: obj.id, 35 | onRequest: function( ){ 36 | if( obj.img !== false && !MONIT.is_null($(obj.id))){ 37 | $( obj.id ).empty( ).adopt( 38 | new Element( 'span', { 39 | class: 'icon-loader', 40 | } ) 41 | ); 42 | } 43 | }, 44 | onSuccess: function( ){ 45 | if (typeof obj.onSuccess === 'function'){ 46 | obj.onSuccess(); 47 | } 48 | }, 49 | onFailure: function( err ){ 50 | var error = 'Загрузка '+obj.location+' не удалась: '+err.status + ' '+err.statusText; 51 | MONIT.console({ 52 | level: 'error', 53 | text: error, 54 | informer: true, 55 | obj: err, 56 | }); 57 | $( obj.id ).empty( ).adopt( 58 | new Element( 'div', { 59 | class: 'error', 60 | text: error, 61 | } ) 62 | ); 63 | if (typeof obj.onError === 'function'){ 64 | obj.onError(); 65 | } 66 | } 67 | } ).post( 'data='+MONIT.base64_encode(obj.request) ); 68 | }else{ 69 | var error = 'Запрашиваемый URL неизвестен'; 70 | MONIT.console({ 71 | level: 'error', 72 | text: error, 73 | informer: true, 74 | obj: obj, 75 | }); 76 | $( obj.id ).empty( ).adopt( 77 | new Element( 'div', { 78 | class: 'error', 79 | text: error, 80 | } ) 81 | ); 82 | } 83 | } 84 | 85 | MONIT.is_null = function( obj ){ 86 | if ( obj === undefined ){ 87 | return 1; 88 | }else if ( obj === null ){ 89 | return 1; 90 | }else if ( obj == 0 ){ 91 | return 1; 92 | }else if ( obj == '' ){ 93 | return 1; 94 | } 95 | return 0; 96 | } 97 | 98 | MONIT.console = function( obj ){ 99 | var options = { 100 | level: 'error', 101 | text: 'no text', 102 | informer: false, 103 | obj: '', 104 | } 105 | if( !MONIT.is_null( obj ) && typeof obj == 'object' ){ 106 | if( !MONIT.is_null( obj.level ) ){ 107 | options.level = obj.level; 108 | } 109 | if( !MONIT.is_null( obj.text ) ){ 110 | options.text = obj.text; 111 | } 112 | if( !MONIT.is_null( obj.informer ) ){ 113 | options.informer = obj.informer; 114 | } 115 | if( !MONIT.is_null( obj.obj ) ){ 116 | options.obj = obj.obj; 117 | } 118 | } 119 | if( options.level == 'error' ){ 120 | console.error( options.text, options.obj ); 121 | }else if( options.level == 'warn' ){ 122 | console.warn( options.text, options.obj ); 123 | }else if( options.level == 'info' ){ 124 | console.info( options.text, options.obj ); 125 | }else{ 126 | console.log( options.text, options.obj ); 127 | } 128 | if( !MONIT.is_null( options.informer ) ){ 129 | if( options.level == 'error' ){ 130 | MONIT.show_info( '2', options.text ); 131 | }else{ 132 | MONIT.show_info( '1', options.text ); 133 | } 134 | } 135 | } 136 | 137 | MONIT.show_info = function( type, text ){ 138 | $( 'informer' ).empty( ).timer( ); //Clear old informer text 139 | var set_class='informer_unknown'; 140 | if( type == 1 ){ 141 | set_class = 'informer_good'; 142 | }else if( type == 2 ){ 143 | set_class = 'informer_bad'; 144 | } 145 | 146 | $( 'informer' ).adopt( new Element( 'div#informermess', { 147 | html: decodeURIComponent( text ), 148 | class: 'informer_general ' + set_class, 149 | } ) ); 150 | if (MONIT.is_null($('body').retrieve('scroll'))){ 151 | $('body').store('scroll','0px'); 152 | } 153 | $( 'informer' ).setStyles({position: 'absolute',top: $('body').retrieve('scroll')}); 154 | $( 'informer' ).removeClass( 'hidden' ); 155 | $( 'informer' ).addClass( 'visible' ); 156 | 157 | $( 'informer' ).timer( { 158 | value: 5000, 159 | callback: function( ){ 160 | $( 'informer' ).removeClass( 'visible' ); 161 | $( 'informer' ).addClass( 'hidden' ); 162 | $( 'informer' ).empty( ); 163 | } 164 | } ); 165 | } 166 | 167 | MONIT.base64_encode = function( data ){ 168 | return btoa( data ); 169 | } 170 | 171 | MONIT.base64_decode = function( data ){ 172 | return atob( data ); 173 | } 174 | 175 | MONIT.base64 = { 176 | _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", 177 | encode : function (input) { 178 | var output = ""; 179 | var chr1, chr2, chr3, enc1, enc2, enc3, enc4; 180 | var i = 0; 181 | 182 | input = MONIT.base64._utf8_encode(input); 183 | 184 | while (i < input.length) { 185 | 186 | chr1 = input.charCodeAt(i++); 187 | chr2 = input.charCodeAt(i++); 188 | chr3 = input.charCodeAt(i++); 189 | 190 | enc1 = chr1 >> 2; 191 | enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); 192 | enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); 193 | enc4 = chr3 & 63; 194 | 195 | if (isNaN(chr2)) { 196 | enc3 = enc4 = 64; 197 | } else if (isNaN(chr3)) { 198 | enc4 = 64; 199 | } 200 | 201 | output = output + 202 | MONIT.base64._keyStr.charAt(enc1) + MONIT.base64._keyStr.charAt(enc2) + 203 | MONIT.base64._keyStr.charAt(enc3) + MONIT.base64._keyStr.charAt(enc4); 204 | 205 | } 206 | return output; 207 | }, 208 | decode : function (input) { 209 | var output = ""; 210 | var chr1, chr2, chr3; 211 | var enc1, enc2, enc3, enc4; 212 | var i = 0; 213 | input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); 214 | while (i < input.length) { 215 | enc1 = MONIT.base64._keyStr.indexOf(input.charAt(i++)); 216 | enc2 = MONIT.base64._keyStr.indexOf(input.charAt(i++)); 217 | enc3 = MONIT.base64._keyStr.indexOf(input.charAt(i++)); 218 | enc4 = MONIT.base64._keyStr.indexOf(input.charAt(i++)); 219 | 220 | chr1 = (enc1 << 2) | (enc2 >> 4); 221 | chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); 222 | chr3 = ((enc3 & 3) << 6) | enc4; 223 | output = output + String.fromCharCode(chr1); 224 | if (enc3 != 64) { 225 | output = output + String.fromCharCode(chr2); 226 | } 227 | if (enc4 != 64) { 228 | output = output + String.fromCharCode(chr3); 229 | } 230 | } 231 | output = MONIT.base64._utf8_decode(output); 232 | return output; 233 | }, 234 | _utf8_encode : function (string) { 235 | string = string.replace(/\r\n/g,"\n"); 236 | var utftext = ""; 237 | for (var n = 0; n < string.length; n++) { 238 | var c = string.charCodeAt(n); 239 | if (c < 128) { 240 | utftext += String.fromCharCode(c); 241 | }else if((c > 127) && (c < 2048)) { 242 | utftext += String.fromCharCode((c >> 6) | 192); 243 | utftext += String.fromCharCode((c & 63) | 128); 244 | }else { 245 | utftext += String.fromCharCode((c >> 12) | 224); 246 | utftext += String.fromCharCode(((c >> 6) & 63) | 128); 247 | utftext += String.fromCharCode((c & 63) | 128); 248 | } 249 | } 250 | return utftext; 251 | }, 252 | _utf8_decode : function (utftext) { 253 | var string = ""; 254 | var i = 0; 255 | var c = c1 = c2 = 0; 256 | while ( i < utftext.length ) { 257 | c = utftext.charCodeAt(i); 258 | if (c < 128) { 259 | string += String.fromCharCode(c); 260 | i++; 261 | }else if((c > 191) && (c < 224)) { 262 | c2 = utftext.charCodeAt(i+1); 263 | string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); 264 | i += 2; 265 | }else { 266 | c2 = utftext.charCodeAt(i+1); 267 | c3 = utftext.charCodeAt(i+2); 268 | string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); 269 | i += 3; 270 | } 271 | } 272 | return string; 273 | } 274 | } 275 | 276 | MONIT.addMenuClick = function( obj ){ 277 | if (!MONIT.is_null(obj.id)){ 278 | Array.each($$('#'+obj.id+' li'), function( v, i ){ 279 | if (v.hasClass('menuBtn')){ 280 | v.removeEvent( 'click', MONIT.menuClick ); 281 | v.addEvent( 'click', MONIT.menuClick ); 282 | } 283 | }); 284 | } 285 | return false; 286 | } 287 | 288 | MONIT.menuClick = function( el ){ 289 | if (!MONIT.is_null($('customMessage'))){ 290 | $('customMessage').empty(); 291 | } 292 | el.preventDefault(); //Prevent default action: go to URL 293 | var ul = el.target.getParent('ul'); 294 | Array.each($$('#'+ul.id+' li a'), function( v, i ){ 295 | v.removeClass('active'); 296 | }); 297 | if (!MONIT.is_null(this.getChildren('a')[0])){ 298 | this.getChildren('a')[0].addClass('active'); 299 | } 300 | if(!MONIT.is_null(this.getChildren('a')[0])){ 301 | var request, location = ''; 302 | if (!MONIT.is_null(this.getChildren('a')[0]) && !MONIT.is_null(this.getChildren('a')[0].href.split('?')[1])){ 303 | location = this.getChildren('a')[0].href.split('?')[1].replace('location=',''); 304 | } 305 | if (!MONIT.is_null(this.getChildren('a')[0].get('data-request'))){ 306 | if (!MONIT.is_null(request)){ 307 | request += '&'; 308 | } 309 | request += this.getChildren('a')[0].get('data-request'); 310 | } 311 | MONIT.mJson({ 312 | id: MONIT.is_null(ul.get('data-update')) ? 'workArea' : ul.get('data-update'), 313 | location: location, 314 | request: request, 315 | }); 316 | } 317 | return false; 318 | } 319 | 320 | MONIT.submitButtonDelay = function( id ){ 321 | if (!MONIT.is_null(id)){ 322 | $(id).disabled=true; 323 | setTimeout(function(){$(id).disabled=false;},2000); 324 | } 325 | } 326 | 327 | MONIT.openModal = function (){ 328 | if (!MONIT.is_null($('modal'))){ 329 | $('modal').removeClass('hidden'); 330 | if (MONIT.is_null($('modalDiv').hasClass('modalShow'))){ 331 | $('modalDiv').addClass('modalShow'); 332 | } 333 | }else{ 334 | MONIT.console({type: 'error', text: 'openModal: modal div not found'}); 335 | } 336 | } 337 | 338 | MONIT.closeModal = function(){ 339 | if (!MONIT.is_null($('modal'))){ 340 | if (MONIT.is_null($('modal').hasClass('hidden'))){ 341 | $('modal').addClass('hidden'); 342 | $('modalDiv').removeClass('modalShow'); 343 | $('modalHeader').empty(); 344 | $('modalContent').empty(); 345 | } 346 | }else{ 347 | MONIT.console({type: 'error', text: 'closeModal: modal div not found'}); 348 | } 349 | } 350 | 351 | MONIT.collector_check_4_errors = function( timer ){ 352 | MONIT.console({ level: 'info', text: 'Check collector errors every ' + timer + ' seconds'}); 353 | MONIT.mJson({ 354 | id: 'collector_check', 355 | location: 'plugins/collector_check.php', 356 | }); 357 | } 358 | }(this)); 359 | 360 | if( typeof Element.prototype.timer === "undefined" ){ 361 | Element.prototype.timer = function( arg ){ 362 | var self = this; 363 | if( arg === undefined ){ 364 | clearTimer( ); 365 | }else if( typeof arg == 'object' ){ 366 | if( /^\d+$/.test( arg.value ) ){ 367 | if( arg.value === undefined || arg.value == 0 ){ 368 | if( self.retrieve( 'timeoutId' ) !== undefined ){ 369 | clearTimer( ); 370 | } 371 | }else{ 372 | if( typeof arg.callback == 'function' ){ 373 | if( self.retrieve( 'timeoutId' ) !== undefined ){ 374 | clearTimer( ); 375 | } 376 | self.getParent( ).addEventListener( 'DOMNodeRemoved', onElementDestroy, false ); 377 | if( arg.debug ){ 378 | console.log( 'Set timeout: ' + arg.callback + '): ' + arg.value ); 379 | } 380 | self.store( 'timeoutId', setTimeout( function( ){ 381 | clearTimer( ); 382 | arg.callback( arg.arg ); 383 | }, arg.value ) ); 384 | } 385 | } 386 | } 387 | } 388 | 389 | function clearTimer( ){ 390 | if( self.retrieve( 'timeoutId' ) !== null ){ 391 | clearTimeout( self.retrieve( 'timeoutId' ) ); 392 | } 393 | if( self.getParent( ) ){ 394 | self.getParent( ).removeEventListener( 'DOMNodeRemoved', onElementDestroy, false ); 395 | } 396 | self.eliminate( 'timeoutId' ); 397 | } 398 | 399 | function onElementDestroy( e ){ 400 | if( arg.debug ){ 401 | console.log( 'Destroy: ', e ); 402 | } 403 | if( e.target.id == self.id ){ 404 | if( arg.debug ){ 405 | console.log( 'clear timer for self: id ' + e.target.id ); 406 | } 407 | clearTimer( self ); 408 | } 409 | } 410 | return self; 411 | } 412 | } 413 | -------------------------------------------------------------------------------- /css/monit.css: -------------------------------------------------------------------------------- 1 | html, body, div, span, applet, object, iframe, 2 | p, blockquote, pre, 3 | a, abbr, acronym, address, big, cite, code, 4 | del, dfn, em, img, ins, kbd, q, s, samp, 5 | small, strike, strong, sub, sup, tt, var, 6 | b, u, i, center, 7 | dl, dt, dd, ol, ul, li, 8 | fieldset, form, label, legend, 9 | table, caption, tbody, tfoot, thead, tr, th, td, 10 | article, aside, canvas, details, embed, 11 | figure, figcaption, footer, header, hgroup, 12 | menu, nav, output, ruby, section, summary, 13 | time, mark, audio, video { 14 | font-size: 14px; 15 | } 16 | 17 | body { 18 | background-color: #339cff; 19 | } 20 | 21 | h1, h2, h3, h4, h5, h6{ 22 | margin: 5px; 23 | padding: 0; 24 | border: 0; 25 | vertical-align: baseline; 26 | } 27 | 28 | ::-webkit-scrollbar { 29 | width: 5px; 30 | } 31 | ::-webkit-scrollbar-track { 32 | -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); 33 | border-radius: 10px; 34 | -webkit-border-radius: 10px; /*Google Chrome*/ 35 | -moz-border-radius: 10px; /*FireFox*/ 36 | -khtml-border-radius: 10px; /*Safari*/ 37 | } 38 | ::-webkit-scrollbar-thumb { 39 | -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); 40 | border-radius: 10px; 41 | -webkit-border-radius: 10px; /*Google Chrome*/ 42 | -moz-border-radius: 10px; /*FireFox*/ 43 | -khtml-border-radius: 10px; /*Safari*/ 44 | } 45 | 46 | div { 47 | display: block; 48 | } 49 | 50 | select:disabled { 51 | color:#888; 52 | } 53 | select { 54 | display: inline-block; 55 | padding: 3px; 56 | margin: 3px; 57 | border-radius:4px; 58 | -webkit-border-radius: 4px; /*Google Chrome*/ 59 | -moz-border-radius: 4px; /*FireFox*/ 60 | -khtml-border-radius: 4px; /*Safari*/ 61 | -webkit-box-shadow: 0 3px 0 #ccc, 0 -1px #fff inset; 62 | -moz-box-shadow: 0 3px 0 #ccc, 0 -1px #fff inset; 63 | box-shadow: 0 3px 0 #ccc, 0 -1px #fff inset; 64 | background: #e6e6e6; 65 | border: 1px solid #339cff; 66 | outline:none; 67 | font-size: 10px; 68 | } 69 | 70 | .no_shadow{ 71 | -webkit-box-shadow: none; 72 | -moz-box-shadow: none; 73 | box-shadow: none; 74 | } 75 | 76 | a:link { 77 | color: blue; 78 | } 79 | a:active, a:hover{ 80 | color: #2dc8d2; 81 | } 82 | a:visited { 83 | color: #2dc8d2; 84 | } 85 | a { 86 | color: black; 87 | text-decoration: none; 88 | } 89 | a.click { 90 | border-bottom: 1px dashed; 91 | } 92 | a.click:hover { 93 | border-bottom: 1px solid; 94 | } 95 | 96 | span.copyright{ 97 | float: right; 98 | margin-top: 4px; 99 | margin-right: 20px; 100 | font-size: 9px; 101 | } 102 | span.copyright > a { 103 | text-decoration: none; 104 | color: inherit; 105 | font-size: 11px; 106 | } 107 | span.new_version > a:visited{ 108 | color: red; 109 | font-weight: bold; 110 | cursor: pointer; 111 | } 112 | span#version{ 113 | float: left; 114 | cursor: pointer; 115 | } 116 | 117 | button:active, button:focus { 118 | outline: none; 119 | } 120 | 121 | small { 122 | font-size: 80%; 123 | } 124 | 125 | hr{ 126 | border: 1px black dotted; 127 | margin: 10px 20px 10px 20px; 128 | } 129 | 130 | ul { 131 | padding-left: 20px; 132 | margin: 10px; 133 | } 134 | ul.tabs{ 135 | padding-left: 0; 136 | margin: 0; 137 | } 138 | ul.spisok { 139 | margin-left: 20px; 140 | font-family: Arial,sans-serif; 141 | text-align: left; 142 | } 143 | ul.spisok li ul { 144 | margin-left: 40px; 145 | } 146 | 147 | table { 148 | width: 100%; 149 | display: table; 150 | border-collapse: separate; 151 | border-spacing: 2px; 152 | } 153 | th, td.head { 154 | color: #fff; 155 | background-color: #339cff; 156 | border: 1px solid black; 157 | padding: 3px; 158 | font-size: 16px; 159 | white-space: nowrap; 160 | } 161 | 162 | tr.gray, td.gray{ 163 | background-color: #dbdada; 164 | } 165 | 166 | tr.warn, td.warn { 167 | background-color: #e4cf69; 168 | } 169 | 170 | tr.alarm, td.alarm, span.alarm { 171 | color: red; 172 | } 173 | 174 | td { 175 | padding: 5px; 176 | border: 1px solid grey; 177 | white-space: normal; 178 | font-size: 12px; 179 | } 180 | 181 | td > span { 182 | font-size: inherit; 183 | } 184 | 185 | td.nb{ 186 | border: none; 187 | } 188 | 189 | td.warn { 190 | background-color: #e4cf69; 191 | } 192 | 193 | tr.center,td.center { 194 | text-align: center; 195 | vertical-align: middle; 196 | } 197 | 198 | 199 | div#content{ 200 | width: 100%; 201 | heigth: 100%; 202 | } 203 | 204 | div#centerArea{ 205 | margin-left: 65px; 206 | } 207 | 208 | div#header{ 209 | height: 15px; 210 | margin-left: 65px; 211 | padding: 5px; 212 | text-align: center; 213 | color: #fff; 214 | font-weight: bold; 215 | font-style: italic; 216 | border-bottom: 1px solid #fff; 217 | border-radius: 10px; 218 | 219 | -webkit-border-radius: 10px; /*Google Chrome*/ 220 | -moz-border-radius: 10px; /*FireFox*/ 221 | -khtml-border-radius: 10px; /*Safari*/ 222 | } 223 | 224 | div#dashboard{ 225 | margin: 10px; 226 | } 227 | /* --- Main menu --- */ 228 | div#mainMenu{ 229 | background: #ddf0f0; 230 | width: 60px; 231 | position: fixed; 232 | z-index: 110; 233 | top: 0; 234 | bottom: 0; 235 | left: 0; 236 | -webkit-transform: translateZ(0); 237 | -webkit-user-select: none; 238 | -moz-user-select: none; 239 | -ms-user-select: none; 240 | user-select: none; 241 | overflow-x: hidden; 242 | overflow-y: auto; 243 | } 244 | 245 | ul.tabs li { 246 | float: left; 247 | width: 57px; 248 | height: 45px; 249 | margin: 15px 0px; 250 | list-style-type: none; 251 | } 252 | 253 | ul.tabs li a { 254 | display: block; 255 | width: 100%; 256 | height: 100%; 257 | background-position: 0 0; 258 | background-repeat: no-repeat; 259 | } 260 | 261 | ul.tabs li a:hover, ul.tabs li a.active { 262 | background-position: 0 -45px; 263 | text-decoration: none; 264 | color: #339cff; 265 | } 266 | 267 | ul.tabs li span { 268 | position: relative; 269 | top: 45px; 270 | display: block; 271 | visibility: visible; 272 | font-size: 10px; 273 | text-align: center; 274 | text-decoration: none; 275 | } 276 | 277 | ul.tabs li a:hover span { 278 | font-weight: bold; 279 | } 280 | 281 | ul.tabs li a.active span { 282 | font-weight: bold; 283 | } 284 | ul.tabs li.exit a { 285 | margin-top: 25px; 286 | background-image: url(../img/exit.png); 287 | } 288 | 289 | /* ------------------- */ 290 | div#workArea{ 291 | min-width: 90%; 292 | min-height: 95%; 293 | overflow: auto; 294 | background-color: #ddf0f0; 295 | margin-top: 5px; 296 | padding: 5px; 297 | border-radius: 10px; 298 | -webkit-border-radius: 10px; /*Google Chrome*/ 299 | -moz-border-radius: 10px; /*FireFox*/ 300 | -khtml-border-radius: 10px; /*Safari*/ 301 | } 302 | 303 | div.error { 304 | border: 1px solid red; 305 | display: inline-block; 306 | padding: 10px; 307 | color: red; 308 | } 309 | 310 | div.error ul { 311 | margin-left: 15px; 312 | } 313 | 314 | div.content{ 315 | padding-left: 10px; 316 | margin: 10px; 317 | } 318 | 319 | /* ----- ICONS ---- */ 320 | span.icon-loader{ 321 | border: 0; 322 | background: url(../img/ajax-loader.gif) no-repeat; 323 | width: 32px; 324 | height: 32px; 325 | display: block; 326 | #margin: auto; 327 | position: absolute; 328 | top: 50%; 329 | margin-left: 50%; 330 | } 331 | 332 | span.icon-del:hover{ 333 | background-position: 0 -25px; 334 | } 335 | span.icon-del{ 336 | background: url(../img/butn-del.png) no-repeat; 337 | display: inline-block; 338 | width: 14px; 339 | height: 14px; 340 | vertical-align: middle; 341 | margin-left: 5px; 342 | cursor: pointer; 343 | } 344 | span.icon-edit:hover{ 345 | background-position: 0 -25px; 346 | } 347 | span.icon-edit{ 348 | background: url(../img/butn-edit.png) no-repeat; 349 | display: inline-block; 350 | width: 14px; 351 | height: 14px; 352 | vertical-align: middle; 353 | margin-left: 5px; 354 | cursor: pointer; 355 | } 356 | span.icon-info{ 357 | background: url(../img/icon-info.gif) no-repeat; 358 | display: inline-block; 359 | height: 12px; 360 | width: 12px; 361 | vertical-align: middle; 362 | cursor: pointer; 363 | } 364 | span.icon-globus{ 365 | background: url(../img/globus.png) no-repeat; 366 | display: inline-block; 367 | height: 16px; 368 | width: 16px; 369 | vertical-align: middle; 370 | cursor: pointer; 371 | } 372 | 373 | /* -------------------- */ 374 | 375 | div.buttons { font-size: 5px; margin: 20px 0; white-space: nowrap; } 376 | .button-main { 377 | min-width: 140px; 378 | display: inline-block; 379 | cursor: pointer; 380 | font: 14px Jura,sans-serif; 381 | font-weight: bold; 382 | } 383 | .button-save { 384 | background: #a4cc63; 385 | padding: 5px 10px; 386 | color: #5a7c27; 387 | border-radius: 20px 0 0 20px; 388 | -webkit-border-radius: 20px 0 0 20px; /*Google Chrome*/ 389 | -moz-border-radius: 20px 0 0 20px; /*FireFox*/ 390 | -khtml-border-radius: 20px 0 0 20px; /*Safari*/ 391 | } 392 | .button-cancel { 393 | background: #ffa000; 394 | padding: 5px 10px; 395 | color: #fff; 396 | border-radius: 0 20px 20px 0; 397 | -webkit-border-radius: 0 20px 20px 0; /*Google Chrome*/ 398 | -moz-border-radius: 0 20px 20px 0; /*FireFox*/ 399 | -khtml-border-radius: 0 20px 20px 0; /*Safari*/ 400 | } 401 | .button-center { 402 | background: #D6CF0C; 403 | padding: 5px 10px; 404 | color: #5a7c27; 405 | border-radius: 0px; 406 | -webkit-border-radius: 0px; /*Google Chrome*/ 407 | -moz-border-radius: 0px; /*FireFox*/ 408 | -khtml-border-radius: 0px; /*Safari*/ 409 | } 410 | 411 | .button-disabled { cursor: not-allowed; } 412 | 413 | .button-rad { 414 | border-radius: 20px; 415 | -webkit-border-radius: 20px; /*Google Chrome*/ 416 | -moz-border-radius: 20px; /*FireFox*/ 417 | -khtml-border-radius: 20px; /*Safari*/ 418 | } 419 | .button-small { 420 | border-radius: 20px; 421 | -webkit-border-radius: 20px; /*Google Chrome*/ 422 | -moz-border-radius: 20px; /*FireFox*/ 423 | -khtml-border-radius: 20px; /*Safari*/ 424 | font-size: 10px; 425 | background-color: lightgray; 426 | } 427 | div.button { 428 | display: inline-block; 429 | padding: 3px 10px; 430 | cursor: pointer; 431 | box-shadow: 0 3px #999; 432 | } 433 | div.button:active { 434 | box-shadow: 0 3px #666; 435 | transform: translateY(1px); 436 | } 437 | .btn-group-vertical.updown { 438 | position: fixed; 439 | right: 5px; 440 | top: 310px; 441 | z-index: 1001; 442 | opacity: 0.8; 443 | } 444 | .btn-group-vertical.updown button { 445 | width: 29px; 446 | font: 12px arial; 447 | text-align: center; 448 | height: 60px; 449 | background-color: #fff; 450 | } 451 | .btn-group-vertical>.btn,.btn-group-vertical>.btn-group{display:block;float:none;width:100%;max-width:100%;} 452 | .btn-group-vertical>.btn-group:before,.btn-group-vertical>.btn-group:after{content:" ";display:table;} 453 | .btn-group-vertical>.btn-group:after{clear:both;} 454 | .btn-group-vertical>.btn-group:before,.btn-group-vertical>.btn-group:after{content:" ";display:table;} 455 | .btn-group-vertical>.btn-group:after{clear:both;} 456 | .btn-group-vertical>.btn-group>.btn{float:none;} 457 | .btn-group-vertical>.btn+.btn,.btn-group-vertical>.btn+.btn-group,.btn-group-vertical>.btn-group+.btn,.btn-group-vertical>.btn-group+.btn-group{margin-top:-1px;margin-left:0;} 458 | .btn-group-vertical>.btn:not(:first-child):not(:last-child){border-radius:0;} 459 | .btn-group-vertical>.btn:first-child:not(:last-child){ 460 | border-top-right-radius:10px; 461 | border-top-left-radius: 10px; 462 | border-bottom-right-radius:0; 463 | border-bottom-left-radius:0; 464 | background-position-x: -27px; 465 | background-position-y: 10px; 466 | background-repeat: no-repeat; 467 | background-size: 50px; 468 | background-image: url(../img/up_down_arrow.png) 469 | } 470 | .btn-group-vertical>.btn:last-child:not(:first-child){ 471 | border-bottom-right-radius: 10px; 472 | border-bottom-left-radius: 10px; 473 | border-top-right-radius:0; 474 | border-top-left-radius:0; 475 | background-position-x: 2px; 476 | background-position-y: 12px; 477 | background-repeat: no-repeat; 478 | background-size: 50px; 479 | background-image: url(../img/up_down_arrow.png); 480 | } 481 | .btn-group-vertical>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0;} 482 | .btn-group-vertical>.btn-group:first-child>.btn:last-child,.btn-group-vertical>.btn-group:first-child>.dropdown-toggle{border-bottom-right-radius:0;border-bottom-left-radius:0;} 483 | .btn-group-vertical>.btn-group:last-child>.btn:first-child{border-top-right-radius:0;border-top-left-radius:0;} 484 | .btn-group-justified{display:table;width:100%;table-layout:fixed;border-collapse:separate;}.btn-group-justified .btn{float:none;display:table-cell;width:1%;} 485 | 486 | /* ---- REQUIRED FIELDS ---- */ 487 | input.required { 488 | border: 1px solid red; 489 | } 490 | textarea.required { 491 | border: 1px solid red; 492 | } 493 | select.required { 494 | border: 1px solid red; 495 | } 496 | /* ----- INFORMER ----- */ 497 | div.informer { 498 | z-index: 20000; 499 | background: #ffffff; 500 | border: 1px solid #aaa; 501 | color: black; 502 | } 503 | 504 | div.informer_general { 505 | font-family: sans-serif, arial, helvetica; 506 | font-style: italic; 507 | font-size: 14px; 508 | padding: 15px 20px 10px 20px; /*top right bottom left*/ 509 | font-weight: bold; 510 | text-align: left; 511 | } 512 | 513 | div.informer_good { 514 | background: url(../img/true.png) 8px 5px no-repeat; 515 | background-color: #dfffdf; 516 | border-color: #9fcf9f; 517 | color: #005f00; 518 | } 519 | 520 | div.informer_bad { 521 | color: #dd0000; 522 | } 523 | 524 | div.informer_unknown { 525 | color: #000080; 526 | } 527 | 528 | /* ------VALIDATOR---------------- */ 529 | div.validation-advice { 530 | color: red; 531 | font-style: italic; 532 | font-size: 12px; 533 | } 534 | /* ------------------------- */ 535 | .hidden{ 536 | display: none; 537 | visibility: hidden; 538 | } 539 | 540 | .visible{ 541 | display: block; 542 | visibility: visible; 543 | } 544 | .display-center{ 545 | display: flex; 546 | justify-content: center; 547 | } 548 | .text-left{ 549 | text-align: left; 550 | } 551 | .text-center{ 552 | text-align: center; 553 | } 554 | .text-right{ 555 | text-align: right; 556 | } 557 | .border-radius-left{ 558 | border-top-left-radius: 3px; 559 | border-bottom-left-radius: 3px; 560 | } 561 | .border-radius-right{ 562 | border-top-right-radius: 3px; 563 | border-bottom-right-radius: 3px; 564 | } 565 | .italic{ 566 | font-style: italic; 567 | } 568 | .click{ 569 | cursor: pointer; 570 | } 571 | .center{ 572 | text-align: center; 573 | } 574 | .bold{ 575 | font-weight: bold; 576 | } 577 | span.click{ 578 | border-bottom: 1px dashed #89b3c7; 579 | } 580 | span.click:hover{ 581 | border-bottom: 1px solid #89b3c7; 582 | color: blue; 583 | } 584 | .font14{ 585 | font-size: 14px; 586 | } 587 | /* ------------------------- */ 588 | 589 | 590 | .headerList{ 591 | padding:5px 0 3px 10px; 592 | vertical-align:middle; 593 | border-bottom:2px solid; 594 | color:#444; 595 | border-top-color:#0046ad; 596 | border-bottom-color:#abc3d7; 597 | background-color:#f4f9fc; 598 | } 599 | div.line { 600 | height: 2px; 601 | border-bottom: 2px solid #0046ad; 602 | background-color: #339cff; 603 | } 604 | 605 | span.vertical-line{ 606 | border-color: #CBDAE6; 607 | margin-left: 5px; 608 | margin-right: 5px; 609 | } 610 | span.vertical-line-right{ 611 | border-right: 1px solid; 612 | } 613 | span.vertical-line-left{ 614 | border-left: 1px solid; 615 | } 616 | 617 | span.info{ 618 | font-style: italic; 619 | } 620 | /* --------------- */ 621 | 622 | .row { 623 | margin-right: -15px; 624 | margin-left: -15px; 625 | } 626 | 627 | .row:before, 628 | .row:after { 629 | display: table; 630 | content: " "; 631 | } 632 | 633 | .row:after { 634 | clear: both; 635 | } 636 | 637 | .row:before, 638 | .row:after { 639 | display: table; 640 | content: " "; 641 | } 642 | 643 | .row:after { 644 | clear: both; 645 | } 646 | .col-md-7 { 647 | position: relative; 648 | min-height: 1px; 649 | padding-right: 15px; 650 | padding-left: 15px; 651 | } 652 | 653 | .text-muted { 654 | color: #999999; 655 | } 656 | 657 | /* Featurettes 658 | ------------------------- */ 659 | 660 | .featurette-divider { 661 | margin: 30px 0; /* Space out the Bootstrap
more */ 662 | } 663 | 664 | /* Thin out the marketing headings */ 665 | .featurette-heading { 666 | font-weight: 300; 667 | line-height: 1; 668 | letter-spacing: -1px; 669 | } 670 | 671 | code { 672 | white-space: pre-wrap; 673 | color: #046d32; 674 | background-color: #e8e8e8; 675 | font-family: monospace; 676 | max-height: 300px; 677 | overflow: auto; 678 | display: block; 679 | font-size: smaller; 680 | border: 1px solid white; 681 | padding: 6px; 682 | } 683 | 684 | .btn { 685 | display: inline-block; 686 | padding: 6px 12px; 687 | margin-bottom: 0; 688 | font-size: 14px; 689 | font-weight: normal; 690 | line-height: 1.428571429; 691 | text-align: center; 692 | white-space: nowrap; 693 | vertical-align: middle; 694 | cursor: pointer; 695 | background-image: none; 696 | border: 1px solid transparent; 697 | border-radius: 4px; 698 | -webkit-user-select: none; 699 | -moz-user-select: none; 700 | -ms-user-select: none; 701 | -o-user-select: none; 702 | user-select: none; 703 | } 704 | 705 | .btn:focus { 706 | outline: thin dotted; 707 | outline: 5px auto -webkit-focus-ring-color; 708 | outline-offset: -2px; 709 | } 710 | 711 | .btn:hover, 712 | .btn:focus { 713 | color: #333333; 714 | text-decoration: none; 715 | } 716 | 717 | .btn:active, 718 | .btn.active { 719 | background-image: none; 720 | outline: 0; 721 | -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); 722 | box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); 723 | } 724 | 725 | .btn.disabled, 726 | .btn[disabled], 727 | fieldset[disabled] .btn { 728 | pointer-events: none; 729 | cursor: not-allowed; 730 | opacity: 0.65; 731 | filter: alpha(opacity=65); 732 | -webkit-box-shadow: none; 733 | box-shadow: none; 734 | } 735 | 736 | .btn-primary { 737 | color: #ffffff; 738 | background-color: #428bca; 739 | border-color: #357ebd; 740 | } 741 | 742 | .btn-primary:hover, 743 | .btn-primary:focus, 744 | .btn-primary:active, 745 | .btn-primary.active, 746 | .open .dropdown-toggle.btn-primary { 747 | color: #ffffff; 748 | background-color: #3276b1; 749 | border-color: #285e8e; 750 | } 751 | 752 | .btn-primary:active, 753 | .btn-primary.active, 754 | .open .dropdown-toggle.btn-primary { 755 | background-image: none; 756 | } 757 | 758 | .btn-primary.disabled, 759 | .btn-primary[disabled], 760 | .btn-primary.disabled:hover, 761 | .btn-primary[disabled]:hover, 762 | .btn-primary.disabled:focus, 763 | .btn-primary[disabled]:focus, 764 | .btn-primary.disabled:active, 765 | .btn-primary[disabled]:active, 766 | .btn-primary.disabled.active, 767 | .btn-primary[disabled].active, 768 | background-color: #428bca; 769 | border-color: #357ebd; 770 | } 771 | 772 | .btn-primary .badge { 773 | color: #428bca; 774 | background-color: #fff; 775 | } 776 | .btn-lg { 777 | padding: 10px 16px; 778 | font-size: 18px; 779 | line-height: 1.33; 780 | border-radius: 6px; 781 | } 782 | 783 | div.success_div, 784 | div.error_div, 785 | div.commonInfoDiv { 786 | margin: 10px 30px 10px 30px; 787 | min-width: 300px; 788 | -webkit-border-radius:5px; 789 | border-radius:5px; 790 | padding:0 40px 20px 40px; 791 | text-align:left; 792 | -webkit-box-sizing:border-box; 793 | -moz-box-sizing:border-box; 794 | box-sizing:border-box; 795 | -webkit-box-shadow:4px 4px 15px 0px #dce6f0,-4px -4px 15px 0px #dce6f0; 796 | -moz-box-shadow:4px 4px 15px 0px #dce6f0,-4px -4px 15px 0px #dce6f0; 797 | box-shadow:4px 4px 15px 0px #dce6f0,-4px -4px 15px 0px #dce6f0 798 | } 799 | 800 | div.success_div{ 801 | color: #fff; 802 | padding-top: 10px; 803 | font-family: sans-serif, arial, helvetica; 804 | font-style: italic; 805 | font-size: 14px; 806 | } 807 | div.error_div{ 808 | color: red; 809 | border: 1px solid red; 810 | background:#FFF; 811 | padding-top: 10px; 812 | } 813 | 814 | sup { 815 | color: red; 816 | } 817 | sup + span{ 818 | font-style: italic; 819 | font-size: smaller; 820 | } 821 | 822 | ol.e-bar{ 823 | display: block; 824 | list-style-type: decimal; 825 | -webkit-margin-before: 1em; 826 | -webkit-margin-after: 1em; 827 | -webkit-margin-start: 0px; 828 | -webkit-margin-end: 0px; 829 | -webkit-padding-start: 40px; 830 | padding:0; 831 | text-align:center; 832 | text-transform:uppercase; 833 | font-family:monospace; 834 | font-size:1.2em; 835 | line-height:1em; 836 | } 837 | ol.e-bar li{ 838 | list-style:none; 839 | display:inline; 840 | margin-left: 5px; 841 | } 842 | ol.e-bar span,.e-bar a{ 843 | display:inline-block; 844 | padding:.3em .4em; 845 | border:1px solid #a08c6e; 846 | margin:0 .1em; 847 | } 848 | ol.e-bar li.big{ 849 | font-weight:bold; 850 | vertical-align:top; 851 | } 852 | ol.e-bar a{ 853 | background:#dbdada; 854 | } 855 | ol.e-bar a:not(:hover){ 856 | text-decoration:none; 857 | } 858 | ol.e-bar a:hover,ol.e-bar a.active{ 859 | background:#f4f9fc; 860 | cursor: pointer; 861 | } 862 | 863 | code.developer{ 864 | overflow: auto; 865 | white-space: pre-wrap; 866 | max-height: 300px; 867 | width: 100%; 868 | } 869 | code.developer > pre { 870 | font-size: 10px; 871 | 872 | } 873 | 874 | .tbl_login{ 875 | width: 400px; 876 | height: 155px; 877 | margin-left: auto; 878 | margin-right: auto; 879 | margin-top: 150px; 880 | } 881 | 882 | table.tbl_login tbody td { 883 | padding: 10px; 884 | border: none; 885 | } 886 | 887 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /func.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | set_error_handler("exception_error_handler"); 9 | 10 | $err=array(); 11 | $const=dirname(__FILE__)."/config.php"; 12 | if (is_file($const)){ 13 | if (is_readable($const)){ 14 | if (!require_once($const)){ 15 | $err[]="CONFIG file required"; 16 | } 17 | }else{ 18 | $err[]="Can`t read CONFIG file"; 19 | } 20 | }else{ 21 | $err[]="CONFIG file don`t exists"; 22 | } 23 | 24 | $const=dirname(__FILE__)."/const.php"; 25 | if (is_file($const)){ 26 | if (is_readable($const)){ 27 | if (!require_once($const)){ 28 | $err[]="CONST file required"; 29 | } 30 | }else{ 31 | $err[]="Can`t read CONST file"; 32 | } 33 | }else{ 34 | $err[]="CONST file don`t exists"; 35 | } 36 | 37 | if (count($err) == 0){ 38 | if (!defined('LOC') || !LOC){ 39 | $err[]=sprintf("Расположение файлов проекта неизвестно%s",is_developer() ? sprintf(" (file: %s, line: %s)",__FILE__,__LINE__) : ""); 40 | }else{ 41 | if (!is_dir(LOC)){ 42 | $err[]=sprintf("Директория с файлами проекта не нейдена%s",is_developer() ? sprintf(" (file: %s, line: %s)",__FILE__,__LINE__) : ""); 43 | } 44 | } 45 | } 46 | 47 | if (count($err) == 0){ 48 | if (!defined('LOGIN') || !defined('PASSWORD')){ 49 | $err[]=sprintf("В конфигурации отсутствуют логин или пароль%s",is_developer() ? sprintf(" (file: %s, line: %s)",__FILE__,__LINE__) : ""); 50 | }else{ 51 | if (!defined('LOGIN') || !defined('PASSWORD') || !LOGIN || !PASSWORD){ 52 | $err[]=sprintf("В конфигурации логин или пароль пусты%s",is_developer() ? sprintf(" (file: %s, line: %s)",__FILE__,__LINE__) : ""); 53 | } 54 | } 55 | 56 | if (!defined('COLLECTOR_DATA_DIR') || !COLLECTOR_DATA_DIR){ 57 | $err[]=sprintf("В конфигурации не указана директория с данными%s",is_developer() ? sprintf(" (file: %s, line: %s)",__FILE__,__LINE__) : ""); 58 | }else{ 59 | $dataDir=sprintf("%s/%s",LOC,COLLECTOR_DATA_DIR); 60 | if (!is_dir($dataDir)){ 61 | $err[]=sprintf("Директории для данных%s несуществует%s",is_developer() ? " ".$dataDir : "",is_developer() ? sprintf(" (file: %s, line: %s)",__FILE__,__LINE__) : ""); 62 | }else{ 63 | if (!is_writable($dataDir)){ 64 | $err[]=sprintf("Отсутствуют права на запись в директорию для данных%s%s",is_developer() ? " ".$dataDir : "",is_developer() ? sprintf(" (file: %s, line: %s)",__FILE__,__LINE__) : ""); 65 | } 66 | } 67 | } 68 | } 69 | 70 | if (count($err) == 0){ 71 | if (!isset($allowedHosts) || !is_array($allowedHosts) || count($allowedHosts) == 0){ 72 | $err[]=sprintf("Отсутствуют разрешенные хосты для сохранения данных%s",is_developer() ? sprintf(" (file: %s, line: %s)",__FILE__,__LINE__) : ""); 73 | } 74 | } 75 | 76 | if (count($err) == 0){ 77 | define('AUTH',md5(sprintf("%s%s",LOGIN,PASSWORD))); 78 | if (!isset($sysUsers) || !is_array($sysUsers)){ 79 | $sysGroups=array(); 80 | } 81 | if (!isset($developer_ips) || !is_array($developer_ips)){ 82 | $developer_ips = array(); 83 | } 84 | if (!isset($services) || !is_array($services) || count($services) == 0){ 85 | $services = array( 86 | '-1' => array( 87 | 'name' => "Неизвестные", 88 | 'key' => 'unknown', 89 | ), 90 | ); 91 | } 92 | $allowedHostsIps = array(); 93 | foreach ($allowedHosts as $host_name=>$ip){ 94 | if (is_array($ip)){ 95 | foreach ($ip as $v){ 96 | if (!isset($allowedHostsIps[$v])){ 97 | if (matchIP($v)){ 98 | $allowedHostsIps[$v]=$v; 99 | } 100 | } 101 | } 102 | }else{ 103 | if (!isset($allowedHostsIps[$ip])){ 104 | if (matchIP($ip)){ 105 | $allowedHostsIps[$ip]=$ip; 106 | } 107 | } 108 | } 109 | } 110 | } 111 | 112 | if (count($err) == 0){ 113 | if (!isset($allowedHostsIps) || !is_array($allowedHostsIps) || count($allowedHostsIps) == 0){ 114 | $err[]=sprintf("Неизвестны IP-адреса разрешенных для сохранения данных хостов%s",is_developer() ? sprintf(" (file: %s, line: %s)",__FILE__,__LINE__) : ""); 115 | } 116 | } 117 | 118 | if (count($err) > 0){ 119 | error_critical($err); 120 | } 121 | 122 | if (!defined('REMOTE_ADDR')){ 123 | define('REMOTE_ADDR','0.0.0.0'); 124 | } 125 | if (!defined('REFRESH_PAGE')){ 126 | define('REFRESH_PAGE',60); 127 | } 128 | if (!defined('COLLECTOR_LOG_REQUEST')){ 129 | define('COLLECTOR_LOG_REQUEST',false); 130 | } 131 | if (!defined('COLLECTOR_CHECK_TIMER')){ 132 | define('COLLECTOR_CHECK_TIMER',300); 133 | } 134 | 135 | if (!is_developer()){ 136 | ini_set('display_errors', 'off'); 137 | error_reporting( 0 ); 138 | }else{ 139 | error_reporting(E_ALL); 140 | ini_set('display_errors', 'on'); 141 | } 142 | 143 | if (!defined('CLI_RUN') || !CLI_RUN){ 144 | session_set_cookie_params(60 * 60 * 24 * 30,"/",HOST); 145 | ini_set('session.gc_maxlifetime', 60 * 60 * 24 * 30); 146 | if(session_status() == PHP_SESSION_NONE){ 147 | session_start(); 148 | } 149 | } 150 | 151 | $param=array(); 152 | if (isset($_GET) && $_GET){ 153 | $param=$_GET; 154 | }elseif(isset($_POST)){ 155 | $param=$_POST; 156 | } 157 | 158 | function exception_error_handler($errno, $errstr, $errfile, $errline ) { 159 | //http://php.net/manual/ru/errorfunc.constants.php 160 | if ($errno != 2){ //exept E_WARNING 161 | if (is_developer()){ 162 | if ( PHP_SAPI === 'cli'){ 163 | print debug_print_backtrace( ); 164 | }else{ 165 | ob_start(); 166 | debug_print_backtrace( ); 167 | $dump = ob_get_clean(); 168 | $dump_text = @htmlspecialchars($dump, REPLACE_FLAGS, CHARSET); 169 | error_critical("Ошибка PHP кода",$dump_text); 170 | } 171 | throw new ErrorException($errstr, 0, $errno, $errfile, $errline); 172 | }else{ 173 | error_critical(sprintf("PHP code %s",$errno)); 174 | } 175 | } 176 | return; 177 | } 178 | 179 | function is_developer( ){ 180 | global $developer_ips; 181 | if (!is_array($developer_ips)){ $developer_ips = array(); } 182 | $dev=0; 183 | 184 | if (PHP_SAPI === 'cli'){ 185 | $dev=1; 186 | }else{ 187 | if ( matchIP( REMOTE_ADDR ) ){ 188 | foreach ($developer_ips as $item){ 189 | $tmp=explode("/",$item); 190 | if (count($tmp) > 1){ 191 | if (ip_vs_net(REMOTE_ADDR,$tmp[0],$tmp[1])){ 192 | $dev=1; 193 | break; 194 | } 195 | }else{ 196 | if (REMOTE_ADDR == $item){ 197 | $dev=1; 198 | break; 199 | } 200 | } 201 | } 202 | } 203 | } 204 | return $dev; 205 | } 206 | 207 | function deb($text){ 208 | $notcli=1; 209 | if (PHP_SAPI === 'cli'){ 210 | $notcli=0; 211 | } 212 | if (is_developer()){ 213 | if ($notcli){print "
";}
 214 | 	print "[DEBUG] ";
 215 | 	if (is_array($text)){
 216 | 	    foreach ($text as $k=>$v){
 217 | 		if (is_array($v)){
 218 | 		    printf("[%s] => array\n",$k);
 219 | 		    print_r($v);
 220 | 		}else{
 221 | 		    printf("[%s] => %s\n",$k,is_bool($v) ? var_export($v,true) : $v);
 222 | 		}
 223 | 	    }
 224 | 	}else{
 225 | 	    printf ("%s\n",is_bool($text) ? var_export($text,true) : $text);
 226 | 	}
 227 | 	if ($notcli){print "
";} 228 | } 229 | } 230 | 231 | function mtime( $micro = ""){ 232 | $mtime = microtime( true ); 233 | if ($micro){ 234 | $mtime = explode(".",$mtime); 235 | return $mtime[1]; 236 | } 237 | return $mtime; 238 | } 239 | 240 | function MONITstripcslashes($input){ 241 | return @stripcslashes($input); 242 | } 243 | 244 | function MONIThtmlspecialchars($input){ 245 | return @htmlspecialchars($input, REPLACE_FLAGS, CHARSET); 246 | } 247 | 248 | function unserialize_xml($input, $callback = null, $recurse = false){ 249 | global $custom_error, $data; 250 | //URL: http://php.net/manual/ru/function.simplexml-load-string.php 251 | //install /usr/ports/textproc/php5-simplexml 252 | if ((!$recurse) && is_string($input)){ 253 | $pre_data=preg_replace('/&/', '&', $input); 254 | if( ( $result = @simplexml_load_string($pre_data) ) === false ){ 255 | $custom_error = 'Error during parse of XML. Please check your request params and don`t forget about param value encoding: UTF-8'; 256 | $data['error'] = 800; 257 | } 258 | }else{ 259 | $result=$input; 260 | } 261 | if ($result instanceof SimpleXMLElement){ 262 | if (count((array)$result)>0){ 263 | $result = (array) $result; 264 | } 265 | } 266 | if (is_array($result)) foreach ($result as &$item) $item = unserialize_xml($item, $callback, true); 267 | return (!is_array($result) && is_callable($callback))? call_user_func($callback, $result): $result; 268 | } 269 | 270 | function ip_vs_net($ip,$network,$mask){ 271 | if (((ip2long($ip))&(ip2long($mask)))==ip2long($network)){ 272 | return 1; 273 | }else{ 274 | return 0; 275 | } 276 | } 277 | 278 | function cidr_2_mask($mask){ 279 | return long2ip(pow(2,32) - pow(2, (32-$mask))); 280 | } 281 | 282 | function mask_2_cidr($mask){ 283 | $a=strpos(decbin(ip2long($mask)),"0"); 284 | if (!$a){$a=32;} 285 | return $a; 286 | } 287 | 288 | function matchIP( $text ){ 289 | $ret=""; 290 | if (preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/",$text)){ 291 | $ret="ip"; 292 | } 293 | if (preg_match("/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/",$text)){ 294 | $ret="ip6"; 295 | } 296 | return $ret; 297 | } 298 | 299 | function write_file( $p = array() ){ 300 | $ret=array(); 301 | $err=array(); 302 | if (!isset($p['file'])){ 303 | $err[]=sprintf("File to write is unknown%s",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 304 | } 305 | if (!isset($p['data'])){ 306 | $err[]=sprintf("No data to write%s",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 307 | } 308 | if (!isset($p['mode'])){ 309 | $p['mode'] = "w"; 310 | } 311 | 312 | if (count($err) == 0){ 313 | $path=pathinfo( $p['file'] ); 314 | if (!is_dir($path['dirname'])){ 315 | $err[]=sprintf("Directory%s not exists or is file%s",is_developer() ? " ".$path['dirname'] : "",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 316 | }else{ 317 | if (!file_exists($p['file'])){ 318 | if (!is_writable($path['dirname'])){ 319 | $err[]=sprintf("Directory%s is not writable%s",is_developer() ? " ".$path['dirname'] : "",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 320 | } 321 | }else{ 322 | if (!is_writable($p['file'])){ 323 | $err[]=sprintf("File%s is not writable%s",is_developer() ? " ".$p['file'] : "",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 324 | } 325 | } 326 | } 327 | } 328 | 329 | if (count($err) == 0){ 330 | $handle=@fopen($p['file'],$p['mode']); 331 | if ( $handle !== false){ 332 | if (@fwrite($handle,$p['data']) === false){ 333 | $err[]=sprintf("Cant write file%s%s",is_developer() ? " ".$p['file'] : "",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 334 | }else{ 335 | @fclose($handle); 336 | } 337 | }else{ 338 | $err[]=sprintf("Cant open file%s for writing%s",is_developer() ? " ".$p['file'] : "",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 339 | } 340 | } 341 | 342 | if (count($err) > 0){ 343 | $ret['error'] = $err; 344 | } 345 | return $ret; 346 | } 347 | 348 | function jsonDecode( $json ){ 349 | return json_decode($json,true,512); 350 | } 351 | 352 | function jsonEncode( $array ){ 353 | return json_encode($array,JSON_FORCE_OBJECT); 354 | } 355 | 356 | function logg( $text ){ 357 | if( defined('LOG') && is_resource( LOG ) ){ 358 | $string=sprintf( "[%s]: %s\n", date( "d.m.Y H:i:s", time( ) ), is_array($text) ? print_r($text,true) : $text ); 359 | fputs( LOG, $string ); 360 | } 361 | } 362 | 363 | function read_dir( $p = array() ){ 364 | $ret = array(); 365 | $err = array(); 366 | 367 | if (!isset($p['dir'])){ 368 | $err[]=sprintf("Директория не задана%s",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 369 | } 370 | if (count($err) == 0){ 371 | $sdir=sprintf("%s/%s",LOC,$p['dir']); 372 | if (is_dir($sdir)){ 373 | if ($dir = opendir($sdir)){ 374 | $ret['list'] = array(); 375 | while (false !== ($file = readdir($dir))){ 376 | if ($file != "." && $file != ".."){ 377 | if (preg_match("/\.(txt|json|xml)$/",$file)){ 378 | if ( !isset($p['filter']) || (isset($p['filter']) && preg_match(sprintf("/%s/",$p['filter']),$file)) ){ 379 | $ret['list'][]=$file; 380 | } 381 | } 382 | } 383 | } 384 | }else{ 385 | $err[]=sprintf("Директория%s не читается%s",is_developer() ? " ".$sdir : "",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 386 | } 387 | }else{ 388 | $err[]=sprintf("Директория%s не найдена%s",is_developer() ? " ".$sdir : "",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 389 | } 390 | } 391 | 392 | if (count($err) > 0){ 393 | $ret['error']=$err; 394 | } 395 | return $ret; 396 | } 397 | 398 | function read_host_file( $p = array() ){ 399 | $ret = array(); 400 | $err = array(); 401 | 402 | if (!isset($p['file'])){ 403 | $err[]=sprintf("Файл хоста не передан%s",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 404 | } 405 | 406 | if (count($err) == 0){ 407 | if (!file_exists($p['file'])){ 408 | $err[]=sprintf("Файл хоста%s не найден%s",is_developer() ? " ".$p['file'] : "",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 409 | } 410 | } 411 | 412 | if (count($err) == 0){ 413 | if (!is_readable($p['file'])){ 414 | $err[]=sprintf("Отсутствуют права доступа на чтение файл хоста%s%s",is_developer() ? " ".$p['file'] : "",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 415 | } 416 | } 417 | 418 | if (count($err) == 0){ 419 | $tmp=file_get_contents($p['file']); 420 | if ($tmp === false){ 421 | $err[]=sprintf("Невозможно прочитать файл хоста%s%s",is_developer() ? " ".$p['file'] : "",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 422 | }else{ 423 | $rf=jsonDecode($tmp); 424 | if ($rf === NULL || $rf === FALSE){ 425 | $err[]=sprintf("Данные в файле хоста отсутствуют%s%s",is_developer() ? " ".$p['file'] : "",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 426 | }else{ 427 | $ret['data']=$rf; 428 | $ret['data']['fdate']=filemtime($p['file']); 429 | } 430 | } 431 | } 432 | 433 | if (count($err) > 0){ 434 | $ret['error']=$err; 435 | } 436 | return $ret; 437 | } 438 | 439 | function mftime( $file = "" ){ 440 | $ret = 0; 441 | if (file_exists($file)){ 442 | $tmp=trim(filemtime($file)); 443 | if (preg_match("/^\d+$/",$tmp)){ 444 | $ret = $tmp; 445 | } 446 | } 447 | return $ret; 448 | } 449 | 450 | function collector_check_4_errors( $clean = ""){ 451 | $ret = ""; 452 | $error_file=sprintf("%s/%s/errors.log",LOC,COLLECTOR_DATA_DIR); 453 | if (file_exists($error_file)){ 454 | $mtime=mftime($error_file); 455 | if ($clean){ 456 | if ( (time() - $mtime) > (int)COLLECTOR_CHECK_TIMER+120){ 457 | unlink($error_file); 458 | } 459 | }else{ 460 | if ( (time() - $mtime) < (int)COLLECTOR_CHECK_TIMER ){ 461 | $ret=file_get_contents($error_file); 462 | } 463 | } 464 | } 465 | return $ret; 466 | } 467 | ////////////////////// WEB /////////////////////////////// 468 | function head($title="",$full_head=1){ 469 | $system_name=(defined('SYSTEM_NAME') && SYSTEM_NAME) ? SYSTEM_NAME : ""; 470 | if (!$title){ 471 | $title=$system_name; 472 | } 473 | $head="\n"; 474 | $head.=sprintf("%s\n",$title); 475 | $head.="\n"; 476 | $head.="\n"; 477 | $head.="\n"; 478 | $head.="\n"; 479 | $head.="\n"; 480 | $head.="\n"; 481 | if ($system_name){ 482 | $head.=''."\n"; 483 | $head.=''."\n"; 484 | $head.=''."\n"; 485 | $head.=''."\n"; 486 | } 487 | $head.=''."\n"; 488 | $head.=''."\n"; 489 | $head.=''."\n"; 490 | $head.=sprintf("\n",URL); 491 | if ($full_head){ 492 | $head.=sprintf("\n",URL); 493 | $head.=sprintf("\n",URL); 494 | } 495 | $head.=sprintf("\n",URL); 496 | $head.=sprintf("\n",URL); 497 | $head.="\n"; 498 | $head.="\n"; 499 | return $head; 500 | } 501 | 502 | function foot(){ 503 | return "\n\n\n"; 504 | } 505 | 506 | function error( $text, $header = "" ){ 507 | if (is_array($text)){ 508 | $tmp=$text; 509 | if (count($tmp)>1){ 510 | $text="
    "; 511 | foreach ($tmp as $v){ 512 | $text.=sprintf("
  • %s
  • ",$v); 513 | } 514 | $text.="
"; 515 | }else{ 516 | $text=$tmp[0]; 517 | } 518 | } 519 | return sprintf("
%s%s
",$header ? "".$header.":
" : "",$text); 520 | } 521 | 522 | function error_critical( $err = array(), $dump = ""){ 523 | print head("",0); 524 | print "
"; 525 | print "
"; 526 | print "
"; 527 | printf("

%s%s

",(defined('SYSTEM_NAME') && SYSTEM_NAME) ? SYSTEM_NAME : "",(defined('VERSION') && VERSION) ? sprintf(" v%s",VERSION) : ""); 528 | print error($err,sprintf("Критическ%s ошибк%s",count($err) == 1 ? "ая" : "ие", count($err) == 1 ? "а" : "и")); 529 | if ($dump){ 530 | printf("
%s",$dump); 531 | } 532 | print "
"; 533 | print "
"; 534 | print "
"; 535 | print foot(); 536 | exit(0); 537 | } 538 | 539 | function get_request_params($data =""){ 540 | $ret = array(); 541 | $err = array(); 542 | 543 | if (!$data){ 544 | $err[]=sprintf("Параметры запроса отсутствуют%s",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 545 | } 546 | 547 | if (count($err) == 0){ 548 | $decode=base64_decode($data); 549 | if ($decode === false){ 550 | $err[]=sprintf("Неверные параметры запроса%s",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 551 | } 552 | } 553 | 554 | if (count($err) == 0){ 555 | $expl = explode("&",$decode); 556 | foreach ($expl as $str){ 557 | $tmp = explode("=",$str); 558 | if (count($tmp) == 2){ 559 | if (!isset($params)){ 560 | $params = array(); 561 | } 562 | $params[$tmp[0]]=$tmp[1]; 563 | } 564 | } 565 | 566 | if (!isset($params) || !is_array($params)){ 567 | $err[]=sprintf("Параметры запроса пусты%s",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 568 | } 569 | } 570 | 571 | if (count($err) == 0){ 572 | $ret['data']=$params; 573 | } 574 | 575 | if (count($err) > 0){ 576 | $ret['error'] = $err; 577 | } 578 | 579 | return $ret; 580 | } 581 | 582 | function chk_auth( $fatal = 0){ 583 | if (isset($_SESSION['auth']) && $_SESSION['auth'] == 1){ 584 | return 1; 585 | }else{ 586 | if ($fatal){ 587 | @session_destroy(); 588 | print error("Вы не авторизованы"); 589 | printf("\n\n",URL); 590 | exit(0); 591 | } 592 | } 593 | return 0; 594 | } 595 | 596 | function goback( $request, $funcParam =array() ){ 597 | $update = ""; 598 | $ret = ""; 599 | $location = "index.php"; 600 | 601 | if (isset($request['location'])){ 602 | $location = $request['location']; 603 | } 604 | unset($request['data'],$request['location']); 605 | 606 | $timeout=3000; 607 | if (isset($funcParam['timeout']) && preg_match("/^\d+$/",$funcParam['timeout']) && (int)$funcParam['timeout'] > 0){ 608 | $timeout=$funcParam['timeout']; 609 | if ($timeout < 1000){ 610 | $timeout=$timeout*1000; 611 | } 612 | } 613 | 614 | $ret.="\n"; 631 | return $ret; 632 | } 633 | 634 | function menu(){ 635 | $ret = array(); 636 | if (isset($_SESSION['auth']) && $_SESSION['auth'] == 1){ 637 | $ret = array( 638 | 'exit' => array( 639 | 'location' => 'plugins/logout.php', 640 | 'class' => 'exit', 641 | 'text' => 'Выход', 642 | ) 643 | ); 644 | } 645 | return $ret; 646 | } 647 | 648 | function get_hosts(){ 649 | $ret = array(); 650 | $err = array(); 651 | 652 | $list=read_dir( 653 | array( 654 | "dir"=>COLLECTOR_DATA_DIR, 655 | "filter"=>"^host_", 656 | ) 657 | ); 658 | 659 | if (isset($list['error'])){ 660 | $err=$list['error']; 661 | } 662 | 663 | if (count($err) == 0){ 664 | if (!isset($list['list']) || !is_array($list['list']) || count($list['list']) == 0){ 665 | $err[]=sprintf("Хостов не найдено%s",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 666 | } 667 | } 668 | 669 | if (count($err) == 0){ 670 | $tmp=array(); 671 | $nn=1; 672 | foreach ($list['list'] as $k=>$f){ 673 | if (preg_match("/^host_(\S+)_(\S+)\.json$/",$f,$m)){ 674 | $group=get_group($m[1]); 675 | $key = isset($tmp[$m[1]]) ? sprintf("%s_%d",$m[1],$nn) : $m[1]; 676 | $tmp[$group][$key]=array( 677 | 'monit_id' => $m[2], 678 | 'name' => $m[1], 679 | 'file' => $f, 680 | 'group' => $group, 681 | ); 682 | $rf=read_host_file(array("file"=>sprintf("%s/%s/%s",LOC,COLLECTOR_DATA_DIR,$f))); 683 | if (isset($rf['error'])){ 684 | $tmp[$group][$key]['error']=$rf['error']; 685 | }else{ 686 | $tmp[$group][$key]['data']=$rf['data']; 687 | } 688 | $nn++; 689 | } 690 | } 691 | ksort($tmp); 692 | foreach ($tmp as $k=>$v){ 693 | ksort($tmp[$k]); 694 | } 695 | foreach ($tmp as $k=>$v){ 696 | foreach ($v as $hn=>$hv){ 697 | $ret['hosts'][$k][$hv['monit_id']]=$hv; 698 | } 699 | } 700 | if (count($ret['hosts']) == 0){ 701 | $err[]=sprintf("Хосты отсутствуют%s",is_developer() ? sprintf(" (file: %s, func: %s, line: %s)",__FILE__,__FUNCTION__,__LINE__) : ""); 702 | } 703 | } 704 | 705 | if (count($err) > 0){ 706 | $ret['error']=$err; 707 | } 708 | return $ret; 709 | } 710 | 711 | function get_group( $name = ""){ 712 | $ret="z_noname_group"; 713 | if ($name){ 714 | $p=parse_url($name); 715 | if (isset($p['path']) && $p['path']){ 716 | $tmp=explode(".",$p['path']); 717 | if (count($tmp) > 1){ 718 | if (count($tmp) == 2){ 719 | $ret=sprintf("%s.%s",$tmp[0],$tmp[1]); 720 | }else{ 721 | $ret=sprintf("%s.%s",$tmp[count($tmp)-2],$tmp[count($tmp)-1]); 722 | } 723 | } 724 | } 725 | } 726 | return $ret; 727 | } 728 | 729 | function parse_services( $data = array() ){ 730 | global $services,$sysUsers,$sysGroups; 731 | 732 | $ret=array(); 733 | foreach ($services as $k=>$v){ 734 | $type[$v['key']] = array(); 735 | } 736 | $ret['alarm'] = 0; 737 | //Хост без сервисов 738 | if (isset($data['service']['@attributes'])){ 739 | $tmp=$data['service']; 740 | $data['service']=array($tmp); 741 | unset($tmp); 742 | } 743 | // 744 | foreach($data as $key=>$srv){ 745 | if (is_array($srv)){ 746 | foreach ($srv as $k=>$v){ 747 | if (isset($v['type'])){ 748 | $status_2_header = ""; 749 | $key = isset($services[$v['type']]['key']) ? $services[$v['type']]['key'] : $services[-1]['key']; 750 | if (isset($v['status'])){ 751 | if ($v['status'] > 0){ 752 | $ret['alarm']++; 753 | $status_2_header=sprintf(" :: статус %d",$v['status']); 754 | } 755 | } 756 | if (!isset($v['monitor'])){ 757 | $v['monitor'] = 0; 758 | } 759 | if ($v['monitor'] == 0){ 760 | $type[$key][]=sprintf("

%s :: Не мониторится

",$v['@attributes']['name']); 761 | }elseif ($v['monitor'] == 2){ 762 | $type[$key][]=sprintf("

%s :: Идет сбор данных

",$v['@attributes']['name']); 763 | } 764 | if ($v['type'] == 5 && $v['monitor'] == 1){ 765 | //system 766 | $type[$key][]=sprintf("

%s%s

",$v['@attributes']['name'],$status_2_header); 767 | if (isset($v['system']['load']) && isset($v['system']['cpu']['user']) && isset($v['system']['cpu']['system'])){ 768 | $type[$key][]=""; 769 | $type[$key][]=""; 770 | $type[$key][]=""; 771 | $type[$key][]=""; 772 | $type[$key][]=""; 773 | $type[$key][]=""; 774 | $type[$key][]=""; 775 | $type[$key][]=""; 776 | $type[$key][]=""; 777 | $type[$key][]=sprintf("",$v['status'] > 0 ? " alarm" : ""); 778 | $type[$key][]=sprintf("",implode("] [",$v['system']['load'])); 779 | $type[$key][]=sprintf("",$v['system']['cpu']['user'],$v['system']['cpu']['system']); 780 | $type[$key][]=sprintf("",isset($v['system']['memory']['percent']) ? sprintf("%s%%",$v['system']['memory']['percent']) : "n/a",(isset($v['system']['memory']['kilobyte']) && $v['system']['memory']['kilobyte'] > 0) ? sprintf(" [%s]",get_bwk($v['system']['memory']['kilobyte']*1024)) : ""); 781 | $type[$key][]=sprintf("",isset($v['system']['swap']['percent']) ? sprintf("%s%%",$v['system']['swap']['percent']) : "n/a",(isset($v['system']['swap']['kilobyte']) && $v['system']['swap']['kilobyte'] > 0) ? sprintf(" [%s]",get_bwk($v['system']['swap']['kilobyte']*1024)) : ""); 782 | $type[$key][]=""; 783 | $type[$key][]="
LoadCPUMemorySwap
[%s]%s%%us,%s%%sy%s%s%s%s
"; 784 | }else{ 785 | $type[$key][]="Нет данных"; 786 | } 787 | }elseif ($v['type'] == 3 && $v['monitor'] == 1){ 788 | //process 789 | $type[$key][]=sprintf("

%s%s

",$v['@attributes']['name'],$status_2_header); 790 | if (isset($v['cpu']) && isset($v['memory']) && isset($v['uptime'])){ 791 | $type[$key][]=""; 792 | $type[$key][]=""; 793 | $type[$key][]=""; 794 | $type[$key][]=""; 795 | $type[$key][]=""; 796 | $type[$key][]=""; 797 | $type[$key][]=""; 798 | $type[$key][]=""; 799 | $type[$key][]=""; 800 | $type[$key][]=""; 801 | $type[$key][]=""; 802 | $type[$key][]=""; 803 | $type[$key][]=""; 804 | $type[$key][]=sprintf("",$v['status'] > 0 ? " alarm" : ""); 805 | $type[$key][]=sprintf("",$v['cpu']['percenttotal'] > 0 ? $v['cpu']['percenttotal'] : 0); 806 | $type[$key][]=sprintf("",$v['memory']['percenttotal'] > 0 ? $v['memory']['percenttotal'] : 0,(isset($v['memory']['kilobytetotal']) && $v['memory']['kilobytetotal'] > 0) ? sprintf(" [%s]",get_bwk($v['memory']['kilobytetotal']*1024)) : ""); 807 | $type[$key][]=sprintf("",uptime($v['uptime'],"string")); 808 | $type[$key][]=sprintf("",$v['pid']); 809 | $type[$key][]=sprintf("",$v['uid']); 810 | $type[$key][]=sprintf("",$v['gid']); 811 | $type[$key][]=sprintf("",$v['threads']); 812 | $type[$key][]=sprintf("",$v['children']); 813 | $type[$key][]=""; 814 | $type[$key][]="
CPUMemoryuptimePIDUIDGIDthreadschildren
%s%%%s%%%s%s%s%s%s%s%s
"; 815 | 816 | if (isset($v['port'])){ 817 | $type[$key][]=""; 818 | $type[$key][]=""; 819 | $type[$key][]=""; 820 | $type[$key][]=""; 821 | $type[$key][]=""; 822 | $type[$key][]=""; 823 | $type[$key][]=""; 824 | $type[$key][]=""; 825 | $type[$key][]=""; 826 | $type[$key][]=""; 827 | if (!isset($v['port'][0])){ 828 | $ptmp=$v['port']; 829 | $v['port']=array( '0' => $ptmp ); 830 | unset($ptmp); 831 | } 832 | foreach ($v['port'] as $kp=>$pv){ 833 | $class = ""; 834 | if ($v['status'] > 0){ 835 | $class = " alarm"; 836 | if (isset($pv['responsetime']) && $pv['responsetime'] > 0 ){ 837 | $class = ""; 838 | } 839 | } 840 | $type[$key][]=sprintf("",$class); 841 | $type[$key][]=""; 842 | $type[$key][]=sprintf("",isset($pv['hostname']) ? $pv['hostname'] : "n/a"); 843 | $type[$key][]=sprintf("",isset($pv['portnumber']) ? $pv['portnumber'] : "n/a"); 844 | $type[$key][]=sprintf("",isset($pv['type']) ? $pv['type'] : "",isset($pv['protocol']) ? sprintf(" (%s)",$pv['protocol']) : ""); 845 | $type[$key][]=sprintf("",(isset($pv['responsetime']) && $pv['responsetime'] > 0 ) ? $pv['responsetime'] : "n/a"); 846 | $type[$key][]=""; 847 | } 848 | unset($class); 849 | $type[$key][]="
ТипХостПортПротоколВремя ответа
Порт%s%s%s%s%s
"; 850 | } 851 | }else{ 852 | $type[$key][]="Нет данных"; 853 | } 854 | }elseif ($v['type'] == 8 && $v['monitor'] == 1){ 855 | //Network 856 | $type[$key][]=sprintf("

%s%s

",$v['@attributes']['name'],$status_2_header); 857 | $type[$key][]=""; 858 | $type[$key][]=""; 859 | $type[$key][]=""; 860 | $type[$key][]=""; 861 | $type[$key][]=""; 862 | $type[$key][]=""; 863 | $type[$key][]=""; 864 | $type[$key][]=""; 865 | $type[$key][]=""; 866 | $type[$key][]=""; 867 | $type[$key][]=""; 868 | $type[$key][]=""; 869 | $type[$key][]=""; 870 | $type[$key][]=""; 871 | $type[$key][]=""; 872 | $type[$key][]=""; 873 | $type[$key][]=""; 874 | $type[$key][]=sprintf("",$v['status'] > 0 ? " alarm" : ""); 875 | $type[$key][]=sprintf("",$v['link']['state'] == 1 ? "Да" : "Нет"); 876 | if ($v['link']['state'] == 1){ 877 | $type[$key][]=sprintf("",$v['link']['speed']/1000000,$v['link']['duplex'] == 1 ? "full-duplex" : "half-duplex"); 878 | $type[$key][]=sprintf("",$v['link']['download']['packets']['total']); 879 | $type[$key][]=sprintf("",get_bwk($v['link']['download']['bytes']['total'])); 880 | $type[$key][]=sprintf("%s",$v['link']['download']['errors']['total'] > 0 ? " class=warn" : "",$v['link']['download']['errors']['total']); 881 | $type[$key][]=sprintf("",$v['link']['upload']['packets']['total']); 882 | $type[$key][]=sprintf("",get_bwk($v['link']['upload']['bytes']['total'])); 883 | $type[$key][]=sprintf("%s",$v['link']['upload']['errors']['total'] > 0 ? " class=warn" : "",$v['link']['upload']['errors']['total']); 884 | }else{ 885 | $type[$key][]=""; 886 | } 887 | $type[$key][]=""; 888 | $type[$key][]="
ЛинкСкоростьDownloadUpload
ПакетыПереданоОшибкиПакетыПереданоОшибки
%s%sMbit %s%s%s%s%sn/a
"; 889 | 890 | if (defined('NETWORK_ERRORS_AS_ALARM') && NETWORK_ERRORS_AS_ALARM === true){ 891 | if ($v['link']['upload']['errors']['total'] > 0 || $v['link']['download']['errors']['total'] > 0){ 892 | $ret['alarm']++; 893 | } 894 | } 895 | }elseif ($v['type'] == 0 && $v['monitor'] == 1){ 896 | //Filesystem 897 | $type[$key][]=sprintf("

%s%s

",$v['@attributes']['name'],$status_2_header); 898 | if ($v['status'] == 512){ 899 | $type[$key][]="Раздела не существует"; 900 | }else{ 901 | $type[$key][]=""; 902 | $type[$key][]=""; 903 | $type[$key][]=""; 904 | $type[$key][]=""; 905 | $type[$key][]=""; 906 | $type[$key][]=""; 907 | $type[$key][]=""; 908 | $type[$key][]=""; 909 | $type[$key][]=""; 910 | $type[$key][]=sprintf("",$v['status'] > 0 ? " alarm" : ""); 911 | $type[$key][]=sprintf("",isset($v['fstype']) ? $v['fstype'] : "n/a"); 912 | $type[$key][]=sprintf("",isset($v['fsflags']) ? (is_array($v['fsflags']) ? implode(", ",$v['fsflags']) : ($v['fsflags'] ? $v['fsflags'] : "нет") ) : "n/a"); 913 | $type[$key][]=sprintf("",isset($v['block']['percent']) ? sprintf("%s%%",$v['block']['percent']) : "n/a",(isset($v['block']['usage']) && $v['block']['usage']> 0) ? sprintf(" [%s]",get_bwk($v['block']['usage']*1024*1024)) : ""); 914 | $type[$key][]=sprintf("",isset($v['inode']['percent']) ? sprintf("%s%%",$v['inode']['percent']) : "n/a",(isset($v['inode']['usage']) && $v['inode']['usage'] > 0) ? sprintf(" [%s objects]",$v['inode']['usage']) : ""); 915 | $type[$key][]=""; 916 | $type[$key][]="
ТипФлагиИспользованоИспользовано inodes
%s%s%s%s%s%s
"; 917 | } 918 | }elseif ($v['type'] == 2 && $v['monitor'] == 1){ 919 | //File checks 920 | $type[$key][]=sprintf("

%s%s

",$v['@attributes']['name'],$status_2_header); 921 | if ($v['status'] == 512){ 922 | $type[$key][]="Файла не существует"; 923 | }else{ 924 | $type[$key][]=""; 925 | $type[$key][]=""; 926 | $type[$key][]=""; 927 | $type[$key][]=""; 928 | $type[$key][]=""; 929 | $type[$key][]=""; 930 | $type[$key][]=""; 931 | $type[$key][]=""; 932 | $type[$key][]=""; 933 | $type[$key][]=""; 934 | $type[$key][]=""; 935 | $type[$key][]=""; 936 | $type[$key][]=""; 937 | $type[$key][]=""; 938 | $type[$key][]=""; 939 | $type[$key][]=""; 940 | $type[$key][]=sprintf("",$v['status'] > 0 ? " alarm" : ""); 941 | $type[$key][]=sprintf("",isset($v['uid']) ? (isset($sysUsers[$v['uid']]) ? $sysUsers[$v['uid']] : $v['uid']) : "n/a"); 942 | $type[$key][]=sprintf("",isset($v['gid']) ? (isset($sysGroups[$v['gid']]) ? $sysGroups[$v['gid']] : $v['gid']) : "n/a"); 943 | $type[$key][]=sprintf("",isset($v['mode']) ? $v['mode'] : "n/a"); 944 | $type[$key][]=sprintf("",(isset($v['size']) && $v['size'] > 0) ? $v['size'] : "n/a"); 945 | $type[$key][]=sprintf("",(isset($v['checksum']) && $v['checksum'] > 0) ? $v['checksum'] : "n/a"); 946 | $type[$key][]=sprintf("",(isset($v['timestamps']['access']) && $v['timestamps']['access'] > 0) ? date("d.m.Y H:i:s",$v['timestamps']['access']) : "n/a"); 947 | $type[$key][]=sprintf("",(isset($v['timestamps']['change']) && $v['timestamps']['change'] > 0) ? date("d.m.Y H:i:s",$v['timestamps']['change']) : "n/a"); 948 | $type[$key][]=sprintf("",(isset($v['timestamps']['modify']) && $v['timestamps']['modify'] > 0) ? date("d.m.Y H:i:s",$v['timestamps']['modify']) : "n/a"); 949 | $type[$key][]=""; 950 | $type[$key][]="
UIDGIDModeРазмерChecksumДаты
accesschangemodify
%s%s%s%s%s%s%s%s
"; 951 | } 952 | }elseif ($v['type'] == 1 && $v['monitor'] == 1){ 953 | //Directory checks 954 | $type[$key][]=sprintf("

%s%s

",$v['@attributes']['name'],$status_2_header); 955 | if ($v['status'] == 512){ 956 | $type[$key][]="Директории не существует"; 957 | }else{ 958 | $type[$key][]=""; 959 | $type[$key][]=""; 960 | $type[$key][]=""; 961 | $type[$key][]=""; 962 | $type[$key][]=""; 963 | $type[$key][]=""; 964 | $type[$key][]=""; 965 | $type[$key][]=""; 966 | $type[$key][]=""; 967 | $type[$key][]=""; 968 | $type[$key][]=""; 969 | $type[$key][]=""; 970 | $type[$key][]=""; 971 | $type[$key][]=""; 972 | $type[$key][]=sprintf("",$v['status'] > 0 ? " alarm" : ""); 973 | $type[$key][]=sprintf("",isset($v['uid']) ? (isset($sysUsers[$v['uid']]) ? $sysUsers[$v['uid']] : $v['uid']) : "n/a"); 974 | $type[$key][]=sprintf("",isset($v['gid']) ? (isset($sysGroups[$v['gid']]) ? $sysGroups[$v['gid']] : $v['gid']) : "n/a"); 975 | $type[$key][]=sprintf("",isset($v['mode']) ? $v['mode'] : "n/a"); 976 | $type[$key][]=sprintf("",isset($v['timestamps']['access']) ? date("d.m.Y H:i:s",$v['timestamps']['access']) : "n/a"); 977 | $type[$key][]=sprintf("",isset($v['timestamps']['change']) ? date("d.m.Y H:i:s",$v['timestamps']['change']) : "n/a"); 978 | $type[$key][]=sprintf("",isset($v['timestamps']['modify']) ? date("d.m.Y H:i:s",$v['timestamps']['modify']) : "n/a"); 979 | $type[$key][]=""; 980 | $type[$key][]="
UIDGIDModeДаты
accesschangemodify
%s%s%s%s%s%s
"; 981 | } 982 | }elseif ($v['type'] == 4 && $v['monitor'] == 1){ 983 | //ICMP and ports check 984 | $type[$key][]=sprintf("

%s%s

",$v['@attributes']['name'],$status_2_header); 985 | if (!isset($v['icmp']) && !isset($v['port'])){ 986 | $type[$key][]="Нет данных"; 987 | }else{ 988 | if (isset($v['icmp'])){ 989 | $type[$key][]=""; 990 | $type[$key][]=""; 991 | $type[$key][]=""; 992 | $type[$key][]=""; 993 | $type[$key][]=""; 994 | $type[$key][]=""; 995 | $type[$key][]=""; 996 | $type[$key][]=sprintf("",$v['status'] > 0 ? " alarm" : ""); 997 | $type[$key][]=sprintf("",isset($v['icmp']['type']) ? $v['icmp']['type'] : "n/a"); 998 | $type[$key][]=sprintf("",(isset($v['icmp']['responsetime']) && $v['icmp']['responsetime'] > 0 ) ? $v['icmp']['responsetime'] : "n/a"); 999 | $type[$key][]=""; 1000 | $type[$key][]="
ТипВремя ответа
%s%s
"; 1001 | } 1002 | if (isset($v['port'])){ 1003 | $type[$key][]=""; 1004 | $type[$key][]=""; 1005 | $type[$key][]=""; 1006 | $type[$key][]=""; 1007 | $type[$key][]=""; 1008 | $type[$key][]=""; 1009 | $type[$key][]=""; 1010 | $type[$key][]=""; 1011 | $type[$key][]=""; 1012 | $type[$key][]=""; 1013 | if (!isset($v['port'][0])){ 1014 | $ptmp=$v['port']; 1015 | $v['port']=array( '0' => $ptmp ); 1016 | unset($ptmp); 1017 | } 1018 | foreach ($v['port'] as $kp=>$pv){ 1019 | $type[$key][]=sprintf("",$v['status'] > 0 ? " alarm" : ""); 1020 | $type[$key][]=""; 1021 | $type[$key][]=sprintf("",isset($pv['hostname']) ? $pv['hostname'] : "n/a"); 1022 | $type[$key][]=sprintf("",isset($pv['portnumber']) ? $pv['portnumber'] : "n/a"); 1023 | $type[$key][]=sprintf("",isset($pv['type']) ? $pv['type'] : "",isset($pv['protocol']) ? sprintf(" (%s)",$pv['protocol']) : ""); 1024 | $type[$key][]=sprintf("",(isset($pv['responsetime']) && $pv['responsetime'] > 0 ) ? $pv['responsetime'] : "n/a"); 1025 | $type[$key][]=""; 1026 | } 1027 | $type[$key][]="
ТипХостПортПротоколВремя ответа
Порт%s%s%s%s%s
"; 1028 | } 1029 | } 1030 | }elseif ($v['type'] == 7 && $v['monitor'] == 1){ 1031 | //scripts checks 1032 | $type[$key][]=sprintf("

%s%s

",$v['@attributes']['name'],$status_2_header ? $status_2_header : " :: OK"); 1033 | }else{ 1034 | if ($v['monitor'] == 1){ 1035 | $type[$key][]=sprintf("

%s%s

",$v['@attributes']['name'],$status_2_header); 1036 | $type[$key][]=error(sprintf("Неизвестный тип данных: %d",$v['type'])); 1037 | } 1038 | } 1039 | }else{ 1040 | deb("TYPE NOT SET"); 1041 | deb($v); 1042 | } 1043 | } 1044 | } 1045 | } 1046 | 1047 | foreach ($type as $k=>$v){ 1048 | if (count($type[$k]) > 0){ 1049 | $ret[$k] = implode("\n",$type[$k]); 1050 | } 1051 | } 1052 | 1053 | return $ret; 1054 | } 1055 | 1056 | function get_bwk($bw,$num=0){ 1057 | $bwm=array("байт","Кб","Мб","Гб"); 1058 | $nn=0; 1059 | while($bw >= 1024){ 1060 | $nn++; 1061 | if($num == 0){ 1062 | $num = 2; 1063 | } 1064 | $bw/=1024; 1065 | } 1066 | return sprintf("%.".$num."f %s",$bw,isset($bwm[$nn]) ? $bwm[$nn] : ""); 1067 | } 1068 | 1069 | function uptime( $sec, $what = ""){ 1070 | $ret = array( 1071 | 'days' => 0, 1072 | 'hours' => 0, 1073 | 'mins' => 0, 1074 | 'secs' => 0, 1075 | 'string' => '', 1076 | ); 1077 | 1078 | if( $ret['days'] = floor( $sec / 86400 ) ){ 1079 | $sec -= $ret['days'] * 86400; 1080 | $ret['string'] = sprintf( "%d дн. ", $ret['days'] ); 1081 | } 1082 | 1083 | if( $ret['hours'] = floor( $sec / 3600 ) ){ 1084 | $sec -= $ret['hours'] * 3600; 1085 | } 1086 | 1087 | if( $ret['mins'] = floor( $sec / 60 ) ){ 1088 | $sec -= $ret['mins'] * 60; 1089 | } 1090 | $ret['secs'] = $sec; 1091 | 1092 | $ret['string'] .= sprintf( "%02d:%02d:%02d", $ret['hours'], $ret['mins'], $ret['secs'] ); 1093 | 1094 | if ($what == "string"){ 1095 | $ret = $ret['string']; 1096 | } 1097 | return $ret; 1098 | } 1099 | 1100 | function check_version( ){ 1101 | $ret = array(); 1102 | $err = array(); 1103 | if (!defined('VERSION') || !VERSION){ 1104 | $err[]="Локальная версия неизвестна"; 1105 | } 1106 | 1107 | if (count($err) == 0){ 1108 | $host="mmonit-free.subnets.ru"; 1109 | $port="80"; 1110 | $get=sprintf("/check_version.php?version=%s",VERSION); 1111 | $text=sprintf("Доступна новая версия ~VERSION~",$host); 1112 | 1113 | if (defined('CHECK_4_NEW_VERSION') && CHECK_4_NEW_VERSION === true){ 1114 | if (!isset($_SESSION['check_version'])){ 1115 | $data=''; 1116 | $sock = @stream_socket_client(sprintf("tcp://%s:%d",$host,$port), $errno, $errstr, 5, STREAM_CLIENT_CONNECT); 1117 | if ($sock&&$errno==0){ 1118 | @fwrite($sock, sprintf("GET %s HTTP/1.0\r\nHost: %s\r\nUser-Agent: mMonit version CHECKER v0.1\r\nAccept: */*\r\n\r\n",$get,$host)); 1119 | while (!@feof($sock)) { 1120 | $data.=@fgets($sock, 1024); 1121 | } 1122 | @fclose($sock); 1123 | } 1124 | if ($data){ 1125 | $tmp=explode("\r\n\r\n",$data); 1126 | if (isset($tmp[1]) && check_version_number($tmp[1])){ 1127 | $ret['version']=$tmp[1]; 1128 | $_SESSION['check_version']=$tmp[1]; 1129 | } 1130 | } 1131 | if (!isset($_SESSION['check_version'])){ 1132 | $_SESSION['check_version'] = VERSION; 1133 | } 1134 | }else{ 1135 | $tmp = check_version_number($_SESSION['check_version']); 1136 | if ($tmp){ 1137 | $ret['version']=$tmp; 1138 | } 1139 | } 1140 | 1141 | if (isset($ret['version'])){ 1142 | $ret['version']=preg_replace("/~VERSION~/",$ret['version'],$text); 1143 | } 1144 | } 1145 | } 1146 | 1147 | if (count($err) > 0){ 1148 | $ret['error']=$err; 1149 | } 1150 | return $ret; 1151 | } 1152 | 1153 | function check_version_number( $version ="" ){ 1154 | $ret=""; 1155 | if (preg_match("/^(\d{1,3})(\.\d{1,2}){0,2}$/",trim($version))){ 1156 | $my=preg_replace("/\./","",VERSION); 1157 | $cur=preg_replace("/\./","",$version); 1158 | if ( (int)$cur > (int)$my ){ 1159 | $ret=$version; 1160 | } 1161 | } 1162 | return $ret; 1163 | } 1164 | 1165 | ?> --------------------------------------------------------------------------------