Simon Scripts

Edit: Still good stuff.

Originally posted January 5, 2016 on AIXchange

For years I’ve been asking you to send me scripts. Sharing your scripting abilities benefits us all. We can use them as is, or as a starting point to create scripts that could help others.

Sometime I find scripts — take these, for instance (herehere and here). Regardless of their origin, I share them when I get permission from their authors. It’s a win-win.

With that in mind, here’s a script that Simon Taylor recently sent me:

Simple script to check/extend dump device. If I wanted to get fancy, I would cron it, read errpt output, and limit the size of dumpdev based on free space in rootvg. But then it wouldn’t be simple.

    #!/usr/bin/ksh
    primary=`sysdumpdev -l | awk ‘/primary/ {print $2}’|cut -d / -f3`
    echo primary is $primary
    ppsz=`lsvg rootvg|awk ‘/SIZE:/ {print $6}’`
    estimated=`sysdumpdev -e|awk ‘{print $NF/1024/1024/’$ppsz’}’`
    let estimated=estimated+1
    real=`lslv $primary|awk ‘/^LPs:/ {print $2}’`
    echo estimated size is $estimated, real is $real
    if [ $real -lt $estimated ] ; then
            let extend=estimated-real
            let extend+=1
            if [ “$1” = extend ] ; then
                    extendlv $primary $extend && echo “extended dump device”        
            else
                    echo ‘call with arg “extend” to extend dump device’
            fi
    fi

I asked Simon if he had other scripts he could share, and he provided several. They’re packaged in this tarball. What follows is from his README file, which is included in the .tar file below.

A collection of (hopefully) useful scripts organized in a couple of directories.

All the scripts that initiate communication with remote hosts assume that they run from an account that has a root ssh key on the remote host.

scripts directory

 menu 

– a simple menu program written in perl in the late 90’s as an antidote         to compiled menu programs with licenses and incomprehensible menu
formats. Documentation in the script and menu file.
Call with a menu name otherwise script looks for
         $(dirname $0)../menus/main.mnu

 qdump

– korn shell script to display the difference in disk blocks between
    the size of the system dump device and the output of “sysdumpdev -e”.
    Call with arg “extend” to extend the dump device to estimated size + 1

menus directory
main.mnu – a sample menu for the menu script. Will display this readme and run the scripts. Does not require the .mnu suffix.
Try scripts/menu
——————————————————————————–

doc_vio_disks directory

 doc_vio_disks – maps vio server and client disks. Reports on misconfiguration.
 Call with arg vio_server_name.
 Script will find the partner vio server, the managing hmc and the clients.

  Assumptions:
  1. User account running the command has root keys on lpars and vio servers
  2. User account running the command has hscroot keys on managing hmcs
  3. Frame has two vio servers and both serve vscsi disks to clients

 support_scripts – subfolder containing scripts used by doc_vio_disks
   chk.disks – collects disk info : name, lun, storage serial, size, vg
       display_vio_diskmap – displays output
   disp_vdisk – collects and formats client disk data
   knock.pl – general purpose script to test connection to ip/socket pair
   get_vioserver_data – collects and formats selected prtconf type data
   get_device_map – collect hmc device map

 doc_vio_disks consists of all these bits because originally it was meant to
 answer the question “What’s the next free disk on the vio servers?”. It started as a means to parse data collected manually from the vio servers and the hmc.  I normally display output in two windows side by side to make errors/problems show up.

——————————————————————————–

pmksysb
 pmksysb – script to pull a mksysb from a server using ssh and a fifo
 pmksysb_client – pushed to the client to run the mksysb

 Written to avoid the annoyance of trying to manage nfs mounts and distributed cron jobs. Can be controlled from the central server using a simple script and file containing “day of month” “local target directory” “server name”.
 The simple script invokes pmksysb on “day of month”, writes “server name” mksysb data to local “target directory”.

 This is the help displayed if pmksysb is run without arguments:
pmksysb -c client_hostname
        [ -d local_directory (default /export/mksysb) ]
        [ -f local_file (default client.mksysb) ]
        [ -v ] verify the local mksysb output
        [ -o ] overwrite existing local_file
        [ -n ] skip mkszfile on client
        [ -s ] skip mkvgdata on client
        [ -z ] gzip the completed mksysb
        [ -k kill_time (default 1 hour) ]
        [ -m mail_file ] merge mail for transmission to someone

Take a mksysb of a remote client using a named fifo.
Also runs savewpar on wpar clients.
The -k flag is meant to be used to prevent the client task from being
killed within 1 hour (done to prevent orphan processes on slow systems)

Behaviour is further modified by optional environment variables
RUNAS – local user with root ssh key on remote system (default root)
LOCAL_BIN – local location of pmksysb_client (default /usr/local/bin)
MKSYSB_DIR – local directory which will receive mksysbs (default /export/mksysb)

——————————————————————————–

where directory
 where_is – looks for a server in the file written by hierarchy.pl and displays
            where the server is.

 where_is a_server  a_server found on a_frame, hmc is a_hmc, vio is a_vio another_vio

 hierarchy.pl

– collects cec and lpar data from hmcs writes a list containing hmc, cec, lpar info

 Sample crontab entry for hierarchy.pl
# crontab entry – midday, because most systems will be up.
# This is why where_is fools with fuser on the data file in case it is
# still being written

0 12 * * * /some/location/hierarchy.pl/some/location/full_hmc.names

# /some/location/full_hmc.names just contains hmc names, one per line

st7392020@gmail.com
——————————————————————————–“

As always, feel free to send me your scripts and I’ll happily share them.