From: hickert Date: Wed, 30 Jun 2010 14:58:47 +0000 (+0000) Subject: Added method to generate RSS feeds from logs X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e1c442f3155892ccb8789cae27027d9df6de1ed0;p=gosa.git Added method to generate RSS feeds from logs git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18890 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 e136adb35..e90d0c4db 100644 --- a/gosa-plugins/rsyslog/addons/rsyslog/class_rsyslog.inc +++ b/gosa-plugins/rsyslog/addons/rsyslog/class_rsyslog.inc @@ -151,6 +151,63 @@ class rsyslog extends plugin return($smarty->fetch(get_template_path("rSyslog.tpl", TRUE))); } + + function logToRss() + { + $result = array(); + foreach($this->servers as $name => $server){ + $link = @mysql_pconnect($server['cn'], $server['User'], $server['Password']); + if ($link === FALSE){ + new log("debug","gosa_logging","dbconnect",array(),@mysql_error()); + $this->servers[$name]['status'] = "connectfailed"; + $this->servers[$name]['error'] = @mysql_error(); + }elseif (! @mysql_select_db($server['Database'])){ + new log("debug","gosa_logging","selectdb",array(),@mysql_error()); + $this->servers[$name]['status'] = "dbmissing"; + $this->servers[$name]['error'] = @mysql_error(); + }else{ + $this->servers[$name]['status'] = "ok"; + $this->servers[$name]['error'] = ""; + } + + if($link){ + $query = "SELECT * FROM SystemEvents WHERE Message like '%GOsa%' ORDER BY ID LIMIT 50"; + $res = mysql_query($query, $link); + if($res){ + while($attrs = mysql_fetch_assoc($res)){ + $result[] = $attrs; + } + } + } + } + $source = + ''. + ' '. + ' '. + ' GOsa'. + ' gosa-project.org'. + ' GOsa'. + ' '.date('d.m.Y H:i:s').''. + ' '; + + foreach($result as $entry){ + $message = $entry['FromHost'].": ".$entry['Message']; + $source .= " + + {$message} + {$message} + 2010-10-25T14:27:39Z + "; + } + $source .= "\n"; + return($source); + } + + + function get_result() { $result = array();