summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c42fb54)
raw | patch | inline | side by side (parent: c42fb54)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 18 Dec 2009 15:17:28 +0000 (15:17 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 18 Dec 2009 15:17:28 +0000 (15:17 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14910 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/rsyslog/addons/rsyslog/class_rsyslog.inc | patch | blob | history | |
gosa-plugins/rsyslog/addons/rsyslog/rSyslog.tpl | patch | blob | history |
diff --git a/gosa-plugins/rsyslog/addons/rsyslog/class_rsyslog.inc b/gosa-plugins/rsyslog/addons/rsyslog/class_rsyslog.inc
index 49a7d14ea782d4042f08433afe5042c6b9f62d91..fe25e7b9c2375b0b8691347374830f22d92e5bdb 100644 (file)
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']);
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'])){
$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", "<img src='images/lists/sort-down.png' class='center' alt='\\/' border='0'>");
+ $smarty->assign("upimg", "<img src='images/lists/sort-up.png' class='center' alt='\\/' border='0'>");
+ $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)));
}
$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);
}
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;
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 ba5573445f10a21701949b8f2de66072f6510934..4c0df584dbbe7b37dc607c5af7712fe5cc1053fc 100644 (file)
-<select name='selected_server' onChange='document.mainform.submit();'>
- {foreach from=$servers item=item key=key}
- <option value='{$key}' {if $key == $selected_server} selected {/if}>{$item.cn}</option>
- {/foreach}
-</select>
-
-<select name='selected_host' onChange='document.mainform.submit();'>
- {foreach from=$hosts item=item key=key}
- <option value='{$key}' {if $key == $selected_host} selected {/if}>{$item}</option>
- {/foreach}
-</select>
+<table width="100%">
+ <tr>
+ <td>{t}Server{/t}:</td>
+ <td>
+ <select name='selected_server' onChange='document.mainform.submit();'>
+ {foreach from=$servers item=item key=key}
+ <option value='{$key}' {if $key == $selected_server} selected {/if}>{$item.cn}</option>
+ {/foreach}
+ </select>
+ </td>
+ <td>{t}Host{/t}:</td>
+ <td>
+ <select name='selected_host' onChange='document.mainform.submit();'>
+ {foreach from=$hosts item=item key=key}
+ <option value='{$key}' {if $key == $selected_host} selected {/if}>{$item}</option>
+ {/foreach}
+ </select>
+ </td>
+ <td>{t}From{/t}:</td>
+ <td>
+ <input type="text" id="startTime" name="startTime" class="date" style='width:100px' value="{$startTime}">
+ <script type="text/javascript">
+ {literal}
+ var datepicker = new DatePicker({ relative : 'startTime', language : '{/literal}{$lang}{literal}', keepFieldEmpty : true,
+ enableCloseEffect : false, enableShowEffect : false });
+ {/literal}
+ </script>
+ </td>
+ <td>{t}to{/t}:</td>
+ <td>
+ <input type="text" id="stopTime" name="stopTime" class="date" style='width:100px' value="{$stopTime}">
+ <script type="text/javascript">
+ {literal}
+ var datepicker = new DatePicker({ relative : 'stopTime', language : '{/literal}{$lang}{literal}', keepFieldEmpty : true,
+ enableCloseEffect : false, enableShowEffect : false });
+ {/literal}
+ </script>
+ </td>
+ <td><input type='submit' name='search' value="{t}Search{/t}">
+ </tr>
+</table>
<p class="separator"> </p>
{if $result.status != 'ok'}
<b>{t}Error{/t}: {$result.status}</b><br>
{$result.error}<br>
{else}
- <b>{t}Results{/t}:</b>
- <table>
+
+ <br>
+ <table width="100%">
+ <tr>
+ <td>
+ <b>
+ <a href='?plug={$plug_id}&sort_value=DeviceReportedTime'>{t}Received{/t}
+ {if $sort_value=="DeviceReportedTime"}{if $sort_type=="DESC"}{$downimg}{else}{$upimg}{/if}{/if}
+ </a>
+ </b>
+ </td>
+ <td>
+ <b>
+ <a href='?plug={$plug_id}&sort_value=FromHost'>{t}Host{/t}
+ {if $sort_value=="FromHost"}{if $sort_type=="DESC"}{$downimg}{else}{$upimg}{/if}{/if}
+ </a>
+ </b>
+ </td>
+ <td>
+ <b>
+ <a href='?plug={$plug_id}&sort_value=Facility'>{t}Facility{/t}
+ {if $sort_value=="Facility"}{if $sort_type=="DESC"}{$downimg}{else}{$upimg}{/if}{/if}
+ </a>
+ </b>
+ </td>
+ <td>
+ <b>
+ <a href='?plug={$plug_id}&sort_value=Priority'>{t}Priority{/t}
+ {if $sort_value=="Priority"}{if $sort_type=="DESC"}{$downimg}{else}{$upimg}{/if}{/if}
+ </a>
+ </b>
+ </td>
+ <td>
+ <b>
+ <a href='?plug={$plug_id}&sort_value=Message'>{t}Message{/t}
+ {if $sort_value=="Message"}{if $sort_type=="DESC"}{$downimg}{else}{$upimg}{/if}{/if}
+ </a>
+ </b>
+ </td>
+ </tr>
+ <tr><td colspan="5"><p class="separator"> </p></td></tr>
{foreach from=$result.entries item=item key=key}
<tr>
- <td>{$item.DeviceReportedTime}</td>
- <td>{$item.FromHost}</td>
- <td>{$item.Facility}</td>
- <td>{$item.Priority}</td>
- <td>{$item.Message}</td>
+ <td title='{$item.DeviceReportedTime}' style='width:120px'>
+ {$item.DeviceReportedTime}
+ </td>
+ <td title='{$item.FromHost}'>
+ {$item.FromHost}
+ </td>
+ <td title='{$item.Facility}'>
+ {$item.Facility}
+ </td>
+ <td title='{$item.Priority}'>
+ {$item.Priority}
+ </td>
+ <td title='{$item.Message}' style="width:600px">
+ <div style='overflow:hidden; width:600px'><nobr>{$item.Message}</nobr></div>
+ </td>
</tr>
{/foreach}
</table>
- {$result.count} {t}entries matching filter{/t}
+ {if !$result.count == 0}
+ <p class="separator"> </p>
+ {/if}
+ <div style='width:40%;float:left;'>{$result.count} {t}entries matching filter{/t}</div>
+ <div style='width:80px;float:right;'>
+ <select name='limit' onChange='document.mainform.submit();'>
+ {html_options options=$limits selected=$limit}
+ </select>
+ </div>
+ <div style='width:200px;float:left;'>{$page_sel}</div>
{/if}