From: hickert Date: Fri, 18 Dec 2009 11:16:15 +0000 (+0000) Subject: Updated rSyslog X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c42fb54fe8a8801cb7e7f24571d1eb6d91dc3493;p=gosa.git Updated rSyslog git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14909 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 40d9c7e9a..49a7d14ea 100644 --- a/gosa-plugins/rsyslog/addons/rsyslog/class_rsyslog.inc +++ b/gosa-plugins/rsyslog/addons/rsyslog/class_rsyslog.inc @@ -97,6 +97,7 @@ class rsyslog extends plugin $result = array(); $result['entries'] = array(); $result['status'] = "ok"; + $result['count'] = 0; $result['error'] = ""; // Check whether the selected server exists. @@ -125,18 +126,38 @@ class rsyslog extends plugin // Get log entries matching the selected filter if(preg_match('/r/', $this->servers[$name]['ACL'])){ - $query = "SELECT * FROM SystemEvents LIMIT 10;"; + + $host = "%%"; + if($this->selected_host != "all") $host = $this->selected_host; + + + $filter = "FROM SystemEvents WHERE FromHost like '{$host}' LIMIT 20;"; + + // Detect amount of matching entries + $query = "SELECT count(ID) as `amount` ".$filter; $res = @mysql_query($query, $link); - if($res){ - while($attrs = @mysql_fetch_assoc($res)){ - $result['entries'][] = $attrs; - } - $this->servers[$name]['status'] = "ok"; - $this->servers[$name]['error'] = ""; + if($res && $attrs = @mysql_fetch_assoc($res)){ + $result['count'] = $attrs['amount']; }else{ $this->servers[$name]['status'] = "query_failed"; $this->servers[$name]['error'] = @mysql_error(); } + + if($result['count']){ + + $query = "SELECT * ".$filter; + $res = @mysql_query($query, $link); + if($res){ + while($attrs = @mysql_fetch_assoc($res)){ + $result['entries'][] = $attrs; + } + $this->servers[$name]['status'] = "ok"; + $this->servers[$name]['error'] = ""; + }else{ + $this->servers[$name]['status'] = "query_failed"; + $this->servers[$name]['error'] = @mysql_error(); + } + } } $result['status'] =$this->servers[$name]['status']; $result['error'] =$this->servers[$name]['error']; diff --git a/gosa-plugins/rsyslog/addons/rsyslog/rSyslog.tpl b/gosa-plugins/rsyslog/addons/rsyslog/rSyslog.tpl index 1049f613c..ba5573445 100644 --- a/gosa-plugins/rsyslog/addons/rsyslog/rSyslog.tpl +++ b/gosa-plugins/rsyslog/addons/rsyslog/rSyslog.tpl @@ -20,11 +20,14 @@ {foreach from=$result.entries item=item key=key} - + + + + + {/foreach}
- {$item.FromHost}; - {$item.DeviceReportedTime}{$item.FromHost}{$item.Facility}{$item.Priority}{$item.Message}
+ {$result.count} {t}entries matching filter{/t} {/if}