Check db2 backup

Here a usefull script to check backup on all dbs in a db2 instance.
It can be used with monitoring products as zabbix or nagios.

 
#!/bin/sh
INS=$1
 
NOW=`date -d '1 day ago' '+%Y%m%d'`
 
 
UNIQUE=`date +%Y%m`
DBS=/tmp/dbs.$UNIQUE
OUTZ=/tmp/outfordbs.$UNIQUE
 
su - $INS -c "db2 list database directory" | grep alias | awk '{ print $4 }' > $DBS
 
while read LN; do
  RESULT=$(su - $INS -c " db2 list history backup since $NOW for $LN" | grep 'B  D' -m 1 | awk '{print $3}')
  if [ -z "${RESULT}" ]; then
   RESULT=" : !!!!!!!!!!!!!! !!!!!!!!!!!!!! ERROR"
  fi
  echo $LN $RESULT >> $OUTZ
done < $DBS
 
cat $OUTZ
rm $DBS
rm $OUTZ

Imagemagick power resizer command

This command is usefull to resize only images greater than x in a folder.It put resized images in a folder called thumbs but you can convert file implace deleting “thumb/” string.

1
for i in `ls *.jpg`; do convert $i -resize 800x800\> thumb/$i ; done

Lvm Extend Volume Group adding new Disk

These are the step to add space to and existing Logical Volume on a Volume Group:

1) add disk and perform  rescan-scsi-bus.sh
2) Add Physical Volume available for LVM:

pvcreate (-t)* /dev/sdc

3) Exteng the volume group (here namend system) with new create physical volume:

vgextend (-t)* system /dev/sdc

4) Extend target logical volume (here named /dev/system/opt) with new space (here 10gb):

lvextend -L +10G -t /dev/system/opt

5) verify :

lvmdisplay

6) In the end you have to resize physical space :

resize2fs /dev/system/opt

 

*Always by tiping -t you can test command before execute on production server.