≡ Menu


Poll: Your Favorite Scripting Language?

Like most sys admin, I'm lazy. I try to automate almost all things in order to save time. Inexperienced sys admin and help desk staff working under me finds all these tools useful. It saves their time and avoids security issues. Automation allows help desk staff to do things that they don't have enough direct system knowledge to do themselves. However, selecting correct tool and applying correct methodology is very important.
[click to continue…]

Lighttpd Install and Configure AwStats Software Log Analyzer

AWStats is a free powerful tool that generates advanced web, streaming, ftp or mail server statistics, graphically. This log analyzer works as a CGI or from command line and shows you all possible information your log contains, in few graphical web pages. It uses a partial information file to be able to process large log files, often and quickly. It can analyze log files from all major server tools like Apache log files (NCSA combined/XLF/ELF log format or common/CLF log format), WebStar, IIS (W3C log format) and a lot of other web, proxy, wap, streaming servers, mail servers and some ftp servers.

You can easily configure awstats under Lighttpd web server.
[click to continue…]

Linux / UNIX RT Project Management Ticketing System Tutorial

Internally we use RT (enterprise-grade ticketing system) for customer support and it is one of the best GPL software around. It enables a group of people to intelligently and efficiently manage tasks, issues, and requests submitted by a community of users. RT manages key tasks such as the identification, prioritization, assignment, resolution and notification required by enterprise-critical applications including project management, help desk, NOC ticketing, CRM and software development.

Linux magazine has published a nice article about RT installation and configuration:

Managing bugs and help requests isn't easy, but it's crucial for effective project management. Using the wrong tool can set your project back to the dark ages, but the right tool can help your team excel. With that in mind, let's look at Request Tracker, an enterprise-grade (and free software) ticketing system written in Perl.

A ticketing system is a piece of software in which every bug, request, or problem is entered as a 'ticket,' which can then be tracked. It can be allocated to someone to fix, given a priority, placed in a queue (to separate out different types of bug or request), commented on, replied to, and finally closed when resolved. The system can also send progress updates and reminders to the initial requester and to other people involved with the ticket. RT handles all of these functions and more.

=> Looking After Your Bugs with Request Tracker

Display IP Address Allocation Table According to Subnet Mask

If you need a tabular representation of relationships and source of the various variables representing a chunk from /32 to /0 subnets use iptab command. This is useful if you are allocating IPs to end users. Following information is displayed with the command:
=> CIDR notation

=> Network Mask

=> Available Networks

=> Available Hosts per network

=> Total usable hosts

$ iptab
Sample output:

| addrs   bits   pref   class  mask            |
|     1      0    /32 |
|     2      1    /31 |
|     4      2    /30 |
|     8      3    /29 |
|    16      4    /28 |
|    32      5    /27 |
|    64      6    /26 |
|   128      7    /25 |
|   256      8    /24      1C   |
|   512      9    /23      2C   |
|    1K     10    /22      4C   |
|    2K     11    /21      8C   |
|    4K     12    /20     16C   |
|    8K     13    /19     32C   |
|   16K     14    /18     64C   |
|   32K     15    /17    128C   |
|   64K     16    /16      1B     |
|  128K     17    /15      2B     |
|  256K     18    /14      4B     |
|  512K     19    /13      8B     |
|    1M     20    /12     16B     |
|    2M     21    /11     32B     |
|    4M     22    /10     64B     |
|    8M     23     /9    128B     |
|   16M     24     /8      1A       |
|   32M     25     /7      2A       |
|   64M     26     /6      4A       |
|  128M     27     /5      8A       |
|  256M     28     /4     16A       |
|  512M     29     /3     32A       |
| 1024M     30     /2     64A       |
| 2048M     31     /1    128A       |
| 4096M     32     /0    256A         |

iptab is nothing but a perl script and part of perl-Net-IP package. Here is script listing (download link):

eval 'exec /usr/bin/perl  -S $0 ${1+"$@"}'
    if 0; # not running under some shell
use Net::IP;
use strict;
print "+----------------------------------------------+
| addrs   bits   pref   class  mask            |
my ($ip,$size,$class,$bits,$len);
my $ip = new Net::IP('0');
for my $len (reverse (0..32))
        $size = $ip->size();
        if ($size >=1048576) # 1024*1024
                $size /= 1048576;
                $size .= 'M';
        elsif ($size >= 1024)
                $size /= 1024;
                $size .= 'K';
        $len = $ip->prefixlen();
        $bits = 32 - $len;
        if ($bits >= 24)
                $class = 2**($bits-24);
                $class.= 'A';
        elsif ($bits >= 16)
                $class = 2**($bits-16);
                $class.= 'B';
        elsif ($bits >= 8)
                $class = 2**($bits-8);
                $class.= 'C';
        printf ("| %5s %6s %6s %7s  %-15s |\n",
print "+----------------------------------------------+\n";

Shell Script: Create Linux Bootable USB Sticks

This may come handy, from the project page:

Mk-boot-usb is a perl script to create multiple-bootable usb sticks (usb keys / usb flash drives). It wipes out an entire usb stick, partitions it, creates file systems on it, installs grub, and installs a minimal linux on it. Mk-boot-usb is meant to speed up and lower the barrier of entry for creating bootable usb sticks. The usb stick will immediately become bootable (using the minimal linux), and more useful distributions can then be installed into other partitions manually simply by (1) copying any Live CD into each partition (2) modifying grub's configuration file.

=> Mk-boot-usb: a Script to Create Multiple-Bootable USB Sticks

Related: How to Create Bootable Linux CD

Happy 20th Birthday Perl!

Perl is a dynamic programming language created by Larry Wall and first released in 1987. Perl is used in many sys admin and web related projects. Perl 1 was released to the public by Larry Wall 20 years ago today. Perl 5.10 isn’t just a bug fix version: it’s full of new features that I’m eager to use: named captures in regular expressions, state variables for subroutines, the defined-or operator, a switch statement (called given-when, though), a faster regex engine, and more. You can read more here and here.

Quick tip: Perl One Liners

Practical Extraction and Report Language is hackers and sys admin's # 1 choice language :)

This site offers examples - perl one liners for command line use, a summary of important perl command line arguments, and how to convert between 1-liners and full Perl scripts. This page assumes the reader has a reasonable amount of Perl experience.

Perl One Liners