diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 6645113104..4683e41e23 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,37 @@ +2008-06-30 Esteban Sanchez + + * include/functions_db.php: Renamed get_db_all_rows_sqlfree() to + get_db_all_rows_sql(). Replaced all occurrences of old function name. + + * general/logon_ok.php, godmode/reporting/reporting_builder.php, + operation/reporting/reporting_viewer.php, reporting/fgraph.php, + include/functions_reporting.php: Replaced all occurrences + ofget_db_all_rows_sqlfree() with get_db_all_rows_sql(). + + * include/config_process.php: Do not add a slash to attachment_store + config variable. + + * include/functions.php: Style correction. + + * operation/agentes/estado_agente.php: Reduced one indentation level + by using comprueba_login() propperly. + + * include/javascript/jquery.cluetip.js: Added to repository. jQuery + plugin to add cute tips support. + + * images/darrowdown.gif, images/darrowright.gif, images/darrowup.gif, + images/darrowleft.gif, images/wait.gif, include/styles/cluetip.css: + Added to repository. Cute tips styling. + + * operation/agentes/networkmap.php: Added support to pretty tips to + each node of the network map. Use a variable to define the name of + Pandora FMS node (maybe it would be a nice idea to let the user + configure it). Added an extra check for file existance when generating + the graphic. Use pandora functions in some cases. Style correction. + + * operation/agentes/ver_agente.php: Added AJAX support to get the + current status of an agent to suit in a tooltip. + 2008-06-27 Esteban Sanchez * include/functions_db.php: Renamed variable from spanish. diff --git a/pandora_console/general/logon_ok.php b/pandora_console/general/logon_ok.php index 992ca91821..c7a5dac04e 100644 --- a/pandora_console/general/logon_ok.php +++ b/pandora_console/general/logon_ok.php @@ -175,7 +175,7 @@ $table->head[4] = lang_string ('comments'); $sql = sprintf ('SELECT * FROM tsesion WHERE (TO_DAYS(fecha) > TO_DAYS(NOW()) - 7) AND ID_usuario = "%s" ORDER BY fecha DESC LIMIT 5', $nick); -$sessions = get_db_all_rows_sqlfree ($sql); +$sessions = get_db_all_rows_sql ($sql); foreach ($sessions as $session) { $data = array (); diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 0a3308d1d9..1e3dc4e21c 100644 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -397,7 +397,7 @@ if ($edit_sla_report_content) { $modules = array (); if ($id_agent) { $sql = sprintf ('SELECT * FROM tagente_modulo WHERE id_agente = %d ORDER BY nombre', $id_agent); - $modules = get_db_all_rows_sqlfree ($sql); + $modules = get_db_all_rows_sql ($sql); } $table->data[3][1] = print_select ($modules, 'id_module', 0, '', '--', 0, true); @@ -437,7 +437,7 @@ if ($edit_sla_report_content) { } $sql = sprintf ('SELECT * FROM treport_content WHERE id_report = %d ORDER BY `order`', $id_report); - $report_contents = get_db_all_rows_sqlfree ($sql); + $report_contents = get_db_all_rows_sql ($sql); if (sizeof ($report_contents)) { $first_id = $report_contents[0]['id_rc']; $last_id = $report_contents[sizeof ($report_contents) - 1]['id_rc']; diff --git a/pandora_console/images/darrowdown.gif b/pandora_console/images/darrowdown.gif new file mode 100644 index 0000000000..e138d9b02b Binary files /dev/null and b/pandora_console/images/darrowdown.gif differ diff --git a/pandora_console/images/darrowleft.gif b/pandora_console/images/darrowleft.gif new file mode 100644 index 0000000000..e22d11c970 Binary files /dev/null and b/pandora_console/images/darrowleft.gif differ diff --git a/pandora_console/images/darrowright.gif b/pandora_console/images/darrowright.gif new file mode 100644 index 0000000000..d36d7e4cb7 Binary files /dev/null and b/pandora_console/images/darrowright.gif differ diff --git a/pandora_console/images/darrowup.gif b/pandora_console/images/darrowup.gif new file mode 100644 index 0000000000..fd7405711d Binary files /dev/null and b/pandora_console/images/darrowup.gif differ diff --git a/pandora_console/images/wait.gif b/pandora_console/images/wait.gif new file mode 100644 index 0000000000..8186b0c050 Binary files /dev/null and b/pandora_console/images/wait.gif differ diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 84a9f840a8..68335e65aa 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -26,7 +26,7 @@ if (!isset($pandora_version)) // This MUST be writtable by http server user, and should be in pandora root. // By default, Pandora adds /attachment to this, so by default is the pandora console home dir -$config["attachment_store"]=$config["homedir"]."/attachment"; +$config["attachment_store"]=$config["homedir"]."attachment"; // Default font used for graphics (a Free TrueType font included with Pandora FMS) $config["fontpath"] = $config["homedir"]."/reporting/FreeSans.ttf"; diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 5f89be53ef..fc3c7fcf68 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -551,7 +551,7 @@ function human_time_description ($period) { * * @return The current time minus the seconds given. */ -function human_date_relative ( $seconds ) { +function human_date_relative ($seconds) { $ahora=date("Y/m/d H:i:s"); $ahora_s = date("U"); $ayer = date ("Y/m/d H:i:s", $ahora_s - $seconds); diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index d01748f85e..e3683f373a 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -231,7 +231,7 @@ function get_agents_in_group ($id_group, $disabled = false) { $sql = sprintf ('SELECT * FROM tagente WHERE id_grupo = %d AND disabled = 0', $id_group); - return get_db_all_rows_sqlfree ($sql); + return get_db_all_rows_sql ($sql); } /** @@ -257,7 +257,7 @@ function get_simple_alerts_in_agent ($id_agent) { FROM talerta_agente_modulo, tagente_modulo WHERE talerta_agente_modulo.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.id_agente = %d', $id_agent); - return get_db_all_rows_sqlfree ($sql); + return get_db_all_rows_sql ($sql); } /** @@ -1256,7 +1256,7 @@ function get_db_sql ($sql, $field = 0) { * * @return A matrix with all the values returned from the SQL statement */ -function get_db_all_rows_sqlfree ($sql) { +function get_db_all_rows_sql ($sql) { global $config; $retval = array (); $result = mysql_query ($sql); @@ -1280,7 +1280,7 @@ function get_db_all_rows_sqlfree ($sql) { * @return A matrix with all the values in the table */ function get_db_all_rows_in_table ($table) { - return get_db_all_rows_sqlfree ('SELECT * FROM '.$table); + return get_db_all_rows_sql ('SELECT * FROM '.$table); } /** @@ -1301,7 +1301,7 @@ function get_db_all_rows_field_filter ($table, $field, $condition) { $sql = sprintf ('SELECT * FROM %s WHERE %s = "%s"', $table, $field, $condition); } - return get_db_all_rows_sqlfree ($sql); + return get_db_all_rows_sql ($sql); } /** @@ -1314,7 +1314,7 @@ function get_db_all_rows_field_filter ($table, $field, $condition) { * @return A matrix with all the values in the table that matches the condition in the field */ function get_db_all_fields_in_table ($table, $field) { - return get_db_all_rows_sqlfree ('SELECT '.$field.' FROM '. $table); + return get_db_all_rows_sql ('SELECT '.$field.' FROM '. $table); } /** @@ -1555,7 +1555,7 @@ function return_moduledata_sum_value ($id_agent_module, $period, $date = 0) { AND utimestamp > %d AND utimestamp <= %d ORDER BY utimestamp ASC', $id_agent_module, $datelimit, $date); - $datas = get_db_all_rows_sqlfree ($sql); + $datas = get_db_all_rows_sql ($sql); /* Get also the previous data before the selected interval. */ $previous_data = get_previous_data ($id_agent_module, $datelimit); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index f0c5e2e7a8..8e5c3bf0fb 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -28,7 +28,7 @@ function return_module_SLA ($id_agent_module, $period, $min_value, $max_value, $ AND utimestamp > %d AND utimestamp <= %d ORDER BY utimestamp ASC', $id_agent, $id_agent_module, $datelimit, $date); - $datas = get_db_all_rows_sqlfree ($sql); + $datas = get_db_all_rows_sql ($sql); $last_data = ""; $total_badtime = 0; $interval_begin = 0; @@ -352,7 +352,7 @@ function monitor_health_reporting ($id_group, $period = 0, $date = 0, $return = AND tagente.id_agente = tagente_modulo.id_agente AND ttipo_modulo.nombre like "%%_proc" AND tagente.id_grupo = %d', $id_group); - $monitors = get_db_all_rows_sqlfree ($sql); + $monitors = get_db_all_rows_sql ($sql); if (sizeof ($monitors) == 0) return; diff --git a/pandora_console/include/javascript/jquery.cluetip.js b/pandora_console/include/javascript/jquery.cluetip.js new file mode 100644 index 0000000000..c8a18b4368 --- /dev/null +++ b/pandora_console/include/javascript/jquery.cluetip.js @@ -0,0 +1,38 @@ +/* + * jQuery clueTip plugin + * Version 0.9.8 (05/22/2008) + * @requires jQuery v1.1.4+ + * @requires Dimensions plugin (for jQuery versions < 1.2.5) + * + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + */ +;(function($){var $cluetip,$cluetipInner,$cluetipOuter,$cluetipTitle,$cluetipArrows,$dropShadow,imgCount;$.fn.cluetip=function(js,options){if(typeof js=='object'){options=js;js=null;} +return this.each(function(index){var $this=$(this);var opts=$.extend(false,{},$.fn.cluetip.defaults,options||{},$.metadata?$this.metadata():$.meta?$this.data():{});var cluetipContents=false;var cluezIndex=parseInt(opts.cluezIndex,10)-1;var isActive=false,closeOnDelay=0;if(!$('#cluetip').length){$cluetipInner=$('
');$cluetipTitle=$('

');$cluetipOuter=$('
').append($cluetipInner).prepend($cluetipTitle);$cluetip=$('
').css({zIndex:opts.cluezIndex}).append($cluetipOuter).append('
')[insertionType](insertionElement).hide();$('
').css({position:'absolute',zIndex:cluezIndex-1}).insertBefore('#cluetip').hide();$cluetip.css({position:'absolute',zIndex:cluezIndex});$cluetipOuter.css({position:'relative',zIndex:cluezIndex+1});$cluetipArrows=$('
').css({zIndex:cluezIndex+1}).appendTo('#cluetip');} +var dropShadowSteps=(opts.dropShadow)?+opts.dropShadowSteps:0;if(!$dropShadow){$dropShadow=$([]);for(var i=0;i').css({zIndex:cluezIndex-i-1,opacity:.1,top:1+i,left:1+i}));};$dropShadow.css({position:'absolute',backgroundColor:'#000'}).prependTo($cluetip);} +var tipAttribute=$this.attr(opts.attribute),ctClass=opts.cluetipClass;if(!tipAttribute&&!opts.splitTitle&&!js)return true;if(opts.local&&opts.hideLocal){$(tipAttribute+':first').hide();} +var tOffset=parseInt(opts.topOffset,10),lOffset=parseInt(opts.leftOffset,10);var tipHeight,wHeight;var defHeight=isNaN(parseInt(opts.height,10))?'auto':(/\D/g).test(opts.height)?opts.height:opts.height+'px';var sTop,linkTop,posY,tipY,mouseY,baseline;var tipInnerWidth=isNaN(parseInt(opts.width,10))?275:parseInt(opts.width,10);var tipWidth=tipInnerWidth+(parseInt($cluetip.css('paddingLeft'))||0)+(parseInt($cluetip.css('paddingRight'))||0)+dropShadowSteps;var linkWidth=this.offsetWidth;var linkLeft,posX,tipX,mouseX,winWidth;var tipParts;var tipTitle=(opts.attribute!='title')?$this.attr(opts.titleAttribute):'';if(opts.splitTitle){if(tipTitle==undefined){tipTitle='';} +tipParts=tipTitle.split(opts.splitTitle);tipTitle=tipParts.shift();} +var localContent;var activate=function(event){if(!opts.onActivate($this)){return false;} +isActive=true;$cluetip.removeClass().css({width:tipInnerWidth});if(tipAttribute==$this.attr('href')){$this.css('cursor',opts.cursor);} +$this.attr('title','');if(opts.hoverClass){$this.addClass(opts.hoverClass);} +linkTop=posY=$this.offset().top;linkLeft=$this.offset().left;mouseX=event.pageX;mouseY=event.pageY;if($this[0].tagName.toLowerCase()!='area'){sTop=$(document).scrollTop();winWidth=$(window).width();} +if(opts.positionBy=='fixed'){posX=linkWidth+linkLeft+lOffset;$cluetip.css({left:posX});}else{posX=(linkWidth>linkLeft&&linkLeft>tipWidth)||linkLeft+linkWidth+tipWidth+lOffset>winWidth?linkLeft-tipWidth-lOffset:linkWidth+linkLeft+lOffset;if($this[0].tagName.toLowerCase()=='area'||opts.positionBy=='mouse'||linkWidth+tipWidth>winWidth){if(mouseX+20+tipWidth>winWidth){$cluetip.addClass(' cluetip-'+ctClass);posX=(mouseX-tipWidth-lOffset)>=0?mouseX-tipWidth-lOffset-parseInt($cluetip.css('marginLeft'),10)+parseInt($cluetipInner.css('marginRight'),10):mouseX-(tipWidth/2);}else{posX=mouseX+lOffset;}} +var pY=posX<0?event.pageY+tOffset:event.pageY;$cluetip.css({left:(posX>0&&opts.positionBy!='bottomTop')?posX:(mouseX+(tipWidth/2)>winWidth)?winWidth/2-tipWidth/2:Math.max(mouseX-(tipWidth/2),0)});} +wHeight=$(window).height();if(js){$cluetipInner.html(js);cluetipShow(pY);} +else if(tipParts){var tpl=tipParts.length;for(var i=0;i'+tipParts[i]+'');}};cluetipShow(pY);} +else if(!opts.local&&tipAttribute.indexOf('#')!=0){if(cluetipContents&&opts.ajaxCache){$cluetipInner.html(cluetipContents);cluetipShow(pY);} +else{var ajaxSettings=opts.ajaxSettings;ajaxSettings.url=tipAttribute;ajaxSettings.beforeSend=function(){$cluetipOuter.children().empty();if(opts.waitImage){$('#cluetip-waitimage').css({top:mouseY+20,left:mouseX+20}).show();}};ajaxSettings.error=function(){if(isActive){$cluetipInner.html('sorry, the contents could not be loaded');}};ajaxSettings.success=function(data){cluetipContents=opts.ajaxProcess(data);if(isActive){$cluetipInner.html(cluetipContents);}};ajaxSettings.complete=function(){imgCount=$('#cluetip-inner img').length;if(imgCount&&!$.browser.opera){$('#cluetip-inner img').load(function(){imgCount--;if(imgCount<1){$('#cluetip-waitimage').hide();if(isActive)cluetipShow(pY);}});}else{$('#cluetip-waitimage').hide();if(isActive)cluetipShow(pY);}};$.ajax(ajaxSettings);}}else if(opts.local){var $localContent=$(tipAttribute+':first');var localCluetip=$.fn.wrapInner?$localContent.wrapInner('
').children().clone(true):$localContent.html();$.fn.wrapInner?$cluetipInner.empty().append(localCluetip):$cluetipInner.html(localCluetip);cluetipShow(pY);}};var cluetipShow=function(bpY){$cluetip.addClass('cluetip-'+ctClass);if(opts.truncate){var $truncloaded=$cluetipInner.text().slice(0,opts.truncate)+'...';$cluetipInner.html($truncloaded);} +function doNothing(){};tipTitle?$cluetipTitle.show().html(tipTitle):(opts.showTitle)?$cluetipTitle.show().html(' '):$cluetipTitle.hide();if(opts.sticky){var $closeLink=$('');(opts.closePosition=='bottom')?$closeLink.appendTo($cluetipInner):(opts.closePosition=='title')?$closeLink.prependTo($cluetipTitle):$closeLink.prependTo($cluetipInner);$closeLink.click(function(){cluetipClose();return false;});if(opts.mouseOutClose){if($.fn.hoverIntent&&opts.hoverIntent){$cluetip.hoverIntent({over:doNothing,timeout:opts.hoverIntent.timeout,out:function(){$closeLink.trigger('click');}});}else{$cluetip.hover(doNothing,function(){$closeLink.trigger('click');});}}else{$cluetip.unbind('mouseout');}} +var direction='';$cluetipOuter.css({overflow:defHeight=='auto'?'visible':'auto',height:defHeight});tipHeight=defHeight=='auto'?Math.max($cluetip.outerHeight(),$cluetip.height()):parseInt(defHeight,10);tipY=posY;baseline=sTop+wHeight;if(opts.positionBy=='fixed'){tipY=posY-opts.dropShadowSteps+tOffset;}else if((posXmouseX)||opts.positionBy=='bottomTop'){if(posY+tipHeight+tOffset>baseline&&mouseY-sTop>tipHeight+tOffset){tipY=mouseY-tipHeight-tOffset;direction='top';}else{tipY=mouseY+tOffset;direction='bottom';}}else if(posY+tipHeight+tOffset>baseline){tipY=(tipHeight>=wHeight)?sTop:baseline-tipHeight-tOffset;}else if($this.css('display')=='block'||$this[0].tagName.toLowerCase()=='area'||opts.positionBy=="mouse"){tipY=bpY-tOffset;}else{tipY=posY-opts.dropShadowSteps;} +if(direction==''){posX=0&&bgY>0)?bgY+'px':/(left|right)/.test(direction)?0:''}).show();}else{$cluetipArrows.hide();} +$dropShadow.hide();$cluetip.hide()[opts.fx.open](opts.fx.open!='show'&&opts.fx.openSpeed);if(opts.dropShadow)$dropShadow.css({height:tipHeight,width:tipInnerWidth}).show();if($.fn.bgiframe){$cluetip.bgiframe();} +if(opts.delayedClose>0){closeOnDelay=setTimeout(cluetipClose,opts.delayedClose);} +opts.onShow($cluetip,$cluetipInner);};var inactivate=function(){isActive=false;$('#cluetip-waitimage').hide();if(!opts.sticky||(/click|toggle/).test(opts.activation)){cluetipClose();clearTimeout(closeOnDelay);};if(opts.hoverClass){$this.removeClass(opts.hoverClass);} +$('.cluetip-clicked').removeClass('cluetip-clicked');};var cluetipClose=function(){$cluetipOuter.parent().hide().removeClass().end().children().empty();if(tipTitle){$this.attr(opts.titleAttribute,tipTitle);} +$this.css('cursor','');if(opts.arrows)$cluetipArrows.css({top:''});};if((/click|toggle/).test(opts.activation)){$this.click(function(event){if($cluetip.is(':hidden')||!$this.is('.cluetip-clicked')){activate(event);$('.cluetip-clicked').removeClass('cluetip-clicked');$this.addClass('cluetip-clicked');}else{inactivate(event);} +this.blur();return false;});}else if(opts.activation=='focus'){$this.focus(function(event){activate(event);});$this.blur(function(event){inactivate(event);});}else{$this.click(function(){if($this.attr('href')&&$this.attr('href')==tipAttribute&&!opts.clickThrough){return false;}});var mouseTracks=function(evt){if(opts.tracking==true){var trackX=posX-evt.pageX;var trackY=tipY?tipY-evt.pageY:posY-evt.pageY;$this.mousemove(function(evt){$cluetip.css({left:evt.pageX+trackX,top:evt.pageY+trackY});});}};if($.fn.hoverIntent&&opts.hoverIntent){$this.mouseover(function(){$this.attr('title','');}).hoverIntent({sensitivity:opts.hoverIntent.sensitivity,interval:opts.hoverIntent.interval,over:function(event){activate(event);mouseTracks(event);},timeout:opts.hoverIntent.timeout,out:function(event){inactivate(event);$this.unbind('mousemove');}});}else{$this.hover(function(event){activate(event);mouseTracks(event);},function(event){inactivate(event);$this.unbind('mousemove');});}}});};$.fn.cluetip.defaults={width:275,height:'auto',cluezIndex:97,positionBy:'auto',topOffset:15,leftOffset:15,local:false,hideLocal:true,attribute:'rel',titleAttribute:'title',splitTitle:'',showTitle:true,cluetipClass:'default',hoverClass:'',waitImage:true,cursor:'help',arrows:false,dropShadow:true,dropShadowSteps:6,sticky:false,mouseOutClose:false,activation:'hover',clickThrough:false,tracking:false,delayedClose:0,closePosition:'top',closeText:'Close',truncate:0,fx:{open:'show',openSpeed:''},hoverIntent:{sensitivity:3,interval:50,timeout:0},onActivate:function(e){return true;},onShow:function(ct,c){},ajaxCache:true,ajaxProcess:function(data){data=data.replace(//g,'').replace(/<(link|title)(.|\s)*?\/(link|title)>/g,'');return data;},ajaxSettings:{dataType:'html'},debug:false};var insertionType='appendTo',insertionElement='body';$.cluetip={};$.cluetip.setup=function(options){if(options&&options.insertionType&&(options.insertionType).match(/appendTo|prependTo|insertBefore|insertAfter/)){insertionType=options.insertionType;} +if(options&&options.insertionElement){insertionElement=options.insertionElement;}};})(jQuery); diff --git a/pandora_console/include/styles/cluetip.css b/pandora_console/include/styles/cluetip.css new file mode 100644 index 0000000000..14477629f9 --- /dev/null +++ b/pandora_console/include/styles/cluetip.css @@ -0,0 +1,97 @@ +/* global */ +#cluetip-close img { + border: 0; +} +#cluetip-title { + overflow: hidden; +} +#cluetip-title #cluetip-close { + float: right; + position: relative; +} +#cluetip-waitimage { + width: 43px; + height: 11px; + position: absolute; + background-image: url(../../images/wait.gif); +} +.cluetip-arrows { + display: none; + position: absolute; + top: 0; + left: -11px; + height: 22px; + width: 11px; + background-repeat: no-repeat; + background-position: 0 0; +} +#cluetip-extra { + display: none; +} +/*************************************** + =cluetipClass: 'default' +-------------------------------------- */ + +.cluetip-default { + background-color: #F5F5DC; + text-align: left; +} +.cluetip-default #cluetip-outer { + position: relative; + margin: 0; + background-color: #F5F5DC; +} +.cluetip-default h3 { + margin: 0 0 5px; + padding: 8px 10px 4px; + font-size: 1.1em; + font-weight: bold; + background-color: #E6E9CD; +} +.cluetip-default h3#cluetip-title { + display: none; + height: 0px; + margin: 0; + padding: 0; +} +.cluetip-default #cluetip-title a { + color: #d9d9c2; + font-size: 0.95em; +} +.cluetip-default #cluetip-inner { + padding: 10px; +} +.cluetip-default div#cluetip-close { + text-align: right; + margin: 0 5px 5px; + color: #900; +} +.cluetip-default ul { + text-align: left; +} +/* default arrows */ + +.clue-right-default .cluetip-arrows { + background-image: url(../../images/darrowleft.gif); +} +.clue-left-default .cluetip-arrows { + background-image: url(../../images/darrowright.gif); + left: 100%; + margin-right: -11px; +} +.clue-top-default .cluetip-arrows { + background-image: url(../../images/darrowdown.gif); + top: 100%; + left: 50%; + margin-left: -11px; + height: 11px; + width: 22px; +} +.clue-bottom-default .cluetip-arrows { + background-image: url(../../images/darrowup.gif); + top: -11px; + left: 50%; + margin-left: -11px; + height: 11px; + width: 22px; +} diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index f2fba3fc81..0e6c67e00f 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -18,351 +18,345 @@ // Load global vars require("include/config.php"); -if (comprueba_login() == 0) { - if (give_acl($id_user, 0, "AR") == 0) { - audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access agent main list view"); - require ("general/noaccess.php"); - exit; - } - - // Take some parameters (GET) - $offset = get_parameter ("offset", 0); - $group_id = get_parameter ("group_id", 0); - $ag_group = get_parameter ("ag_group", -1); - if (($ag_group == -1) && ($group_id != 0)) - $ag_group = $group_id; - if (isset($_GET["ag_group_refresh"])){ - $ag_group = $_GET["ag_group_refresh"]; - } - $search = get_parameter ("search", ""); - - - echo "

".$lang_label["ag_title"]." > ".$lang_label["summary"]."

"; - - // Show group selector (POST) - if (isset($_POST["ag_group"])){ - $ag_group = $_POST["ag_group"]; - echo "
"; - } else { - echo ""; - } - - echo ""; - echo ""; - echo "
".$lang_label["group"].""; - echo ""; - echo " - - "; - - echo $lang_label["free_text_search"]; - echo ""; - echo "
"; - echo ""; - echo "
"; - echo ""; - echo ""; - echo "
"; - - - if ($search != ""){ - $search_sql = " AND nombre LIKE '%$search%' "; - } else { - $search_sql = ""; - } - - // Show only selected groups - if ($ag_group > 1){ - $sql="SELECT * FROM tagente WHERE id_grupo=$ag_group - AND disabled = 0 $search_sql ORDER BY nombre LIMIT $offset, ".$config["block_size"]; - $sql2="SELECT COUNT(id_agente) FROM tagente WHERE id_grupo=$ag_group - AND disabled = 0 $search_sql ORDER BY nombre"; - - // Not selected any specific group - } else { - // Is admin user ?? - if (get_db_sql ("SELECT * FROM tusuario WHERE id_usuario ='$id_user'", "nivel") == 1){ - $sql="SELECT * FROM tagente WHERE disabled = 0 $search_sql ORDER BY nombre, id_grupo LIMIT $offset, ".$config["block_size"]; - $sql2="SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 $search_sql ORDER BY nombre, id_grupo"; - - // standard user - } else { - - // User has explicit permission on group 1 ? - $all_group = get_db_sql ("SELECT COUNT(id_grupo) FROM tusuario_perfil WHERE id_usuario='$id_user' AND id_grupo = 1"); - - if ($all_group > 0){ - $sql="SELECT * FROM tagente WHERE disabled = 0 $search_sql - ORDER BY nombre, id_grupo LIMIT $offset, ".$config["block_size"]; - $sql2="SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 $search_sql - ORDER BY nombre, id_grupo"; - } else { - $sql="SELECT * FROM tagente WHERE disabled = 0 $search_sql AND id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='$id_user') - ORDER BY nombre, id_grupo LIMIT $offset,".$config["block_size"]; - $sql2="SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 $search_sql AND id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='$id_user') ORDER BY nombre, id_grupo"; - } - - } - } - - $result2=mysql_query($sql2); - $row2=mysql_fetch_array($result2); - $total_events = $row2[0]; - // Prepare pagination - - pagination ($total_events, -"index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=$ag_group&refr=60", $offset); - // Show data. - $result=mysql_query($sql); - if (mysql_num_rows($result)){ - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - // For every agent defined in the agent table - $color = 1; - while ($row=mysql_fetch_array($result)){ - $intervalo = $row["intervalo"]; // Interval in seconds - $id_agente = $row['id_agente']; - $nombre_agente = substr(strtoupper($row["nombre"]),0,18); - $direccion_agente =$row["direccion"]; - $id_grupo=$row["id_grupo"]; - $id_os = $row["id_os"]; - $ultimo_contacto = $row["ultimo_contacto"]; - $biginterval=$intervalo; - foreach ($mis_grupos as $migrupo){ //Verifiy if the group this agent begins is one of the user groups - if (($migrupo ==1) || ($id_grupo==$migrupo)){ - $pertenece = 1; - break; - } - else - $pertenece = 0; - } - if ($pertenece == 1) { // Si el agente pertenece a uno de los grupos que el usuario puede visualizar - // Obtenemos la lista de todos los modulos de cada agente - $sql_t="SELECT * FROM tagente_estado, tagente_modulo - WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND - tagente_modulo.disabled = 0 - AND tagente_modulo.id_agente=".$id_agente; - $result_t=mysql_query($sql_t); - $estado_general = 0; - $numero_modulos = 0; - $numero_monitor = 0; - $est_timestamp = ""; - $monitor_bad=0; - $monitor_ok = 0; - $monitor_down=0; - $numero_datamodules=0; - $estado_cambio=0; - $ahora=date("Y/m/d H:i:s"); - // Calculate module/monitor totals for this agent - while ($row_t=mysql_fetch_array($result_t)){ - $est_modulo = $row_t["estado"]; - $ultimo_contacto_modulo = $row_t["timestamp"]; - $module_interval = $row_t["module_interval"]; - if ($module_interval > $biginterval) - $biginterval = $module_interval; - if ($module_interval !=0) - $intervalo_comp = $module_interval; - else - $intervalo_comp = $intervalo; - if ($ultimo_contacto <> "") - $seconds = strtotime($ahora) - strtotime($ultimo_contacto_modulo); - else - $seconds = -1; - - # Defines if Agent is down (interval x 2 > time last contact - if ($seconds >= ($intervalo_comp*2)){ // If (intervalx2) secs. ago we don't get anything, show alert - if ($est_modulo != 100) - $numero_monitor++; - $monitor_down++; - } - elseif ($est_modulo != 100) { // estado=100 are data modules - $estado_general = $estado_general + $est_modulo; - $estado_cambio = $estado_cambio + $row_t["cambio"]; - $numero_monitor ++; - if ($est_modulo != 0) - $monitor_bad++; - else - $monitor_ok++; - } elseif ($est_modulo == 100){ // Data modules - $numero_datamodules++; - } - $numero_modulos++; - } - // Color change for each line (1.2 beta2) - if ($color == 1){ - $tdcolor = "datos"; - $color = 0; - } - else { - $tdcolor = "datos2"; - $color = 1; - } - echo ""; - echo ""; - - // Show SO icon :) - echo ""; - // If there are a module interval bigger than agent interval - if ($biginterval > $intervalo) { - echo ""; - } else { - echo ""; - } - - // Show GROUP icon - echo ''; - - - echo ""; - /* - if ($numero_monitor <> 0){ - if ($estado_general <> 0){ - if ($estado_cambio == 0){ - // RED - echo ""; - echo ""; - echo "
".$lang_label["agent"]."".$lang_label["os"]."".$lang_label["interval"]."".$lang_label["group"]."".$lang_label["modules"]."".$lang_label["status"]."".$lang_label["alerts"]."".$lang_label["last_contact"]."
"; - if (give_acl($id_user, $id_grupo, "AW")==1){ - echo " - "; - } - echo "  - ".$nombre_agente." - ".dame_so_name($id_os)." - ".$biginterval."".$intervalo." - '; - echo ' ". - $numero_modulos." / ".$numero_monitor; - if ($monitor_bad <> 0) { - echo " / ".$monitor_bad.""; - } - if ($monitor_down <> 0){ - echo " / ".$monitor_down.""; - } - echo ""; - } else { - // Yellow - echo ""; - } - } elseif ($monitor_ok > 0) { - // Green - echo ""; - } - elseif ($numero_datamodules > 0) { - // Grey #1 - echo ""; - } - elseif ($monitor_down > 0) { - // Grey - Red - echo ""; - } - } else { - // Blue - echo ""; - } - */ - - echo ""; - if ($numero_monitor <> 0){ - if ($estado_general <> 0){ - if ($estado_cambio == 0){ - echo ""; - } else { - echo ""; - } - } elseif ($monitor_ok > 0) { - echo ""; - } - elseif ($numero_datamodules > 0) { - echo ""; - } - elseif ($monitor_down > 0) { - echo ""; - } - } else - echo ""; - - // checks if an alert was fired recently - echo ""; - if (give_disabled_group($id_grupo) == 1) - echo ""; - else { - if (check_alert_fired($id_agente) == 1) - echo ""; - else - echo ""; - } - echo ""; - if ( $ultimo_contacto == "0000-00-00 00:00:00"){ - echo $lang_label["never"]; - } else { - $ultima = strtotime($ultimo_contacto); - $ahora = strtotime("now"); - $diferencia = $ahora - $ultima; - if ( $diferencia > ($biginterval*2)) - echo ""; - - echo human_time_comparation($ultimo_contacto); -/* - if ($biginterval > 0){ - $percentil = round($diferencia/(($biginterval*2) / 100)); - } else { - $percentil = -1; - } - echo " - -  $ultimo_contacto";*/ - } - - } // If pertenece/belongs to group - } - echo "

"; - require "bulbs.php"; - } - else { - echo '
'.$lang_label["no_agent"].'
'; - $id_user = $_SESSION["id_usuario"]; - if ( (give_acl($id_user, 0, "LM")==1) OR (give_acl($id_user, 0, "AW")==1 ) OR (give_acl($id_user, 0, "PM")==1) OR (give_acl($id_user, 0, "DM")==1) OR (give_acl($id_user, 0, "UM")==1 )){ - echo " 
"; - } - } - -} else { +if (comprueba_login ()) { audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Agent view"); - require ("general/noaccess.php"); + require ("general/noaccess.php"); +} +if (give_acl($id_user, 0, "AR") == 0) { + audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access agent main list view"); + require ("general/noaccess.php"); + exit; +} + +// Take some parameters (GET) +$offset = get_parameter ("offset", 0); +$group_id = get_parameter ("group_id", 0); +$ag_group = get_parameter ("ag_group", -1); +if (($ag_group == -1) && ($group_id != 0)) + $ag_group = $group_id; +if (isset($_GET["ag_group_refresh"])){ + $ag_group = $_GET["ag_group_refresh"]; +} +$search = get_parameter ("search", ""); + +echo "

".$lang_label["ag_title"]." > ".$lang_label["summary"]."

"; + +// Show group selector (POST) +if (isset($_POST["ag_group"])){ + $ag_group = $_POST["ag_group"]; + echo "
"; +} else { + echo ""; +} + +echo ""; +echo ""; +echo "
".$lang_label["group"].""; +echo ""; +echo " + +"; + +echo $lang_label["free_text_search"]; +echo ""; +echo "
"; +echo ""; +echo "
"; +echo ""; +echo ""; +echo "
"; + + +if ($search != ""){ + $search_sql = " AND nombre LIKE '%$search%' "; +} else { + $search_sql = ""; +} + +// Show only selected groups +if ($ag_group > 1){ + $sql="SELECT * FROM tagente WHERE id_grupo=$ag_group + AND disabled = 0 $search_sql ORDER BY nombre LIMIT $offset, ".$config["block_size"]; + $sql2="SELECT COUNT(id_agente) FROM tagente WHERE id_grupo=$ag_group + AND disabled = 0 $search_sql ORDER BY nombre"; + +// Not selected any specific group +} else { +// Is admin user ?? +if (get_db_sql ("SELECT * FROM tusuario WHERE id_usuario ='$id_user'", "nivel") == 1){ + $sql="SELECT * FROM tagente WHERE disabled = 0 $search_sql ORDER BY nombre, id_grupo LIMIT $offset, ".$config["block_size"]; + $sql2="SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 $search_sql ORDER BY nombre, id_grupo"; + +// standard user +} else { + + // User has explicit permission on group 1 ? + $all_group = get_db_sql ("SELECT COUNT(id_grupo) FROM tusuario_perfil WHERE id_usuario='$id_user' AND id_grupo = 1"); + + if ($all_group > 0){ + $sql="SELECT * FROM tagente WHERE disabled = 0 $search_sql + ORDER BY nombre, id_grupo LIMIT $offset, ".$config["block_size"]; + $sql2="SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 $search_sql + ORDER BY nombre, id_grupo"; + } else { + $sql="SELECT * FROM tagente WHERE disabled = 0 $search_sql AND id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='$id_user') + ORDER BY nombre, id_grupo LIMIT $offset,".$config["block_size"]; + $sql2="SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 $search_sql AND id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='$id_user') ORDER BY nombre, id_grupo"; + } + +} +} + +$result2=mysql_query($sql2); +$row2=mysql_fetch_array($result2); +$total_events = $row2[0]; +// Prepare pagination + +pagination ($total_events, +"index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=$ag_group&refr=60", $offset); +// Show data. +$result=mysql_query($sql); +if (mysql_num_rows($result)){ + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + // For every agent defined in the agent table + $color = 1; + while ($row=mysql_fetch_array($result)){ + $intervalo = $row["intervalo"]; // Interval in seconds + $id_agente = $row['id_agente']; + $nombre_agente = substr(strtoupper($row["nombre"]),0,18); + $direccion_agente =$row["direccion"]; + $id_grupo=$row["id_grupo"]; + $id_os = $row["id_os"]; + $ultimo_contacto = $row["ultimo_contacto"]; + $biginterval=$intervalo; + foreach ($mis_grupos as $migrupo){ //Verifiy if the group this agent begins is one of the user groups + if (($migrupo ==1) || ($id_grupo==$migrupo)){ + $pertenece = 1; + break; + } + else + $pertenece = 0; + } + if ($pertenece == 1) { // Si el agente pertenece a uno de los grupos que el usuario puede visualizar + // Obtenemos la lista de todos los modulos de cada agente + $sql_t="SELECT * FROM tagente_estado, tagente_modulo + WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND + tagente_modulo.disabled = 0 + AND tagente_modulo.id_agente=".$id_agente; + $result_t=mysql_query($sql_t); + $estado_general = 0; + $numero_modulos = 0; + $numero_monitor = 0; + $est_timestamp = ""; + $monitor_bad=0; + $monitor_ok = 0; + $monitor_down=0; + $numero_datamodules=0; + $estado_cambio=0; + $ahora=date("Y/m/d H:i:s"); + // Calculate module/monitor totals for this agent + while ($row_t=mysql_fetch_array($result_t)){ + $est_modulo = $row_t["estado"]; + $ultimo_contacto_modulo = $row_t["timestamp"]; + $module_interval = $row_t["module_interval"]; + if ($module_interval > $biginterval) + $biginterval = $module_interval; + if ($module_interval !=0) + $intervalo_comp = $module_interval; + else + $intervalo_comp = $intervalo; + if ($ultimo_contacto <> "") + $seconds = strtotime($ahora) - strtotime($ultimo_contacto_modulo); + else + $seconds = -1; + + # Defines if Agent is down (interval x 2 > time last contact + if ($seconds >= ($intervalo_comp*2)){ // If (intervalx2) secs. ago we don't get anything, show alert + if ($est_modulo != 100) + $numero_monitor++; + $monitor_down++; + } + elseif ($est_modulo != 100) { // estado=100 are data modules + $estado_general = $estado_general + $est_modulo; + $estado_cambio = $estado_cambio + $row_t["cambio"]; + $numero_monitor ++; + if ($est_modulo != 0) + $monitor_bad++; + else + $monitor_ok++; + } elseif ($est_modulo == 100){ // Data modules + $numero_datamodules++; + } + $numero_modulos++; + } + // Color change for each line (1.2 beta2) + if ($color == 1){ + $tdcolor = "datos"; + $color = 0; + } + else { + $tdcolor = "datos2"; + $color = 1; + } + echo ""; + echo ""; + + // Show SO icon :) + echo ""; + // If there are a module interval bigger than agent interval + if ($biginterval > $intervalo) { + echo ""; + } else { + echo ""; + } + + // Show GROUP icon + echo ''; + + + echo ""; + /* + if ($numero_monitor <> 0){ + if ($estado_general <> 0){ + if ($estado_cambio == 0){ + // RED + echo ""; + echo ""; + echo "
".$lang_label["agent"]."".$lang_label["os"]."".$lang_label["interval"]."".$lang_label["group"]."".$lang_label["modules"]."".$lang_label["status"]."".$lang_label["alerts"]."".$lang_label["last_contact"]."
"; + if (give_acl($id_user, $id_grupo, "AW")==1){ + echo " + "; + } + echo "  + ".$nombre_agente." + ".dame_so_name($id_os)." + ".$biginterval."".$intervalo." + '; + echo ' ". + $numero_modulos." / ".$numero_monitor; + if ($monitor_bad <> 0) { + echo " / ".$monitor_bad.""; + } + if ($monitor_down <> 0){ + echo " / ".$monitor_down.""; + } + echo ""; + } else { + // Yellow + echo ""; + } + } elseif ($monitor_ok > 0) { + // Green + echo ""; + } + elseif ($numero_datamodules > 0) { + // Grey #1 + echo ""; + } + elseif ($monitor_down > 0) { + // Grey - Red + echo ""; + } + } else { + // Blue + echo ""; + } + */ + + echo ""; + if ($numero_monitor <> 0){ + if ($estado_general <> 0){ + if ($estado_cambio == 0){ + echo ""; + } else { + echo ""; + } + } elseif ($monitor_ok > 0) { + echo ""; + } + elseif ($numero_datamodules > 0) { + echo ""; + } + elseif ($monitor_down > 0) { + echo ""; + } + } else + echo ""; + + // checks if an alert was fired recently + echo ""; + if (give_disabled_group($id_grupo) == 1) + echo ""; + else { + if (check_alert_fired($id_agente) == 1) + echo ""; + else + echo ""; + } + echo ""; + if ( $ultimo_contacto == "0000-00-00 00:00:00"){ + echo $lang_label["never"]; + } else { + $ultima = strtotime($ultimo_contacto); + $ahora = strtotime("now"); + $diferencia = $ahora - $ultima; + if ( $diferencia > ($biginterval*2)) + echo ""; + + echo human_time_comparation($ultimo_contacto); +/* + if ($biginterval > 0){ + $percentil = round($diferencia/(($biginterval*2) / 100)); + } else { + $percentil = -1; + } + echo " + +  $ultimo_contacto";*/ + } + + } // If pertenece/belongs to group + } + echo "

