Enterprise Linux Log - A SearchEnterpriseLinux.com blog

Enterprise Linux Log:

 

A SearchEnterpriseLinux.com blog


A blog for Linux administrators covering Red Hat, SUSE, Ubuntu, Linux in data centers, Oracle Linux, Linux vs. Windows, Linux vs. Unix, interoperability, migration, the Linux kernel and more.

More Linux commands for your scripting pleasure

One of our users, James Lowden, emailed us to say that our recent 77 useful Linux commands and utilities guide missed a couple of his favorites:

I’m a NetBSD guy, but I have RHEL at work.

As for commands, I like:

  1. pax better than tar

  2. hexdump better than od

  3. tnfpt better than wget

Pax has a much better command-line interface than tar, especially for copying trees. Consider:

$ pax -rw -pe src dest # to copy a tree

$ pax -wzf file.pax.gz src # to create and archive

hexdump -C is what you almost always want.

Tnftp (a port of the NetBSD FTP client to other systems) is a much saner way to fetch stuff. Why the GNU world focuses on wget instead is a mystery to me. It doesn’t do anything tnftp doesn’t do, and it doesn’t do anything better, either.

If you would like to share your opinions of our essential Linux command guide, feel free to drop us line and share some of your favorite commands with the Enterprise Linux Log.

Enterprise streaming media? Sure, and on virtual Linux systems!

Many IT shops have strict policies prohibiting the storage of multimedia content on shared systems. Issues over copyrighted content and inappropriate material pose many problems. However, more business products offer various content in audio or video media. These can be training videos, quality assurance audio recordings, company commercials for employee viewing, bandwidth abuse or even music for lobby purposes.  Several options for a streaming multimedia server are available in Enterprise Linux environments.

Streaming multimedia storage

Some of these options include icecast, gnump3d, jinzora and shoutcast. I had an opportunity to configure GNUMP3d on my CentOS linux system and found it quite a good solution. For GNUP3d, the install was obtaining a tar file and a simple extraction, then running the following command:

make install

The GNUMP3d server configuration file is located at /gnump3d-3.0/etc/gnump3d.conf in the path where you extracted your tar file. Reading through this file is fairly intuitive and you can point your media path, some basic performance options, host server configuration, and security settings. Once it is saved and index operation is performed and the service started as /gnump3d-3.0/bin/gnump3d2 to start the service. From there, a website is up and running with your indexed media.

Some further customization of the interface to brand it to your Intranet would be a good idea as it is fairly basic and looks like free software. The various packages offer different levels of functionality and levels of the look and feel. GNUMP3d gets a star because it can be configured and running in a matter of five minutes.

Client streaming strategy

Virtual Linux environments can host these systems, especially if there is any concern about the bandwidth required if rolling this solution into existing Linux systems. Some bandwidth throttling and front-side firewalling may also be a good idea to ensure the intended audiences — even internally — are able to access this content for all configurations. For example, if you have many remote sites on limited bandwidth, the streaming media would not be appropriate.

Linux PC sells out at Wal-Mart

Linux PC

On October 31, Wired Blogs wrote about Wal-Mart’s $200 Linux-based PC. Today, about a month and a half later, the Linux PC (sans monitor) has sold all 10,000 units. The customer reviews are glowing, to say the least. “It’s $200, with no gimmicks or subsidies,” Everex spokesman David Liu said.

Score one for the good guys. That is, score one if you treat operating system sales like you treat religious wars.

UPDATE REMINDER: Product of the Year nominations are going on now!

2007 Product of the Year AwardsWorking with vendors is tough. You need their help, they want your money. Hopefully, whatever it is they help you install works and the price meets you both somewhere in the middle (as in your side of the middle, right?).

Sometimes this process is a headache, but sometimes a project can really surprise you—things just work and upper management is just peachy keen with how the whole thing looks on the balance sheet.

In that vein, SearchEnterpriseLinux.com wants to help its readers discover the best of the best in Linux products for the enterprise in our prestigious SearchEnterpriseLinux.com 2007 Products of the Year awards. We’ve been asking readers and vendors over at SearchEnterpriseLinux.com to nominate a favorite product they’ve used or to nominate their own new product, and now we’ve opened it up to the Intertubes here at the Enterprise Linux Log. Regardless of where you fall — vendor, user or general Linux guru –the deadline is drawing near!

Our editorial team and a select panel of industry experts and analysts are currently accepting submissions online until 5 p.m. PST on Nov. 9, 2007 in a range of categories, including: Server Linux platform product (either a distribution release or a new, integrated server Linux offering); Security applications/tools for Linux on the server; Virtualization product for Linux on the server; and Linux administration tools. You can access the 2007 POY submission page in the link above.

