Specials

The following is a special collection of freeware tools for system administration written in Perl. They cover advanced topics for the experienced admin, and are a valuable addition to a senior admin's collection or those wishing to be a senior admin. Most are related to performance or fault prevention.

Note: These are unsupported freeware programs and have nothing to do with the respective operating system vendors. Use at your own risk.

Operating Systems

Any OS that runs Perl, unless specified at the top of the script. They have been developed on Unix.

Screenshots and Downloads

The following are short demonstrations for each of the programs with links to download the code.

baud Run commands safley at their native baud, eg 2400, 9600. Commands are often run over high speed ssh or telnet sessions, causing Command Fault Heat State Exception (CFHSE) errors due to overbauding. This program helps prevent such faults. Full example here.

brendan:/etc/ftpd> baud -9600 ls -l
total 14
-rw-r--r--   1 root     sys         1249 Jun  4  2002 ftpaccess
-rw-r--r--   1 root     sys          551 Jun  4  2002 ftpconversions   
-rw-r--r--   1 root     sys          104 Jun  4  2002 ftpgroups
-rw-r--r--   1 root     sys          108 Jun  4  2002 ftphosts
-rw-r--r--   1 root     sys          114 Jun  4  2002 ftpservers
-rw-r--r--   1 root     sys          180 Jun 10  2002 ftpusers

ishadm Information Super Highway Administration. This checks and enables network routes to the Information Super Highway to ensure maximum Internet performance. Full example here.

# ishadm -e
add host information-super-highway: gateway 127.0.0.1
Information-Super-Highway is now ON.
#
# netstat -r
 
Routing Table: IPv4
  Destination           Gateway           Flags  Ref   Use   Interface
-------------------- -------------------- ----- ----- ------ ---------
information-super-highway localhost            UH        1      0  lo0   
192.168.1.0          jupiter              U         1    927  rtls0
default              mars                 UG        1      0  rtls0
localhost            localhost            UH        4     91  lo0
#

3rot13 Triple ROT13 - a new heavyweight encryption algorithm. This is a symmetric stateless keyless cypher that outperforms other modern encryption algorithms on speed. Full example. A newer version, nrot13 allows the number of ROT13 cycles to be customised; however due to export regulations cycles greater than 1024 should not be used.

$ 3rot13 -e < /etc/release > release.3rot13
$ 
$ cat release.3rot13 
                           Fbynevf 9 f9_58fujcy3 FCNEP
           Pbclevtug 2002 Fha Zvpebflfgrzf, Vap.  Nyy Evtugf Erfreirq.   
                        Hfr vf fhowrpg gb yvprafr grezf.
                             Nffrzoyrq 15 Ncevy 2002
$

turbo Toggle the turbo button. This is for servers that lack the physical turbo button that is used to double the CPU speed. You may be shocked to find that some of your servers have been running with turbo switched off all this time. Full example here.

# turbo 
TURBO is now on
#
# cat -n /etc/turbo.conf 
     1  #
     2  # turbo.conf
     3  #
     4  # Configuration parameters for turbo.
     5  # Do NOT edit this file by hand -- use turbo(1m) instead.   
     6  #
     7  TURBO=on
#

maybe /usr/bin/maybe. A companion to /usr/bin/true and /usr/bin/false. Full example here.

$ if maybe; then echo yes; fi
$ if maybe; then echo yes; fi   
yes
$

icmpcharger ICMP driver trickle charger. This trickle charges the ICMP driver by sending a series of echo reply packets to localhost at regular intervals. This prevents a common fault where the batteries in the kernel's ICMP driver become depleted, causing high latency or dropped packets. This script serves as a precaution against driver failure.

# icmpcharger &
[1] 21620
# ICMP trickle charger: once per 111 secs...   
# 

xmanagerstat A sophisticated system status tool with blinking lights. This provides a view of the server thinking in real time, a technique that was popular in the days of mainframe computers and is equally useful today.

$ xmanagerstat &

onstat Server on status. This program tells you if your server is switched on. There is also a C version, onstat.c. Full example here.

$ onstat
Server is ON.   