"; + require "bulbs.php"; +} else { + echo '
'.$lang_label["no_agent"].'
'; + $id_user = $_SESSION["id_usuario"]; + if ( (give_acl($id_user, 0, "LM")==1) OR (give_acl($id_user, 0, "AW")==1 ) OR (give_acl($id_user, 0, "PM")==1) OR (give_acl($id_user, 0, "DM")==1) OR (give_acl($id_user, 0, "UM")==1 )){ + echo " 
"; + } } ?> diff --git a/pandora_console/operation/agentes/networkmap.php b/pandora_console/operation/agentes/networkmap.php index 2ad72f7c0c..f560ffc979 100644 --- a/pandora_console/operation/agentes/networkmap.php +++ b/pandora_console/operation/agentes/networkmap.php @@ -15,13 +15,17 @@ // Load global vars require("include/config.php"); +$pandora_name = 'Pandora FMS'; + /////////////////////////////////////////////////////////////////////////////// // DOT related functions /////////////////////////////////////////////////////////////////////////////// // Generate a dot graph definition for graphviz -function generate_dot( $simple = 0) { - global $config; +function generate_dot ($simple = 0) { + global $config; + global $pandora_name; + $group_id = -1; $parents = array(); $orphans = array(); @@ -63,7 +67,7 @@ function generate_dot( $simple = 0) { // Create a central node if orphan nodes exist if (count($orphans) > 0) { - $graph .= create_pandora_node ('Pandora FMS'); + $graph .= create_pandora_node ($pandora_name); } // Define edges @@ -83,85 +87,83 @@ function generate_dot( $simple = 0) { } // Returns an edge definition -function create_edge($head, $tail) { - +function create_edge ($head, $tail) { $edge = $head . ' -- ' . $tail . '[color="#BDBDBD", headclip=false, tailclip=false];'; return $edge; } // Returns a node definition -function create_node($agent, $simple = 0) { - $bad_modules = mysql_query('SELECT estado FROM tagente_estado AS e, - tagente_modulo AS m - WHERE m.id_agente=' . $agent['id_agente'] . - ' AND m.id_tipo_modulo in (2, 6, 9, 18, 21, 100) - AND e.id_agente_modulo = m.id_agente_modulo - AND m.disabled = 0 - AND e.estado = 1'); - +function create_node ($agent, $simple = 0) { + $sql = sprintf ('SELECT COUNT(*) FROM tagente_estado, + tagente_modulo + WHERE tagente_modulo.id_agente = %d + AND tagente_modulo.id_tipo_modulo in (2, 6, 9, 18, 21, 100) + AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + AND tagente_modulo.disabled = 0 + AND tagente_estado.estado = 1', $agent['id_agente']); + $bad_modules = get_db_sql ($sql); + // Set node status - if (mysql_num_rows($bad_modules) > 0) { + if ($bad_modules) { $status_color = '#FF1D1D'; - } - else { + } else { $status_color = '#8DFF1D'; } - // Short name - $name = strtolower($agent["nombre"]); + // Short name + $name = strtolower ($agent["nombre"]); if (strlen($name) > 12) $name = substr($name,0,12); - if ($simple == 0){ + if ($simple == 0){ // Set node icon if (file_exists('images/networkmap/' . $agent['id_os'] . '.png')) { $img_node = 'images/networkmap/' . $agent['id_os'] . '.png'; - } - else { + } else { $img_node = 'images/networkmap/0.png'; } - + $node = $agent['id_agente'] . ' [ color="' . $status_color . '", fontsize=9, style="filled", fixedsize=true, width=0.40, height=0.40, label=< - -
' . $name . '
>, - shape="ellipse", tooltip="' . $agent["nombre"] . ' (' . $agent['direccion'] . ')", URL="' - . 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' - . $agent['id_agente'] . '"];'; - } else { - $node = $agent['id_agente'] . ' [ color="' . $status_color . '", fontsize=7, style="filled", fixedsize=true, width=0.20, height=0.20, label="", URL="' - . 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' - . $agent['id_agente'] . '"];'; - } + + ' . $name . '>, + shape="ellipse", URL="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].'", + tooltip="ajax.php?page=operation/agentes/ver_agente&get_agent_status_tooltip=1&id_agent=' + . $agent['id_agente'].'"];'; + } else { + $node = $agent['id_agente'] . ' [ color="' . $status_color . '", fontsize=7, style="filled", fixedsize=true, width=0.20, height=0.20, label="", + tooltip="ajax.php?page=operation/agentes/ver_agente& + get_agent_status_tooltip=1&id_agent='.$agent['id_agente'].'"];'; + } return $node; } // Returns the definition of the central module -function create_pandora_node($name) { +function create_pandora_node ($name) { $node = '0 [ color="#364D1F", fontsize=10, style="filled", fixedsize=true, width=0.8, height=0.6, label=< - -
' . $name . '
>, - shape="ellipse", tooltip="' . $name . '", URL="index.php?sec=estado&sec2=operation/agentes/estado_grupo" ];'; + + ' . $name . '>, + shape="ellipse", tooltip="' . $name . '", URL="index.php?sec=estado&sec2=operation/agentes/estado_grupo" ];'; return $node; } // Opens a group definition -function open_group($id) { +function open_group ($id) { $img = 'images/' . dame_grupo_icono($id) . '.png'; $name = dame_nombre_grupo($id); $group = 'subgraph cluster_' . $id . - ' { style=filled; color=darkolivegreen3; label=< - -
' . $name . '
>; tooltip="' . $name . '"; - URL="index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=' - . $id . '";'; + ' { style=filled; color=darkolivegreen3; label=< + +
' . $name . '
>; tooltip="' . $name . '"; + URL="index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=' + . $id . '";'; return $group; } // Closes a group definition -function close_group() { +function close_group () { return '}'; } @@ -187,48 +189,47 @@ function open_graph() { } $size = $size_x . ',' . $size_y; - // BEWARE: graphwiz DONT use single ('), you need double (") + // BEWARE: graphwiz DONT use single ('), you need double (") $head = "graph networkmap { - labeljust=l; - margin=0; - ranksep=\"$ranksep\"; - outputorder=edgesfirst; - overlap=\"$overlap\"; - ratio=fill; - root=0; - size=\"$size\"; - "; + labeljust=l; + margin=0; + ranksep=\"$ranksep\"; + outputorder=edgesfirst; + overlap=\"$overlap\"; + ratio=fill; + root=0; + size=\"$size\"; + "; return $head; -} +} // Closes a graph definition function close_graph() { return '}'; } -/////////////////////////////////////////////////////////////////////////////// -// General purpose functions -/////////////////////////////////////////////////////////////////////////////// - // Returns the filter used to achieve the desired layout function set_filter() { global $layout; switch($layout) { - case 'flat': return 'dot'; - case 'radial': return 'twopi'; - case 'circular': return 'circo'; - case 'spring1': return 'neato'; - case 'spring2': return 'fdp'; - default: return 'twopi'; + case 'flat': + return 'dot'; + case 'radial': + return 'twopi'; + case 'circular': + return 'circo'; + case 'spring1': + return 'neato'; + case 'spring2': + return 'fdp'; + default: + return 'twopi'; } } -/////////////////////////////////////////////////////////////////////////////// -// Main code -/////////////////////////////////////////////////////////////////////////////// - +/* Main code */ // Load variables $layout = (string) get_parameter ('layout'); $nooverlap = (boolean) get_parameter ('nooverlap'); @@ -247,29 +248,26 @@ if (comprueba_login() != 0) { exit; } -if ((give_acl($id_user, 0, "AR") != 1 ) AND (dame_admin($id_user) !=1 )) { +if ((give_acl($id_user, 0, "AR") != 1 ) && (dame_admin($id_user) !=1 )) { audit_db($id_user, $REMOTE_ADDR, "ACL Violation", "Trying to access node graph builder"); include("general/noaccess.php"); exit; } -echo '