To qualify, new or significantly upgraded products must have been shipped after October 31, 2006, and before November 1, 2007. Submit your entry today and let us know what you think are the top data center products on the market!

IBM presents the anatomy of a Linux file system

IBM’s DeveloperWorks site has an up-to-date, concise explainer about the Linux file system up today that’s worth a quick read, for refresher’s sake.

When it comes to file systems, Linux is the Swiss Army knife of operating systems. Linux supports a large number of file systems, from journaling to clustering to cryptographic. Linux is a wonderful platform for using standard and more exotic file systems and also for developing file systems. This article explores the virtual file system (VFS)—sometimes called the virtual filesystem switch—in the Linux kernel and then reviews some of the major structures that tie file systems together.

It covers all the basics (and I mean BASICS; example of a header found within: What is a file system?), and then goes into the technical stuff after that. Like I said, worth a quick read when you get the chance!

Script tracks Perl modules for you

Michael Hurley shares a script that he wrote called modlister. I’ll let him explain:

It’s a script to tell you what Perl modules you have installed and where, to query whether you have a particular module installed, to see associated files, etc. For example:

    1. List all installed modules:
  1. modlister.pl

  2. Only show filenames (strip directories):
  3. modlister.pl -f

  4. See if Compress::Zlib is installed:
  5. modlister.pl -m Zlib

  6. See all the files associated with Zlib:
  7. modlister.pl -m Zlib -a

Thanks for the script, Michael.

Try this one out yourself. Tell us what you think or submit one of your own. If we use your script, you will receive a gift a Starbucks gift certificate. More scripting goodness after the jump… Read more »

Top Linux applications, anyone?

Is your IT shop desperate to get off the Windows IV and into the free-wheelin’, foot loose and fancy free world of open source applications? No? Are you sure you’re on the right blog?

I only ask because I got an email today from reader Rich I. that contained a link to the top 50 applications to get your office on open source and I thought it was pretty interesting. A lot of the stuff I had heard of before, but it was nice to see all those apps compiled into a handy dandy list. Even I, in my infinite Linux wisdom*, found a new one here and there. Zabbix anyone?

I’d like to see more though. Throughout 2007 I’ve made it a point to ask which applications people are running on their Linux servers, and why. We’ve covered Samba and Apache a lot already, so anything and everything else is fair game. What works? What doesn’t? Let me know in the comments or at my email address.

* This is exaggerated because I work on the Internet.

Handy script protects Linux against traffic spikes

We received another user-submitted Linux script for our “Share scripts… win Starbucks” series. This one comes from David Witham, who writes:

I administer a consumer VoIP switch for a VSP. The switch acts as a SIP registrar and proxy. Many thousands of devices register and re-register with the registrar every few minutes so there’s a pretty constant stream of traffic hitting it. Some SIP devices have flakey firmware and misbehave in such a way that they flood the registrar with registration requests to the point that performance is compromised, so I needed a way to protect the registrar from those devices.

I wrote a script that takes a sample of network traffic using Ethereal, checks for IP addresses transmitting excessive packets and blocks them by adding them to a list of addresses to drop in the INPUT chain of iptables.

David suggests running the script every 15 minutes to allow new IP addresses to be added to the list, then flushing the addresses and re-adding them so IP addresses that have stopped flooding can re-register.

Give it a try. This script was optimized for RHEL4 but should run on other Linux and Unix systems that have Ethereal or iptables. Feel free to modify it any way you like, or maybe you have one of your own to share? Share a script with us and, if we use it, we’ll treat you to Starbucks.

Keep the scripts coming!

#!/bin/bash
#
# Run from cron on a frequent basis, including on the hour, to block IP addresses flooding with SIP requests
# Use -f to force a flush of the INPUT chain
#
# First 3 octets of destination IP address of the flooding packets

BASE=xxx.xxx.xxx

# Whole destination IP address of the flooding packets

HOSTIP=xxx.xxx.xxx.xxx

# Interface on which the flooding is occurring

INTERFACE=eth3

