On 2002-08-11 13:19:13 -0800, Mark Weisman wrote:
> Hello List:
>   What is the command structure to grab an uptime request from a remote
> computer? I have several systems in my organization that I would like to
> grab the uptime for, then post them to a dynamic web page. The web page
> I've already got done, I just need the command structure for grabbing
> the uptime. Help in grabbing uptime from a Win32 box would be helpful as
> well. I'm trying to grab data from a group of FreeBSD boxes, and a
> singular Win2K box. Any suggestions?

I can't help you with Win2K, but the FreeBSD boxen are easy. I tried this
thing:

==== script begin ====
#!/usr/bin/perl -w

use strict;

my %machines = (
    firewall => 'admin',
    samba => 'operator',
    web => 'bofh',
);

foreach my $host (sort keys %machines) {
    print $host . ':' . `ssh -l $machines{$host} $host "uptime"`;
}   
==== script end ====

Example Output:
firewall: 3:47AM  up 18 days, 10:44, 0 users, load averages: 0.00, 0.00, 0.00
samba: 2:46AM  up 38 days,  2:05, 6 users, load averages: 0.20, 0.17, 0.17
web: 3:47AM  up 1 day,  9:14, 2 users, load averages: 0.14, 0.15, 0.17

Names changed to protect the guilty, but it's tested, and it Works For
Me[TM].

Caveat:
You need to have your ssh setup to use public key auth, and have a
ssh-agent(1) running on the machine your running the script on. This is
a minor thing, as you should have this already. :)

Possible solution for a Win2K box:
Install Cygwin on it, and run an sshd on it, then it'll look just like
the BSD machines scripting wise. I haven't tried this as I have no
Microsoft OS'en with me ATM.

Have a nice day
                                 Morten

-- 
Morten Liebach <[EMAIL PROTECTED]>, http://m.mongers.org/
PGP-key: http://m.mongers.org/m_gpg.asc

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to