Permalink
Browse files

moved options in-line and changed require to 'needs'

  • Loading branch information...
1 parent 4fbe492 commit edc00bac856299d5d311d57fba55f32f7c8f1bef Andre Lewis committed Mar 10, 2010
@@ -1,6 +1,13 @@
-%w( fastercsv open-uri ).each { |f| require f }
-
class HaproxyStats < Scout::Plugin
+
+ needs 'fastercsv', 'open-uri'
+
+ OPTIONS=<<-EOS
+ uri:
+ name: URI
+ notes: URI of the haproxy CSV stats url. See the 'CSV Export' link on your haproxy stats page
+ EOS
+
def build_report
FasterCSV.parse(open(option(:uri)), :headers => true) do |row|
if row["svname"] == 'FRONTEND' || row["svname"] == 'BACKEND'
@@ -1,5 +0,0 @@
-options:
- uri:
- name: URI
- notes: URI of the haproxy CSV stats url. See the 'CSV Export' link on your haproxy stats page
- default:
View
@@ -1 +0,0 @@
-Log tail
View
@@ -1,41 +0,0 @@
-require "time"
-require "digest/md5"
-
-# Log Tail plugin for Scout.
-# based heavily on the MySQL Slow Queries Monitoring plugin
-
-class ScoutLogTail < Scout::Plugin
- needs "elif"
-
- def build_report
- log_file_path = option("logfile").to_s.strip
- if log_file_path.empty?
- return error( "A path to the a log file wasn't provided." )
- end
-
- log_lines_count = 0
- last_run = memory(:last_run) || Time.now
- current_time = Time.now
- Elif.foreach(log_file_path) do |line|
- if line =~ Regexp.new(option("date_regex").to_s.strip)
- t = Time.parse($1)
- t2 = last_run
- if t < t2
- break
- else
- regex = Regexp.new(option("alert_regex").to_s.strip)
- if regex =~ line
- log_lines_count = log_lines_count + 1
- alert(:subject => log_file_path, :body => line)
- end
- end
- end
- end
-
- elapsed_seconds = current_time - last_run
- elapsed_seconds = 1 if elapsed_seconds < 1
- # calculate per-second
- report(:lines => log_lines_count/(elapsed_seconds/60.to_f))
- remember(:last_run,Time.now)
- end
-end
View
@@ -1,14 +0,0 @@
-options:
- logfile:
- default: /var/log/system.log
- name: Full path to the log file you'd like to monitor
- date_regex:
- default: (^\w*\b \d{1,2} [\d:]{8})
- name: Regular Expression to extract the date from the logfile. Detects the syslog format by default.
- alert_regex:
- default:
- name: Generate an alert for all log entries matching this regular expression (optional)
-metadata:
- lines:
- units: /min
- precision: 2
@@ -1,6 +1,14 @@
-%w( nokogiri open-uri ).each { |f| require f }
-
class PowermtaStats < Scout::Plugin
+
+ needs 'nokogiri','open-uri'
+
+ OPTIONS=<<-EOS
+ uri:
+ name: URI
+ notes: URI of the PowerMTA Web Interface url
+ default: http://127.0.0.1:8080/
+ EOS
+
def build_report
uri = option(:uri) || "http://127.0.0.1:8080/"
status = Nokogiri::XML(open(uri+'status?format=xml'))
@@ -1,8 +1,3 @@
-options:
- uri:
- name: URI
- notes: URI of the PowerMTA Web Interface url
- default: http://127.0.0.1:8080/
metadata:
"Out: Messages/min":
units: ""

0 comments on commit edc00ba

Please sign in to comment.