# Flush iptables INPUT filter chain each hour in case some IPs have stopped flooding and are genuinely trying to use the service
if [ $(date +%M) = “00″ -o “$1″ = “-f” ]; then
        /sbin/iptables -F INPUT
        # Wait 5 seconds for IPs to start flooding again (most flooding IPs send REGISTER every 4 seconds if not getting a response)
        sleep 5
        # Add IP address to drop to iptables INPUT filter chain. Repeat a couple of times to catch all IPs
        /usr/sbin/tethereal -i $INTERFACE-a duration:10 2>/dev/null | awk ‘{print $2;print $4}’ | grep -v $BASE | sort | uniq -c | sort -rn | awk ‘$1 > 30 {print $2}’ | while read ip; do /sbin/iptables -A INPUT -s $ip -d $HOSTIP -j DROP ; done
        sleep 5
        /usr/sbin/tethereal -i $INTERFACE-a duration:10 2>/dev/null | awk ‘{print $2;print $4}’ | grep -v $BASE | sort | uniq -c | sort -rn | awk ‘$1 > 30 {print $2}’ | while read ip; do /sbin/iptables -A INPUT -s $ip -d $HOSTIP -j DROP ; done
        sleep 5
        /usr/sbin/tethereal -i $INTERFACE-a duration:10 2>/dev/null | awk ‘{print $2;print $4}’ | grep -v $BASE | sort | uniq -c | sort -rn | awk ‘$1 > 30 {print $2}’ | while read ip; do /sbin/iptables -A INPUT -s $ip -d $HOSTIP -j DROP ; done
else
        # Add more IP addresses to drop to iptables INPUT filter chain
        /usr/sbin/tethereal -i $INTERFACE-a duration:10 2>/dev/null | awk ‘{print $2;print $4}’ | grep -v $BASE | sort | uniq -c | sort -rn | awk ‘$1 > 30 {print $2}’ | while read ip; do /sbin/iptables -A INPUT -s $ip -d $HOSTIP -j DROP ; done

fi 

Call for Entries - SearchEnterpriseLinux.com Products of the Year Awards

SearchEnterpriseLinux.com wants to help our readers discover the best of the best in Linux products for the enterprise in our 2007 Products of the Year awards. Nominate a favorite product youve used, or nominate your companys new product. Our editorial teams will be accepting submissions online until 5 pm PST on Nov. 9, 2007 in a wide range of categories, including: Server Linux platform product (either a distribution release or a new, integrated server Linux offering) Security applications/tools for Linux on the server, Virtualization product for Linux on the server and Linux administration tool.

To qualify, new or significantly upgraded products must have been shipped after October 31, 2006, and before November 1, 2007. Submit your entry today and let us know what you think are the top data center products on the market.

Does this script work for you?

Recently, we asked our readers to share some of their Linux scripts with us. Our first script comes to us from Diethard Ohrt, who sent us a script named “survf”. He writes:

The script “survf” monitors a file so you can check whether this file is growing (e.g. during ftp transfer). If you link it to the name “survp,” it monitors a running process… when the process terminates it sounds a bell and terminates.

Take a look at survf and give it a try. Diethard adds that he originally wrote it for the Korn shell on a Unix box a few years ago (so you might want to tweak it with “proper, real bash syntax.”)

Thank you, Diethard! To show our appreciation, we are sending you a gift certificate for some Starbucks coffee. Enjoy.

Let us know what you think of the script or send us one of your own. If we use it, you can earn yourself a Starbucks gift certificate plus you’ll be helping out other users.

If you would like some more scripts, check out our tips section. Whether it is help with Linux migrations or managing high-volume CPU processes, our SearchEnterpriseLinux experts help you navigate through the Linux world.

Hope you like the script. Keep them coming.


!/bin/bash

survp/f: primitive process/file surveillance
==================================================
monitors a given process using ps(1)
process may be given by PID or name
if called as "survf", a given file is monitored
("CUP" means "cursor up" ...)
__________________________________________________

PROGNAME=`basename $0`

trap echo -e "\n$PROGNAME: terminated." exit 0 2 15

is_int=0

How have we been called? _________________________
if [ $PROGNAME = survp ]
then
OBJECT=process
CMD="ps -U $LOGNAME | grep $1"
if (( $ != 1 ))
then
echo "usage: $PROGNAME { pid | process_name }"
exit 1
fi
Check: is parameter a number, thus PID?
export item2test=$1
bash -u -c typeset -i NUM=$item2test > /dev/null 2>&1
(( $? == 0 )) && is_int=1
else
invoked as "survf" _____________________________
OBJECT=file
CMD="ls -l $1"
if (( $ != 1 ))
then
echo "usage: $PROGNAME { file_name }"
exit 1
fi
fi

typeset -i STATE=0

echo $PROGNAME: surveillance of $OBJECT $1
echo " (use ^C to terminate)"
CUP=`tput cuu1``tput cuu1`
while [ true ]
do
if [ $OBJECT = process ]
then
if (( $is_int == 0 ))
then
ps -u $LOGNAME | grep $1
STATE=$?
else
ps -fp $item2test
STATE=$?
echo $CUP
fi
else
$CMD
STATE=$?
fi
if (( $STATE != 0 ))
then
echo -e "07\n$PROGNAME: *** ERROR *** $OBJECT $1 not found!"
exit 1
fi
echo $CUP
sleep 10
done