Finding system uptime without login

Hi,
Am writing a script where I want to find uptime of certain servers. Is there any command where we can find uptime without login to the server, since the server list is big logging to the server will time consuming.

Thanks in advance

Using ssh keys and ssh "$host" uptime

Note that with ssh, technically you will be login in to the remote server.

Should you want to explore a different way (not that I would recommend it though ...) there is the old school ruptime commands that requires in.rwhod to be launched on every server..

ssh -q <host> /usr/bin/uptime

Another solution is...

root@server1 # inetadm -d /network/finger
root@server1 # inetadm -m /network/finger exec="/usr/bin/uptime"
root@server1 # inetadm -e /network/finger

Then you can ask the server1 from other server like this:

root@server2 # finger @server1

Of course now normal finger will not work.
I'm not sure is there any security issue with that solution. But if your network is secure, then it works fine.

Above example is for Solaris10.
On Solaris 9 you can just edit /etc/inetd.conf.
On Solaris 11 I cat't find finger :confused:

You can use nmap for such action.
It will guess the uptime using TCP, but on most hosts i've scaned it's correct.

For instance :

nmap -O host

create a script: call it something like solaris_10_command:

#!/bin/bash
for i in \
 sun19 sun20 sun21 sun12 sun17 sun11 sun18 sun31 sun38 sun41 sun42 \
 sun48 sun49 sun51 sun58 sun61 sun68 sun410 sun25 sun26 sun27 sun28 sun29
do
echo $i
ssh $i $1
echo ""
done

Then create another script calling this one:

#!/bin/bash
/root/solaris_10_command "uptime" >> uptime.txt
uuencode uptime.txt uptime.txt|mailx -s "uptime report" user@email.com

The Unix command for remote uptime:

rup myserver

Where myserver must have the rstat service enabled.

inetadm | grep rstat

Solaris 9:

cat /etc/inetd.conf

rstatd/...

<serverlist xargs rup