How to check if the Linux Box is available

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat How to check if the Linux Box is available
# 1  
Old 06-05-2010
How to check if the Linux Box is available

Hi,
I need to query and find out if anyone is logged into a Linux box or if the Linux Box is free available for login. This information is required to post the availability of the Linux Host for an instrument for another user to start using the instrument.
Is there a command or script to query and obtain this information?

Thanks.
# 2  
Old 06-05-2010
Bug To find who is logged into a system at any given time

I am not sure of what exactly you want as output but am assuming you want to knw who is logged into the system as any given time.
I would suggest the following commands to use. read the man pages for details explanation of what these commands can actually output.

Code:
who
w

# 3  
Old 06-05-2010
Thanks

Thanks, I am aware of who or w. This however requires I login, then find out.
I am looking to find out if a given host is free or being used (logged in) at any given time, without actually logging into the host.
I guess similar to ruser?
# 4  
Old 06-05-2010
You could run a daemon/server on the target machines:
Code:
#!/usr/bin/perl

 # server1.pl - a simple server


 use strict;

 use Socket;


 # use port 7890 as default

 my $port = shift || 7890;

 my $proto = getprotobyname('tcp');


 # create a socket, make it reusable

 socket(SERVER, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";

 setsockopt(SERVER, SOL_SOCKET, SO_REUSEADDR, 1) or die "setsock: $!";


 # grab a port on this machine

 my $paddr = sockaddr_in($port, INADDR_ANY);


 # bind to a port, then listen

 bind(SERVER, $paddr)      or die "bind: $!";

 listen(SERVER, SOMAXCONN) or die "listen: $!";

 print "SERVER started on port $port\n";

 $| = 1;


 # for each connection...

 my $client_addr;

 while ($client_addr = accept(CLIENT, SERVER)) {
    # find out who connected
    my ($client_port, $client_ip) =
                     sockaddr_in($client_addr);
    my $client_ipnum = inet_ntoa($client_ip);
    my $client_host =
             gethostbyaddr($client_ip, AF_INET);
    # tell who connected
    print "got a connection from: $client_host",
          " [$client_ipnum]\n";
    # send them a message, close connection
    my $w = `w`;
    # log the access event
    print CLIENT "$w\n ";
    close CLIENT;

 }

Now when you run telnet targetmachine 7890 you will see the output of the command w.
http://targetmachine:7890 should also work.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. How to Post in the The UNIX and Linux Forums

Copying , renaming the file from windox box and ftp to Linux box

Hello my dear friends, Two file are auto generated from mon - fri at different directories on same windows box.Every day i have to copy the file, rename it (specific name)and ftp it to linux box specified directory. is it possible to automate this process,If yes this has to be done from windows... (1 Reply)
Discussion started by: umesh yadav
1 Replies

2. Red Hat

How to access redhat Linux box graphically from windows box?

Hi I have a linux box and need to access from windows graphically # uname -a Linux pc-l416116 2.6.18-155.el5 #1 SMP Fri Jun 19 17:06:47 EDT 2009 i686 i686 i386 GNU/Linux What components do I need to install on Linux and windows to do that? TIA (6 Replies)
Discussion started by: magnus29
6 Replies

3. UNIX for Dummies Questions & Answers

Mounting Linux box to Linux box

Hi, I've been able to mount my linux box to a windows machine, but I can't seem to mount my linux box to another linux box I have. (I know I could scp, but for other reasons I need to do it this way) Samba is installed. Here is an example where I mount to a Win machine.--> works fine mount... (12 Replies)
Discussion started by: jdilts
12 Replies

4. AIX

How to check the LPAR in a AIX box ?

I have login into a server, and when i launch this command uname -L. I can see there is a LPAR. But is there anymore commands i can use to get more information on the LPAR ? like it is VIO ? wat the IP address ? etc, etc. please help. Thank you. (7 Replies)
Discussion started by: wingcross
7 Replies

5. UNIX for Dummies Questions & Answers

How to check if an application has been installed on a unix/linux box?

hi, guys, now I face a problem. I have developed an application, and when it starts, it shall check if an application has been installed on the running linux/unix. If result is positive, i do something with the application command. just as an example: I want to check if sshd has been... (3 Replies)
Discussion started by: sk1418
3 Replies

6. Linux

How to find remote Linux box login account without login in to that box?

Hi, How to find remote Linux box login account without login in to that box? I don't have login account at my remote Linux box. But I need who are all having login account. How do I findout? Thanks, --Muthu. (3 Replies)
Discussion started by: Muthuselvan
3 Replies

7. Shell Programming and Scripting

PHP required check box

I am new to PHP scripting. I have a page with a checkbox and I'd like to make it required before submiting Here is the code I have for displaying: <tr> <td align="center" colspan="4"><font size="2" color="#990000" face="Arial, Helvetica, sans-serif"> By checking this box you agree... (1 Reply)
Discussion started by: lochraven
1 Replies

8. HP-UX

How to check if DHCP is running on HP-UX box?

Hello all, Can someone help me with a command to check if DHCP is running on HP-UX box? Thanks (2 Replies)
Discussion started by: nuGuy
2 Replies

9. UNIX for Dummies Questions & Answers

How to check if DHCP is running on HP-UX box?

Hello all, Can someone help me with a command to check if DHCP is running on HP-UX box? Thanks (1 Reply)
Discussion started by: nuGuy
1 Replies

10. Shell Programming and Scripting

Script to Reboot a linux box from a windows box

HI All, I need a script to reboot a linux box from a windows box. The script needs to run automatically whenever a sitescope alerts with an error message. Have searched for this in the forums, but could not get something relative. Pls. let me know the various alternatives we have to do... (2 Replies)
Discussion started by: Crazy_murli
2 Replies
Login or Register to Ask a Question