From c42fb54fe8a8801cb7e7f24571d1eb6d91dc3493 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 18 Dec 2009 11:16:15 +0000 Subject: [PATCH] Updated rSyslog git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14909 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../rsyslog/addons/rsyslog/class_rsyslog.inc | 35 +++++++++++++++---- .../rsyslog/addons/rsyslog/rSyslog.tpl | 9 +++-- 2 files changed, 34 insertions(+), 10 deletions(-) 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} -- 2.30.2