Need simple ping monitoring script

  • Follow


Gents,

I'm in a bit of a jam without the proper tools (I have no funds for).

Just need a script (on Sol 9 server) that well telnet to port 5101
(every 2 seconds) on a specific foreign host and write the results to
a log. (Dropping the connection after each telnet attempt).

Should I do this via cron or is there a better way?

Thanks in advance

Ron W.
0
Reply unixzip (36) 5/5/2009 8:36:44 PM

You might want to try a shell script using netcat (the tcp/ip
swiss army knife), or something like that.

I just checked, my copy is 10 years old...

  Netcat 1.10 is an updated release of Netcat, a simple Unix utility 
  which reads and writes data across network connections using TCP or 
  UDP protocol.  It is designed to be a reliable "back-end" tool that 
  can be used directly or easily driven by other programs and scripts.  
  At the same time it is a feature-rich network debugging and exploration 
  tool, since it can create almost any kind of connection you would 
  need and has several interesting built-in capabilities.

-Mike

unixzip@yahoo.com writes:
>Gents,

>I'm in a bit of a jam without the proper tools (I have no funds for).

>Just need a script (on Sol 9 server) that well telnet to port 5101
>(every 2 seconds) on a specific foreign host and write the results to
>a log. (Dropping the connection after each telnet attempt).

>Should I do this via cron or is there a better way?

>Thanks in advance

>Ron W.
0
Reply Mike 5/5/2009 11:49:04 PM


Hello, unixzip@yahoo.com!

 u> (every 2 seconds)
....
 u> Should I do this via cron or is there a better way?

cron granularity is 1 minute.

----
A 


0
Reply Andrew 5/6/2009 2:33:19 AM

unixzip@yahoo.com wrote:
> Just need a script (on Sol 9 server) that well telnet to port 5101
> (every 2 seconds) on a specific foreign host and write the results to
> a log. (Dropping the connection after each telnet attempt).

install "nc" (netcat) if you don't have it.
You should find it on blastwave.org or opencsw.org or sunfreeware.com

#!/bin/sh
while true; do
   nc hostname 5101 < /dev/null >> logfile
   sleep 2
done
0
Reply Oscar 5/6/2009 2:24:50 PM

On May 6, 10:24=A0am, Oscar del Rio <del...@mie.utoronto.ca> wrote:
> unix...@yahoo.com wrote:
> > Just need a script (on Sol 9 server) that well telnet to port 5101
> > (every 2 seconds) on a specific foreign host and write the results to
> > a log. (Dropping the connection after each telnet attempt).
>
> install "nc" (netcat) if you don't have it.
> You should find it on blastwave.org or opencsw.org or sunfreeware.com
>
> #!/bin/sh
> while true; do
> =A0 =A0nc hostname 5101 < /dev/null >> logfile
> =A0 =A0sleep 2
> done

Thanks. When I try to install the netcat package it tells me that "no
acceptable C compiler is found in  $PATH.
0
Reply unixzip 5/7/2009 3:04:35 PM

unixzip@yahoo.com wrote:
> On May 6, 10:24 am, Oscar del Rio <del...@mie.utoronto.ca> wrote:
>> unix...@yahoo.com wrote:
>>> Just need a script (on Sol 9 server) that well telnet to port 5101
>>> (every 2 seconds) on a specific foreign host and write the results to
>>> a log. (Dropping the connection after each telnet attempt).
>> install "nc" (netcat) if you don't have it.
>> You should find it on blastwave.org or opencsw.org or sunfreeware.com
>>
>> #!/bin/sh
>> while true; do
>>    nc hostname 5101 < /dev/null >> logfile
>>    sleep 2
>> done
> 
> Thanks. When I try to install the netcat package it tells me that "no
> acceptable C compiler is found in  $PATH.

Then you probably need to install either Sun Studio or GCC in order to 
build the software!
0
Reply Richard 5/7/2009 4:25:09 PM

unixzip@yahoo.com wrote:
> Thanks. When I try to install the netcat package it tells me that "no
> acceptable C compiler is found in  $PATH.

What file did you grab?  It sounds like you grabbed a source tarball.  That
isn't strictly necessary, as Blastwave, OpenCSW, and Sunfreeware all provide
precompiled versions.

Do you have root on the machine?

-- 
Brandon Hume    - hume -> BOFH.Ca, http://WWW.BOFH.Ca/
0
Reply hume 5/7/2009 5:46:57 PM

On May 6, 10:24=A0am, Oscar del Rio <del...@mie.utoronto.ca> wrote:
> unix...@yahoo.com wrote:
> > Just need a script (on Sol 9 server) that well telnet to port 5101
> > (every 2 seconds) on a specific foreign host and write the results to
> > a log. (Dropping the connection after each telnet attempt).
>
> install "nc" (netcat) if you don't have it.
> You should find it on blastwave.org or opencsw.org or sunfreeware.com
>
> #!/bin/sh
> while true; do
> =A0 =A0nc hostname 5101 < /dev/null >> logfile
> =A0 =A0sleep 2
> done

ok. got the correct nc package. thanks.

The logfile though only contains one entry for first connect on the
port. Shouldn't there be an entry for every 2 seconds of connections.
This is what I need to track bad attempts.
0
Reply unixzip 5/7/2009 9:27:30 PM

unixzip@yahoo.com wrote:
> The logfile though only contains one entry for first connect on the
> port. Shouldn't there be an entry for every 2 seconds of connections.
> This is what I need to track bad attempts.

Are you using '>' instead of '>>'?

If you change '#!/bin/sh' to '#!/bin/sh -x' the shell script will print its
actions before doing them as well, to trace what it's doing.

-- 
Brandon Hume    - hume -> BOFH.Ca, http://WWW.BOFH.Ca/
0
Reply hume 5/8/2009 12:03:49 AM

On May 7, 8:03=A0pm, hume.spamfil...@bofh.ca wrote:
> unix...@yahoo.com wrote:
> > The logfile though only contains one entry for first connect on the
> > port. Shouldn't there be an entry for every 2 seconds of connections.
> > This is what I need to track bad attempts.
>
> Are you using '>' instead of '>>'?
>
> If you change '#!/bin/sh' to '#!/bin/sh-x' the shell script will print it=
s
> actions before doing them as well, to trace what it's doing.
>
> --
> Brandon Hume =A0 =A0- hume -> BOFH.Ca,http://WWW.BOFH.Ca/

What's happening is that after:

 nc hostname 5101 < /dev/null >> logfile

the script just stops and never goes to next line (sleep 2).

I think there needs to be some other command to force a disconnect
from the port it connected to.


0
Reply unixzip 5/8/2009 2:21:47 AM

unixzip@yahoo.com writes:
>I think there needs to be some other command to force a disconnect
>from the port it connected to.

There's command line options (and examples in the README or however the
doc is packaged now...) that you can add to nc and it will do just
what you want...

-Mike
0
Reply Mike 5/8/2009 1:40:10 PM

10 Replies
580 Views

(page loaded in 3.253 seconds)

Similiar Articles:













7/22/2012 6:58:56 AM


Reply: