Script to monitor network


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to monitor network
# 1  
Old 05-05-2014
Question Script to monitor network

Hello Guys,

I am starting with shell scripting and I need some help with my problem... The scenario is, I have like 20 servers inside one company, where I face some network issues affecting my servers functionality (Voice/recorder/IVR systems). So, to evidence the network events, I decided to code one script simple to monitor the ping events.

Here is the code:
-------------------------------------------------------------------------
Code:
#!/bin/bash
ping HOST | while read pong; do echo "$(date): $pong"; done >> out.txt

-------------------------------------------------------------------------

It's simple, but worked fine... the problem is... I need to improve this, I need to print the results with names and archive it (.tar.gz) each 24 hours, and keep it for only 15 days, also ping multiple hosts simmultaneously. The name has to be date.IP.tar.gz.
Another important point is that it does not save the timout intervals, so I will just have an interval with no data... and I need to evidence that.

Any help ?

Last edited by Don Cragun; 05-05-2014 at 11:25 PM..
# 2  
Old 05-06-2014
So do you mean that you want you output file to have a date in it, e.g. for today you want the file to be out_2014_05_06.txt so you can then (at the end of each month) collect up all of out_2014_05-*.txt and create an out_2014_05.tar.gz ?

Is that it? Forgetting the ping/pong bit and this is all about log file management. Is that correct?

If so:-
  • What have you tried so far?
  • What errors/output/problems are you getting?
  • What OS and version are you using?
  • What tools are you most comfortable with?
Most importantly, what have you tried so far?

Going back to the ping/pong one line of code, how would you expect this to end? on unix, the ping usually continues until interrupted, not like on DOS/Windoze.

You will need to check that manual pages for ping to check the flags to set a limit. It may be -n, -c or something else on your OS. You may have heard that unix is all the same, but at out level, they're all different.




Regards,
Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. IP Networking

I would like to monitor network traffic for a computer on my network

My son does homework on a school laptop. I was thinking about setting up a gateway on my home network, so that I can monitor web traffic and know if he is doing his homework without standing over his shoulder. Ideally I would like to use the Raspberry Pi Model b that I already have. However, I... (15 Replies)
Discussion started by: gandolf989
15 Replies

2. Shell Programming and Scripting

Monitor some of network services

Hi I want to write a script for netflow service because my service doesnt send any packet to netflow walker (server). Although the service is started but it does not send any packet to server until i restart the service I want to write a script in order to restart the service... (7 Replies)
Discussion started by: mohsen1366
7 Replies

3. Windows & DOS: Issues & Discussions

Network monitor script

Hi, Although I'm not at my nature habitat, I need some assistance in having a basic windows script to monitor TCP connections from a host to other hosts. script heed to display the following: 1. ping a remote host/hosts every 1 second (or other adjustable timer) 2. Display a fail/success. 3.... (2 Replies)
Discussion started by: assafde
2 Replies

4. Red Hat

How to monitor network device traffic using MRTG?

How to monitor network device traffic using MRTG? How can I add network devices in MRTG configuration to monitor? (2 Replies)
Discussion started by: manalisharmabe
2 Replies

5. UNIX for Advanced & Expert Users

Monitor % utilization of the network card

Hello, How to we typically monitor the % of utilization of network cards on a Unix box,basically the % utilization of the bytes transfered of the network card. This is required on all the flavours of OS - HP, AIX, RHEL, Sun etc. Please let me know. Thanks. (1 Reply)
Discussion started by: devtakh
1 Replies

6. Programming

Help in developing a Network Appliation to monitor pc in a network

I am developing a Network Appliation to monitor computers in a network. Specs are App monitors the current web page viewed in each system App also can shutdown the computer in the network App can show all process run by each computer in the network I am now confused how to start my... (2 Replies)
Discussion started by: valaparambil88
2 Replies
Login or Register to Ask a Question