Friday 3 January 2014

SHELL SCRIPT PART 2

------------------------------------------------------------------------------------------------------------------------------------
[ exp ] && ( true) || ( false)
If exp is true then true block is excuted
Id exp is false then false block is executed
----------------------------------------------------------------------------------------------------------------------------------------
To find out file in curren location:
$ touch sai
# [ -f sai ] && echo "found" || echo "notfound"
 Found
$ rm sai
$ [ -f sai ] && echo "found" || echo "notfound"
notfound

1.to find out file is exist in the current location?
$ [ ! –f  <nameof file>] &&[not exist] ||[exist]
Eg:
To check a file called sai in the current location:
[ ! -f sai ] &&  echo "file is not exist"  ||  echo "file exist"    
o/p:file is not exist
-----
bash-3.00$ touch sai
bash-3.00$ [ ! -f sai ] &&  echo "file is not exist"  ||  echo "file exist"
o/p: file exist
---

$ touch sai
$ [ -f sai ] &&( echo "found" ) && (echo "notfount")
found
$[ -f sai ] &&( echo "found" ) && (echo "notfount") || (echo "foll ||")
found
notfount
$rm sai
$ [ -f sai ] &&( echo "found" ) && (echo "notfount") || (echo "foll ||")
foll ||
$[ -f sai ] &&( echo "found" ) && (echo "notfount") || (echo "foll ||")&& (echo "follow &&")
foll ||
follow &&
$[ -f sai ] || echo "found" && echo "not found"
found
not found
$touch sai
$ [ -f sai ] || echo "found" && echo "not found"
not found

q) to create a file if not exist?
$ [ -f sai ] && ( touch sai ) || ( echo " file not exist")
 File not exist

$[ ! -f sai ] && ( touch sai ) || ( echo " filenot exist")
Now it creates file
To check dir:

bash-3.00$ [ -d one ] && echo found || echo not found
found
bash-3.00$ [ ! -d one ] && echo found || echo not found
not found
To create dir if not exist
bash-3.00$ [ -d sai ] && (mkdir sai) || (echo not found)
not found
bash-3.00$ [ ! -d sai ] && (mkdir sai) || (echo not found)
o/P : now it generates
to create multipulte files:
a=true;
i=0;
while $a;
 do
 if [ $i -lt 100 ]
 then touch bad$i
 i=`expr $i + 1`
 else a=false
 fi
 done
------------------------------------------------
To delete unwanted data :
DIR=/usr/one/b adfile;
$find $DIR  -mtime -1 –name “b*1”  -exec  ls –lrth {} \;
Above cmd will list all files which are started with b and ended with 1
Eg:
find . -mtime -1 -name "b*8" -exec ls -lrth {} \;
-rw-r--r--   1 one      other          0 May 27  2011 ./bad98
----------------------------------------------------------------------------
-rw-r--r--   1 one      other          0 May 27  2011 ./bad28
To remove unwanted list files:
$find . -mtime -1 -name "b*8" -exec rm {} \;
$ find . -mtime -1 -name "b*8" -exec ls -lrth {} \;

-----------------------------------------------------------------------------------------------
To check out  fmadm  faulty information
a=` more fault |grep fault` > /dev/null
bash-3.00# echo $a
Fault class : fault.io.pci.device-invreq faulted but still in service faulty this fault device(s). Use fmadm faulty to identify the devices or contact

$[ ! -z  "$a"  ] && (echo true) || (echo false)
True
[ ! -z "$a"  ] && ( more fault  >> temp) && (echo >> temp) && echo 8
If condition is true then it redirect output to  temp file and  append null and print value 8

To check diagnostics of server
b=`prtdiag -v|egrep "FAIL|fault"`
---------------------------------------------------------------------------------------------------------------------------------
Sample program:
#! /bin/ftp       ------------------- which shell interprets
echo "welcome"                  -------------------- to Display ino
$ sh first                                    -------------------------> to execute
o/p:welcome
$ . first -------------------------------> to execute@2 way
o/p:welcome
$ ./first       ----------------------------> to execute @3 way
NOTE:  ./first: Permission denied              ------------------> indicates no privileges to execute
$ chmod 700 first                         -----------------------------> given the rwx------ priviliges
$ ./first                                        -------------------------------> now its start execution find error as follows
./first: unknown host or invalid literal address
ftp> q
?Ambiguous command
ftp> bye
-------------------------------------------- #! /bin/sh--------------------------------
$ more first
#! /bin/sh
echo "welcome"
---------out put---------------
$ sh first
welcome
$ . first
welcome
$ ./first
Welcome
---------------------------------------------------------------------
Comments in shell scripting:  comments are helpful to give instructions.
#--> is a single line comment.
#!  --> is a calling of specific interpreter.

-bash-3.00$ more saisample
echo "comment"
# this line not exectued
-bash-3.00$ sh saisample
comment

-bash-3.00$ more saisample
echo "welcome to Reliance"
echo welcome to Reliane
echo 'welcome to Reliance'
echo "----------------------------------"
echo *
echo "welcome to reliance *"
echo 'welcome to reliance *'
echo welcome to reliance *
echo "---------------------------------"
echo welcome            to              slash
echo "welcome           to              slash"
echo 'welcome           to              slash'
echo "---------------------------------"
echo " tabspace \t betw"   ##gives tab space
echo " newline \n between" ## gives new line
echo " backspacex\b between"  ##removes preceding one char
echo "carriage returns \r between" ##removes preceding one ward
echo "formfeed \f between" ##clear the screan and print information
echo "-----------------------------------"
a=`echo *`
echo "double $a"
echo 'single $a'
echo normal $a
echo "-----------------------------------"
echo "welcome to reliance"
echo "welcome to \"reliance\""  ### to print into double quote
echo "welcome to ' reliance ' "
echo "welcome to  ril \
        welcome to again"   ###to combine
echo "-------------------------------------"
-bash-3.00$ sh saisample
Output:
welcome to Reliance
welcome to Reliane
welcome to Reliance
----------------------------------
a b first local.cshrc local.login local.profile saisample two
welcome to reliance *
welcome to reliance *
welcome to reliance a b first local.cshrc local.login local.profile saisample two
---------------------------------
welcome to slash
welcome         to              slash
welcome         to              slash
---------------------------------
 tabspace        betw
 newline
 between
 backspace between
 between returns
formfeed
 between
-----------------------------------
double a b first local.cshrc local.login local.profile saisample two
single $a
normal a b first local.cshrc local.login local.profile saisample two
-----------------------------------
welcome to reliance
welcome to "reliance"
welcome to ' reliance '
welcome to  ril         welcome to again
-------------------------------------
To remove list of files:
$ ls -lrth|head|awk '{print $9}'|xargs rm --->(it will remove first 10 files)
$rm `ls -lrth|head|awk '{print $9}'` ---->(it will removes first 10 files)
-----------------------------------------------

To print the output of pipe symbol cmd:
$ls|xargs echo
--------------------------------------------------------------
To set environmental variables:
#PS1="{[\$HOSTNAME]@[\$LOGNAME]:[\$PWD]}#"

------------------------------------------------------

echo "enviromental variables"
echo "to see host name $HOSTNAME"
echo "to see login name $LOGNAME"
echo "to see present woking directroy $PWD"
echo "to see terminal information $PS1"
echo "to print userid:$UID"
echo "-----------------------"
echo "to view environmental variables info"
env
echo "to vies os variables info"
set
echo "------------------------"
echo "to view user defined variables"
a=10
echo "value of a is :$a"
a="sai"
echo "value of a is:$a"
echo "-----------------------"
echo "to make variable as static variables"
a=100
echo $a
#readonly a
a=200
echo $a
echo "-------------------------"

--------------------------------------
$ a=10
$ echo $a
10
$ sh
$ echo $a
$ csh
sai1testserver% echo $a
a: Undefined variable
sai1testserver% ksh
$ echo $a
$
-------------------------------------------------------------------------
Life span of global variable
$ a=10
 $export a
