From: hickert Date: Fri, 18 Dec 2009 15:17:28 +0000 (+0000) Subject: Updated rSyslog view X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=bd8041238f5c1146898d4308f4983f153ebf40a1;p=gosa.git Updated rSyslog view git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14910 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/rsyslog/addons/rsyslog/class_rsyslog.inc b/gosa-plugins/rsyslog/addons/rsyslog/class_rsyslog.inc index 49a7d14ea..fe25e7b9c 100644 --- a/gosa-plugins/rsyslog/addons/rsyslog/class_rsyslog.inc +++ b/gosa-plugins/rsyslog/addons/rsyslog/class_rsyslog.inc @@ -9,11 +9,23 @@ class rsyslog extends plugin var $selected_server = ""; var $selected_host = ""; + var $startTime = ""; + var $stopTime = ""; + + var $sort_value = "FromHost"; + var $sort_type = "DESC"; + var $limit = 20; + var $limits = array(20,50,100,200,500,1000,'-'); + var $page = 0; + function rsyslog (&$config, $dn= NULL) { $this->config= &$config; $this->ui = get_userinfo(); + $this->startTime = date("d.m.Y", (time() - 7*24*60*60)); + $this->stopTime = date("d.m.Y", time()); + // Get list of rsyslog servers $ldap = $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); @@ -75,6 +87,7 @@ class rsyslog extends plugin function execute() { $smarty = get_smarty(); + $smarty->assign("usePrototype", "true"); $ui = get_userinfo(); if(!isset($this->servers[$this->selected_server]) || !count($this->servers[$this->selected_server]['Hosts'])){ @@ -84,11 +97,29 @@ class rsyslog extends plugin $hosts = array_merge($hosts,$this->servers[$this->selected_server]['Hosts']); } + $result =$this->get_result(); + $smarty->assign("servers",$this->servers); $smarty->assign("hosts",$hosts); $smarty->assign("selected_server",$this->selected_server); $smarty->assign("selected_host",$this->selected_host); - $smarty->assign("result", $this->get_result()); + $smarty->assign("startTime", $this->startTime); + $smarty->assign("stopTime", $this->stopTime); + $smarty->assign("sort_type", $this->sort_type); + $smarty->assign("sort_value", $this->sort_value); + $smarty->assign("limits", $this->limits); + $smarty->assign("limit", $this->limit); + $smarty->assign("page", $this->page); + $smarty->assign("plug_id", $_GET['plug']); + $smarty->assign("downimg", "\\/"); + $smarty->assign("upimg", "\\/"); + $smarty->assign("result", $result); + if($this->limit != '-'){ + $smarty->assign("page_sel", range_selector($result['count'],$this->page,$this->limits[$this->limit])); + }else{ + $smarty->assign("page_sel", ""); + } + return($smarty->fetch(get_template_path("rSyslog.tpl", TRUE))); } @@ -130,9 +161,10 @@ class rsyslog extends plugin $host = "%%"; if($this->selected_host != "all") $host = $this->selected_host; - - $filter = "FROM SystemEvents WHERE FromHost like '{$host}' LIMIT 20;"; - + $filter = "FROM SystemEvents WHERE FromHost like '{$host}' "; + $filter.= "AND DeviceReportedTime >= '".(date("Y.m.d 00:00:00", strtotime($this->startTime)))."' "; + $filter.= "AND DeviceReportedTime <= '".(date("Y.m.d 23:59:59", strtotime($this->stopTime)))."' "; + // Detect amount of matching entries $query = "SELECT count(ID) as `amount` ".$filter; $res = @mysql_query($query, $link); @@ -144,9 +176,14 @@ class rsyslog extends plugin } if($result['count']){ - + $filter.= "ORDER BY ".$this->sort_value." ".$this->sort_type." "; + if($this->limit != "-"){ + $filter.= "LIMIT ".$this->page.", ".$this->limits[$this->limit]; + }else{ + $this->page = 0; + } $query = "SELECT * ".$filter; - $res = @mysql_query($query, $link); + $res = mysql_query($query, $link); if($res){ while($attrs = @mysql_fetch_assoc($res)){ $result['entries'][] = $attrs; @@ -167,9 +204,27 @@ class rsyslog extends plugin function save_object() { - foreach(array("selected_host","selected_server") as $attr){ + foreach(array("selected_host","selected_server","stopTime","startTime") as $attr){ if(isset($_POST[$attr])) $this->$attr = get_post($attr); } + + if(isset($_GET['start'])) $this->page = $_GET['start']; + if(isset($_POST['limit']) && isset($this->limits[$_POST['limit']])){ + $this->limit = $_POST['limit']; + } + + if(isset($_GET['sort_value']) && in_array($_GET['sort_value'], + array("DeviceReportedTime","FromHost","Facility","Priority","Message"))){ + $sort_value = $_GET['sort_value']; + if($this->sort_value == $sort_value){ + if($this->sort_type == "ASC"){ + $this->sort_type="DESC"; + }else{ + $this->sort_type="ASC"; + } + } + $this->sort_value=$sort_value; + } } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/gosa-plugins/rsyslog/addons/rsyslog/rSyslog.tpl b/gosa-plugins/rsyslog/addons/rsyslog/rSyslog.tpl index ba5573445..4c0df584d 100644 --- a/gosa-plugins/rsyslog/addons/rsyslog/rSyslog.tpl +++ b/gosa-plugins/rsyslog/addons/rsyslog/rSyslog.tpl @@ -1,33 +1,121 @@ - - - + + + + + + + + + + + +
{t}Server{/t}: + + {t}Host{/t}: + + {t}From{/t}: + + + {t}to{/t}: + + + +

 

{if $result.status != 'ok'} {t}Error{/t}:  {$result.status}
{$result.error}
{else} - {t}Results{/t}: - + +
+
+ + + + + + + + {foreach from=$result.entries item=item key=key} - - - - - + + + + + {/foreach}
+ + {t}Received{/t} + {if $sort_value=="DeviceReportedTime"}{if $sort_type=="DESC"}{$downimg}{else}{$upimg}{/if}{/if} + + + + + {t}Host{/t} + {if $sort_value=="FromHost"}{if $sort_type=="DESC"}{$downimg}{else}{$upimg}{/if}{/if} + + + + + {t}Facility{/t} + {if $sort_value=="Facility"}{if $sort_type=="DESC"}{$downimg}{else}{$upimg}{/if}{/if} + + + + + {t}Priority{/t} + {if $sort_value=="Priority"}{if $sort_type=="DESC"}{$downimg}{else}{$upimg}{/if}{/if} + + + + + {t}Message{/t} + {if $sort_value=="Message"}{if $sort_type=="DESC"}{$downimg}{else}{$upimg}{/if}{/if} + + +

 

{$item.DeviceReportedTime}{$item.FromHost}{$item.Facility}{$item.Priority}{$item.Message} + {$item.DeviceReportedTime} + + {$item.FromHost} + + {$item.Facility} + + {$item.Priority} + +
{$item.Message}
+
- {$result.count} {t}entries matching filter{/t} + {if !$result.count == 0} +

 

+ {/if} +
{$result.count} {t}entries matching filter{/t}
+
+ +
+
{$page_sel}
{/if}