' . $lang_label['ag_title'] . ' > ' . lang_string("Network Map") . ' '; +echo '

' . $lang_label['ag_title'].' > '.lang_string("Network Map").' '; if ($pure == 1) { - echo ''; -} -else { - echo ''; + echo ''; +} else { + echo ''; } echo '

'; // Layout selection -$layout_array = array ( - 'radial' => 'radial', - 'circular' => 'circular', - 'spring1' => 'spring 1', - 'spring2' => 'spring 2', - 'flat' => 'flat', -); +$layout_array = array ('radial' => 'radial', + 'circular' => 'circular', + 'spring1' => 'spring 1', + 'spring2' => 'spring 2', + 'flat' => 'flat'); echo '
'; echo ''; @@ -294,7 +292,7 @@ if ($pure == "1") { '1.6' => 'x3', '2' => 'x4', '2.5' => 'x5', - '5' => 'x10', + '5' => 'x10', ); echo ''; echo '
' . lang_string('Zoom') . '  '; @@ -305,7 +303,7 @@ if ($pure == "1") { //echo ' Display groups '; echo ''; echo ''; + $lang_label["update"] . '">'; echo '
'; echo '
'; @@ -316,18 +314,35 @@ $filter = set_filter(); // Generate dot file $graph = generate_dot($simple); -//DEBUG -//$fh = fopen("networkmap.dot", 'w') or die("can't open file"); -//fwrite($fh, $graph); -//fclose($fh); - // Generate image and map $cmd = "echo " . escapeshellarg($graph) . - " | $filter -Tcmapx -o".$config["attachment_store"]."/networkmap.map -Tpng -o".$config["attachment_store"]."/networkmap.png"; - -if (system($cmd) !== false) { + " | $filter -Tcmapx -o".$config["attachment_store"]."/networkmap.map -Tpng -o".$config["attachment_store"]."/networkmap.png"; + +$result = system ($cmd); + +if ($result !== false) { + if (! file_exists ($config["attachment_store"]."/networkmap.map")) { + echo '

