On Oct 29, 12:39 am, Ronald Valente
<rawn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I have been working with rails on and off for a while now. I still
> consider myself a noob with rails. Now with EDGE rails I am quite
> lost. I am using the Preview Release right now. My database migrations
> are quite sexy. I am just having the following trouble.
>
> Right now I have started development of a snmp monitor app which will
> just be used for in house, for now.
>
> I want to add another link in the show view called "Walk" which
will
> run an SNMP walk on the IP that is provided in the box. How would I go
> about doing that.
> Would the snmp commands get run via the model or the controller?
>
> Thanks
> -Ron
I would create a model that will run your snmpwalk and parse the
results into some sort of object or a collection of objects. Then,
you would call that from your controller.
For example:
Say you have a processes controller with a show method. It calls the
SystemProcess model, which is simply something you wrote to walk the
process tree and put that into an array of Process objects.
(This below is for MERB, not Rails, but its very similar. I think you
can get the point of it.)
def show
begin
@process = SystemProcess.find_by_host(params[:hostname])
rescue Exception => e
raise NotFound.new(e.message)
end
if params[:process]
@process = @process.select {|s|
Regexp.new(params[:process],true).match(
s.name) }
end
respond_to do |f|
f.txt { render_no_layout }
f.xml { render }
f.html { render }
end
end
So, that returns to you an @process object, which you can then render
in your views. If there was a process param passed, then we will go
through the collection of processes and only keep ones that match
whatever regex was passed.
That helpful?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---