Quick Tip: Quickly Rename a Group of Files with BASH

While configuring Nagios checks for my Asterisk box I stumbled upon something interesting I hadn’t noticed before, PBX in a Flash is based on a 32-bit version of CentOS 6. This was a problem as both my Nagios and Puppet infrastructures are designed to monitor and manage 64-bit machines. A simple if/else statement was all that was required to expand my NRPE Puppet manifest to address both 32 and 64-bit architectures, but the Nagios check files themselves proved more of a challenge.
Continue reading “Quick Tip: Quickly Rename a Group of Files with BASH”

Quick Tip: Ping an IP Range From the Command Line

A few weeks ago I was finishing up some year-end infrastructure documentation and realized I had a wayward host on my network. Specifically, I’d lost a wireless access point. I had failed to document the access point’s IP address and wasn’t looking forward to aimlessly pinging hosts on my network and navigating to the hosts that responded in hopes of finding a web interface. While tools like Angry IP Scanner, which allows you to ping a pre-determined IP range and reports hosts that respond, exist for Windows I use OS X and CentOS daily and wanted a UNIX-native solution that would be reusable should I ever lose another host. With that goal in mind, I came up with a quick and dirty bit of shell script that’s nothing more than a simple for loop.
Continue reading “Quick Tip: Ping an IP Range From the Command Line”

Quick Tip: Pass a Command to an SSH Session as an Argument

Today’s Quick Tip isn’t necessarily an easier way of accomplishing a task, it’s simply a time saver I find myself using often. SSH is a fabulous tool for administrating remote systems via a remote shell, but you may not always need a fully interactive environment to accomplish a given task. Let’s take for example restarting a service. In order to restart a service via a traditional SSH session you must connect to the machine, restart the service with either the¬†service command¬†or /etc/init.d/, and disconnect. Using today’s Quick Tip, that entire process can be wrapped up into a single command. First, we’ll look at the basic method of passing the command then show how a service can be restarted in this way.
Continue reading “Quick Tip: Pass a Command to an SSH Session as an Argument”