osstat OS version status. This program provides a convenient way to determine if your OS is upgraded, rebooted, reinstalled or BFU'd while you are using it. Full example here.

$ osstat 1
    TIME OS_Ver               u/s r/s i/s b/s
16:51:14 SunOS_5.11           0.0 0.0 0.0 0.0
16:51:15 SunOS_5.11           0.0 0.0 0.0 0.0
16:51:16 SunOS_5.11           0.0 0.0 0.0 0.0
16:51:17 SunOS_5.11           0.0 0.0 0.0 0.0
16:51:18 SunOS_5.11           0.0 0.0 0.0 0.0   
^C
[...]

cdrewind Rewind CDROMs before ejection. This should be performed before every ejection, otherwise discs can remain positioned incorrectly or can leave tracks behind in the drives. Full example here.

$ cdrewind -v /vol/dev/aliases/cdrom0   
CDROM rewound successfully.
  
$ eject cdrom

bnull.c This is a block device version of /dev/null. It has been written to obey the Solaris 10 DDI. Full example.

# find /etc > /dev/null
# find /etc > /dev/bnull
#
# ls -lL /dev/null
crw-rw-rw-   1 root     sys       13,  2 Nov 27 15:00 /dev/null
#
# ls -lL /dev/bnull
brw-rw-rw-   1 root     sys      181,  0 Nov 27 15:00 /dev/bnull   
#

notrandom.c This Solaris 10 device driver provides /dev/notrandom, which provides fast and reliable not random numbers. Full example.

# od -vc /dev/random | head -5
0000000   +   n 253 026   - 020 210   R 321 324   V   Q   ? 033 312   ?
0000020   U 360 020 364   P 267 312 313  \b 204   = 251 262 267 244   @
0000040 223 035 377 362   S   , 332 217 330 201 261 240 031 216   \   2
0000060   A   5 336 326 335 177 304 203   Q   U 357   Y 365 346 327 246
0000100 304 325 026 240 344 035   S   =   r 031 311   6 225 320 302 242
#
# od -vc /dev/notrandom | head -5
0000000 007 007 007 007 007 007 007 007 007 007 007 007 007 007 007 007
0000020 007 007 007 007 007 007 007 007 007 007 007 007 007 007 007 007
0000040 007 007 007 007 007 007 007 007 007 007 007 007 007 007 007 007
0000060 007 007 007 007 007 007 007 007 007 007 007 007 007 007 007 007
0000100 007 007 007 007 007 007 007 007 007 007 007 007 007 007 007 007   
#

wumpus.c This is an mdb loadable module that provides a new dcmd, "::wumpus" that plays the classic game of Hunt the Wumpus. This is based on a clone of the original BASIC game. Full example here.

# mdb
> ::load wumpus
> ::wumpus
INSTRUCTIONS (Y-N)
?N
HUNT THE WUMPUS
 
I SMELL A WUMPUS!
BATS NEARBY!
YOU ARE IN ROOM 17
TUNNELS LEAD TO 7 16 18      
 
SHOOT OR MOVE (S-M)
?

bottom This is the opposite of top, it displays processes that are using the least CPU. It is the companion to the "prstat" command. Full example here.

