Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Patch for PingMonitor agent to run on Linux
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
ChrisM.  
View profile  
 More options Oct 23, 4:02 pm
From: "ChrisM." <cm.mc...@gmail.com>
Date: Fri, 23 Oct 2009 13:02:30 -0700 (PDT)
Local: Fri, Oct 23 2009 4:02 pm
Subject: Patch for PingMonitor agent to run on Linux
Hi,

  According to http://peachfuzzer.com/PingMonitor, Linux needs some
changes to work.  Here is a patch to make this change.  I'm not sure
what your commit criteria is, so let me know if I need to do something
different.

Cheers,
Chris M.

Index: Peach/Agent/network.py
===================================================================
--- Peach/Agent/network.py      (revision 1882)
+++ Peach/Agent/network.py      (working copy)
@@ -93,22 +93,42 @@
                '''
                Check if a fault was detected.
                '''
-               pipe = os.popen("ping -n 2 " + self.hostname)
-               buff = pipe.read()
-               pipe.close()
-
-               if re.compile(r"Reply from \d+\.\d+\.\d+\.\d+:
bytes=", re.M).search(buff) != None:
-                       return False
-
-               # If we didn't see a ping, lets try again with 3 pings
just to make sure
-
-               pipe = os.popen("ping -n 3 " + self.hostname)
-               buff = pipe.read()
-               pipe.close()
-
-               if re.compile(r"Reply from \d+\.\d+\.\d+\.\d+:
bytes=", re.M).search(buff) != None:
-                       return False
-
+               if sys.platform == "win32":
+                       pipe = os.popen("ping -n 2 " + self.hostname)
+                       buff = pipe.read()
+                       pipe.close()
+
+                       if re.compile(r"Reply from \d+\.\d+\.\d+\.\d+:
bytes=", re.M).search(buff) != None:
+                               return False
+
+                       # If we didn't see a ping, lets try again with
3 pings just to make sure
+
+                       pipe = os.popen("ping -n 3 " + self.hostname)
+                       buff = pipe.read()
+                       pipe.close()
+
+                       if re.compile(r"Reply from \d+\.\d+\.\d+\.\d+:
bytes=", re.M).search(buff) != None:
+                               return False
+
+               elif sys.platform == "linux2":
+                       pipe = os.popen("ping -c 2 " + self.hostname)
+                       buff = pipe.read()
+                       pipe.close()
+
+                       if re.compile(r"64 bytes from \d+\.\d+\.\d+\.\d
+:", re.M).search(buff) != None:
+                               return False
+
+                       # If we didn't see a ping, lets try again with
3 pings just to make sure
+
+                       pipe = os.popen("ping -c 3 " + self.hostname)
+                       buff = pipe.read()
+                       pipe.close()
+
+                       if re.compile(r"64 bytes from \d+\.\d+\.\d+\.\d
+:", re.M).search(buff) != None:
+                               return False
+               else:
+                       raise RuntimeError("PingMonitor running on
unsupported platform %s" % sys.platform)
+
                return True


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ChrisM.  
View profile  
 More options Oct 23, 4:19 pm
From: "ChrisM." <cm.mc...@gmail.com>
Date: Fri, 23 Oct 2009 13:19:07 -0700 (PDT)
Local: Fri, Oct 23 2009 4:19 pm
Subject: Re: Patch for PingMonitor agent to run on Linux
That's a bit ugly, how about this one instead.

Cheers,
Chris M.

Index: Peach/Agent/network.py
===================================================================
--- Peach/Agent/network.py      (revision 1882)
+++ Peach/Agent/network.py      (working copy)
@@ -93,20 +93,31 @@
                '''
                Check if a fault was detected.
                '''
-               pipe = os.popen("ping -n 2 " + self.hostname)
+               if sys.platform == "win32":
+                       ping_send_command = "ping -n 2 "
+                       ping_send_command3 = "ping -n 3 "
+                       ping_reply_regex = r"Reply from \d+\.\d+\.\d+\.
\d+: bytes="
+               elif sys.platform == "linux2":
+                       ping_send_command = "ping -c 2 "
+                       ping_send_command3 = "ping -c 3 "
+                       ping_reply_regex = r"64 bytes from \d+\.\d+\.\d
+\.\d+:"
+               else:
+                       raise Exception("PingAgent running on
unsupported platform %s" % sys.platform)
+
+               pipe = os.popen(ping_send_command + self.hostname)
                buff = pipe.read()
                pipe.close()

-               if re.compile(r"Reply from \d+\.\d+\.\d+\.\d+:
bytes=", re.M).search(buff) != None:
+               if re.compile(ping_reply_regex, re.M).search(buff) !=
None:
                        return False

                # If we didn't see a ping, lets try again with 3 pings
just to make sure

-               pipe = os.popen("ping -n 3 " + self.hostname)
+               pipe = os.popen(ping_send_command3 + self.hostname)
                buff = pipe.read()
                pipe.close()

-               if re.compile(r"Reply from \d+\.\d+\.\d+\.\d+:
bytes=", re.M).search(buff) != None:
+               if re.compile(ping_reply_regex, re.M).search(buff) !=
None:
                        return False

                return True

On Oct 23, 4:02 pm, "ChrisM." <cm.mc...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Eddington  
View profile  
 More options Oct 27, 2:32 pm
From: Michael Eddington <medding...@gmail.com>
Date: Tue, 27 Oct 2009 11:32:36 -0700
Local: Tues, Oct 27 2009 2:32 pm
Subject: Re: [Peach] Re: Patch for PingMonitor agent to run on Linux
Patched applied.

mike

On 10/23/2009 1:19 PM, ChrisM. wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ChrisM.  
View profile  
 More options Oct 28, 11:14 am
From: "ChrisM." <cm.mc...@gmail.com>
Date: Wed, 28 Oct 2009 08:14:24 -0700 (PDT)
Local: Wed, Oct 28 2009 11:14 am
Subject: Re: Patch for PingMonitor agent to run on Linux
Thanks Mike.

Chris M.

On Oct 27, 2:32 pm, Michael Eddington <medding...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google