'.lang_string ('Map could not be generated').'

'; + echo $result; + return; + } echo ''; include $config["attachment_store"]."/networkmap.map"; } - ?> + + + + + + + diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index f3954d187b..d476db56d9 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -22,6 +22,7 @@ require("include/config.php"); if (defined ('AJAX')) { $get_agent_json = (bool) get_parameter ('get_agent_json'); $get_agent_modules_json = (bool) get_parameter ('get_agent_modules_json'); + $get_agent_status_tooltip = (bool) get_parameter ("get_agent_status_tooltip"); if ($get_agent_json) { $id_agent = (int) get_parameter ('id_agent'); @@ -38,6 +39,52 @@ if (defined ('AJAX')) { echo json_encode ($agent_modules); exit (); } + + if ($get_agent_status_tooltip) { + $id_agent = (int) get_parameter ('id_agent'); + $agent = get_db_row ('tagente', 'id_agente', $id_agent); + echo '

'.$agent['nombre'].'

'; + echo ''.lang_string ('IP').': '.$agent['direccion'].'
'; + echo ''.lang_string ('Last contact').': '.$agent['ultimo_contacto'].'
'; + echo ''.lang_string ('Last remote contact').': '.$agent['ultimo_contacto_remoto'].'
'; + echo ''.lang_string ('Group').': '; + echo ' '; + echo dame_nombre_grupo ($agent['id_grupo']).'
'; + + $sql = sprintf ('SELECT tagente_modulo.descripcion, tagente_modulo.nombre + FROM tagente_estado, tagente_modulo + WHERE tagente_modulo.id_agente = %d + AND tagente_modulo.id_tipo_modulo in (2, 6, 9, 18, 21, 100) + AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo + AND tagente_modulo.disabled = 0 + AND tagente_estado.estado = 1', $id_agent); + $bad_modules = get_db_all_rows_sql ($sql); + $sql = sprintf ('SELECT COUNT(*) + FROM tagente_modulo + WHERE id_agente = %d + AND id_tipo_modulo in (2, 6, 9, 18, 21, 100)', $id_agent); + $total_modules = get_db_sql ($sql); + echo ''.lang_string ('Monitors down').': '.sizeof ($bad_modules).' / '.$total_modules; + if (sizeof ($bad_modules)) { + echo '
    '; + foreach ($bad_modules as $module) { + echo '
  • '; + if ($module['descripcion'] != '') + $name = $module['descripcion']; + else + $name = $module['nombre']; + echo substr ($name, 0, 25); + if (strlen ($name) > 25) + echo '(...)'; + echo '
  • '; + } + echo '
