Possible project? sysinfo lib

  • Thread starter E F van de Laar
  • Start date
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::platform.get_factory

DRb.start_service("druby://#{Socket.gethostname}:2222", tk)
DRb.thread.join


--jRHKVT23PllUwdXP--
 
A

Ara.T.Howard

--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

have you seen this?

http://raa.ruby-lang.org/list.rhtml?name=proclib

-a

--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL :: http://www.ngdc.noaa.gov/stp/
| TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done
===============================================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,265
Messages
2,571,069
Members
48,771
Latest member
ElysaD

Latest Threads

Top