$echo $a
10
$bash
bash-3.00$ echo $a
10
bash-3.00$ sh
$ echo $a
10
$ csh
sai1testserver% echo $a
10
sai1testserver% ksh
$ echo $a
10
$
-------------------------------------------------------------
Knowing about script cmd <it will maintain entire information of shell it starts new shell it ends when we exit form shell
Eg:
# script /one
Script started, file is /one
# echo $0
sh
# exit
Script done, file is /one
# echo $0
-sh
--------
To append information in same file
# script -a /one
Script started, file is /one
# lsll
lsll: not found
# exit
Script done, file is /one
-----
TO find out  pkg I present or not
[jgtest@root:/root]#more shhh
echo "Enter PACKAGE to CHECK ::"
read pkg
a=`pkginfo -l $pkg 2> /dev/null`
a=$?
if [ $a = 0 ]
then
a=`pkginfo -l $pkg | grep -i version`
echo -------------------------
echo "$pkg is FOUND"
echo "$pkg VERSION is :$a"
echo ---------------------------
else
echo "$pkg is NOT FOUND"
fi
----
To find out group of servers in
Take all ips in file
for i in `cat retail`
do
echo "---------------">>/outputsh1
echo "ip:$i" >>/outputsh1
ssh root@$i pkginfo -l VRTSvxvm VRTSvxfs VRTSvcs >>/outputsh1
echo "---------------">>/outputsh1
done
----
[jgtest@root:/root]#for i in 1 2 3  4 5  6 7 8 9
root@jgtest > do
root@jgtest > echo $i
root@jgtest > done
1
2
3
4
5
6
7
8
9
[jgtest@root:/root]#for ((i=0;i<=10;i++))
root@jgtest > do
root@jgtest > echo $i
root@jgtest > done
0
1
2
3
4
5
6
7
8
9
10
[test1@root:/]#su - uone -c 'ls'
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
contrl.cf      dbs            local.cshrc    local.login    local.profile
[test1@root:/]#su - uone -c 'cd dbs'
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
[test1@root:/]#su - uone -c 'cd dbs;ls'
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
inittest.ora
[test1@root:/]#su - uone -c 'cd dbs;ls|cat *'
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
cntrl
[test1@root:/]#su - uone -c 'cd dbs;ls|cat '
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
inittest.ora
[test1@root:/]#su - uone -c 'cd dbs;ls|cat *'
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
Cntrl
[test1@root:/]#su - uone -c 'grep -i cntrl "$TEST_HOME"/dbs/inittest.ora'|awk -F= '{print $2}'
xyz yza zab
[test1@root:/]#su - uone -c 'grep -i cntrl "$TEST_HOME"/dbs/inittest.ora'|awk -F= '{print $2}'|awk -F" " '{print $1 $2 $3}'
xyzyzazab
[test1@root:/]#su - uone -c 'grep -i cntrl "$TEST_HOME"/dbs/inittest.ora'|awk -F= '{print $2}'|awk -F" " '{print $1 "\t"$2 "\t"$3}'
xyz     yza     zab
[test1@root:/]#for i in `su - uone -c 'grep -i cntrl "$TEST_HOME"/dbs/inittest.ora'|awk -F= '{print $2}'|awk -F" " '{print $1 "\t"$2 "\t"$3}'`
> do
> echo $i
> done
xyz
yza
zab
printf "enter info";
getopts abc  ii                      //hear ii is the variable which take info
case   $ii in
a)
        echo this is a
;;
b)
        echo this is b
;;
c)
        echo this is c
;;
*)      echo not
Esac
[jgtest@root:/root]#sh one -a
enter infothis is a
[jgtest@root:/root]#sh one -b
enter infothis is b
[jgtest@root:/root]#sh one -c
enter infothis is c
[jgtest@root:/root]#sh one -d
enter infoone: illegal option -- d
not
[jgtest@root:/root]#
[test1@root:/]#more one
getopts 1234  rama
case $rama in
1) echo "one";;
2) echo "two";;
3) echo "three";;
4) echo "four";;
*)echo "star";;
Esac

[test1@root:/]#sh one
star
[test1@root:/]#sh one -1
one
[test1@root:/]#sh one -2
two
[test1@root:/]#sh one -3
three
[test1@root:/]#sh one -4
four
[test1@root:/]#sh one -5
one: illegal option -- 5
star
[test1@root:/]#more one
getopts 1234:  rama
case $rama in
1) echo "one";;
2) echo "two";;
3) echo "three";;
4) echo "four";;
*)echo "star";;
Esac
[test1@root:/]#. one -1
star
[test1@root:/]#sh one -1
one
[test1@root:/]#ksh one -1
one
[test1@root:/]#csh one -1
rama: Undefined variable
[test1@root:/]#sh one -5
one: illegal option -- 5
star
---
[test1@root:/]#more one
while getopts 1234:  rama
do
case $rama in
1) echo "one";;
2) echo "two";;
3) echo "three";;
4) echo "four";;
*)echo "star";;
esac
done
--
[test1@root:/]#sh one
[test1@root:/]#sh one -1 -2 -3
one
two
three
[test1@root:/]#sh one -5 -3 -2 -1
one: illegal option -- 5
star
three
two
one
[test1@root:/]#. one
[test1@root:/]#. one -1 -2 -3
one
two
three
[test1@root:/]#ksh one -1 -2 -3
one
two
three
[test1@root:/]#bash one -5 -3 -2
one: illegal option -- 5
star
three
two
[jgtest@root:/root]#man sneep
Reformatting page.  Please Wait... done
User Commands                                            sneep(1)
NAME
     sneep - Serial Number in EEPROM
     Store  and  retrieve   Chassis   (Product)   Serial   Number
     (CSN/PSN)  and  other  user-defined information using system
     EEPROM and other system services.
SYNOPSIS
     sneep [-aeFhTvV] [-t tag[,tag...]] [-s setting ] \
          [-P ds1:ds2...] [-d default] [-o separator]
     sneep [start | stop | restart ]
     (Deprecated)
          setcsn -c serialnumber
          showplatform -p csn
DESCRIPTION
     Sneep uses the system  EEPROM  to  store  and  retrieve  the
     Chassis Serial Number on all known Solaris systems.
     Sneep can also be used to store  and  retrieve  user-defined
     data such as asset tag, serial numbers for attached storage,
     etc.
     A relatively  small  number  of  Solaris  platforms  have  a
     built-in  method for obtaining the product or chassis serial
     number in software.  With sneep,  all  Solaris  systems  can
     have  this capability, which can be accessed in a simple and
     uniform way on every host, domain, and zone.
     Sneep searches for the serial number or other requested data
     in  several  data  sources,  including  the  system  eeprom,
     platform-specific hardware-based sources, the  configuration
     files  for  the  Sun  "explorer"  and "Configuration Service
     Tracker (CST)" tools, and its own  backup  file.   The  data
     sources  are  searched  in a specific order corresponding to
     the estimated reliability of the  data  source.  The  search
     order can be controlled by means of the -P option.
     Sneep returns the requested data from the first and  presum-
     ably  most reliable of the data sources which have available
     data.  If data cannot be obtained from any of  the  sources,
     sneep reports a value of "unknown" by default.
     In the absence of valid data,  it  is  necessary  to  inform
     sneep  of  the  actual serial number once, so that sneep can
     store it into the eeprom and take steps to preserve it.  For
     details, see the "-s" option.
     Note  that  some  platforms  with  support   for   software-
     accessible  serial  numbers  may  report an incorrect serial
     number (e.g. 00000).  This is not uncommon in X86/X64  plat-
     forms  from some vendors.  In these cases, sneep can be used
     to override the value reported.
SunOS 5.10                Last change:                          1
User Commands                                            sneep(1)
     To promote configuration consistency and  minimize  adminis-
     trative  work,  sneep  will  also  reference  and update the
     serial number in any available "explorer" and  "CST"  confi-
     guration  files,  and  will create a special Serial tracking
     event in the CST event history.
     Sneep logs all important changes or problems to syslogd  for
     auditing purposes.
SHOWPLATFORM EMULATION
     The first Command Line Interface (CLI) from Sun  for  access
     to  the  Chassis  Serial  Number  was the combination of the
     "setcsn" and "showplatform" programs from System  Management
     Services [SMS] 1.4.  on the SunFire 15000 platform.
     To comply with this early standard, sneep offers as a subset
     of  its  Command  Line  Interface  a  limited  emulation  of
     "showplatform" and "setcsn".
     Subsequent Sun products did not make use of  this  CLI  from
     SMS,  so the use of the sneep setcsn/showplatform CLI emula-
     tion is now deprecated.  Note that sneep  does  not  provide
     any  of  the  other functionality of the actual showplatform
     and setcsn programs.
OPTIONS
     The following options are supported:
     -a
               All sources: show results from all  data  sources.
               Implies -v .
     -c serial
               (setcsn only) Set serial number to <serial>
     -d defaultval
               Specify the default value to be  returned  if  the
               requested information is not found.
               The null string "" is permitted.
               The  default  value   is   the   unquoted   string
               "unknown".
     -e
               Erase. When used in combination  with  options  -T
               and  -v,  output  the  sneep commands necessary to
               erase selected tags and values.
               This option has no effect except  when  used  with
               both -T and -v.
     -F
               Force.  Overrides safety restrictions.
SunOS 5.10                Last change:                          2
User Commands                                            sneep(1)
               NOTE: Sneep uses a conservative  estimate  of  the
               eeprom  nvramrc  capacity.  Do not use this option
               to forcibly store additional data  in  the  eeprom
               unless  you  are  certain  that  the true limit is
               greater than the  program's  estimate.   Exceeding
               the  true  limits  of  the eeprom nvramrc can have
               severe consequences including failure to boot.
     -h
               This help message
     -o separator
               Output Field  Separator.   Inserted  between  each
               value printed when more than one tag is specified.
               See option -t .
               Default separator is comma.
     -p csn
               (showplatform only) Print serial number.
               <csn> parameter must be the unquoted string  "csn"
               .
     -P ds1:ds2...
               Set Priority of data sources.
               Data sources in this colon-separated list are used
               in  order  from  left  to  right.  When requesting
               data, the first source  reporting  data  is  used.
               This  option  overrides  the priority which can be
               controlled by environment variable SNEEPPATH or by
               a setting in the sneep backup file.
               Default is
                    eeprom:ipmi:smbios:prtdiag:\
                         sms:fruid:prtconf:backup:explorer:cst
     -s setting
               Associate <setting> with an EEPROM identifier tag.
               The <setting> must be a valid  Serial  Number  (or
               null)  unless  the  -t  option  is  used to select
               another tag.
               If <setting> is the null string "",  the  tag  and
               value are deleted.
               Note that <setting>  is  always  stored  into  the
               eeprom  and  backup data sources, even if they are
               not on the priority list.
     -t tag[,tag...]
               Use  <tag>  as  EEPROM  identifier  to  store   or
               retrieve values.
