[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Reliable ping method from Windows?

Glen Holcomb

9/18/2008 8:09:00 PM

[Note: parts of this message were removed to make it a legal post.]

Is there a reliable "Ruby" method for pinging/checking whether hosts are up?

I have been using Net::PingExternal as I'm pinging Windows machines and not
all of them have port 7 open. However when I try to check 900 or so
machines I get a SocketError after a while. It complains that there is no
such service echo/tcp. When I try similar code in irb I get the socket
error after a few minutes then if I try the loop again I get the socket
error immediately.

I've tried a generic ICMP packet but that doesn't work under Windows with
the standard Ruby build and I don't have the tools/time to build it my self
under Windows.

--
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can't hear a word you're saying."

-Greg Graffin (Bad Religion)

5 Answers

Glen Holcomb

9/18/2008 8:54:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

On Thu, Sep 18, 2008 at 2:09 PM, Glen Holcomb <damnbigman@gmail.com> wrote:

> Is there a reliable "Ruby" method for pinging/checking whether hosts are
> up?
>
> I have been using Net::PingExternal as I'm pinging Windows machines and not
> all of them have port 7 open. However when I try to check 900 or so
> machines I get a SocketError after a while. It complains that there is no
> such service echo/tcp. When I try similar code in irb I get the socket
> error after a few minutes then if I try the loop again I get the socket
> error immediately.
>
> I've tried a generic ICMP packet but that doesn't work under Windows with
> the standard Ruby build and I don't have the tools/time to build it my self
> under Windows.
>
> --
> "Hey brother Christian with your high and mighty errand, Your actions speak
> so loud, I can't hear a word you're saying."
>
> -Greg Graffin (Bad Religion)
>

Here is the full method if anyone wants more context:

# Lets find MAC addresses for the machines in the list
def find_macs
# This technique will only give MAC addresses for the machines on our
subnet.
# However since those are the only ones we can wake it doesn't really
matter.
# It is nasty slow and a better way should be found some day.

DB[:computers].each do |computer|
begin
Net::PingExternal.new(computer[:name]).ping
rescue SocketError => exception
next
end
end

arp_table = `arp -a`.split("\n")[2..-1]

arp_table.each do |address|
full_name = Socket.gethostbyname(address.split(' ')[0])

comp = Computer.find :name => full_name.split('.')[0]
comp.mac = address.split(' ')[1].gsub!('-', ':')
comp.save
end
close()
end # find_macs

--
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can't hear a word you're saying."

-Greg Graffin (Bad Religion)

Jeff Moore

9/19/2008 3:09:00 AM

0

Glen Holcomb wrote:
> On Thu, Sep 18, 2008 at 2:09 PM, Glen Holcomb <damnbigman@gmail.com>
> wrote:
>
>> I've tried a generic ICMP packet but that doesn't work under Windows with
>> the standard Ruby build and I don't have the tools/time to build it my self
>> under Windows.
>>
>> --
>> "Hey brother Christian with your high and mighty errand, Your actions speak
>> so loud, I can't hear a word you're saying."
>>
>> -Greg Graffin (Bad Religion)
>>
>
> Here is the full method if anyone wants more context:
>
> # Lets find MAC addresses for the machines in the list
> def find_macs
> # This technique will only give MAC addresses for the machines on
> our
> subnet.
> # However since those are the only ones we can wake it doesn't
> really
> matter.
> # It is nasty slow and a better way should be found some day.
>
> DB[:computers].each do |computer|
> begin
> Net::PingExternal.new(computer[:name]).ping
> rescue SocketError => exception
> next
> end
> end
>
> arp_table = `arp -a`.split("\n")[2..-1]
>
> arp_table.each do |address|
> full_name = Socket.gethostbyname(address.split(' ')[0])
>
> comp = Computer.find :name => full_name.split('.')[0]
> comp.mac = address.split(' ')[1].gsub!('-', ':')
> comp.save
> end
> close()
> end # find_macs


NMap is very fast and comes in a WinDoze flavor.

Since you're already mashing up the arp output,
I assume you will have no qualms about doing the
same for NMap output.

Not a pure Ruby solution but then NMap is open source
so if you're really into purity you could transcribe it's
approach to WinDoze discovery (maybe...possibly...)

But if expedience is the order of the day...

http:/...

You'll need WinPCap as well (the packet capture lib)

http://www.wi...

djief
--
Posted via http://www.ruby-....

Glen Holcomb

9/24/2008 1:59:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

On Thu, Sep 18, 2008 at 9:08 PM, Jeff Moore <jcmoore@pressenter.com> wrote:

> Glen Holcomb wrote:
> > On Thu, Sep 18, 2008 at 2:09 PM, Glen Holcomb <damnbigman@gmail.com>
> > wrote:
> >
> >> I've tried a generic ICMP packet but that doesn't work under Windows
> with
> >> the standard Ruby build and I don't have the tools/time to build it my
> self
> >> under Windows.
> >>
> >> --
> >> "Hey brother Christian with your high and mighty errand, Your actions
> speak
> >> so loud, I can't hear a word you're saying."
> >>
> >> -Greg Graffin (Bad Religion)
> >>
> >
> > Here is the full method if anyone wants more context:
> >
> > # Lets find MAC addresses for the machines in the list
> > def find_macs
> > # This technique will only give MAC addresses for the machines on
> > our
> > subnet.
> > # However since those are the only ones we can wake it doesn't
> > really
> > matter.
> > # It is nasty slow and a better way should be found some day.
> >
> > DB[:computers].each do |computer|
> > begin
> > Net::PingExternal.new(computer[:name]).ping
> > rescue SocketError => exception
> > next
> > end
> > end
> >
> > arp_table = `arp -a`.split("\n")[2..-1]
> >
> > arp_table.each do |address|
> > full_name = Socket.gethostbyname(address.split(' ')[0])
> >
> > comp = Computer.find :name => full_name.split('.')[0]
> > comp.mac = address.split(' ')[1].gsub!('-', ':')
> > comp.save
> > end
> > close()
> > end # find_macs
>
>
> NMap is very fast and comes in a WinDoze flavor.
>
> Since you're already mashing up the arp output,
> I assume you will have no qualms about doing the
> same for NMap output.
>
> Not a pure Ruby solution but then NMap is open source
> so if you're really into purity you could transcribe it's
> approach to WinDoze discovery (maybe...possibly...)
>
> But if expedience is the order of the day...
>
> http:/...
>
> You'll need WinPCap as well (the packet capture lib)
>
> http://www.wi...
>
> djief
> --
> Posted via http://www.ruby-....
>
>
Thanks Jeff,

Although it looks like both parsing arp and the External ping are causing me
other problems. With over 900 machines to check the app keeps borking with
too many open files. So it would appear I need to find another way to
acquire MAC addresses.

--
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can't hear a word you're saying."

-Greg Graffin (Bad Religion)

Jim Morrison

3/26/2010 4:13:00 AM

0


"Violent Chicago Obamathug" <Obamathug@WhiteHouse.gov> wrote in message
news:hoh7oi$vkl$1@news.eternal-september.org...
>
>
> "Spartakus" <spartakus@my-deja.com> wrote in message
> news:b33f8ce3-6c7f-4876-8993-2e06572da32d@a4g2000prb.googlegroups.com...
>> "Violent thug" wrote:
>>
>>> http://www.nytimes.com/2010/03/25/business/economy/25soci...
>>>
>>> Social Security to See Payout Exceed Pay-In This Year
>>> By MARY WILLIAMS WALSH
>>> Published: March 24, 2010
>>> . The bursting of the real estate bubble and the ensuing recession
>>
>> started during the Bush administration.
>> ====================
>
> The housing market started crashing as soon as the Democraps took over
> congress and ran everything into the ground.

Bush destroyed housing in 2003. Fact.



--- news://freenews.netfront.net/ - complaints: news@netfront.net ---

Spartakus

4/8/2010 3:20:00 AM

0

"Violent thug" wrote:
> "Spartakus" <sparta...@my-deja.com> wrote...
> > "Violent thug"  wrote:

> >> Social Security to See Payout Exceed Pay-In This Year
> >> By MARY WILLIAMS WALSH
> >> Published: March 24, 2010
> >> . The bursting of the real estate bubble and the ensuing recession

> > started during the Bush administration.

> The housing market started crashing as soon as the Democraps took over
> congress and ran everything into the ground.

OK, thug, that's a fine demonstration of a bullshit response. Here's
your chance to put up or shut up. What specific legislation did
Congress pass and Bush signed that caused the real estate bubble to
burst?

After you fail to find any such legislation, google on "post hoc, ergo
propter hoc" and get back to us.