$ bottom
 
   PID USERNAME  SIZE   RSS STATE  PRI NICE   TIME  CPU PROCESS/NLWP   
   505 brendan  2124K  924K sleep   59    0  00:00 0.0% fbconsol/1
   511 brendan  2552K  832K sleep   59    0  00:00 0.0% speckeys/1
   347 root     1680K  608K sleep   59    0  00:00 0.0% smcboot/1
   208 root     1680K  760K sleep   59    0  00:00 0.0% sac/1
   225 root     1788K  812K sleep   59    0  00:00 0.0% ttymon/1
   462 root     2124K  880K sleep   59    0  00:00 0.0% fbconsol/1
   430 root     2716K 1188K sleep   59    0  00:02 0.0% vold/3
   604 brendan  2508K 1536K sleep   59    0  00:00 0.0% bash/1
   601 brendan  2508K 1448K sleep   59    0  00:00 0.0% bash/1
   108 root     1228K  536K sleep   59    0  00:00 0.0% powerd/2
   488 brendan  1176K  644K sleep   59    0  00:00 0.0% Xsession/1
   582 brendan  7508K 1936K sleep   49    0  00:00 0.0% dtfile/1
 18640 brendan  1160K  848K sleep   59    0  00:00 0.0% more/1
    84 root     2584K  740K sleep   59    0  00:00 0.0% picld/4
   587 brendan  1160K  624K sleep   59    0  00:00 0.0% sdtvolch/1
   560 brendan  2136K  724K sleep   59    0  00:00 0.0% dsdm/1
   598 brendan  2508K 1488K run     58    0  00:01 0.0% bash/1
   200 daemon   2040K  816K sleep   60  -20  00:00 0.0% lockd/2
   460 root     6540K 1560K sleep   59    0  00:00 0.0% snmpd/1
 18857 root      948K  656K sleep   49    0  00:00 0.0% sleep/1
   193 daemon   2276K  800K sleep   59    0  00:00 0.0% rpcbind/1
     7 root       11M 2056K sleep   59    0  00:02 0.0% svc.star/12

psss Process Status with Star Sign, an improved ps version that inserts a field to display the starsign of the process. See the Process Star Sign Chart for starsign characteristics. Full example here.

$ psss 
  UID   PID    STIME  STARSIGN %CPU %MEM COMMAND
    0     0   Apr_06     aries  0.0  0.0 sched
    0     1   Apr_06     aries  0.0  0.1 /etc/init -
    0     2   Apr_06     aries  0.0  0.0 pageout
    0     3   Apr_06     aries  0.2  0.0 fsflush
    0   434   Apr_06     aries  0.0  0.1 /usr/lib/saf/sac -t 300     
[...]

lsss ls with StarSign, an improved ls command that inserts a field to display the starsign of each file. Full example here.

$ lsss /etc/default
total 49
-r-xr-xr-x   1 root           12     gemini Jun  4  2002 cron
-r--r--r--   1 root          204     gemini Jun  4  2002 devfsadm
-r--r--r--   1 root         3388     gemini Jun  4  2002 dhcpagent   
-r--r--r--   1 root           10     gemini Jun  4  2002 fs
-r--r--r--   1 root          719   aquarius Jan 23  2004 inetd
-r--r--r--   1 root          379     gemini Jun  4  2002 inetinit
-r-xr-xr-x   1 root          638     gemini Jun  4  2002 init
-r--r--r--   1 root         1182      virgo Sep 15  2002 kbd
[...]

ged.jar GUI-ed. A Java/Swing GUI front-end for the "ed" line editor. This enhances the classic "ed" editor by wrapping it in an easy to use GUI. The GUI provides tunable options such as sound effects, themes, and has an awe-inspiring monochrome splash screen. This runs on any OS with Java 1.5 and a valid "/usr/bin/ed". src.

Solaris/Linux:

$ ./ged.jar /etc/passwd

OS X:

$ sudo ln -s /bin/ed /usr/bin/ed
$ java -jar ged.jar /etc/passwd

music.xml Background Music Service for Solaris 10's SMF. This plays background computer music in a constant loop, making your server appear more important and high-tech. Full example here.

# svcadm enable music
# svcs music
STATE          STIME    FMRI
online         18:40:59 svc:/site/music:default     
#

typewriter-0.75.tar.gz These are DTrace scripts that make your console keyboard sound like a mechanical keyboard, including the "ping-whoosh" sound when you hit enter. This is helpful if you have no feeling in your hands and you'd like to know when they are hitting keys. Or, if you are raising several kittens in the server room, this can alert you if they jump up on the keyboards.

# ./ultra5.d &
[1] 7660
typewriter.d running for the console keyboard.    
#

gwhiz GWhiz. This will whiz files or commands, making them easier to read so that you do not miss important details. Full example.

$ gwhiz /etc/release
			   SOLARIS 9 S9_58SHWPL3 SPARC!!!
           COPYRIGHT 2002 SUN MICROSYSTEMS, INC.  ALL RIGHTS RESERVED.!!!
			USE IS SUBJECT TO LICENSE TERMS.!!!
                             ASSEMBLED 15 APRIL 2002!!!
 