SunOS 5.10                Last change:                          3
User Commands                                            sneep(1)
               A comma-separated list of tags  may  be  specified
               for  data  retrieval.   Only  one tag may be given
               when used with -s to set a value.
               Default tag is "ChassisSerialNumber".
               Tags "serial", "CSN", "csn", "PSN", and "psn"  are
               equivalent to "ChassisSerialNumber".
               Pseudo-tags "hostname" and "hostid" can be used to
               retrieve  the  Operating  System  values  for host
               (domain) name and host identifier.  Use  of  these
               two  tags  to store information in eeprom is inef-
               fective, as the information will only be retrieved
               from the Operating System, and not from eeprom.
               The "model" tag can be  used to retrieve  a  value
               describing the hardware model reported by the sys-
               tem.  It can be overridden by means of  "-t  model
               -s newvalue"
     -T
               Report tags as well as values.
               Reports all tags unless the -t option is  used  to
               select particular tags.  Ignores option -a .
               The default output format has the tag  followed  a
               tab,  followed by the corresponding value enclosed
               in  quotation  marks.  Each  tag/value  pair    is
               presented on a separate line.
               If -v option is used with  -T,  the  output  is  a
               series  of sneep commands suitable for setting the
               tags, and intended to simplify recovery of data.
               If -e option is used with -T and -v, the ouput  is
               a  series  of  sneep commands suitable for erasing
               the tags.
     -v
               Verbose: show the source of the reported value.
               With -T, show commands instead of the data source.
     -V
               Print version information.
               Please  report  this  information  any  time   you
               request help from the Sun Technical Support Center
               or sneep-support@sun.com
     start | restart
               Perform data consistency checks and  automatically
               repair  inconsistent  or missing data if possible.
               Messages are logged  to  the  system  log  if  the
SunOS 5.10                Last change:                          4
User Commands                                            sneep(1)
               Chassis  Serial  Number  in  EEPROM  is missing or
               inconsistent with other available data sources.
               If the serial number is present in the eeprom, but
               is  not present in the sneep backup file, then all
               of the sneep settings in the eeprom will  be  used
               to automatically correct the backup file and other
               sources.  Any settings found only  in  the  backup
               file will remain unchanged.
               If the serial number is missing from  the  eeprom,
               but  is  present  in  the  backup file, and if the
               backup file is the correct  one  for  the  current
               system,  all of the settings from the backup which
               are not already in the  eeprom  will  be  used  to
               correct the eeprom and other sources.
               The start option is used automatically by  default
               at  system  startup,  and is not normally intended
               for use at any other time.  However, if sneep  has
               just  been  installed  and valid data is available
               from one or more data sources, this  is  a  simple
               way  to set the serial and perform some other one-
               time activities.
     stop
               Ignored. Included for completeness.
OPERANDS
     tag
               Identifier used to store or retrieve a value. Does
               not  have  to  be  supplied  in  normal  usage for
               Chassis Serial Number.
               Only a few special characters are permitted in the
               tag.  These characters are @ # _ + = -
     setting
               The value to be stored in the EEPROM.  It may  not
               contain  quotation  marks  or control characters (
               including newline ).  If the Chassis Serial Number
               is  being  set,  the  setting will be converted to
               upper case, and will be  checked  for  length  and
               content.
     ds1:ds2...
               Data Source (n).
                     e.g.
                    eeprom:prtdiag:smbios:backup:explorer:cst...
               A colon-separated sequence of places  which  sneep
               understands  as  possible  sources  of  data. When
               requesting a value for a tag, sneep searches  them
SunOS 5.10                Last change:                          5
User Commands                                            sneep(1)
               in the given sequence, from left to right, return-
               ing the first value found.  The  default  list  is
               arranged  to search the most authoritative sources
               first.
               Having the eeprom first allows the user  to  over-
               ride every other data source.
NOTES
     Superuser privilege is  required  to  store  information  in
     EEPROM  and  in the explorer and CST configuration files. It
     is likely that any user can  use  sneep  to  retrieve  data,
     although   some  sources  (like  SMS)  may  require  special
     privileges.
     Serial numbers are stored in upper case only.  This  can  be
     overridden  if  necessary,  but it will be incompatible with
     serial number data used by Sun and may fail to provide  full
     value.  Values for other tags are left unchanged.
     When making a setting with the -s <setting> option, if <set-
     ting>  is  the same as the default value (e.g. "unknown", or
     the <defaultval> set with  "-d"),  the  tag  and  value  are
     deleted.  Subsequent  requests will return the default value
     because the tag is absent.  This prevents accidentally  set-
     ting  the  serial  to "UNKNOWN" when it has never previously
     been defined, and the serial is set using the value returned
     from sneep ("unknown").
     There are many different mechanisms used for  accessing  the
     Serial  Number  on  the various Sun hardware platforms which
     support a software-accessible serial number, but only a sub-
     set  of  these  mechanisms  are known to sneep. As a result,
     sneep may not be able to retrieve  the  Serial  Number  from
     some  platforms known to have this feature.  Future versions
     of sneep will strive to support as many  mechanisms  as  are
     practical.  Until  then,  it  may be necessary to use the -s
     option to inform sneep of the serial number one time.
     The "model" tag is usually very effective in the global zone
     where  sneep  can  find the necessary data.  In a non-global
     zone, the data available to determine  model  can  be  quite
     limited, especially on x86/X64 hardware.  To obtain accurate
     model information from non-global zones, it may be necessary
     to set the model using -t model -s newvalue"
EXAMPLES
     Store  serial number in EEPROM, updating  explorer  and  CST
     configuration files.
               # sneep -s 1234abcd
               #
SunOS 5.10                Last change:                          6
User Commands                                            sneep(1)
     Print previously stored serial number:
               $ sneep
               1234ABCD
               $
     Store asset data in EEPROM :
               # sneep -t ASSETTAG -s Asset1234
     Print value for ASSETTAG :
               $ sneep -t ASSETTAG
               Asset1234
     Show Serial number using showplatform format
               $ showplatform -p csn
                    CSN:
                    ====
                    Chassis Serial Number: 1234ABCD
     Show all tags and values :
               $ sneep -T
               ChassisSerialNumber "1234ABCD"
               ASSETTAG "Asset1234"
     Show serial number from all sources :
     (Note that the value from smbios is incorrect and  would  be
     overridden by the value in eeprom)
               $ sneep -a
                    ChassisSerialNumber from eeprom :
               86078428H
                    ChassisSerialNumber from smbios :
               00000000
                    ChassisSerialNumber     from     backup     :
                    /etc/default/SUNWsneep :
               86078428H
                    ChassisSerialNumber from explorer :
               86078428H
                    ChassisSerialNumber from cst :
               86078428H
     Show Inventory data as comma-separated list
               $ sneep -t hostname,hostid,serial,ASSETTAG,model
               MyHostname,8000008,1234ABCD,Asset1234,T2000
ENVIRONMENT
     The following environment variables permit the user to over-
     ride defaults:
     SNEEPPATH
          Priority search path for data sources.
SunOS 5.10                Last change:                          7
User Commands                                            sneep(1)
          Overrides optional setting from the sneep backup file.
     SNEEP_SYSLOG
          Syslog facility.level. Default "daemon.notice".
          Overrides optional setting from the sneep backup file.
     SIMULATION
          Set to "true" to use simulation data.
          Primarily for testing.
     SIMBASE
          Path to directory containing simulation data.
          Default is "./sim"
     EXPLO_BASE
          Path to directory containing expanded  explorer  to  be
          used in simulation.
          Overrides SIMBASE
     UNAME_I, UNAME_P, UNAME_A, UNAME_M
          For simulation. Used instead of the various outputs  of
          uname(1)
     FORCE_UCASE
          If "false", do not force serial  numbers  to  be  upper
          case.   Serial  numbers  containing  lower  case may be
          incompatible to some degree with internal Sun tools.
EXIT STATUS
     0 indicates normal or successful operation.
     1 indicates an error in usage, or an  inability  to  perform
     the   requested   action;   e.g.   because  of  insufficient
     privilege.
FILES
     /etc/default/SUNWsneep
          Backup  file  containing  all  tags  and  settings  for
          recovery  of eeprom, as well as customized default set-
          tings.  Format for the customized default settings:
          System logging preference
               sneep<space>syslog<tab><facility.level>
          Priority search path (see -P option and SNEEPPATH)
               sneep<space>path<tab><ds1:ds2:...dsn>
          Explorer defaults file, if non-standard
               sneep<space>explorerdefaults<tab>/full/path
SEE ALSO
     eeprom(1M),   syslog.conf(4),    logger(1),    explorer(1M),
     uname(1),  prtdiag(1M), prtconf(1M), smbios(1M), prtfru(1M),
SunOS 5.10                Last change:                          8
User Commands                                            sneep(1)
     ipmitool(1m)
     Sneep User Guide,
     Configuration Service Tracker User Guide
     Sun System Handbook (for hardware serial number location)
          http://sunsolve.sun.com/handbook_pub/
SUPPORT
     To report  problems,  request  enhancements,  or  contribute
     helpful  information regarding sneep, please send electronic
     mail to
          sneep-support@sun.com
     If you report a problem, please include the version informa-
     tion from sneep -V .
     To find out about new versions of sneep or possible problems
     affecting  sneep users, please join the sneep-announce elec-
     tronic mail alias.  Send your request to  be  added  to  the
     alias to sneep-support@sun.com
SunOS 5.10                Last change:                          9
[jgtest@root:/root]#
• $$ = The PID number of the process executing the shell.
• $? = Exit status variable.
• $0 = The name of the command you used to call a program.
• $1 = The first argument on the command line.
• $2 = The second argument on the command line.
• $n = The nth argument on the command line.
• $* = All the arguments on the command line.
• $# The number of command line arguments
[jgtest@root:/root]#more one
#!/bin/bash
echo $$
echo $?
echo $0
echo $1
echo $2
echo $*
echo $#
echo $@
[jgtest@root:/root]#sh one 1 2  3 4 5  6
8865
0
one
1
2
1 2 3 4 5 6
6
1 2 3 4 5 6

