Permalink
Browse files

Added more plugins

  • Loading branch information...
1 parent 9da88c0 commit 59769c2b2c8b2656fb83f7b6b65ffeb7151bf1f8 @itsderek23 itsderek23 committed Dec 8, 2009
View
@@ -0,0 +1,15 @@
+Redis Info Plugin
+======================
+Created by [Matt Todd](http://twitter.com/mtodd)
+
+Overview
+------------
+
+Reports Redis memory used and changes since the last save.
+
+Dependencies
+------------
+
+Requires access to the `redis-cli info` command.
+
+
View
@@ -0,0 +1,11 @@
+require 'yaml'
+
+class Redis < Scout::Plugin
+ def build_report
+ info = YAML.load(%x{redis-cli info}.gsub(/:/, ": "))
+
+ %w(used_memory changes_since_last_save).each do |key|
+ report(key => info[key])
+ end
+ end
+end
View
@@ -0,0 +1,15 @@
+Swappiness Plugin
+======================
+Created by [Eric Lindvall](http://twitter.com/lindvall)
+
+Overview
+------------
+
+Reports on various SWAP-related memory metrics, generating alerts if Swap-Ins and/or Swap-Outs increase significantly.
+
+Dependencies
+------------
+
+Requires `vmstat` (read by the plugin via `/proc/vmstat`).
+
+
View
@@ -0,0 +1,64 @@
+#
+# Created by Eric Lindvall <eric@sevenscale.com>
+#
+# Name provided by Jesse Newland <jesse@railsmachine.com>
+#
+
+class Swappiness < Scout::Plugin
+ def build_report
+ if vmstat?
+ counter('Swap-ins', vmstat['pswpin'], :per => :second, :round => true)
+ counter('Swap-outs', vmstat['pswpout'], :per => :second, :round => true)
+ counter('Page-ins', vmstat['pgpgin'], :per => :second, :round => true)
+ counter('Page-outs', vmstat['pgpgout'], :per => :second, :round => true)
+ counter('Page Faults', vmstat['pgfault'], :per => :second, :round => true)
+ end
+ rescue Exception => e
+ error("An error occurred profiling the memory:\n\n#{e.class}: #{e.message}\n\t#{e.backtrace.join("\n\t")}")
+ end
+
+ def vmstat?
+ File.exists?('/proc/vmstat')
+ end
+
+ def vmstat
+ @vmstat ||= begin
+ hash = {}
+ IO.foreach('/proc/vmstat') do |line|
+ _, key, value = *line.match(/^(\w+)\s+(\d+)/)
+ hash[key] = value.to_i
+ end
+ hash
+ end
+ end
+
+ private
+ # Would be nice to be part of scout internals
+ def counter(name, value, options = {})
+ current_time = Time.now
+
+ if data = memory(name)
+ last_time, last_value = data[:time], data[:value]
+ elapsed_seconds = current_time - last_time
+
+ # We won't log it if the value has wrapped or enough time hasn't
+ # elapsed
+ if value >= last_value && elapsed_seconds >= 1
+ result = value - last_value
+
+ case options[:per]
+ when :second, 'second'
+ result = result / elapsed_seconds.to_f
+ when :minute, 'minute'
+ result = result / elapsed_seconds.to_f / 60.0
+ end
+
+ result = result.to_i if options[:round]
+
+ report(name => result)
+ end
+ end
+
+ remember(name => { :time => current_time, :value => value })
+ end
+end
View
@@ -0,0 +1,44 @@
+metadata:
+ Swap-ins:
+ units: "KB/s"
+ larger_is_better: "0"
+ delimiter: ","
+ precision: "0"
+ label: Swap-ins
+ Swap-outs:
+ units: "KB/s"
+ larger_is_better: "0"
+ delimiter: ","
+ precision: "0"
+ label: Swap-outs
+ Page-ins:
+ units: "pages/s"
+ larger_is_better: "0"
+ delimiter: ","
+ precision: "0"
+ label: Page-ins
+ Page-outs:
+ units: "pages/s"
+ larger_is_better: "0"
+ delimiter: ","
+ precision: "0"
+ label: Page-outs
+ Page Faults:
+ units: "faults/s"
+ larger_is_better: "0"
+ delimiter: ","
+ precision: "0"
+ label: Page faults
+triggers:
+- percentage_change: 100
+ type: trend
+ min_value: 0
+ window_reference: PRECEDING_WINDOW
+ dname: Swap-ins
+ direction: UP
+- percentage_change: 100
+ type: trend
+ min_value: 0
+ window_reference: PRECEDING_WINDOW
+ dname: Swap-outs
+ direction: UP
View
@@ -0,0 +1,15 @@
+TCP Socket State Plugin
+======================
+Created by [Eric Lindvall](http://twitter.com/lindvall)
+
+Overview
+------------
+
+Reports the status of TCP sockets (Established, listen, etc.).
+
+Dependencies
+------------
+
+Requires `netstat`.
+
+
@@ -0,0 +1,17 @@
+#
+# Created by Eric Lindvall <eric@sevenscale.com>
+#
+class TcpSocketState < Scout::Plugin
+ def build_report
+ socket_states = Hash.new { |h,k| h[k] = 0 }
+
+ IO.popen("netstat -a -n -t") do |io|
+ io.each do |line|
+ next unless m = line.match(/^tcp.*?(\w+)\s*$/)
+ socket_states[m[1]] += 1
+ end
+ end
+
+ report socket_states
+ end
+end
@@ -0,0 +1,25 @@
+metadata:
+ ESTABLISHED:
+ precision: "0"
+ TIME_WAIT:
+ precision: "0"
+ LISTEN:
+ precision: "0"
+ CLOSE_WAIT:
+ precision: "0"
+ SYN_SENT:
+ precision: "0"
+ SYN_RECV:
+ precision: "0"
+ FIN_WAIT1:
+ precision: "0"
+ FIN_WAIT2:
+ precision: "0"
+ CLOSED:
+ precision: "0"
+ CLOSING:
+ precision: "0"
+ LAST_ACK:
+ precision: "0"
+ UNKNOWN:
+ precision: "0"

0 comments on commit 59769c2

Please sign in to comment.