27 Jul 2011

Get serial number from command line

To obtain the serial number of the server from Solaris command line. HP Blades


/usr/sbin/smbios -t 1

On  linux run

dmidecode -t system

07 Jul 2011

Hanging cron jobs

I found a application user that was using cron  to monitor the app every minute of the day.
At 03H10 the logadm would run and rotates cron's log file. On the odd occasion this would occur the same time the app user runs a script vi cron and cause logadm & cron into a dead lock situation and prevent cron & logadm from processing any further requests.

To fix the  problem search for all PIDs & PPIDs associated with logadm and look for the defunct process's. This would normally indicate the offending process.


for PID in $( ps -ef | grep logad[m] | awk '{print $3}')
do
        PIDS="${PID}|${PID}"
done
ps -ef | egrep "${PIDS}"
 BAD_APP 18635 14216   0        - ?           0:00 <defunct>
    root 14216     1   0   Jul 04 ?           0:07 /usr/sbin/cron
     sys 18632 14216   0        - ?           0:00 <defunct>
     sys 19104 14216   0        - ?           0:01 <defunct>
    root 20894 20090   0 11:33:08 pts/25      0:00 egrep 14216|14216
    root 18629 14216   0   Jul 06 ?           0:00 sh -c /usr/sbin/logadm


Running:

# svcs cron
STATE          STIME    FMRI
online         Nov_02   svc:/system/cron:default   

You will notice all looks well and it is not :-(
Restart cron and all the held back jobs will start running again.

# svcadm restart cron

22 Jun 2011

Keep users history.

Set the default shell that users use to bash.
http://stanlo-solaris.blogspot.com/search/label/useradd


Next add this to your /etc/profile file

HISTTIMEFORMAT='%F %T '
export HISTTIMEFORMAT

Then create a .bash_logout script for the user.
#----------------------------------------------------------
#               Record bash history
#
#       Written : Stan Lovisa
#       Date    : 29-01-2010
#       Mod     :
#
#----------------------------------------------------------
TSATMP=$(date +%Y%M%d-%T)
if [ ! -d ~/.hist ]
then
        mkdir ~/.hist
fi
who am i > ~/.hist/$$.bash_history.${TSATMP}
history >> ~/.hist/$$.bash_history.${TSATMP}
banner bye

Each time the user logs out a history file is created in $HOME/.hist

Sample output:

480  2011-06-21 14:44:24 lr
481  2011-06-21 14:44:29 l tmp/
482  2011-06-21 14:44:35 l dat
483  2011-06-21 14:44:42 cd dat
484  2011-06-21 14:44:44 c
485  2011-06-21 14:44:44 l
486  2011-06-21 14:44:50 l 2011/
487  2011-06-21 14:44:56 ls 2011/
488  2011-06-21 14:45:07 cd ../..
489  2011-06-21 14:45:09 l tmp/
490  2011-06-21 14:45:17 lf tmp
491  2011-06-21 14:45:25 lf /tmp
492  2011-06-21 14:46:05 digs -x 172.19.1.50
493  2011-06-21 18:06:09 . s.bashrc
494  2011-06-21 18:06:20 ssh stl@suse-dell
495  2011-06-22 08:04:00 . s.bashrc
496  2011-06-22 08:04:00 c
497  2011-06-22 08:04:03 history
498  2011-06-22 08:04:13 cd /etc/
499  2011-06-22 08:04:15 vi profile
500  2011-06-22 08:07:38 cd
501  2011-06-22 08:07:41 vi .profile
502  2011-06-22 08:07:53 l
503  2011-06-22 08:07:56 lf
504  2011-06-22 08:08:10 vi .bash_logout
505  2011-06-22 08:11:41 history

useradd

Adding a user in Solaris:
Changing the defaults settings in this file:

/usr/sadm/defadduser

defgroup=1
defgname=other
defparent=/home
defskel=/etc/skel
defshell=/bin/bash
definact=0
defexpire=
defauthorization=
defprofile=
defproj=3
defprojname=
defrole=

I searched hi & lo for this file. I could not find it documented any where, so here it is.

08 Jun 2011

crle

Manage Library path

Display current library paths
crle 
 Configuration file [version 4]: /var/ld/ld.config
  Default Library Path (ELF):   /lib:/usr/lib:/opt/csw/lib
  Trusted Directories (ELF):    /lib/secure:/usr/lib/secure  (system default)

Update library path

crle -l /lib:/usr/lib:/opt/csw/lib

12 Apr 2011

pools

Create new pool resources. Limit the number of cpus.

poolcfg -c discover
poolcfg -c 'create pset mypool-pset  (uint pset.min=1 ; uint pset.max=2)'
poolcfg -c 'create pool mypool-pool'
poolcfg -c 'associate pool mypool-pool (pset mypool-pset)'

Create new pool resources.

pooladm -c

View changes.

poolladm | pg

zones: capped resources

Cap memory.

zonecfg -z zone
zonecfg:zone> add capped-memory
zonecfg:zonecapped-memory> set physical=2G
zonecfg:zonecapped-memory> end
zonecfg:zone> verify
zonecfg:zone> commit
zonecfg:zone> exit


To cap the number of cpus.


zonecfg -z zone
zonecfg:zone> add dedicated-cpu
zonecfg:zone:dedicated-cpu> set ncpus=1-2
zonecfg:zone:dedicated-cpu> set importance=10
zonecfg:zone:dedicated-cpu> end
zonecfg:zone> verify
zonecfg:zone> commit
zonecfg:zone> exit

zfs: create new filesystem

Create new filesystem

zfs create tank/data

Set the mount point.

zfs set mountpoint=/data tank/data

05 Jan 2011

Install perl modules on Solaris

- /usr/perl5/bin/perlgcc Makefile.PL
- /usr/sfw/bin/gmake
- /usr/sfw/bin/gmake test
- /usr/sfw/bin/gmake install