r/linuxadmin 7d ago

A simple, lightweight Bash script to check server status from a server.txt list using ping."

Hey everyone! 👋

Often, small setups don't need heavy monitoring software like Prometheus or Grafana just to check if multiple servers or IPs are up and running.

So, I built a quick, lightweight Bash automation script that reads a list of servers from a server.txt file and pings them automatically to check their live status.

How it works:

  1. Reads line by line from server.txt.
  2. Validates the entry using regex.
  3. Sends a ping request and prints out whether the server is running or down.

Check out the snippet below! Always looking for feedback or ways to optimize it. 🚀

0 Upvotes

18 comments sorted by

20

u/ikdoeookmaarwat 7d ago

I have no idea why you would share a simple bash script with an image.

7

u/kezow 7d ago

It would be better to use something that checks the health of the services running on the server. 

Ping is only checking that server is on the network but doesn't inform beyond that.

5

u/terAREya 7d ago

I see no snippet 

3

u/Baxmoke 7d ago

LGTM

2

u/Cirked 7d ago

I don't disagree less is more, but you have to manage either a cron to run this, or manually check yourself?

Picking the free tier of uptimerobot, or similar, would surely save a headache here

1

u/emprahsFury 7d ago

what if server.txt is a fifo and we just dump server.txt into server.txt continuously? Would that work (no I won't try it myself).

1

u/UptimeRobot 6d ago

Thanks for mentioning us!

2

u/xonxoff 5d ago

it would be helpful if this did some actual status checking ...

5

u/PipeItToDevNull 7d ago

Jesus, this isn't even vibe coding it is just a straight AI hooked to reddit

5

u/Charles1nCharge83 7d ago

Pure slop... even if its not ai.

2

u/theschizopost 7d ago

You spelled "running" wrong

-2

u/emprahsFury 7d ago

strictly speaking, when you use an adverb to modify a verb you should add -ly as a suffix. So he spelled running wrongly. Like you spelled wrongly wrongly. It's ok- dictionaries aren't prescriptive. You should consider switching to French though, where they are.

1

u/ikdoeookmaarwat 7d ago

> French

Based upon? Time in the screenshot tells you differently.

-1

u/emprahsFury 7d ago edited 7d ago

Let the ai help you figure it out. "Consider switching to French," where their dictionaries are prescriptive. No idea why people insist on commenting that literally cannot understand either what their writing (grandparent comment) or what they're reading (you). And I'm incredibly sorry to tell you that the english localization is on the screenshot. So you don't even need to guess using the clock about where or what language is being used.

1

u/Cyber-tech-432 7d ago

IO often takes time, why not just load file in memory or save in variable and set a timer to reload file every few minutes

1

u/JohnnyricoMC 7d ago
ansible all -m ansible.builtin.ping

1

u/Actual-Neighborhood6 4d ago

fping -f <filename>