$ df -k | gwhiz
FILESYSTEM		      KBYTES	USED   AVAIL CAPACITY  MOUNTED ON!!!
/DEV/DSK/C0T0D0S1	246463  101675  142324	42%    /!!!
/DEV/DSK/C0T0D0S3    4628486 2057182 2525020	45%    /USR!!!
/PROC			   0	   0	   0	 0%    /PROC!!!
MNTTAB			   0	   0	   0	 0%    /ETC/MNTTAB!!!
FD			   0	   0	   0	 0%    /DEV/FD!!!
/DEV/DSK/C0T0D0S5	492422  229179  263243	47%    /VAR!!!
SWAP			454088	 120  453968	 1%    /VAR/RUN!!!
SWAP			476424   22456  453968	 5%    /TMP!!!
/DEV/DSK/C0T0D0S7	246463   48333  173484	22%    /DATA!!!
/DEV/DSK/C0T0D0S4    2052750 1304271  727952	65%    /OPT!!!
/DEV/DSK/C0T2D0S1    18530217 3682119 14662796	  21%	 /EXPORT/HOME!!!
  
$ uptime | gwhiz
  8:47PM  UP 286 DAY(S),  6:50,	 3 USERS,  LOAD AVERAGE: 0.00, 0.01, 0.02!!!     
 

If your terminal supports colour, gwhiz can highlight in colour using the "-c" option. Here we also use "-v" for verbose,

$ df -k | gwhiz -cv
FILESYSTEM            KBYTES    USED   AVAIL CAPACITY  MOUNTED ON Wow!!!
/DEV/DSK/C0T0D0S1     246463  101675  142324    42%    / Wow!!!
/DEV/DSK/C0T0D0S3    4628486 2057185 2525017    45%    /USR!!!
/PROC                      0       0       0     0%    /PROC Fairdinkum!!!
MNTTAB                     0       0       0     0%    /ETC/MNTTAB!!!
FD                         0       0       0     0%    /DEV/FD Crikey!!!
/DEV/DSK/C0T0D0S5     492422  229335  263087    47%    /VAR!!!
SWAP                  444472     120  444352     1%    /VAR/RUN!!!
SWAP                  466824   22472  444352     5%    /TMP!!!
/DEV/DSK/C0T0D0S7     246463   48333  173484    22%    /DATA!!!
/DEV/DSK/C0T0D0S4    2052750 1305957  726266    65%    /OPT Cor Blimey!!!
/DEV/DSK/C0T2D0S1    18530217 3685344 14659571    21%    /EXPORT/HOME Gee Whiz!!!   

l33t converts formal and confusing text into easily understandable l33t-speak. In the example below we show an original file, a l33t output, and a l33t output with all (-a) options. Full example.

$ cat /etc/release
                           Solaris 9 s9_58shwpl3 SPARC
           Copyright 2002 Sun Microsystems, Inc.  All Rights Reserved.
                        Use is subject to license terms.
                             Assembled 15 April 2002
 
$ l33t /etc/release
                           S0lari5 9 s9_58ZhWpL3 zpaRc!!!1
           copyrIghT 2002 sun miCr0$y5T3mZ, inc.  a1l riGH75 r3SERV3D.!!!!1
                        use Is 5uBj3c7 To lIC3ns3 7eRms.!!!11!!1ONE!
                             a$$emb1ed 15 APri1 2002!!!!
 
$ l33t -a /etc/release
                           S()lAR1s 9 $9_58ShwPL3 Sp@rC!!!!!! d00d
           cOPyRIgh+ 2002 SuN micROsYsT3mz, 1NC.  aLL R1gHTz Re53|2V3d.!!!!   
                        use I5 $Ubj3C+ TO 1ic3NSE T3rM5.!!!
                             aS5eMB1ed 15 ApRIl 2002!!!!!! w00t!

ltzip Compress text files using a lossy text compression algorithm. Not only is the byte count reduced, but the bytes themselves are smaller bytes - and weigh less when stored on disk. Decompression to the original is not possible, however an ltunzip command exists for lossy decompression. Full example here.

