diff --git a/README.md b/README.md index 0a2c975..8e500cf 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Las funcionalidades de **sysMonDash** son las siguientes: * Filtrado de servicios para NO mostrar en vista principal * Selección de elementos críticos para mostrar siempre * Detección de paradas programadas que se hayan establecido, así como su visualización en la vista principal +* Enlace con backends remotos mediante API JSON --- @@ -41,6 +42,7 @@ The **sysMonDash** key features are: * Services filtering to NOT be shown in the main view * Critical items selection to be always shown * Scheduled downtimes detection and showing them in the main view +* Link to remote backends through JSON API --- diff --git a/ajax/checkConfig.php b/ajax/checkConfig.php index 22233e6..e8f084e 100644 --- a/ajax/checkConfig.php +++ b/ajax/checkConfig.php @@ -23,6 +23,7 @@ * */ +use Exts\Zabbix\ZabbixApiLoader; use SMD\Core\Init; use SMD\Http\Request; use SMD\Http\Response; @@ -54,7 +55,7 @@ $json = Util::getDataFromUrl($url); break; case 'zabbixBackend': - $ZabbixLoader = new \Exts\Zabbix\ZabbixApiLoader(); + $ZabbixLoader = new ZabbixApiLoader(); $Zabbix = $ZabbixLoader->getAPI($data->version); $Zabbix->setApiUrl($data->url); $Zabbix->userLogin(array('user' => $data->user, 'password' => $data->pass)); diff --git a/css/styles.css b/css/styles.css index 24c9426..9cdcc2f 100644 --- a/css/styles.css +++ b/css/styles.css @@ -4,7 +4,7 @@ } body { - font-family: Arial, helvetica, verdana, tahoma, "sans serif"; + font-family: Arial, helvetica, verdana, tahoma, "sans serif", serif; line-height: 1.3em; overflow-x: hidden; font-size: 1.2em; @@ -33,6 +33,8 @@ tr.item-data > td, thead > th { .new { font-weight: bold; + background-color: #ffff00; + color: #333333; } .up a, .new a { diff --git a/css/styles.min.css b/css/styles.min.css index 339732e..06f85b5 100644 --- a/css/styles.min.css +++ b/css/styles.min.css @@ -1 +1 @@ -*{margin:0;padding:0}body{font-family:Arial,helvetica,verdana,tahoma,"sans serif";line-height:1.3em;overflow-x:hidden;font-size:1.2em;background-color:#f5f5f5}table{border-collapse:collapse;width:100%}tr.item-data>td,thead>th{padding:.3em 1em;border-bottom:1px solid #fff}.head{background:#d9d9d9;color:#555;text-align:center}.head th{padding:.2em 10px}.new{font-weight:bold}.up a,.new a{color:#999}.up,.new-up{background-color:#66bb6a}.critical{background-color:#ef5350}.warning{background-color:#ffa726}.unknown{background:#7e57c2}.downtime{background:#42a5f5}.acknowledged{background:#78909c}.flapping{background:#d4e157;color:#555}.flapping,.flapping a{color:#555}.average{background-color:#fb8c00}.high{background-color:#ef9a9a}.information{background-color:#5c6bc0}.critical,.warning,.unknown,.downtime,.acknowledged,.new-up,.average,.information,.critical a,.warning a,.unknown a,.downtime a,.acknowledged a,.new-up a{color:#fff;font-size:1em;font-weight:bold}.statusinfo{font-size:.7em!important}#total{font-size:.7em;color:#777;text-align:right;padding:.3em 1em}#total a{color:#777}#loading{background:transparent url(../imgs/throbber.gif) no-repeat center center;width:214px;height:13px;display:inline-block}#refreshing{color:gray}#refreshing_countdown{display:inline-block;width:15px;text-align:center}#refreshing,#loading{line-height:50px;font-size:1em}#icinga_header{border:0;overflow:hidden;height:80px;width:100%}#monitor-data{margin:1em 0;width:100%}footer{text-align:right;color:#c9c9c9;font-size:.8em;margin-bottom:2em;border-top:1px solid #d9d9d9;padding:.5em 0}footer a,footer a:visited{color:#c9c9c9}footer #project{margin-right:2em}footer #project a{vertical-align:baseline}.action-link,.action-link img{font-size:10px;vertical-align:middle;padding:0}.action-link img{margin:0 1em;width:20px;height:20px}#logo{padding:1em;text-align:left;background-color:#555;-webkit-box-shadow:0 3px 5px 0 rgba(50,50,50,0.5);-moz-box-shadow:0 3px 5px 0 rgba(50,50,50,0.5);box-shadow:0 3px 5px 0 rgba(50,50,50,0.5)}#logo img{border:0}#logo h1,#logo h2{font-size:1em}#hora{position:absolute;top:0;left:0;width:100%;margin:0 auto;text-align:center;color:#fff;font-size:1.3em;display:inline-block}#titulo{position:absolute;top:0;right:1em;text-align:right;color:#fff}#nomessages{width:30%;margin:1em auto;color:green;text-align:center;background-color:#f2f2f2;padding:1em;border-radius:5px}#nomessages.full{width:90%;padding:.5em}#nomessages.error{border-top:1px solid #f44336;border-bottom:1px solid #f44336;color:#f44336;background-color:#ffebee;border-radius:0}div#nagvis-view{margin:0;margin-left:auto;margin-right:auto;width:1280px;height:500px;border:1px solid #d9d9d9;border-radius:5px;background-color:#fff;overflow-x:hidden;overflow-y:hidden;margin-bottom:2em}div#nagvis-view>iframe{width:100%;height:100%;border:0;overflow-x:hidden;overflow-y:hidden}#tblDowntime{margin-top:1em;font-size:14px}#tblDowntime thead.head{background-color:#dfdfdf;color:#777;text-align:center}#tblDowntime tbody tr{color:#fff;background-color:#42a5f5;text-align:center}div.title{width:100%;margin:0 auto;color:#777;text-align:center;border-top:1px solid #d9d9d9;padding:.5em 0}.center{text-align:center}footer #updates{display:inline-block;margin-right:.5em} \ No newline at end of file +*{margin:0;padding:0}body{font-family:Arial,helvetica,verdana,tahoma,"sans serif",serif;line-height:1.3em;overflow-x:hidden;font-size:1.2em;background-color:#f5f5f5}table{border-collapse:collapse;width:100%}tr.item-data>td,thead>th{padding:.3em 1em;border-bottom:1px solid #fff}.head{background:#d9d9d9;color:#555;text-align:center}.head th{padding:.2em 10px}.new{font-weight:bold;background-color:#ff0;color:#333}.up a,.new a{color:#999}.up,.new-up{background-color:#66bb6a}.critical{background-color:#ef5350}.warning{background-color:#ffa726}.unknown{background:#7e57c2}.downtime{background:#42a5f5}.acknowledged{background:#78909c}.flapping{background:#d4e157;color:#555}.flapping,.flapping a{color:#555}.average{background-color:#fb8c00}.high{background-color:#ef9a9a}.information{background-color:#5c6bc0}.critical,.warning,.unknown,.downtime,.acknowledged,.new-up,.average,.information,.critical a,.warning a,.unknown a,.downtime a,.acknowledged a,.new-up a{color:#fff;font-size:1em;font-weight:bold}.statusinfo{font-size:.7em !important}#total{font-size:.7em;color:#777;text-align:right;padding:.3em 1em}#total a{color:#777}#loading{background:transparent url(../imgs/throbber.gif) no-repeat center center;width:214px;height:13px;display:inline-block}#refreshing{color:gray}#refreshing_countdown{display:inline-block;width:15px;text-align:center}#refreshing,#loading{line-height:50px;font-size:1em}#icinga_header{border:0;overflow:hidden;height:80px;width:100%}#monitor-data{margin:1em 0;width:100%}footer{text-align:right;color:#c9c9c9;font-size:.8em;margin-bottom:2em;border-top:1px solid #d9d9d9;padding:.5em 0}footer a,footer a:visited{color:#c9c9c9}footer #project{margin-right:2em}footer #project a{vertical-align:baseline}.action-link,.action-link img{font-size:10px;vertical-align:middle;padding:0}.action-link img{margin:0 1em;width:20px;height:20px}#logo{padding:1em;text-align:left;background-color:#555;-webkit-box-shadow:0 3px 5px 0 rgba(50,50,50,0.5);-moz-box-shadow:0 3px 5px 0 rgba(50,50,50,0.5);box-shadow:0 3px 5px 0 rgba(50,50,50,0.5)}#logo img{border:0}#logo h1,#logo h2{font-size:1em}#hora{position:absolute;top:0;left:0;width:100%;margin:0 auto;text-align:center;color:#fff;font-size:1.3em;display:inline-block}#titulo{position:absolute;top:0;right:1em;text-align:right;color:#fff}#nomessages{width:30%;margin:1em auto;color:green;text-align:center;background-color:#f2f2f2;padding:1em;border-radius:5px}#nomessages.full{width:90%;padding:.5em}#nomessages.error{border-top:1px solid #f44336;border-bottom:1px solid #f44336;color:#f44336;background-color:#ffebee;border-radius:0}div#nagvis-view{margin:0;margin-left:auto;margin-right:auto;width:1280px;height:500px;border:1px solid #d9d9d9;border-radius:5px;background-color:#fff;overflow-x:hidden;overflow-y:hidden;margin-bottom:2em}div#nagvis-view>iframe{width:100%;height:100%;border:0;overflow-x:hidden;overflow-y:hidden}#tblDowntime{margin-top:1em;font-size:14px}#tblDowntime thead.head{background-color:#dfdfdf;color:#777;text-align:center}#tblDowntime tbody tr{color:#fff;background-color:#42a5f5;text-align:center}div.title{width:100%;margin:0 auto;color:#777;text-align:center;border-top:1px solid #d9d9d9;padding:.5em 0}.center{text-align:center}footer #updates{display:inline-block;margin-right:.5em} \ No newline at end of file diff --git a/inc/SMD/Util/Util.class.php b/inc/SMD/Util/Util.class.php index 508c16c..829e2ce 100644 --- a/inc/SMD/Util/Util.class.php +++ b/inc/SMD/Util/Util.class.php @@ -130,7 +130,7 @@ public static function checkRefreshSession() */ public static function getVersion($retBuild = false) { - $build = 2016061502; + $build = 2016061601; $version = array(1, 0); if ($retBuild) { diff --git a/js/functions.js b/js/functions.js index af5fda3..ea5edc4 100644 --- a/js/functions.js +++ b/js/functions.js @@ -144,8 +144,6 @@ function SMD() { newItemsCount = newItems.length; playBeep(); } - - newItems.highlight({bgcolor_on: self.hex2rgb('#ffff00'), fgcolor_on: self.hex2rgb('#333333')}); }, error: function (xhr, textStatus, errorThrown) { placeHolder.html("
" + Config.getLang(1) + "

" + xhr.status + " " + xhr.statusText + "

"); @@ -286,6 +284,7 @@ function SMD() { $html.find('[name=\'backend[zabbix][version]\']')[0].name = "backend[zabbix][" + len + "][version]"; $html.find('[name=\'backend[zabbix][user]\']')[0].name = "backend[zabbix][" + len + "][user]"; $html.find('[name=\'backend[zabbix][pass]\']')[0].name = "backend[zabbix][" + len + "][pass]"; + $html.find('[name=\'backend[zabbix][level]\']')[0].name = "backend[zabbix][" + len + "][level]"; $html.find('[name=\'backend[zabbix][active]\']')[0].name = "backend[zabbix][" + len + "][active]"; return $html.html(); @@ -509,12 +508,6 @@ function SMD() { }) }; - /** - * Establecer los eventos para la vista de eventos - */ - this.setDashboardHooks = function () { - }; - /** * Reproducir sonido */ diff --git a/js/functions.min.js b/js/functions.min.js index af519d7..dd8e463 100644 --- a/js/functions.min.js +++ b/js/functions.min.js @@ -1 +1 @@ -(function(a){a.fn.highlight=function(c){var d={delay:1000};var b=a.extend(d,c);return this.each(function(){var e=a(this);a(e).css("color",b.fgcolor_on);a(e).css("background-color",b.bgcolor_on)})}}(jQuery));function SMD(){jQuery.noConflict();var c;var a;var b=this;var f=0;var g=false;this.SMDConfig=function(){var l=10000,i=0,h="/ajax/getData.php",m="",k=false;var j=[];this.setTimeout=function(n){l=n*1000};this.getTimeout=function(){return l};this.setScroll=function(n){i=n};this.getScroll=function(){return i};this.setAjaxFile=function(n){h=n};this.getAjaxFile=function(){if(m===""){return b.getRootPath()+h}return h};this.setLang=function(n){j.push(n)};this.getLang=function(n){return j[n]};this.setRemoteServer=function(n){m=n};this.getRemoteServer=function(){return m};this.setAudioEnabled=function(n){k=n};this.getAudioEnabled=function(){return k}};this.getRootPath=function(){var i=window.location.pathname.split("/");var h=function(){var j="";for(var k=1;k<=i.length-2;k++){j+="/"+i[k]}return j};return window.location.protocol+"//"+window.location.host+h()};this.hex2rgb=function(l){var k=parseInt(l.substring(1),16);var j=(k&16711680)>>16;var i=(k&65280)>>8;var h=k&255;return"rgb("+j+", "+i+", "+h+")"};this.updateNagiosData=function(){var i=jQuery("#monitor-data");this.setTime();var h=a.getRemoteServer()+a.getAjaxFile();jQuery.ajax({url:h,cache:false,timeout:a.getTimeout(),dataType:"html",success:function(k){i.html(k);if(a.getScroll()){c=jQuery(document).height();if(c>window.innerHeight){setTimeout(function(){b.pageScroll()},a.getTimeout()/2)}}var j=jQuery(".new");if(f'+a.getLang(1)+"

"+k.status+" "+k.statusText+"

")}})};this.updateCountDown=function(){var i=jQuery("#refreshing_countdown");var h=parseInt(i.text());if(h==0){b.updateNagiosData();i.text(a.getTimeout())}else{i.text(h-1)}};this.setTime=function(){var k=new Date();var h=("0"+k.getDate()).slice(-2)+"-"+("0"+(k.getMonth()+1)).slice(-2)+"-"+k.getFullYear();var l=("0"+k.getHours()).slice(-2);var i=("0"+k.getMinutes()).slice(-2);var j=("0"+k.getSeconds()).slice(-2);jQuery("#hora").find("h1").html(h+"
"+l+":"+i+":"+j)};this.pageScroll=function(){jQuery("body,html").animate({scrollTop:c},a.getTimeout()/2,function(){b.pageUnScroll()}).on("mousemove",function(){jQuery(this).stop(true)})};this.pageUnScroll=function(){jQuery("body,html").scrollTop(0)};this.reloadPage=function(){window.location.reload(false)};this.saveConfig=function(h){jQuery.ajax({url:b.getRootPath()+"/ajax/saveConfig.php",type:"post",dataType:"json",data:h.serialize(),success:function(i){var j=jQuery("#result");j.removeClass();if(i.status==0){j.addClass("ok")}else{j.addClass("error")}j.html(i.description)}})};this.getNewLivestatusBackend=function(){var i=jQuery(".backendLivestatus").length;var h=jQuery(".livestatusTemplate").clone();h.find("[name='backend[livestatus][alias]']")[0].name="backend[livestatus]["+i+"][alias]]";h.find("[name='backend[livestatus][path]']")[0].name="backend[livestatus]["+i+"][path]]";h.find("[name='backend[livestatus][active]']")[0].name="backend[livestatus]["+i+"][active]]";return h.html()};this.getNewStatusBackend=function(){var i=jQuery(".backendStatus").length;var h=jQuery(".statusTemplate").clone();h.find("[name='backend[status][alias]']")[0].name="backend[status]["+i+"][alias]]";h.find("[name='backend[status][path]']")[0].name="backend[status]["+i+"][path]]";h.find("[name='backend[status][active]']")[0].name="backend[status]["+i+"][active]]";return h.html()};this.getNewZabbixBackend=function(){var i=jQuery(".backendZabbix").length;var h=jQuery(".zabbixTemplate").clone();h.find("[name='backend[zabbix][alias]']")[0].name="backend[zabbix]["+i+"][alias]";h.find("[name='backend[zabbix][url]']")[0].name="backend[zabbix]["+i+"][url]";h.find("[name='backend[zabbix][version]']")[0].name="backend[zabbix]["+i+"][version]";h.find("[name='backend[zabbix][user]']")[0].name="backend[zabbix]["+i+"][user]";h.find("[name='backend[zabbix][pass]']")[0].name="backend[zabbix]["+i+"][pass]";h.find("[name='backend[zabbix][active]']")[0].name="backend[zabbix]["+i+"][active]";return h.html()};this.getNewSMDBackend=function(){var i=jQuery(".backendSMD").length;var h=jQuery(".SMDTemplate").clone();h.find("[name='backend[smd][alias]']")[0].name="backend[smd]["+i+"][alias]";h.find("[name='backend[smd][url]']")[0].name="backend[smd]["+i+"][url]";h.find("[name='backend[smd][token]']")[0].name="backend[smd]["+i+"][token]";h.find("[name='backend[smd][active]']")[0].name="backend[smd]["+i+"][active]";return h.html()};this.getUpdates=function(){jQuery("#updates").load(this.getRootPath()+"/ajax/getUpdates.php")};this.startSMD=function(){jQuery.ajaxSetup({global:false,timeout:a.getTimeout()/2});this.updateNagiosData();setInterval(function(){b.updateNagiosData()},a.getTimeout())};this.setConfig=function(h){a=h};this.makeHash=function(k){var l="";var j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(var h=0;h",{"class":"backendLivestatus backendConfig",html:b.getNewLivestatusBackend()}).hide().appendTo("#backends-config-container").slideDown("slow");var k=i.offset();window.scroll(0,k.top)});jQuery("#addStatusBackend").on("click",function(j){j.preventDefault();var i=jQuery("
",{"class":"backendStatus backendConfig",html:b.getNewStatusBackend()}).hide().appendTo("#backends-config-container").slideDown("slow");var k=i.offset();window.scroll(0,k.top)});jQuery("#addZabbixBackend").on("click",function(j){j.preventDefault();var i=jQuery("
",{"class":"backendZabbix backendConfig",html:b.getNewZabbixBackend()}).hide().appendTo("#backends-config-container").slideDown("slow");var k=i.offset();window.scroll(0,k.top)});jQuery("#addSMDBackend").on("click",function(j){j.preventDefault();var i=jQuery("
",{"class":"backendSMD backendConfig",html:b.getNewSMDBackend()}).hide().appendTo("#backends-config-container").slideDown("slow");var k=i.offset();window.scroll(0,k.top)});jQuery("#backends-config-container").on("click",".backendDelete",function(k){k.preventDefault();var i=window.confirm(a.getLang(0));if(i===true){var j=jQuery(this).parent().parent(".backendConfig");j.slideUp("slow",function(){j.remove()})}}).on("click",".backendCheckSMD",function(n){n.preventDefault();var m=jQuery(this).parent().parent(".backendConfig");var k=m.find(".backend_smd_url").val();var l=m.find(".backend_smd_token").val();if(k===""){alertify.alert(a.getLang(4));return}var j={url:k,action:10,token:l};var i={action:"smdBackend",data:JSON.stringify(j)};e(i)}).on("click",".backendCheckZabbix",function(p){p.preventDefault();var n=jQuery(this).parent().parent(".backendConfig");var j=n.find(".backend_zabbix_version").val();var m=n.find(".backend_zabbix_url").val();var l=n.find(".backend_zabbix_user").val();var o=n.find(".backend_zabbix_pass").val();if(j===""||m===""){alertify.alert(a.getLang(4));return}var k={url:m,version:j,user:l,pass:o};var i={action:"zabbixBackend",data:JSON.stringify(k)};e(i)});jQuery(".btn-gen-token, .btn-gen-pass").click(function(j){var i=b.makeHash(32);document.getElementById(this.getAttribute("data-dst")).value=i;jQuery(this).next(".fa-eye").attr("title",i)});jQuery(".fa-eye").click(function(){var i=this.getAttribute("title");if(i!==""){alertify.alert(i)}});jQuery("#special_config_pass").on("keyup",function(){jQuery(this).parent().find(".fa-eye").attr("title",this.value)});jQuery("#btnBack").click(function(){location.href=b.getRootPath()});jQuery(".container-state").on("click",function(k){var i=document.getElementById(this.getAttribute("data-container"));var j=i.getAttribute("aria-expanded");if(j=="true"){i.setAttribute("aria-expanded","false");jQuery(this).removeClass("fa-caret-up").addClass("fa-caret-down");jQuery(i).slideUp("slow")}else{i.setAttribute("aria-expanded","true");jQuery(this).removeClass("fa-caret-down").addClass("fa-caret-up");jQuery(i).slideDown("slow")}})};this.setDashboardHooks=function(){};var d=function d(){if(a.getAudioEnabled()){var h=document.getElementById("audio-alarm");var i=a.getTimeout()/1000;if(h.duration>=i&&g===false){h.addEventListener("timeupdate",function(){g=true;if(h.currentTime>=i-2){h.pause();h.currentTime=0}})}h.play()}};var e=function(h){jQuery.ajax({url:b.getRootPath()+"/ajax/checkConfig.php",type:"post",dataType:"json",data:h,success:function(i){var j;if(typeof i.status==="undefined"||i.status!==0){j=a.getLang(3)+"
"+a.getLang(2)+" "+i.description||"";alertify.alert(j)}else{j=a.getLang(1)+"
"+a.getLang(2)+" "+i.description;alertify.alert(j)}}})}}var smd=new SMD();var config=new smd.SMDConfig(); \ No newline at end of file +(function(a){a.fn.highlight=function(c){var d={delay:1000};var b=a.extend(d,c);return this.each(function(){var e=a(this);a(e).css("color",b.fgcolor_on);a(e).css("background-color",b.bgcolor_on)})}}(jQuery));function SMD(){jQuery.noConflict();var c;var a;var b=this;var f=0;var g=false;this.SMDConfig=function(){var l=10000,i=0,h="/ajax/getData.php",m="",k=false;var j=[];this.setTimeout=function(n){l=n*1000};this.getTimeout=function(){return l};this.setScroll=function(n){i=n};this.getScroll=function(){return i};this.setAjaxFile=function(n){h=n};this.getAjaxFile=function(){if(m===""){return b.getRootPath()+h}return h};this.setLang=function(n){j.push(n)};this.getLang=function(n){return j[n]};this.setRemoteServer=function(n){m=n};this.getRemoteServer=function(){return m};this.setAudioEnabled=function(n){k=n};this.getAudioEnabled=function(){return k}};this.getRootPath=function(){var i=window.location.pathname.split("/");var h=function(){var j="";for(var k=1;k<=i.length-2;k++){j+="/"+i[k]}return j};return window.location.protocol+"//"+window.location.host+h()};this.hex2rgb=function(l){var k=parseInt(l.substring(1),16);var j=(k&16711680)>>16;var i=(k&65280)>>8;var h=k&255;return"rgb("+j+", "+i+", "+h+")"};this.updateNagiosData=function(){var i=jQuery("#monitor-data");this.setTime();var h=a.getRemoteServer()+a.getAjaxFile();jQuery.ajax({url:h,cache:false,timeout:a.getTimeout(),dataType:"html",success:function(k){i.html(k);if(a.getScroll()){c=jQuery(document).height();if(c>window.innerHeight){setTimeout(function(){b.pageScroll()},a.getTimeout()/2)}}var j=jQuery(".new");if(f'+a.getLang(1)+"

"+k.status+" "+k.statusText+"

")}})};this.updateCountDown=function(){var i=jQuery("#refreshing_countdown");var h=parseInt(i.text());if(h==0){b.updateNagiosData();i.text(a.getTimeout())}else{i.text(h-1)}};this.setTime=function(){var k=new Date();var h=("0"+k.getDate()).slice(-2)+"-"+("0"+(k.getMonth()+1)).slice(-2)+"-"+k.getFullYear();var l=("0"+k.getHours()).slice(-2);var i=("0"+k.getMinutes()).slice(-2);var j=("0"+k.getSeconds()).slice(-2);jQuery("#hora").find("h1").html(h+"
"+l+":"+i+":"+j)};this.pageScroll=function(){jQuery("body,html").animate({scrollTop:c},a.getTimeout()/2,function(){b.pageUnScroll()}).on("mousemove",function(){jQuery(this).stop(true)})};this.pageUnScroll=function(){jQuery("body,html").scrollTop(0)};this.reloadPage=function(){window.location.reload(false)};this.saveConfig=function(h){jQuery.ajax({url:b.getRootPath()+"/ajax/saveConfig.php",type:"post",dataType:"json",data:h.serialize(),success:function(i){var j=jQuery("#result");j.removeClass();if(i.status==0){j.addClass("ok")}else{j.addClass("error")}j.html(i.description)}})};this.getNewLivestatusBackend=function(){var i=jQuery(".backendLivestatus").length;var h=jQuery(".livestatusTemplate").clone();h.find("[name='backend[livestatus][alias]']")[0].name="backend[livestatus]["+i+"][alias]]";h.find("[name='backend[livestatus][path]']")[0].name="backend[livestatus]["+i+"][path]]";h.find("[name='backend[livestatus][active]']")[0].name="backend[livestatus]["+i+"][active]]";return h.html()};this.getNewStatusBackend=function(){var i=jQuery(".backendStatus").length;var h=jQuery(".statusTemplate").clone();h.find("[name='backend[status][alias]']")[0].name="backend[status]["+i+"][alias]]";h.find("[name='backend[status][path]']")[0].name="backend[status]["+i+"][path]]";h.find("[name='backend[status][active]']")[0].name="backend[status]["+i+"][active]]";return h.html()};this.getNewZabbixBackend=function(){var i=jQuery(".backendZabbix").length;var h=jQuery(".zabbixTemplate").clone();h.find("[name='backend[zabbix][alias]']")[0].name="backend[zabbix]["+i+"][alias]";h.find("[name='backend[zabbix][url]']")[0].name="backend[zabbix]["+i+"][url]";h.find("[name='backend[zabbix][version]']")[0].name="backend[zabbix]["+i+"][version]";h.find("[name='backend[zabbix][user]']")[0].name="backend[zabbix]["+i+"][user]";h.find("[name='backend[zabbix][pass]']")[0].name="backend[zabbix]["+i+"][pass]";h.find("[name='backend[zabbix][level]']")[0].name="backend[zabbix]["+i+"][level]";h.find("[name='backend[zabbix][active]']")[0].name="backend[zabbix]["+i+"][active]";return h.html()};this.getNewSMDBackend=function(){var i=jQuery(".backendSMD").length;var h=jQuery(".SMDTemplate").clone();h.find("[name='backend[smd][alias]']")[0].name="backend[smd]["+i+"][alias]";h.find("[name='backend[smd][url]']")[0].name="backend[smd]["+i+"][url]";h.find("[name='backend[smd][token]']")[0].name="backend[smd]["+i+"][token]";h.find("[name='backend[smd][active]']")[0].name="backend[smd]["+i+"][active]";return h.html()};this.getUpdates=function(){jQuery("#updates").load(this.getRootPath()+"/ajax/getUpdates.php")};this.startSMD=function(){jQuery.ajaxSetup({global:false,timeout:a.getTimeout()/2});this.updateNagiosData();setInterval(function(){b.updateNagiosData()},a.getTimeout())};this.setConfig=function(h){a=h};this.makeHash=function(k){var l="";var j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(var h=0;h",{"class":"backendLivestatus backendConfig",html:b.getNewLivestatusBackend()}).hide().appendTo("#backends-config-container").slideDown("slow");var k=i.offset();window.scroll(0,k.top)});jQuery("#addStatusBackend").on("click",function(j){j.preventDefault();var i=jQuery("
",{"class":"backendStatus backendConfig",html:b.getNewStatusBackend()}).hide().appendTo("#backends-config-container").slideDown("slow");var k=i.offset();window.scroll(0,k.top)});jQuery("#addZabbixBackend").on("click",function(j){j.preventDefault();var i=jQuery("
",{"class":"backendZabbix backendConfig",html:b.getNewZabbixBackend()}).hide().appendTo("#backends-config-container").slideDown("slow");var k=i.offset();window.scroll(0,k.top)});jQuery("#addSMDBackend").on("click",function(j){j.preventDefault();var i=jQuery("
",{"class":"backendSMD backendConfig",html:b.getNewSMDBackend()}).hide().appendTo("#backends-config-container").slideDown("slow");var k=i.offset();window.scroll(0,k.top)});jQuery("#backends-config-container").on("click",".backendDelete",function(k){k.preventDefault();var i=window.confirm(a.getLang(0));if(i===true){var j=jQuery(this).parent().parent(".backendConfig");j.slideUp("slow",function(){j.remove()})}}).on("click",".backendCheckSMD",function(n){n.preventDefault();var m=jQuery(this).parent().parent(".backendConfig");var k=m.find(".backend_smd_url").val();var l=m.find(".backend_smd_token").val();if(k===""){alertify.alert(a.getLang(4));return}var j={url:k,action:10,token:l};var i={action:"smdBackend",data:JSON.stringify(j)};e(i)}).on("click",".backendCheckZabbix",function(p){p.preventDefault();var n=jQuery(this).parent().parent(".backendConfig");var j=n.find(".backend_zabbix_version").val();var m=n.find(".backend_zabbix_url").val();var l=n.find(".backend_zabbix_user").val();var o=n.find(".backend_zabbix_pass").val();if(j===""||m===""){alertify.alert(a.getLang(4));return}var k={url:m,version:j,user:l,pass:o};var i={action:"zabbixBackend",data:JSON.stringify(k)};e(i)});jQuery(".btn-gen-token, .btn-gen-pass").click(function(j){var i=b.makeHash(32);document.getElementById(this.getAttribute("data-dst")).value=i;jQuery(this).next(".fa-eye").attr("title",i)});jQuery(".fa-eye").click(function(){var i=this.getAttribute("title");if(i!==""){alertify.alert(i)}});jQuery("#special_config_pass").on("keyup",function(){jQuery(this).parent().find(".fa-eye").attr("title",this.value)});jQuery("#btnBack").click(function(){location.href=b.getRootPath()});jQuery(".container-state").on("click",function(k){var i=document.getElementById(this.getAttribute("data-container"));var j=i.getAttribute("aria-expanded");if(j=="true"){i.setAttribute("aria-expanded","false");jQuery(this).removeClass("fa-caret-up").addClass("fa-caret-down");jQuery(i).slideUp("slow")}else{i.setAttribute("aria-expanded","true");jQuery(this).removeClass("fa-caret-down").addClass("fa-caret-up");jQuery(i).slideDown("slow")}})};var d=function d(){if(a.getAudioEnabled()){var h=document.getElementById("audio-alarm");var i=a.getTimeout()/1000;if(h.duration>=i&&g===false){h.addEventListener("timeupdate",function(){g=true;if(h.currentTime>=i-2){h.pause();h.currentTime=0}})}h.play()}};var e=function(h){jQuery.ajax({url:b.getRootPath()+"/ajax/checkConfig.php",type:"post",dataType:"json",data:h,success:function(i){var j;if(typeof i.status==="undefined"||i.status!==0){j=a.getLang(3)+"
"+a.getLang(2)+" "+i.description||"";alertify.alert(j)}else{j=a.getLang(1)+"
"+a.getLang(2)+" "+i.description;alertify.alert(j)}}})}}var smd=new SMD();var config=new smd.SMDConfig(); \ No newline at end of file