Created
June 29, 2009 00:09
-
-
Save msonnabaum/137412 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'statgrab' | |
require 'json' | |
sg = Statgrab.new | |
stats = {} | |
#puts "#{sg.memory[:free]/1024}m" | |
#puts sg.memory.to_json() | |
sg_methods = ['cpu', 'cpu_difference', 'cpu_percents', 'cpu_stats', 'cpu_stats_diff', 'disk_io_stats', 'disk_io_stats_diff', 'file_system', 'fs', 'fs_stats', 'host', 'host_info', 'iface', 'load_average', 'load_stats', 'loadavg', 'mem_stats', 'memory', 'net', 'net_difference', 'net_iface', 'net_io', 'network', 'network_difference', 'network_iface', 'network_iface_stats', 'network_io', 'network_io_difference', 'network_io_stats', 'network_io_stats_diff', 'page', 'page_difference', 'page_stats', 'page_stats_diff', 'pages', 'proc', 'proc_count', 'process_count', 'process_stats', 'processes', 'ps', 'swap_stats', 'system', 'system_load', 'user_stats', 'users'] | |
#puts sg.cpu.to_json | |
sg_methods.each do |m| | |
begin | |
stat = sg.send(m) | |
stats[m] = stat.to_json | |
rescue Statgrab::ParseError | |
# puts m | |
end | |
end | |
jsonfile = File.new("stats.js", "w") | |
jsonfile.puts(stats.to_json) | |
`gzip -f stats.js` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment