Code

Updated rSyslog
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 18 Dec 2009 11:16:15 +0000 (11:16 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 18 Dec 2009 11:16:15 +0000 (11:16 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14909 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/rsyslog/addons/rsyslog/class_rsyslog.inc
gosa-plugins/rsyslog/addons/rsyslog/rSyslog.tpl

index 40d9c7e9ad8d6a572697f8326acf7129e93073d5..49a7d14ea782d4042f08433afe5042c6b9f62d91 100644 (file)
@@ -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'];
index 1049f613c24eb29038ff8b1703bd4cce177fc3ed..ba5573445f10a21701949b8f2de66072f6510934 100644 (file)
   <table>
     {foreach from=$result.entries item=item key=key}
     <tr>
-      <td>
-        {$item.FromHost};
-      </td>
+      <td>{$item.DeviceReportedTime}</td>
+      <td>{$item.FromHost}</td>
+      <td>{$item.Facility}</td>
+      <td>{$item.Priority}</td>
+      <td>{$item.Message}</td>
     </tr>
     {/foreach}
   </table>
+  {$result.count} {t}entries matching filter{/t}
 {/if}