diff --git a/gosa-plugins/rsyslog/addons/rsyslog/class_rsyslog.inc b/gosa-plugins/rsyslog/addons/rsyslog/class_rsyslog.inc
index 93b593bb3617bfeb286e4d6fd6c460142ee3e9bc..7c878da801510e502af068e22fda3573e992bb29 100644 (file)
class rsyslog extends plugin
{
var $plHeadline= "System logs";
- var $plDescription= "View systemlogs that got recorded with rsyslog";
+ var $plDescription= "View recorded systemlogs";
var $servers = array();
var $selected_server = "";
function rsyslog (&$config, $dn= NULL)
{
+ $this->initTime = microtime(TRUE);
+
+ // Create statistic table entry
+ stats::log('plugin', $class = get_class($this), $category = array($this->acl_category), $action = 'open',
+ $amount = 1, $duration = (microtime(TRUE) - $this->initTime));
+
+
$this->config= &$config;
$this->ui = get_userinfo();
plugin::execute();
$smarty = get_smarty();
- $smarty->assign("usePrototype", "true");
+
$ui = get_userinfo();
if(!isset($this->servers[$this->selected_server]['Hosts']) || !count($this->servers[$this->selected_server]['Hosts'])){
$result =$this->get_result();
- $smarty->assign("servers",$this->servers);
- $smarty->assign("hosts",$hosts);
- $smarty->assign("priorities",$priorities);
- $smarty->assign("selected_server",$this->selected_server);
- $smarty->assign("selected_host",$this->selected_host);
- $smarty->assign("selected_priority",$this->selected_priority);
- $smarty->assign("search_for",$this->search_for);
- $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", image('images/lists/sort-down.png'));
- $smarty->assign("upimg", image('images/lists/sort-up.png'));
+ $smarty->assign("servers", set_post($this->servers));
+ $smarty->assign("hosts", set_post($hosts));
+ $smarty->assign("priorities", set_post($priorities));
+ $smarty->assign("selected_server", set_post($this->selected_server));
+ $smarty->assign("selected_host", set_post($this->selected_host));
+ $smarty->assign("selected_priority",set_post($this->selected_priority));
+ $smarty->assign("search_for", set_post($this->search_for));
+ $smarty->assign("startTime", set_post($this->startTime));
+ $smarty->assign("stopTime", set_post($this->stopTime));
+ $smarty->assign("sort_type", set_post($this->sort_type));
+ $smarty->assign("sort_value", set_post($this->sort_value));
+ $smarty->assign("limits", set_post($this->limits));
+ $smarty->assign("limit", set_post($this->limit));
+ $smarty->assign("page", set_post($this->page));
+ $smarty->assign("plug_id", set_post($_GET['plug']));
+ $smarty->assign("downimg", image('images/lists/sort-down.png'));
+ $smarty->assign("upimg", image('images/lists/sort-up.png'));
$smarty->assign("result", $result);
$smarty->assign("matches", sprintf(_("%s entries match the filter"), $result["count"]));
if($this->limits[$this->limit] != '-'){
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 DESC LIMIT 50";
+ $res = mysql_query($query, $link);
+ if($res){
+ while($attrs = mysql_fetch_assoc($res)){
+ $result[] = $attrs;
+ }
+ }
+ }
+ }
+ $source =
+ '<?xml version="1.0" encoding="utf-8"?>'.
+ ' <rdf:RDF'.
+ ' xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"'.
+ ' xmlns="http://purl.org/rss/1.0/"'.
+ ' xmlns:dc="http://purl.org/dc/elements/1.1/">'.
+ ' <channel rdf:about="Gosa">'.
+ ' <description>GOsa</description>'.
+ ' <link>gosa-project.org</link>'.
+ ' <title>GOsa</title>'.
+ ' <dc:date>'.date('d.m.Y H:i:s').'</dc:date>'.
+ ' </channel>';
+
+ foreach($result as $entry){
+
+ $message = $entry['ReceivedAt']." - ".htmlentities($entry['FromHost'].": ".$entry['Message']);
+ $source .= "
+ <item>
+ <title>{$message}</title>
+ <description>{$message}</description>
+ <pubDate>2010-10-25T14:27:39Z</pubDate>
+ </item>";
+ }
+ $source .= "\n</rdf:RDF>";
+ return($source);
+ }
+
+
+
function get_result()
{
$result = array();
$filter = "FROM SystemEvents WHERE 1=1 ";
if($host != "%%"){
- $filter.= " AND FromHost like '{$host}' ";
+ $filter.= " AND FromHost like '".mysql_real_escape_string($host)."' ";
}
if($prio != "%%"){
- $filter.= "AND Priority like '{$prio}' ";
+ $filter.= "AND Priority like '".mysql_real_escape_string($prio)."' ";
}
$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)))."' ";
if(!empty($this->search_for)){
- $filter.= "AND ( ( SysLogTag like '%".$this->search_for."%' ) OR ( Message like '%".$this->search_for."%' ) ) ";
+ $filter.= "AND ( ( SysLogTag like '%".mysql_real_escape_string($this->search_for).
+ "%' ) OR ( Message like '%".mysql_real_escape_string($this->search_for)."%' ) ) ";
}
// Detect amount of matching entries
// Get server from post
if( isset($_POST['selected_server']) && isset($this->servers[$_POST['selected_server']])){
- $this->selected_server = $_POST['selected_server'];
+ $this->selected_server = get_post('selected_server');
}
// Get Host
if( isset($this->servers[$this->selected_server]['Hosts']) && isset($_POST['selected_host']) &&
($_POST['selected_host'] == "all" ||
- in_array($_POST['selected_host'],$this->servers[$this->selected_server]['Hosts']))){
- $this->selected_host = $_POST['selected_host'];
+ in_array_strict($_POST['selected_host'],$this->servers[$this->selected_server]['Hosts']))){
+ $this->selected_host = get_post('selected_host');
}
// Get priority from post
if( isset($this->servers[$this->selected_server]['Priorities']) && isset($_POST['selected_priority']) &&
($_POST['selected_priority'] == "all" ||
- in_array($_POST['selected_priority'],$this->servers[$this->selected_server]['Priorities']))){
- $this->selected_priority = $_POST['selected_priority'];
+ in_array_strict($_POST['selected_priority'],$this->servers[$this->selected_server]['Priorities']))){
+ $this->selected_priority = get_post('selected_priority');
}
// Get serach string
// Get page navigation attributes
if(isset($_GET['start'])) $this->page = $_GET['start'];
if(isset($_POST['limit']) && isset($this->limits[$_POST['limit']])){
- $this->limit = $_POST['limit'];
+ $this->limit = get_post('limit');
}
// Get sorting attributes
- if(isset($_GET['sort_value']) && in_array($_GET['sort_value'],
+ if(isset($_GET['sort_value']) && in_array_strict($_GET['sort_value'],
array("DeviceReportedTime","FromHost","Facility","Priority","Message","SysLogTag"))){
$sort_value = $_GET['sort_value'];
if($this->sort_value == $sort_value){