[jgtest@root:/root]#set a1 b2 c3 d4
[jgtest@root:/root]#echo $*
a1 b2 c3 d4
[jgtest@root:/root]#echo $#
4
[jgtest@root:/root]#echo $@
a1 b2 c3 d4
[jgtest@root:/root]#echo $$
9855
[jgtest@root:/root]#echo $$
9855
[jgtest@root:/root]#echo $!
[jgtest@root:/root]#echo $0
-bash
[jgtest@root:/root]#echo $1
a1
[jgtest@root:/root]#echo $2
b2
[jgtest@root:/root]#shift
[jgtest@root:/root]#echo $1
b2
[jgtest@root:/root]#shift
[jgtest@root:/root]#echo $1
c3
[jgtest@root:/root]#shift
[jgtest@root:/root]#echo $1
d4
[jgtest@root:/root]#shift
[jgtest@root:/root]#echo $1
## the below function defines how to use script

USAGE()
{
        echo "Usage: tpk [-d] [-f] [-c] <Request1> <Request2> ...\n\t -f  force mode\n\t -d  to disable dependency check\n\t -c  to check if
request is done"
                echo "\t Where Request should be of format D16K######\n\n"

}
----------------------------------------------------------------------------
## getting orguments and enter in to specific session

while getopts :fdc KEY $*
do case $KEY in
        f) opt=U126;shift;;
        d) dep=no;shift ;;
        c) chk=yes;shift ;;
        *) print -u2 Illegal option: -$OPTARG
                USAGE
                exit 1 ;;
        esac
done
----------------------------------------------------------------------------
##if u dont enter any arguments then automatically it is exits TEST


if [[ "$#" -lt 1 ]];then
        USAGE
        exit 2
fi

--------------------------------------------------------------------------
## it checks all request which are belongs to Q16 are not ,if not exit
for i in $*
do
        if [[ `echo $i|cut -c1-4` != D16K ]];then
                echo "Invalid Format Request No. $i!"
                USAGE
                exit 3
        fi
done
---------------------------------------------------------------------------
## while transporting it create /tmp/tpk.LCK by using this technique w can determine transport is going or not
if [[ -e /tmp/tpk.LCK ]];then
echo "Already tpk execution is going on"
exit
fi
------------------------------------------------------------------------------
##
trap "echo y|rm /tmp/tpk.LCK 2> /dev/null;exit" 0 1 2 5 9 15
-----------------------------------------------------------------------------
## create required file
touch /tmp/tpk.LCK
-----------------------------------------------------------------------------
## if u enter transport numner
## first it will check in destination server for any updations are happend for required Request
## if exists then return Transport Return code else  ( if u try which c option it display msg request is not transported)
##(if u dont try with c option it start its excution)
##  it copy data and cofiles from source to destination
## if not copy throug an error
## request add to buffer and import them
## if any problem occures queries you
## after transport remover /tmp/tpk.LCK file
while [[ $1 != "" ]];do
        file=`echo $1|cut -c5-10`
