1

I have many linux servers which I would like to check uptime but I have to login to every one. Is this possible to check linux server running time without ssh login to it?

PS. My distributions are RHEL 7/8 and OL 8.

7 Answers 7

4

If your servers are in a trusted, secure network, all in one or just a few network segments, installing an old rwhod service and its clients (rwho and ruptime) might also fit the bill. In Debian, those services are still packaged and installable by just installing two packages (rwhod and rwho), so if your distribution has it available and it fits your requirements, it might be the easiest solution.

RHEL 7 (and probably distributions related to it) has both the service and the clients packaged as a single rwho package; RHEL 8 and newer don't seem to include that package any more.

rwhod will send out a broadcast packet once per minute, listing the logged-in users and the current uptime, and listens for other similar broadcasts; the rwho and ruptime commands will take the reports collected by rwhod and output a report of all hosts that have been broadcasting within the last 11 minutes. rwho lists the users logged in each broadcasting host according to the last report received; ruptime lists the uptime of each reporting host.

2
  • My distributions are RHEL 7/8 and OL 8. This seems like a nice solution. Is it also available for these distributions? Commented Nov 17, 2022 at 8:22
  • 1
    You should edit your question to add that information in, since it is important for accurate answers, and these comments will eventually expire. And no, RHEL/OL 8 does not seem to include one, but RHEL 7 has both the server and the clients in a single rwho package. Commented Nov 17, 2022 at 8:31
3

Just create a "xinetd" service, like that:

# cat /etc/xinetd.d/uptime service uptime { port = 10200 disable = no socket_type = stream protocol = tcp log_on_success += USERID log_on_failure += USERID server = /usr/bin/uptime user = root instances = UNLIMITED wait = no log_type = SYSLOG daemon debug } # service xinetd restart # netstat -ant | grep 10200 tcp6 0 0 :::10200 :::* LISTEN # telnet localhost 10200 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 08:59:39 up 23 days, 16:36, 1 user, load average: 0.00, 0.01, 0.05 
3

If you have many servers, and I assume you will not just be interested in uptime, then the correct tool would be to load SNMP on each and have a monitoring station set up for their snmptrap responses. This is what the major players use. All the methods shown do not show missed boots, but SNMP will.

0

I would not fulfill your precept "without ssh login", but maybe it is a possible botched solution.

My idea is to make a script to which you pass the list of IPs that you want to check, so that you automate the process of logging in to each machine and asking for the uptime.

Something like:

#!/bin/bash if [ -z "$1" ]; then echo -e "" else read -a words -d "" < $1 for ip in "${words[@]}" do if ping -c1 $ip &> /dev/null; then ssh $ip -t "echo \$(hostname): \$(uptime)" 2>/dev/null; else echo "No communication with $ip" fi done fi 

Where the file it receives as an argument would be:

192.168.1.1 192.168.2.1 192.168.3.1 192.168.4.1 192.168.5.1 192.168.6.1 192.168.7.1 192.168.8.1 192.168.9.1 192.168.10.1 

The result would be like:

$ ./uptime-script.sh lan pc01-pc: 09:13:33 up 34 days, 1:40, 1 user, load average: 0.10, 0.16, 0.13 pc02-pc: 09:13:35 up 42 days, 2:50, 1 user, load average: 0.09, 0.10, 0.09 pc03-pc: 09:13:38 up 33 days, 23:37, 1 user, load average: 0.32, 0.19, 0.12 pc04-pc: 09:13:42 up 42 days, 2:15, 1 user, load average: 0.09, 0.13, 0.09 pc05-pc: 09:13:45 up 42 days, 2:08, 1 user, load average: 0.32, 0.25, 0.16 No communication with 192.168.6.1 pc07-pc: 09:13:58 up 42 days, 2:28, 1 user, load average: 0.20, 0.20, 0.18 pc08-pc: 09:14:01 up 6 days, 15:11, 1 user, load average: 0.77, 0.26, 0.14 server01-pc: 09:14:03 up 30 days, 3:02, 1 user, load average: 0.02, 0.05, 0.00 server02-pc: 09:14:05 up 30 days, 3:00, 1 user, load average: 0.01, 0.02, 0.00 

It would be a simple way to monitor these computers.

2
  • I'm lost. How do you get the remote "uptime" on your script? Commented Nov 17, 2022 at 11:09
  • @Alberto I think I had a script error and the ssh command itself was missing, oops. It's already edited, as you can see, the connection is made by: ssh $ip -t "echo \$(hostname): \$(uptime)" 2>/dev/null;. Commented Nov 17, 2022 at 11:38
0

Very late to the party, but (assuming that uptime is not the only thing of interest in your vast server fleet's health) I'd suggest using a proper tool for that job.

Consider using Prometheus, scraping all sorts of metrics from your fleet in 5-minute intervals, including metrics like uptime.

Well. To query a machine's uptime you'd go node_time() - node_boot_time() (that's uptime in seconds, feel free to do the maths for different time units), but that's essentially what you're asking.

-1

Also try rup. In debian packages rstatd on the server and rstat-client on the client.

-3

I have rewritten a new implementation of ruptime in a more modern way. It is here https://github.com/alexmyczko/ruptime

It encrypts the traffic, is not limited to a network. Easily adaptable/extensible. And will also work on macOS.

Special: rload shows cpu/mem/gpu usage in %.

Installation is classic. You download the release or master. Run make install as root.

If you have a Debian (or based on it) system, you can use the .deb files.

On macOS the preferred installation is via brew and my tap.

What does it look like?

$ ruptime # FQDN State Uptime Users Load Averages 1' 5' 15' dolphin.ocean.net up 15+05:57 0 users load 0.04 0.08 0.07 fish.ocean.net up 4+21:27 0 users load 0.22 0.25 0.25 tuna.ocean.net up 4+21:27 0 users load 0.20 0.30 0.42 
2
  • 4
    This is not much different from your previously deleted answer. Please describe how to get this tool, how to use it, what the output looks like, etc. in the post. Commented Feb 14, 2024 at 7:07
  • Yes, while telling us about your tool is welcome, if you don't explain how this tool can be used to answer the question, then it isn't a valid answer and will get deleted. Please show how your tool can be used to show uptime without ssh. Commented Feb 15, 2024 at 11:59

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.