Track availability of computers

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Track availability of computers
# 1  
Old 05-27-2010
Track availability of computers

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
I must write a program that records the availability of computers. For the argument i have to give him a file containing a list of computers, the program should check every five minutes if they are available. If a computer is not reachable, then the program should write into the file the name of computer and the time when it was't available.

Example usage:

$ Check list_of_computers.txt

The print in the file:

io.something.si not reachable at 15:31
io.something.si not reachable at 15:36
io.something.si not available at the 15:41
verbena.something.si not reachable at 15:41


2. Relevant commands, code, scripts, algorithms:
?


3. The attempts at a solution (include all code and scripts):
The command "ping" is given as a hint

Any ideas?


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
University of Ljubljana, Ljubljana, Slovenia, Janez Novak, ID63709

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Old 05-27-2010
Code:
#!/bin/sh

while true; do
 while read line; do
  ping -c2 $line >/dev/null
   if [ $? != 0 ]; then
   echo $line not reachable at $(date "+%H:%M") >> heartbeat.log
   fi
 done < "$1"
sleep 300
done

# 3  
Old 05-28-2010
Thank for the answer!

i have a question, what does the: -c2 switch do and: >/dev/null ?
the 2 means two packets transmitted right, what if i type 3 ?
how does this: done < "$1" work?
# 4  
Old 05-28-2010
Quote:
Originally Posted by petel1
i have a question, what does the: -c2 switch do
...
the 2 means two packets transmitted right, what if i type 3 ?
-c count
Stop after sending (and receiving) count ECHO_RESPONSE packets.
If this option is not specified, ping will operate until inter-
rupted. If this option is specified in conjunction with ping
sweeps, each sweep will consist of count packets.

If you type 3, then ping will obviously send 3 echo_response packets.
Simply try to manually run this command and you will immediately know what it does.

Quote:
Originally Posted by petel1
and: >/dev/null ?
It simply prevents all that ping output to be shown on the terminal.
Try to remove it, and you will see the difference.

Quote:
Originally Posted by petel1
how does this: done < "$1" work?
Thats the argument you submit with this script, namely the file with computer names/ip's.
When you run this script like ./script computerlist.txt the $1 will become computerlist.txt
This User Gave Thanks to pseudocoder For This Post:
# 5  
Old 05-28-2010
Hey thanks for the answer Smilie !
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Solaris

Rcp between 2 computers

Hi, I need to rcp heavy files between 2 solaris 10/sparc M3000 computers. Currently theses 2 computers are linked via a switch/firewall and the rcp commands take a very long time, I have been told that this is because of the firewall (old one). I asked my client to by a cross ethernet cable and... (2 Replies)
Discussion started by: zionassedo
2 Replies

2. What is on Your Mind?

How Many Computers Do You Have At Home?

Here is an easy one. Count the number of desktops and servers you have running at home, including your home office if you have one. Don't count those that are in storage or you rarely use, count the ones that are powered on most, if not all, of the day (and night). (86 Replies)
Discussion started by: Neo
86 Replies

3. UNIX for Dummies Questions & Answers

Communicating Via Terminals With Other Computers

Hello, I would like to know if it is possible to communicate between two terminals on seperate computers for free - e.g. not using proprietary software or using the built in UNIX terminals on operating systems of the UNIX flavor. Thanks, photray94 (2 Replies)
Discussion started by: photray94
2 Replies

4. UNIX for Advanced & Expert Users

Using other computers for processing

Hello I've wrote a C++ program which does some mathematical calculations, but the problem is that it takes way too long on any computer to finish. Is there anyway to make more than 1 computer do the processing so it can process faster? (5 Replies)
Discussion started by: arya6000
5 Replies

5. UNIX for Dummies Questions & Answers

Possible to track FTP user last login? Last and Finger don't track them.

Like the topic says, does anyone know if it is possible to check to see when an FTP only user has logged in? Because the shell is /bin/false and they are only using FTP to access the system doing a "finger" or "last" it says they have never logged in. Is there a way to see when ftp users log in... (1 Reply)
Discussion started by: LordJezo
1 Replies

6. IP Networking

two computers one internet

i have a computer (sempron 2200+) with Suse 9.3 and another computer with windows 98 (PI 233 Mhz). I'm connect first computer (with Suse) on the Internet through ethernet but second computers in not connect. How can connect second computers on the internet (with 3 network card...two on the first... (8 Replies)
Discussion started by: dragos
8 Replies

7. UNIX for Dummies Questions & Answers

two computers - one modem

I have two mashines with RedHat 8.0......they connected with cross over cabel...I want use both mashines for Internet, but modem has only first computer... Maybe..through gateway ?.... What must i do for it ?...... sorry for my terrible english.... (3 Replies)
Discussion started by: Pennywize
3 Replies
Login or Register to Ask a Question