$ ltzip -v release
Read   : release                                       236 bytes
Created: release.ltz                                   122 bytes
Reduced: 48.31%
$
$ cat release
                           Solaris 9 s9_58shwpl3 SPARC
           Copyright 2002 Sun Microsystems, Inc.  All Rights Reserved.   
                        Use is subject to license terms.
                             Assembled 15 April 2002
$ cat release.ltz
solaris9s9_58shwpl3sparc
copyright22sunmicrosystems,inc.allrightsreserved.
useissubjecttolicenseterms.
assembled15april22
$
$ ltunzip release.ltz
$ cat release.ltz.un
solARiS  9 s9  _58      shwpL3  spaR C
Co0P y r ight2  2sunm I c  r OSYstemS  ;i  Nc:ALlr  iGHt  sr  ese  0rved:   
  Us  eisSubJect        T  o lic ensEt  eRms:
        ASsemb  LeD15Ap ri l22

mkzombie.c This program creates one or more zombies and a daemon their leader. It can be used to replenish system zombies, or to feed the init monster. Full example here.

$ ./mkzombie 10
[1]+  Stopped                 ./mkzombie 10
$ ptree $$
402   /usr/dt/bin/dtlogin -daemon
  461   /usr/dt/bin/dtlogin -daemon
    488   /bin/ksh /usr/dt/bin/Xsession
      558   /usr/dt/bin/sdt_shell -c       unset DT;      DISPLAY=:0;       
        561   -bash -c       unset DT;      DISPLAY=:0;        /usr/dt/bin/d 
          574   /usr/dt/bin/dtsession
            584   /usr/dt/bin/dtterm -session dthiaONe
              598   /bin/bash
                15904 ./mkzombie 10
                  15914 <defunct>
                  15913 <defunct>
                  15912 <defunct>
                  15911 <defunct>
                  15910 <defunct>
                  15909 <defunct>
                  15908 <defunct>
                  15907 <defunct>
                  15906 <defunct>
                  15905 <defunct>
                15915 ptree 598

pam_happy_hour.c PAM happy hour module. This creates a happy hour on Solaris during which passwords aren't required, any will do. Full example here.

$ telnet jupiter 
Trying 192.168.1.15...
Connected to jupiter.
Escape character is '^]'.
Jupiter. Authorized users only.
login: fred
Password: 
Welcome to happy hour!
Last login: Sun Mar  6 22:31:51 from localhost
Sun Microsystems Inc.   SunOS 5.10      s10_63  May 2004   
$

crypt_3rot13.c this is a password encryption library for Solaris 9, that allows the system to use the 3ROT13 (Triple-ROT13) algorithm for /etc/shadow passwords. Full example and Makefile here.

# passwd fred
New Password: 
Re-enter new Password: 
passwd: password successfully changed for fred   
# 
# grep fred /etc/shadow
fred:$3rot13$serq123:12856::::::

jecho Java version of echo. This obeys the POSIX 1003.1, 2004 standard. It provides a standard version of echo to run on all systems rather than depending on quirky shell builtins. Full example here.

$ java jecho Hello World     
Hello World

rshutdown rough shutdown, shutdown in roughly 5 minutes or so. This program uses the same countdown timer as many major railway networks throughout the world, including Sydney's CityRail. Full example here.

# rshutdown -N
 
Shutdown started.    Thu Dec  2 18:09:22 EST 2004   
 
The system mars will be shutdown in 5 minutes
The system mars will be shutdown in 4 minutes
The system mars will be shutdown in 3 minutes
The system mars will be shutdown in 2 minutes
The system mars will be shutdown in 1 minute
The system mars will be shutdown in 2 minutes
The system mars will be shutdown in 1 minute
THE SYSTEM mars IS BEING SHUT DOWN NOW ! ! !

allslow This program prevents greedy CPU-bound processes consuming so much CPU, by creating a DTrace program that is even greedier. It slows down every process on the system to about a tenth of their usual speed. Full example here.

# allslow
allslow running...
^C
Wasted CPU time 90%      
#

Linux Kernel Internals This is a diagram showing Linux kernel internals (from my SCaLE12x talk):


Last updated: 02-Feb-2014