E
E F van de Laar
--jRHKVT23PllUwdXP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
'lo all,
I've been playing with the idea of starting a new little personal project and
would like a little feedback before I really get started. I'm still brainstorming
at the moment.
My situation is as follows:
We admin several diverse servers in our student organization. The
administration team periodically gets new members and members leave as they
graduate. You can see that documenting is an important element to ease these
transitions. We have created a LaTeX doc documenting the network/system
configuration. This document is currently maintained manually and as
configurations change, we modify the doc. You can image that this
documentation will get out of sync real quick.
I'm looking to probe for various systems for specific information in real
time. At the core of this project would be a library which provides tools to
probe the underlying system for this info (CPU, mem, disks, net interfaces, etc).
Much like phpSysInfo without the web interface. This lib would only be capable
of doing the probing and how you use the info would be up to you (I would use
it with templates and perhaps a web interface a la phpSysInfo).
I'm aware of Daniel Berger's sysutils, however I'm curious if a lib like this
could be somewhat of an "umbrella" for all the system utils out there. Most of the
probing would be done by parsing output from standard system utils, however a C
extension per platform would be possible.
I threw together the attached code to make things a little clearer as to what
I'm trying to realize.
And so.
Suggestions are welcome.
Cheers,
Emiel
--
E F van de Laar
PGP pubkey: %finger (e-mail address removed)
--jRHKVT23PllUwdXP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="sysinfo.rb"
=begin
The idea is to be able to write apps querying for system information i.e. cpu,
memory, disk, network interfaces, process stats.
Apps using this lib could query for this information regardless of the
underlying platform.
My intention for this lib is so that I will be able to build documentation for
the various machines under my administration.
Possible a web interface showing all the machines in your network.
=end
module Toolkit
class Platform
def self.get_factory
case `uname`
when /linux/i
return Linux.new
when /freebsd/i
return FreeBSD.new
else
warn "Unsupported platform"
exit 1
end
end
end
class Linux < Platform
class CPU
attr_reader :bogomips
def initialize
# Read /proc/cpuinfo
self.load
end
def load
File.open("/proc/cpuinfo", "r") do |fp|
fp.each_line do |line|
case line
when /^bogomips\s*:\s*(.*)/
@bogomips = $1
end
end
end
end
end
def get_cpu
return CPU.new
end
end
class FreeBSD < Platform
class CPU
def bogomips
end
end
def get_cpu
return CPU.new
end
end
end
--jRHKVT23PllUwdXP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="infoclient.rb"
require 'drb/drb'
require 'sysinfo'
hosts = ["charm", "marvin"]
infos = {}
DRb.start_service # necessary
hosts.each do |host|
begin
infos[host] = DRbObject.new_with_uri("druby://#{host}:2222")
rescue
warn $!
end
end
infos.each { |host, info| puts "#{host} bogomips: " + info.get_cpu.bogomips }
--jRHKVT23PllUwdXP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="infoserver.rb"
require 'socket'
require 'drb/drb'
require 'sysinfo'
tk = Toolkit:
latform.get_factory
DRb.start_service("druby://#{Socket.gethostname}:2222", tk)
DRb.thread.join
--jRHKVT23PllUwdXP--
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
'lo all,
I've been playing with the idea of starting a new little personal project and
would like a little feedback before I really get started. I'm still brainstorming
at the moment.
My situation is as follows:
We admin several diverse servers in our student organization. The
administration team periodically gets new members and members leave as they
graduate. You can see that documenting is an important element to ease these
transitions. We have created a LaTeX doc documenting the network/system
configuration. This document is currently maintained manually and as
configurations change, we modify the doc. You can image that this
documentation will get out of sync real quick.
I'm looking to probe for various systems for specific information in real
time. At the core of this project would be a library which provides tools to
probe the underlying system for this info (CPU, mem, disks, net interfaces, etc).
Much like phpSysInfo without the web interface. This lib would only be capable
of doing the probing and how you use the info would be up to you (I would use
it with templates and perhaps a web interface a la phpSysInfo).
I'm aware of Daniel Berger's sysutils, however I'm curious if a lib like this
could be somewhat of an "umbrella" for all the system utils out there. Most of the
probing would be done by parsing output from standard system utils, however a C
extension per platform would be possible.
I threw together the attached code to make things a little clearer as to what
I'm trying to realize.
And so.
Cheers,
Emiel
--
E F van de Laar
PGP pubkey: %finger (e-mail address removed)
--jRHKVT23PllUwdXP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="sysinfo.rb"
=begin
The idea is to be able to write apps querying for system information i.e. cpu,
memory, disk, network interfaces, process stats.
Apps using this lib could query for this information regardless of the
underlying platform.
My intention for this lib is so that I will be able to build documentation for
the various machines under my administration.
Possible a web interface showing all the machines in your network.
=end
module Toolkit
class Platform
def self.get_factory
case `uname`
when /linux/i
return Linux.new
when /freebsd/i
return FreeBSD.new
else
warn "Unsupported platform"
exit 1
end
end
end
class Linux < Platform
class CPU
attr_reader :bogomips
def initialize
# Read /proc/cpuinfo
self.load
end
def load
File.open("/proc/cpuinfo", "r") do |fp|
fp.each_line do |line|
case line
when /^bogomips\s*:\s*(.*)/
@bogomips = $1
end
end
end
end
end
def get_cpu
return CPU.new
end
end
class FreeBSD < Platform
class CPU
def bogomips
end
end
def get_cpu
return CPU.new
end
end
end
--jRHKVT23PllUwdXP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="infoclient.rb"
require 'drb/drb'
require 'sysinfo'
hosts = ["charm", "marvin"]
infos = {}
DRb.start_service # necessary
hosts.each do |host|
begin
infos[host] = DRbObject.new_with_uri("druby://#{host}:2222")
rescue
warn $!
end
end
infos.each { |host, info| puts "#{host} bogomips: " + info.get_cpu.bogomips }
--jRHKVT23PllUwdXP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="infoserver.rb"
require 'socket'
require 'drb/drb'
require 'sysinfo'
tk = Toolkit:
DRb.start_service("druby://#{Socket.gethostname}:2222", tk)
DRb.thread.join
--jRHKVT23PllUwdXP--