Monday, February 24, 2025

Leveraging WSL (or Linux), and fping to ping multiple hosts

 

Have a pending cutover or maintenance window and need a quick and easy way to monitor assets?

The "correct" answer should be to leverage your monitoring software*, but if your like me and you want to save on some screen real estate and know a bit sooner SHTF than it takes for an app to update a GUI or a page in your browser, you can use a combo of linux (or WSL) and fping to track the status of a handfull of hosts

You'll need to make sure you have fping installed. Its easy enough, just use whatever package manager you use to apt-get or yum or whatever to install fping 

Second step is to create a text file containing the hosts you would like to ping. Both IP addresses and hostnames are valid options. Each host should be on its own line like the example below. My example is a file named testhosts.txt


 

 Now the actual command were going to use looks like

watch -n 0.5 fping --stats --file testhosts.txt

Quick break down, This is the combo of a few basic linux commands. Watch is bog standard linux. Here I've combined it with fping's ability to print a summary status and ping hosts from a file. You can use the -l (--loop) flag with fping to loop through hosts in a text file, but the output will be atleast what is in my opinion a bit messy. But by using watch and just the stats flag I have a smaller footprint that will update in 0.5 seconds. 

I'm confident that this:


Is much neater than this constantly filling a terminal

It would be way to easy to miss a change in status. 

Next Steps and Future Improvements

Now that I've used this in production a few times, I have some improvements I'd like to tackle eventually.

To stop the pings, you need to Ctrl+C out of the loop, but in doing so you also loose all the summary data. It would be nice to retain this info 

Another nice feature would be color coding.  Maybe Red when a host is unreachable. Just may increase the likely hood a down host will catch you eye. 


*for gods sake, if you don't have a monitoring platform get one!


Using Powershell to prep for a DHCP cutover

 Alright, here is the background.  Recently I was working on migrating a few locations off of bog standard Microsoft Windows DHCP server to ...