if [[ -e /sapmnt/trans/log/D16V${file}.Q16 ]] && [[ $opt != U126 ]];then
        tpcod=0
        for i in /sapmnt/trans/log/*${file}.$SAPSYSTEMNAME;do
        code=`tail -3 $i|grep "exit code"|awk '{print $6}'|awk -F\" '{print $2}'|awk -F\" '{print $1}'`   
        if [[ $code -gt $tpcod ]];then
        tpcod=$code
        fi
        done
        echo $1 already transported with return code $tpcod!
        shift
else

        if [[ $chk = yes ]];then
        echo "Request $1 is not transported"
        shift
        else
        tp=y

        ## If yes then start copying file from QA to PD ##
        if [[ $tp != no ]];then
        echo "Wait copying files..."

datafile=R"${file}".D16
datafile1=D"${file}".D16
cofile=K"${file}".D16
/usr/bin/scp d16adm@10.66.10.87:/sapmnt/trans/data/$datafile /sapmnt/trans/data/
/usr/bin/scp d16adm@10.66.10.87:/sapmnt/trans/data/$datafile1 /sapmnt/trans/data/
/usr/bin/scp d16adm@10.66.10.87:/sapmnt/trans/cofiles/$cofile /sapmnt/trans/cofiles/
        cpstat="$?"
        if [[ "$cpstat" != 0 ]];then
                echo "File copy failed please check if request $1 is released or transported to QA10"
                tp=no
        fi
        fi

        if [[ "$tp" != "no" ]];then
                cd /sapmnt/trans/bin
                tp addtobuffer $1 Q16  2>>/tmp/$1.log
                tp import $1 Q16 client=316 $opt 2>>/tmp/$1.log
                laststat=$?
        laststat=8
        fi
shift
        if ([[ "$cpstat" -gt 0 ]] || [[ "$laststat" -gt 4 ]]) && [[ $1 != "" ]] && [[ $dep != no ]];then
                echo "Proceed with next $1 skip(s), continue(c) or Exit (x)  ? "
                read resp
                case $resp in
                        s)shift ;;
                        c)echo ok;;
                        x)exit ;;
                        *)echo "please respond with skip(s), continue(c) or Exit (x)" ;;
                esac
        fi
fi
fi
done
echo y|rm /tmp/tpk.LCK 2> /dev/null

root@murexhub # a=`cat media|grep -n "Q10_TUE_SET2" |cut -d ":" -f 1`
root@murexhub # b=`cat media|grep -n "Q15_FRI_SET1" |cut -d ":" -f 1`
root@murexhub # echo $a $b
485 493
root@murexhub # sed -ne $a,$b\p media
Q10_TUE_SET2 pool
CI0666  HCART3   TLD      0       121    -       -     -        AVAILABLE
CI0667  HCART3   TLD      0       132    -       -     -        AVAILABLE
CI0670  HCART3   TLD      0       133    -       -     -        AVAILABLE
CI0677  HCART3   TLD      0       117    -       -     -        AVAILABLE
CI0678  HCART3   TLD      0       116    -       -     -        AVAILABLE
Q15_FRI_SET1 pool
Example of mail in HTML FORMAT
From: sap-ops.mumbai@ril.com
To:sapops.mumbai@ril.com,makarand.jog@ril.com,sudhakar.mhatre@ril.com,rajesh.p.sarda@ril.com,Vikas.Agrawal@ril.com,prashant.shukla@ril.com,
ril.basis@ril.com,Pravin.Kudav@ril.com,Samarendra.Singh@ril.com,Sachin.Vatsaraj@ril.com,Ashok.V.Pawar@ril.com,idc.sysadmins@ril.com
Reply-To: sap-ops.mumbai@ril.com
Subject: MASTER---SYNCHRONOUS DGs REPLICATION STATUS ( 2011-08-18-15Hrs15Min )...
Content-type: text/htm

Eg:
root@TIBDEV # more test.html
<html>
<head> test head</head>
<body bgcolor=pink>
<h1>headline</h1>
<table>
<tr>welcome</tr>
</table>
</body>
</html>
root@TIBDEV # more test.html |mail sap-ops.mumbai@ril.com

root@TIBDEV # more test.html |mailx sap-ops.mumbai@ril.com

root@TIBDEV # more test.html
Content-type: text/html
 <html>
<head> test head</head>
<body bgcolor=pink>
<h1>headline</h1>
<table>
<tr>welcome</tr>
</table>
</body>
</html>

root@TIBDEV # more test.html|mail sap-ops.mumbai@ril.com

root@p10app05 # cat /tmp/test|mail sap-ops.mumbai@ril.com
root@p10app05 # cat /tmp/test
To: sap-ops.mumbai@mail.ril.com
Reply-To: sap-ops.mumbai@mail.ril.com
Subject:TKP_1000 :test
Content-type: text/html
<html>
<body bgcolor=red>
<font color=green>
<h1> hello</h1>
</font>
</body>
</html>





root@TIBDEV # more test.html|mailx sap-ops.mumbai@ril.com

To verify logs:
root@P109XMED01 # while true
root@P109XMED01 > do
root@P109XMED01 > echo "******** LATEST FILE ******************"
root@P109XMED01 > ls -lrth|tail -1
root@P109XMED01 > echo "***************************************"
root@P109XMED01 > ls -lrth|tail -1|awk '{print $9}'|xargs tail -20
root@P109XMED01 > echo "**********************END OF VERIFICATION****************"
root@P109XMED01 > echo
root@P109XMED01 > sleep 1000
root@P109XMED01 > done
TO LIST OUT FILE IN REMOTE SERVERS
Cat >test1
Server ips
root@hppapp10 # for i in `cat test1`
root@hppapp10 > do
root@hppapp10 > ssh -q $i ls -l /scripts/\*_output.txt
root@hppapp10 > done
-rw-r--r--   1 root     root       95683 Oct 22 15:54 /scripts/p60ci_output.txt
-rw-------   1 root     root       94977 Oct 22 15:54 /scripts/p60db_output.txt
-rw-r--r--   1 root     root       95493 Oct 22 15:54 /scripts/p30ci_output.txt
-rw-r--r--   1 root     root       94711 Oct 22 15:54 /scripts/p30db_output.txt
-rw-------   1 root     root       91469 Feb 16  2011 /scripts/murexdb_output.txt
-rw-r--r--   1 root     root       93372 Oct 22 15:54 /scripts/p30app03_output.txt
-rw-r--r--   1 root     root       92937 Oct 22 15:54 /scripts/p30app04_output.txt
-rw-------   1 root     root       92937 Oct 22 15:54 /scripts/p30app05_output.txt
-rw-------   1 root     root       93118 Oct 22 15:54 /scripts/p30app06_output.txt
-rw-------   1 root     root       93351 Oct 22 15:54 /scripts/p60app01_output.txt
-rw-------   1 root     root       93109 Oct 22 15:54 /scripts/p60app02_output.txt
-rw-r--r--   1 root     root       91312 Feb 16  2011 /scripts/murexapp_output.txt

Note:
If I am giving
> ssh -q $i ls -l /scripts/\`hostname`_output.txt
It will search hostname on which centeral server u are using
To copy from different servers:
root@hppapp10 # for i in `cat test1`
root@hppapp10 > do
root@hppapp10 > scp $i:/scripts/\*_output.txt /scripts/RIL-output
root@hppapp10 > done
---------------------
To execute script in different servers
t@hppapp10 # for i in `cat test1`
root@hppapp10 > do
root@hppapp10 > echo "********$i*************"
root@hppapp10 > ssh -q $i bash /scripts/file-perm-new
root@hppapp10 > done
--------------------
root@murexhub # su - user1
$ PS1=${HOST:=`uname -n`}"$";export PS1 HOST;
murexhub$echo echo $HOST
echo murexhub
murexhub$echo $PS1
murexhub$
--
$ UP=`date;uptime`
$ echo $UP
Wednesday, February 29, 2012 7:01:40 PM IST 7:01pm up 54 day(s), 8:09, 1 user, load average: 1.54, 1.17, 1.11
--
$ echo $1250
250
$ echo \$1250
$1250
$ echo $226
26
------
Ldom creation scrips:-
root@STAR1-B:/scripts/luns/PP1# more luns_ctds.sh
for i in `cat /scripts/luns/PP1/PP1-SP`;do
/scripts/emcgrab/tools/bin/inq.sol64 -nodots -showvol|grep -i $i|awk '{print $1}';done
root@STAR1-B:/scripts/luns/PP1# cat luns_nos.sh
for i in `cat /scripts/luns/PP1/PP1-SP`;do
/scripts/emcgrab/tools/bin/inq.sol64 -nodots -showvol|grep -i $i|awk '{print $7}';done

root@STAR1-B:/scripts/luns/PP1# cat create_pp1service.sh
#!/bin/bash
> /scripts/luns/PP1/vdisk.sh
output=/scripts/luns/PP1/vdisk.sh
for i in `cat luns_pp1`
do
LUNID=`echo $i|cut -d ":" -f 1`
#echo $LUNID
CTDSNO=`echo $i|cut -d ":" -f 2`
#echo $CTDSNO
echo "ldm add-vdsdev mpgroup=PIPP1SP-$LUNID-gp $CTDSNO PIPP1SP-$LUNID@primary-vds0" >> $output
echo "ldm add-vdsdev mpgroup=PIPP1SP-$LUNID-gp $CTDSNO PIPP1SP-$LUNID@secondary-vds0" >> $output
echo "ldm add-vdisk vdisk_$LUNID PIPP1SP-$LUNID@primary-vds0 PIPP1SP" >> $output
done
root@STAR1-B:/scripts/luns/PP1# cat remove_pp1service.sh
#!/bin/bash
> /scripts/luns/PP1/remove_vdisk.sh
output=/scripts/luns/PP1/remove_vdisk.sh
for i in `cat luns_pp1`
do
LUNID=`echo $i|cut -d ":" -f 1`
#echo $LUNID
CTDSNO=`echo $i|cut -d ":" -f 2`
#echo $CTDSNO
echo "ldm remove-vdsdev PIPP1SP-$LUNID@primary-vds0" >> $output
echo "ldm remove-vdsdev PIPP1SP-$LUNID@secondary-vds0" >> $output
#echo "ldm add-vdisk vdisk_$LUNID PIPP1SP-$LUNID@primary-vds0 PIPP1SP" >> $output
Done

root@STAR1-A:~# cat control-domain.sh
#!/usr/bin/bash
set -x
ldm start-reconf primary
ldm set-vcpu -c 4 primary
ldm set-mem 64g primary
#ldm rm-io pci_0 primary
#ldm rm-io pci_1 primary
#ldm rm-io pci_2 primary
ldm rm-io pci_3 primary
#ldm rm-io pci_4 primary
#ldm rm-io pci_5 primary
#ldm rm-io pci_6 primary
#ldm rm-io pci_7 primary
ldm rm-io pci_8 primary
ldm rm-io pci_9 primary
ldm rm-io pci_10 primary
#ldm rm-io pci_11 primary
ldm rm-io pci_12 primary
ldm rm-io pci_13 primary
ldm rm-io pci_14 primary
ldm rm-io pci_15 primary
ldm rm-io pci_16 primary
ldm rm-io pci_17 primary
ldm rm-io pci_18 primary
ldm rm-io pci_19 primary
ldm rm-io pci_20 primary
ldm rm-io pci_21 primary
ldm rm-io pci_22 primary
ldm rm-io pci_23 primary
ldm rm-io pci_24 primary
ldm rm-io pci_25 primary
ldm rm-io pci_26 primary
ldm rm-io pci_27 primary
ldm rm-io pci_28 primary
ldm rm-io pci_29 primary
ldm rm-io pci_30 primary
ldm rm-io pci_31 primary
ldm add-vconscon port-range=5000-5200 primary-vcc0 primary
svcadm enable vntsd
ldm add-vsw net-dev=net0 primary-vsw0 primary
ldm add-vdiskserver primary-vds0 primary
ldm add-spconfig ldom-base

root@STAR1-A:~# cat createaggr.txt
ON IO-Domain
dladm create-aggr -L active -l net1 -l net3 secondaryaggr0
ldm add-vsw net-dev=secondaryaggr0 secondary-vsw1 STAR1-A-IO
ldm add-vdiskserver secondary-vds0 STAR1-A-IO
On Control Domain
dladm create-aggr -L active -l net1 -l net3 primaryaggr0
ldm add-vsw net-dev=primaryaggr0 primary-vsw1 primary

root@STAR1-A:~# cat io-domain.sh
#!/usr/bin/bash
set -x
ldm add-domain STAR1-A-IO
ldm set-vcpu -c 4 STAR1-A-IO
ldm set-mem 64g STAR1-A-IO
ldm add-io pci_16 STAR1-A-IO
ldm add-io pci_17 STAR1-A-IO
ldm add-io pci_18 STAR1-A-IO
ldm add-io pci_20 STAR1-A-IO
ldm add-io pci_21 STAR1-A-IO
ldm add-io pci_22 STAR1-A-IO
ldm add-io pci_23 STAR1-A-IO
ldm add-io pci_27 STAR1-A-IO
ldm add-vnet vnet1 primary-vsw0 STAR1-A-IO
ldm set-vconsole port=5001 service=primary-vcc0 STAR1-A-IO
ldm add-spconfig ldm-base-io

root@STAR1-A:~# cat m5guestldmcreate.sh
#!/bin/bash
if [ $# -le 7 ];
then
        echo "Usage : $0 <DOMAIN> <CONS> <CPU> <MEM> <DISK1> <DISK2> <VNET> <VDISK>"
        echo
        exit 1
fi
set -x
DOM=$1
CONS=$2
CPU=$3
MEM=$4
DISK1=$5
DISK2=$6
VNET=$7
VDISK=$8
ldm add-domain $DOM
ldm set-core $CPU $DOM
ldm set-mem ${MEM}g $DOM
ldm add-vnet ${VNET}_p primary-vsw1 $DOM
ldm add-vdsdev /dev/dsk/${DISK1} ${DOM}_disk1@primary-vds0
ldm add-vdisk ${VDISK}_p ${DOM}_disk1@primary-vds0 $DOM
ldm add-vnet ${VNET}_s secondary-vsw1 $DOM
ldm add-vdsdev /dev/dsk/${DISK2} ${DOM}_disk2@secondary-vds0
ldm add-vdisk ${VDISK}_s ${DOM}_disk2@secondary-vds0 $DOM
ldm set-vconsole port=$CONS service=primary-vcc0 $DOM
ldm bind-domain $DOM
ldm start $DOM
echo "LDOM $DOM created sucessfully!!!"
root@STAR1-A:~#
==========
root@STAR1-A:~# cat m5ovmioinstall.ksh
#! /bin/ksh
# Each arry must have the same number of space separated arguments
# The primary and secondary domains are assigned whole-cores, whereas the DIO ldoms are just whole-cores
# PDOMA
export DOMAIN_BUSES="PDomAprimary PDomAsecondary PDomAdioA PDomAdioB"
export DOMAIN_NAMES="primary secondary dioA dioB"
export DOMAIN_CORES="0,2,4,6,8,10 16,18,20,22,24,26 12 12"
export DOMAIN_MEMS="64g 64g 192g 192g"
export DOMAIN_NETS="net0,net1,net2 net3,net4,net5 net6,net7,net8 net9,net10,net11"
# Need to run twice (will reboot after first run)
./m5ovmiosetup.ksh -vie 2>> m5ovmiosetup.cmd
# Single PDOM in the labs
exit
# PDOMB
export DOMAIN_BUSES="PDomBprimary PDomBsecondary PDomBdioA PDomBdioB"
export DOMAIN_NAMES="primary secondary dioA dioB"
export DOMAIN_CORES="0,2,4,6,8,10 16,18,20,22,24,26 12 12"
export DOMAIN_MEMS="64g 64g 192g 192g"
export DOMAIN_NETS="net0,net1,net2 net3,net4,net5 net6,net7,net8 net9,net10,net11"
# Need to run twice (will reboot after first run)
./m5ovmiosetup.ksh -vie 2>> m5ovmiosetup.cmd
=============
root@STAR1-A:~# cat m5ovmiosetup.cmd
ldm list-bindings
ldm start-reconf primary
ldm set-core cid=0,1,2,3 primary
ldm set-mem 64g primary
ldm rm-io pci_16 primary
ldm rm-io pci_17 primary
ldm rm-io pci_18 primary
ldm rm-io pci_19 primary
ldm rm-io pci_20 primary
ldm rm-io pci_21 primary
ldm rm-io pci_22 primary
ldm rm-io pci_23 primary
ldm rm-io pci_8 primary
ldm rm-io pci_9 primary
ldm rm-io pci_10 primary
ldm rm-io pci_11 primary
ldm rm-io pci_12 primary
ldm rm-io pci_13 primary
ldm rm-io pci_14 primary
ldm rm-io pci_15 primary
ldm rm-io pci_24 primary
ldm rm-io pci_25 primary
ldm rm-io pci_26 primary
ldm rm-io pci_27 primary
ldm rm-io pci_28 primary
ldm rm-io pci_29 primary
ldm rm-io pci_30 primary
ldm rm-io pci_31 primary
ldm remove-vds primary-vds0
ldm remove-vsw primary-vsw0
ldm remove-vcc primary-vcc0
ldm list-bindings
reboot
reboot: Failed to stop svc:/application/graphical-login/gdm:default.
ldm add-vcc port-range=5001-5200 primary-vcc0 primary
ldm add-vsw net-dev=net0 primary-vsw0 primary
ldm add-vds primary-vds0 primary
ldm set-vcons port=5000 service=primary-vcc0 primary
ldm add-domain secondary
ldm set-core cid=16,18,20,22,24,26 secondary
ldm set-mem 64g secondary
ldm set-vcons port=5001 service=primary-vcc0 secondary
ldm set-var auto-boot?=false secondary
ldm add-io pci_16 secondary
ldm add-io pci_17 secondary
ldm add-io pci_18 secondary
ldm add-io pci_19 secondary
ldm add-io pci_20 secondary
ldm add-io pci_21 secondary
ldm add-io pci_22 secondary
ldm add-io pci_23 secondary
ldm bind secondary
ldm start secondary
ldm add-domain dioA
ldm set-core 12 dioA
ldm set-mem 192g dioA
ldm set-var auto-boot?=false dioA
ldm add-io pci_8 dioA
ldm add-io pci_9 dioA
ldm add-io pci_10 dioA
ldm add-io pci_11 dioA
ldm add-io pci_12 dioA
ldm add-io pci_13 dioA
ldm add-io pci_14 dioA
ldm add-io pci_15 dioA
ldm bind dioA
ldm start dioA
ldm add-domain dioB
ldm set-core 12 dioB
ldm set-mem 192g dioB
ldm set-var auto-boot?=false dioB
ldm add-io pci_24 dioB
ldm add-io pci_25 dioB
ldm add-io pci_26 dioB
ldm add-io pci_27 dioB
ldm add-io pci_28 dioB
ldm add-io pci_29 dioB
ldm add-io pci_30 dioB
ldm add-io pci_31 dioB
ldm bind dioB
ldm start dioB
ldm add-spconfig ovm-initial
svcadm enable vntsd

root@STAR1-A:~# cat m5ovmiosetup.ksh
#! /bin/ksh
#
#       Shell script to setup M5-32 OVM consisting of a Control Domain,
#       IO Domain and up to two DIO LDOMs.
#
#       Version : 1.1
#       Last Mod: 08-Nov-2013 by DLV
#       Author  : David.Visser@Oracle.com
#
#       1.0  [DLV]: Created!
#       1.1  [DLV]: Allow for flexibility in core allocation
#
#       Known Problems:
#
#       1)   Static config, bus aligned.
#       2)   Uninstall needs more work.
#
# Static variables
typeset MyName=${0##*/}
typeset Version="1.1"
typeset Update="08-Nov-2013"
typeset Comment="#"
# Control flags
typeset -i ECHO=0
typeset -i EXECUTE=1
typeset -i VERBOSE=0
typeset -i MODE=0               # Default mode is to show current config (non-destructive)
# Standard functions
_log() {
        print - "$MyName [$(date '+%d/%m/%y %H:%M:%S')] $1: $2"; return 0
}
_task() {
        if (( EXECUTE )); then $@; return $?; else return 0; fi
}
info() {
        if (( VERBOSE )); then _log INFO "$@"; fi; return 0
}
warn() {
        _log WARN "$@"; return 0
}
fail() {
        typeset -i rc=$1; shift; _log FAIL "$@"; exit $rc
}
task() {
        if (( ECHO )); then print -u 2 "$@"; fi; _task "$@"; return $?
}
chrc() {
        typeset -i rc=$1; shift; if (( $rc )); then fail $rc "$* ($rc)"; else info "$* (ok)"; fi
}
# M5-32 bus assignment variables
typeset PDomAprimary="
pci@300|pci_0
pci@340|pci_1
pci@380|pci_2
pci@3c0|pci_3
pci@400|pci_4
pci@440|pci_5
pci@480|pci_6
pci@4c0|pci_7
"
typeset PDomAsecondary="
pci@700|pci_16
pci@740|pci_17
pci@780|pci_18
pci@7c0|pci_19
pci@800|pci_20
pci@840|pci_21
pci@880|pci_22
pci@8c0|pci_23
"
typeset PDomAdioA="
pci@500|pci_8
pci@540|pci_9
pci@580|pci_10
pci@5c0|pci_11
pci@600|pci_12
pci@640|pci_13
pci@680|pci_14
pci@6c0|pci_15
"
typeset PDomAdioB="
pci@900|pci_24
pci@940|pci_25
pci@980|pci_26
pci@9c0|pci_27
pci@a00|pci_28
pci@a40|pci_29
pci@a80|pci_30
pci@ac0|pci_31
"
typeset PDomBprimary="
pci@b00|pci_32
pci@b40|pci_33
pci@b80|pci_34
pci@bc0|pci_35
pci@c00|pci_36
pci@c40|pci_37
pci@c80|pci_38
pci@cc0|pci_39
"
typeset PDomBsecondary="
pci@f00|pci_48
pci@f40|pci_49
pci@f80|pci_50
pci@fc0|pci_51
pci@1000|pci_52
pci@1040|pci_53
pci@1080|pci_54
pci@10c0|pci_55
"
typeset PDomBdioA="
pci@d00|pci_40
pci@d40|pci_41
pci@d80|pci_42
pci@dc0|pci_43
pci@e00|pci_44
pci@e40|pci_45
pci@e80|pci_46
pci@ec0|pci_47
"
typeset PDomBdioB="
pci@1100|pci_56
pci@1140|pci_57
pci@1180|pci_58
pci@11c0|pci_59
pci@1200|pci_60
pci@1240|pci_61
pci@1280|pci_62
pci@12c0|pci_63
"
# Default behaviour
set -A DBuses "PDomAprimary PDomAsecondary PDomAdioA PDomAdioB PDomBprimary PDomBsecondary PDomBdioA PDomBdioB"
set -A DNames "primary secondary dioA dioB"
set -A DCores "0,2,4,6,8,10 16,18,20,22,24,26 12 12"
set -A DMems "64g 64g 192g 192g"
set -A DNets "net0,net1,net2 net3,net4,net5 net6,net7,net8 net9,net10,net11"    # Obviously a guess, need to override
#
#       usage()
#
usage() {
        print - "
Usage   : ${MyName} [-heinuv]
Options :
    -h    Show this help usage screen.
    -e    Echo the commands to stderr.
    -i    Install (setup) domains.
    -n    Do NOT execute the commands.
    -u    Uninstall (factory-defaults) domains.
    -v    Print verbose information during execution.
Defaults:
    Echo      = OFF (commands are not displayed).
    Execute   = ON (commands are executed by default).
    Verbose   = OFF (silent operation).
Examples:
    ${MyName} -ei      - Execute and echo the commands.
    ${MyName} -vu      - Execute and display verbose information.
Version : ${Version} (${Update})
"
}
#
#       options()
#
options () {
        typeset h= opt=
        while getopts ":heinuv" opt
        do
                case $opt in
                        h)      usage
                                return 1 ;;
                        e)      (( ECHO = 1 )) ;;
                        i)      (( MODE = 1 )) ;;
                        n)      (( EXECUTE = 0 )) ;;
                        u)      (( MODE = 2 )) ;;
                        v)      (( VERBOSE = 1 )) ;;
                        \?)     fail 1 "Unknown option '$OPTARG'" ;;
                esac
        done
        return 0
}
#
#       status() - mode 0
#
status() {
        info "Current OVM configuration ..."
        task ldm list-constraints
        info "OVM service status:"
        task svcs -l ldmd
        show_plan "$DBuses"
        return 0
}
#
#       install() - mode 1
#
install() {
        info "Setting up OVM config ..."
        [ ! -z $DOMAIN_BUSES ] || fail -1 "Set environment variable \"\$DOMAIN_BUSES\" first"
        [ ! -z $DOMAIN_NAMES ] || fail -1 "Set environment variable \"\$DOMAIN_NAMES\" first"
        [ ! -z $DOMAIN_CORES ] || fail -1 "Set environment variable \"\$DOMAIN_CORES\" first"
        [ ! -z $DOMAIN_MEMS ] || fail -1 "Set environment variable \"\$DOMAIN_MEMS\" first"
        [ ! -z $DOMAIN_NETS ] || fail -1 "Set environment variable \"\$DOMAIN_NETS\" first"
        set -A DBuses $DOMAIN_BUSES
        set -A DNames $DOMAIN_NAMES
        set -A DCores $DOMAIN_CORES
        set -A DMems $DOMAIN_MEMS
        set -A DNets $DOMAIN_NETS
        # remove all buses except PDomAprimary
        [ -f /var/tmp/.${MyName} ] || first_run "$(echo $DOMAIN_BUSES | awk '{for(i=2;i<=NF;i++) print $i}')"
        second_run
        return 0
}
#
#       uninstall() - mode 2
#
uninstall() {
        info "Resetting OVM config to factory-defaults ..."
        task ldm list-bindings
        task ldm cancel-operation reconf primary
        task ldm rm-spconfig ovm-initial
        task ldm set-spconfig factory-default
        # remove state, do not task this command
        rm -f /var/tmp/.${MyName}
        task ldm list-bindings
        warn "Reboot imminent!"
        task reboot
        exit 0
}
# Helper to add a single bus
add_bus() {
        info "Add bus: $1 to $2"
        task ldm add-io $(echo $1 | awk -F'|' '{print $2}') $2
}
# Helper to remove a single bus
remove_bus() {
        info "Remove bus: $1 from $2"
        task ldm rm-io $(echo $1 | awk -F'|' '{print $2}') $2
}
# Helper to assign multiple buses
assign_buses() {
        for d in $1
        do
                for b in $(eval echo \$$d)
                do
                        add_bus $b $2
                done
        done
}
# Helper to unassign multiple buses
unassign_buses() {
        for d in $1
        do
                for b in $(eval echo \$$d)
                do
                        remove_bus $b $2
                done
        done
}
# Determine core data format
get_format() {
        (( $(echo $1 | nawk '{ print match($0, /\-/) }') )) && return 2
        (( $(echo $1 | nawk '{ print match($0, /\,/) }') )) && return 1
        return 0
}
# Add a secondary domain
add_secondary() {
        info "Adding secondary domain ..."
        task ldm add-domain $1
        get_format $2
        if (( $? )); then
                task ldm set-core cid=$2 $1
        else
                task ldm set-core $2 $1
        fi
        task ldm set-mem $3 $1
        task ldm set-vcons port=5000 service=primary-vcc0 $1
        task ldm set-var auto-boot?=false $1
        assign_buses "$4" $1
        # task ldm add-vsw net-dev=$5 secondary-vsw0 $1
        # task ldm add-vds secondary-vds0 $1
        task ldm bind $1
        task ldm start $1
}
# Add a Direct IO domain
add_dio() {
        info "Adding Direct IO domain ..."
        task ldm add-domain $1
        get_format $2
        if (( $? )); then
                task ldm set-core cid=$2 $1
        else
                task ldm set-core $2 $1
        fi
        task ldm set-mem $3 $1
        task ldm set-var auto-boot?=false $1
        assign_buses "$4" $1
        task ldm bind $1
        task ldm start $1
}
# Show plan
show_plan() {
        info "Bus assignment plan ..."
        for d in $1
        do
                info "Domain: $d, buses: $(eval echo \$$d)"
        done
}
# First run
first_run() {
        info "First run to shrink primary to minimal config ..."
        # First entry should be the primary
        task ldm list-bindings
        task ldm start-reconf primary
        get_format "${DCores[0]}"
        if (( $? )); then
                task ldm set-core cid="${DCores[0]}" primary
        else
                task ldm set-core "${DCores[0]}" primary
        fi
        task ldm set-mem "${DMems[0]}" primary
        unassign_buses "$1" primary
        task ldm remove-vds primary-vds0
        task ldm remove-vsw primary-vsw0
        task ldm remove-vcc primary-vcc0
        # create state for second run of script, do not task this command
        touch /var/tmp/.${MyName}
        task ldm list-bindings
        warn "Reboot imminent!"
        task reboot
        exit 0
}
# Second run
second_run() {
        typeset net0=$(echo ${DNets[0]} | awk -F',' '{print $1}')
        typeset net1=$(echo ${DNets[0]} | awk -F',' '{print $2}')
        typeset net2=$(echo ${DNets[0]} | awk -F',' '{print $3}')
        # info "Create network aggregriate for primary ..."
        # task dladm create-aggr -L active -l $net1 -l $net2 aggr0
        info "Second run to create secondary and DIO ldoms ..."
        task ldm add-vcc port-range=5000-5200 primary-vcc0 primary
        task ldm add-vsw net-dev=$net0 primary-vsw0 primary
        # task ldm add-vsw net-dev=aggr0 primary-vsw1 primary
        task ldm add-vds primary-vds0 primary
        # Second entry should be the secondary
        add_secondary "${DNames[1]}" "${DCores[1]}" "${DMems[1]}" "${DBuses[1]}" "${DNets[1]}"
        # Remaining entries are DIO ldoms
        (( i = 2 ))
        while (( i < ${#DBuses[@]} ))
        do
                add_dio "${DNames[i]}" "${DCores[i]}" "${DMems[i]}" "${DBuses[i]}" "${DNets[i]}"
                (( i += 1 ))
        done
        task ldm add-spconfig ovm-initial
        task svcadm enable vntsd
        task svccfg -s ldmd setprop ldmd/recovery_mode = astring: auto
        task svcadm refresh ldmd
        # remove state, do not task this command
        rm -f /var/tmp/.${MyName}
}
#
#       main()
#
options "$@"
typeset -i rc=$?
if (( $rc )); then
        exit $rc
fi
case $MODE in
        0)
                status ;;
        1)
                install ;;
        2)
                uninstall ;;
        *)
                fail 1 "Unknown execution mode" ;;
        esac
