<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/tasks/nagioscheck.rake</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -34,13 +34,7 @@ class ApplicationController &lt; ActionController::Base
   end
 
   def build_conditions_from_blacklist
-    conditions = Array.new
-    bl_terms = Blacklistterm.find :all
-    bl_terms.each do |term|
-      conditions &lt;&lt; [ &quot;Message NOT LIKE ?&quot;, &quot;%#{term.message}%&quot; ] unless term.message.blank?
-    end
-
-    return Logentry.merge_conditions *conditions
+    return Blacklist.build_conditions
   end
   
   def build_conditions_for_blacklist blacklist_id</diff>
      <filename>app/controllers/application_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,50 +1,21 @@
 class DashboardController &lt; ApplicationController
 
   def index
-    @dashboard_settings = get_dashboard_settings
-    @new_messages = get_new_messages @dashboard_settings[&quot;timespan&quot;]
-    @alert = alert? @dashboard_settings[&quot;number_of_allowed_messages&quot;], @new_messages
+    @dashboard_settings = Setting.get_dashboard_settings
+    @new_messages = Logentry.get_new_messages @dashboard_settings[&quot;timespan&quot;], build_conditions_from_blacklist
+    @alert = Logentry.alert? @dashboard_settings[&quot;number_of_allowed_messages&quot;], @new_messages
   end
   
   def nagioscheck
-    @dashboard_settings = get_dashboard_settings
-    @new_messages = get_new_messages @dashboard_settings[&quot;timespan&quot;]
+    @dashboard_settings = Setting.get_dashboard_settings
+    @new_messages = Logentry.get_new_messages @dashboard_settings[&quot;timespan&quot;], build_conditions_from_blacklist
     
-    if !alert? @dashboard_settings[&quot;number_of_allowed_messages&quot;], @new_messages
+    if !Logentry.alert? @dashboard_settings[&quot;number_of_allowed_messages&quot;], @new_messages
       render :text =&gt; &quot;okay&quot;
       return
     end
     
     render :text =&gt; &quot;alert&quot;
   end
-  
-  private
-  def get_new_messages timespan
-    blacklist_conditions = build_conditions_from_blacklist
-    timespan_condition = [ &quot;ReceivedAt &gt; ?&quot;, timespan.minutes.ago]
-    conditions = Logentry.merge_conditions blacklist_conditions, timespan_condition
-    return Logentry.count :conditions =&gt; conditions
-  end
-  
-  def get_dashboard_settings
-    if Setting.last.blank?
-      timespan = 10
-      number_of_allowed_messages = 100
-      fontsize = 50
-    else
-      Setting.last.dashboard_timespan.blank? ? timespan = 10 : timespan = Setting.last.dashboard_timespan.to_i
-      Setting.last.dashboard_messages.blank? ? number_of_allowed_messages = 100 : number_of_allowed_messages = Setting.last.dashboard_messages.to_i
-      Setting.last.dashboard_font_size.blank? ? fontsize = 50 : fontsize = Setting.last.dashboard_font_size.to_i
-    end
-    
-    return { &quot;number_of_allowed_messages&quot; =&gt; number_of_allowed_messages,
-             &quot;timespan&quot; =&gt; timespan,
-             &quot;fontsize&quot; =&gt; fontsize }
-  end
-  
-  def alert? number_of_allowed_messages, new_messages
-    return true if new_messages &gt; number_of_allowed_messages
-    return false
-  end
 
 end</diff>
      <filename>app/controllers/dashboard_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,13 @@
 class Blacklist &lt; ActiveRecord::Base
   has_many :blacklistterms
+  
+  def self.build_conditions
+    conditions = Array.new
+    bl_terms = Blacklistterm.find :all
+    bl_terms.each do |term|
+      conditions &lt;&lt; [ &quot;Message NOT LIKE ?&quot;, &quot;%#{term.message}%&quot; ] unless term.message.blank?
+    end
+
+    return Logentry.merge_conditions *conditions
+  end
 end</diff>
      <filename>app/models/blacklist.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,17 @@ class Logentry &lt; ActiveRecord::Base
   
   include AuthenticatedSystem
 
+  def self.get_new_messages timespan, blacklist_conditions
+    timespan_condition = [ &quot;ReceivedAt &gt; ?&quot;, timespan.minutes.ago]
+    conditions = self.merge_conditions blacklist_conditions, timespan_condition
+    return self.count :conditions =&gt; conditions
+  end
+  
+  def self.alert? number_of_allowed_messages, new_messages
+    return true if new_messages &gt; number_of_allowed_messages
+    return false
+  end
+
   def human_readable_severity
     case self.Priority
       when 0: &quot;Emergency&quot;</diff>
      <filename>app/models/logentry.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,2 +1,19 @@
 class Setting &lt; ActiveRecord::Base
+  
+  def self.get_dashboard_settings
+    if self.last.blank?
+      timespan = 10
+      number_of_allowed_messages = 100
+      fontsize = 50
+    else
+      self.last.dashboard_timespan.blank? ? timespan = 10 : timespan = self.last.dashboard_timespan.to_i
+      self.last.dashboard_messages.blank? ? number_of_allowed_messages = 100 : number_of_allowed_messages = self.last.dashboard_messages.to_i
+      self.last.dashboard_font_size.blank? ? fontsize = 50 : fontsize = self.last.dashboard_font_size.to_i
+    end
+    
+    return { &quot;number_of_allowed_messages&quot; =&gt; number_of_allowed_messages,
+             &quot;timespan&quot; =&gt; timespan,
+             &quot;fontsize&quot; =&gt; fontsize }
+  end
+  
 end</diff>
      <filename>app/models/setting.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a92520ad3ad38e006bd84b407172be0ffc0c5fe0</id>
    </parent>
  </parents>
  <author>
    <name>Lennart Koopmann</name>
    <email>lennart@linux.jimdo.office</email>
  </author>
  <url>http://github.com/lennartkoopmann/Graylog/commit/98bab556351dd6771a8e5aa311deac982363a16f</url>
  <id>98bab556351dd6771a8e5aa311deac982363a16f</id>
  <committed-date>2009-10-06T08:32:11-07:00</committed-date>
  <authored-date>2009-10-06T08:32:11-07:00</authored-date>
  <message>More refactoring. Also added rake task for Nagios NRPE check</message>
  <tree>a4993525546a74fca9fa1c3597c24fe60284565b</tree>
  <committer>
    <name>Lennart Koopmann</name>
    <email>lennart@linux.jimdo.office</email>
  </committer>
</commit>