'; + } + echo '
'; + + exit (); + } + exit (); } diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index 01a9e0e786..83b7eab3b8 100644 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -121,7 +121,7 @@ $table->rowclasses = array (); $group_name = dame_grupo ($report['id_group']); $sql = sprintf ('SELECT * FROM treport_content WHERE id_report = %d ORDER BY `order`', $id_report); -$contents = get_db_all_rows_sqlfree ($sql); +$contents = get_db_all_rows_sql ($sql); foreach ($contents as $content) { $table->data = array (); diff --git a/pandora_console/reporting/fgraph.php b/pandora_console/reporting/fgraph.php index 192851444b..3dfbb373f1 100644 --- a/pandora_console/reporting/fgraph.php +++ b/pandora_console/reporting/fgraph.php @@ -435,7 +435,7 @@ function grafico_modulo_sparse ($id_agente_modulo, $periodo, $show_event, if ($show_event){ // If we want to show events in graphs $sql = sprintf ('SELECT utimestamp FROM tevento WHERE id_agente = %d AND utimestamp > %d', $id_agente, $fechatope); - $eventos = get_db_all_rows_sqlfree ($sql); + $eventos = get_db_all_rows_sql ($sql); foreach ($eventos as $row) { $utimestamp = $row[0]; for ($i = 0; $i <= $resolution; $i++) {