exit 0
==========
root@STAR1-A:~# cat m5ovmiouninstall.ksh
#! /bin/ksh
# Each arry must have the same number of space separated arguments
# The primary and secondary domains are assigned whole-cores, whereas the DIO ldoms are just whole-cores
# PDOMA
export DOMAIN_BUSES="PDomAprimary PDomAsecondary PDomAdioA PDomAdioB"
export DOMAIN_NAMES="primary secondary dioA dioB"
export DOMAIN_CORES="0,2,4,6,8,10 16,18,20,22,24,26 12 12"
export DOMAIN_MEMS="64g 64g 192g 192g"
export DOMAIN_NETS="net0,net1,net2 net3,net4,net5 net6,net7,net8 net9,net10,net11"
# Only run once (will reboot)
./m5ovmiosetup.ksh -vue 2>> m5ovmiosetup.cmd
# Single PDOM in the labs
exit
# PDOMB
export DOMAIN_BUSES="PDomBprimary PDomBsecondary PDomBdioA PDomBdioB"
export DOMAIN_NAMES="primary secondary dioA dioB"
export DOMAIN_CORES="0,2,4,6,8,10 16,18,20,22,24,26 12 12"
export DOMAIN_MEMS="64g 64g 192g 192g"
export DOMAIN_NETS="net0,net1,net2 net3,net4,net5 net6,net7,net8 net9,net10,net11"
# Only run once (will reboot)
./m5ovmiosetup.ksh -vue 2>> m5ovmiosetup.cmd
=============
root@STAR1-A:~# cat old_m5ovmiosetup.ksh
#! /bin/ksh
#
#       Shell script to setup M5-32 OVM consisting of a Control Domain,
#       IO Domain and up to two DIO LDOMs.
#
#       Version : 1.0
#       Last Mod: 01-Nov-2013 by DLV
#       Author  : David.Visser@Oracle.com
#
#       1.0  [DLV]: Created!
#
#       Known Problems:
#
#       1)      Static config, bus aligned
#
# Static variables
typeset MyName=${0##*/}
typeset Version="1.0"
typeset Update="01-Nov-2013"
typeset Comment="#"
# Control flags
typeset -i ECHO=0
typeset -i EXECUTE=1
typeset -i VERBOSE=0
typeset -i MODE=0               # Default mode is to show current config (non-destructive)
# Standard functions
_log() {
        print - "$MyName [$(date '+%d/%m/%y %H:%M:%S')] $1: $2"; return 0
}
_task() {
        if (( EXECUTE )); then $@; return $?; else return 0; fi
}
info() {
        if (( VERBOSE )); then _log INFO "$@"; fi; return 0
}
warn() {
        _log WARN "$@"; return 0
}
fail() {
        typeset -i rc=$1; shift; _log FAIL "$@"; exit $rc
}
task() {
        if (( ECHO )); then print -u 2 "$@"; fi; _task "$@"; return $?
}
chrc() {
        typeset -i rc=$1; shift; if (( $rc )); then fail $rc "$* ($rc)"; else info "$* (ok)"; fi
}
# M5-32 bus assignment variables
typeset PDomAprimary="
pci@300|pci_0
pci@340|pci_1
pci@380|pci_2
pci@3c0|pci_3
pci@400|pci_4
pci@440|pci_5
pci@480|pci_6
pci@4c0|pci_7
"
typeset PDomAsecondary="
pci@700|pci_16
pci@740|pci_17
pci@780|pci_18
pci@7c0|pci_19
pci@800|pci_20
pci@840|pci_21
pci@880|pci_22
pci@8c0|pci_23
"
typeset PDomAdioA="
pci@500|pci_8
pci@540|pci_9
pci@580|pci_10
pci@5c0|pci_11
pci@600|pci_12
pci@640|pci_13
pci@680|pci_14
pci@6c0|pci_15
"
typeset PDomAdioB="
pci@900|pci_24
pci@940|pci_25
pci@980|pci_26
pci@9c0|pci_27
pci@a00|pci_28
pci@a40|pci_29
pci@a80|pci_30
pci@ac0|pci_31
"
typeset PDomBprimary="
pci@b00|pci_32
pci@b40|pci_33
pci@b80|pci_34
pci@bc0|pci_35
pci@c00|pci_36
pci@c40|pci_37
pci@c80|pci_38
pci@cc0|pci_39
"
typeset PDomBsecondary="
pci@f00|pci_48
pci@f40|pci_49
pci@f80|pci_50
pci@fc0|pci_51
pci@1000|pci_52
pci@1040|pci_53
pci@1080|pci_54
pci@10c0|pci_55
"
typeset PDomBdioA="
pci@d00|pci_40
pci@d40|pci_41
pci@d80|pci_42
pci@dc0|pci_43
pci@e00|pci_44
pci@e40|pci_45
pci@e80|pci_46
pci@ec0|pci_47
"
typeset PDomBdioB="
pci@1100|pci_56
pci@1140|pci_57
pci@1180|pci_58
pci@11c0|pci_59
pci@1200|pci_60
pci@1240|pci_61
pci@1280|pci_62
pci@12c0|pci_63
"
# Default behaviour
set -A DBuses "PDomAprimary PDomAsecondary PDomAdioA PDomAdioB PDomBprimary PDomBsecondary PDomBdioA PDomBdioB"
set -A DNames "primary secondary dioA dioB"
set -A DCores "0,2,4,6,8,10 16,18,20,22,24,26 12 12"
set -A DMems "64g 64g 192g 192g"
set -A DNets "net0,net1,net2 net3,net4,net5 net6,net7,net8 net9,net10,net11"    # Obviously a guess, need to override
#
#       usage()
#
usage() {
        print - "
Usage   : ${MyName} [-heinuv]
Options :
    -h    Show this help usage screen.
    -e    Echo the commands to stderr.
    -i    Install (setup) domains.
    -n    Do NOT execute the commands.
    -u    Uninstall (factory-defaults) domains.
    -v    Print verbose information during execution.
Defaults:
    Echo      = OFF (commands are not displayed).
    Execute   = ON (commands are executed by default).
    Verbose   = OFF (silent operation).
Examples:
    ${MyName} -ei      - Execute and echo the commands.
    ${MyName} -vu      - Execute and display verbose information.
Version : ${Version} (${Update})
"
}
#
#       options()
#
options () {
        typeset h= opt=
        while getopts ":heinuv" opt
        do
                case $opt in
                        h)      usage
                                return 1 ;;
                        e)      (( ECHO = 1 )) ;;
                        i)      (( MODE = 1 )) ;;
                        n)      (( EXECUTE = 0 )) ;;
                        u)      (( MODE = 2 )) ;;
                        v)      (( VERBOSE = 1 )) ;;
                        \?)     fail 1 "Unknown option '$OPTARG'" ;;
                esac
        done
        return 0
}
#
#       status() - mode 0
#
status() {
        info "Current OVM configuration ..."
        task ldm list-constraints
        info "OVM service status:"
        task svcs -l ldmd
        show_plan "$DBuses"
        return 0
}
#
#       install() - mode 1
#
install() {
        info "Setting up OVM config ..."
        [ ! -z $DOMAIN_BUSES ] || fail -1 "Set environment variable \"\$DOMAIN_BUSES\" first"
        [ ! -z $DOMAIN_NAMES ] || fail -1 "Set environment variable \"\$DOMAIN_NAMES\" first"
        [ ! -z $DOMAIN_CORES ] || fail -1 "Set environment variable \"\$DOMAIN_CORES\" first"
        [ ! -z $DOMAIN_MEMS ] || fail -1 "Set environment variable \"\$DOMAIN_MEMS\" first"
        [ ! -z $DOMAIN_NETS ] || fail -1 "Set environment variable \"\$DOMAIN_NETS\" first"
        set -A DBuses $DOMAIN_BUSES
        set -A DNames $DOMAIN_NAMES
        set -A DCores $DOMAIN_CORES
        set -A DMems $DOMAIN_MEMS
        set -A DNets $DOMAIN_NETS
        # remove all buses except PDomAprimary
        [ -f /var/tmp/.${MyName} ] || first_run "$(echo $DOMAIN_BUSES | awk '{for(i=2;i<=NF;i++) print $i}')"
        second_run
        return 0
}
#
#       uninstall() - mode 2
#
uninstall() {
        info "Resetting OVM config to factory-defaults ..."
        task ldm list-bindings
        task ldm cancel-operation reconf primary
        task ldm rm-spconfig ovm-initial
        task ldm set-spconfig factory-default
        # remove state, do not task this command
        rm -f /var/tmp/.${MyName}
        task ldm list-bindings
        warn "Reboot imminent!"
        task reboot
        exit 0
}
# Helper to add a single bus
add_bus() {
        info "Add bus: $1 to $2"
        task ldm add-io $(echo $1 | awk -F'|' '{print $2}') $2
}
# Helper to remove a single bus
remove_bus() {
        info "Remove bus: $1 from $2"
        task ldm rm-io $(echo $1 | awk -F'|' '{print $2}') $2
}
# Helper to assign multiple buses
assign_buses() {
        for d in $1
        do
                for b in $(eval echo \$$d)
                do
                        add_bus $b $2
                done
        done
}
# Helper to unassign multiple buses
unassign_buses() {
        for d in $1
        do
                for b in $(eval echo \$$d)
                do
                        remove_bus $b $2
                done
        done
}
# Add a secondary domain
add_secondary() {
        info "Adding secondary domain ..."
        task ldm add-domain $1
        task ldm set-core cid=$2 $1
        task ldm set-mem $3 $1
        task ldm set-vcons port=5001 service=primary-vcc0 $1
        task ldm set-var auto-boot?=false $1
        assign_buses "$4" $1
        # task ldm add-vsw net-dev=$5 secondary-vsw0 $1
        # task ldm add-vds secondary-vds0 $1
        task ldm bind $1
        task ldm start $1
}
# Add a Direct IO domain
add_dio() {
        info "Adding Direct IO domain ..."
        task ldm add-domain $1
        task ldm set-core $2 $1
        task ldm set-mem $3 $1
        task ldm set-var auto-boot?=false $1
        assign_buses "$4" $1
        task ldm bind $1
        task ldm start $1
}
# Show plan
show_plan() {
        info "Bus assignment plan ..."
        for d in $1
        do
                info "Domain: $d, buses: $(eval echo \$$d)"
        done
}
# First run
first_run() {
        info "First run to shrink primary to minimal config ..."
        # First entry should be the primary
        task ldm list-bindings
        task ldm start-reconf primary
        task ldm set-core cid="${DCores[0]}" primary
        task ldm set-mem "${DMems[0]}" primary
        unassign_buses "$1" primary
        task ldm remove-vds primary-vds0
        task ldm remove-vsw primary-vsw0
        task ldm remove-vcc primary-vcc0
        # create state for second run of script, do not task this command
        touch /var/tmp/.${MyName}
        task ldm list-bindings
        warn "Reboot imminent!"
        task reboot
        exit 0
}
# Second run
second_run() {
        typeset net0=$(echo ${DNets[0]} | awk -F',' '{print $1}')
        typeset net1=$(echo ${DNets[0]} | awk -F',' '{print $2}')
        typeset net2=$(echo ${DNets[0]} | awk -F',' '{print $3}')
        # info "Create network aggregriate for primary ..."
        # task dladm create-aggr -L active -l $net1 -l $net2 aggr0
        info "Second run to create secondary and DIO ldoms ..."
        task ldm add-vcc port-range=5001-5200 primary-vcc0 primary
        task ldm add-vsw net-dev=$net0 primary-vsw0 primary
        # task ldm add-vsw net-dev=aggr0 primary-vsw1 primary
        task ldm add-vds primary-vds0 primary
        # Second entry should be the secondary
        add_secondary "${DNames[1]}" "${DCores[1]}" "${DMems[1]}" "${DBuses[1]}" "${DNets[1]}"
        # Remaining entries are DIO ldoms
        (( i = 2 ))
        while (( i < ${#DBuses[@]} ))
        do
                add_dio "${DNames[i]}" "${DCores[i]}" "${DMems[i]}" "${DBuses[i]}" "${DNets[i]}"
                (( i += 1 ))
        done
        task ldm add-spconfig ovm-initial
        task svcadm enable vntsd
        # remove state, do not task this command
        rm -f /var/tmp/.${MyName}
}
#
#       main()
#
options "$@"
typeset -i rc=$?
if (( $rc )); then
        exit $rc
fi
case $MODE in
        0)
                status ;;
        1)
                install ;;
        2)
                uninstall ;;
        *)
                fail 1 "Unknown execution mode" ;;
        esac
exit 0
================
Performance monitoring :-
root@p60db # more /scripts/perf/perf.sh
#!/usr/bin/bash
DATE=`date +%d%b%Y`
date | tee -a /scripts/perf/log/prstatop.$DATE
prstat -a 5 10 2>&1 | tee -a /scripts/perf/log/prstatop.$DATE &
date | tee -a /scripts/perf/log/sarop.$DATE
sar 5 10 | tee -a /scripts/perf/log/sarop.$DATE &
date | tee -a /scripts/perf/log/vmstat1.$DATE
vmstat -pS 5 10 | tee -a /scripts/perf/log/vmstat1.$DATE &
date | tee -a /scripts/perf/log/vmstat.$DATE
vmstat 5 10 | tee -a /scripts/perf/log/vmstat.$DATE
===
to find the files and removing
#find /var/spool/mqueue/ -mtime +1 -exec rm {} \


 

1 comment:

  1. Are you trying to earn cash from your traffic by using popunder ads?
    If so, did you take a look at Clickadu?

    ReplyDelete