-
Notifications
You must be signed in to change notification settings - Fork 0
/
metric-windows-iis-file-cache-hits.rb
39 lines (36 loc) · 1.17 KB
/
metric-windows-iis-file-cache-hits.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!C:/opt/sensu/embedded/bin/ruby.exe
require 'sensu-plugin/metric/cli'
require 'socket'
class FileCacheHitsMetric < Sensu::Plugin::Metric::CLI::Graphite
option :scheme,
description: 'Metric naming scheme, text to prepend to .$parent.$child',
long: '--scheme SCHEME',
default: Socket.gethostname.to_s
option :app,
description: 'For W3SVC_W3WP, you need to put WorkerProcessID_AppPoolName. ex: 14604_DefaultAppPool',
short: '-a APP',
long: '--apppool APP',
default: '_TOTAL'
def accquire_File_Cache_Hits
temp_arr = []
timestamp = Time.now.utc.to_i
IO.popen("typeperf -sc 1 \"\\W3SVC_W3WP(#{config[:app]})\\File Cache Hits\"") { |io| io.each { |line| temp_arr.push(line) } }
temp = temp_arr[2].split(',')[1]
metric = temp[1, temp.length - 3].to_f
[metric, timestamp]
end
def run
values = accquire_File_Cache_Hits
metrics = {
WorkerProcessCache: {
FileCacheHits: values[0]
}
}
metrics.each do |parent, children|
children.each do |child, value|
output [config[:scheme], parent, child].join('.'), value, values[1]
end
end
ok
end
end