Monday, April 27, 2015

MegaCli script to check controller status..........

#!/bin/sh
CONT="a0"
STATUS=0
MEGACLI=/opt/MegaRAID/MegaCli/MegaCli64

echo -n "Checking RAID status on "
hostname
for a in $CONT
 do

   NAME=`$MEGACLI -AdpAllInfo -$a |grep "Product Name" | cut -d: -f2`
   echo "Controller $a: $NAME"
   noonline=`$MEGACLI PDList -$a | grep Online | wc -l`
   echo "No of Physical disks online : $noonline"
   DEGRADED=`$MEGACLI -AdpAllInfo -a0  |grep "Degrade"`
   echo $DEGRADED
   NUM_DEGRADED=`echo $DEGRADED |cut -d" " -f3`
   [ "$NUM_DEGRADED" -ne 0 ] && STATUS=1
   FAILED=`$MEGACLI -AdpAllInfo -a0  |grep "Failed Disks"`
   echo $FAILED
   NUM_FAILED=`echo $FAILED |cut -d" " -f4`
   [ "$NUM_FAILED" -ne 0 ] && STATUS=1

 done

exit $STATUS

Python script to map devices with host adapter

#!/bin/env python

import glob
import os,sys
import re

if sys.version_info < (2, 6) and sys.version_info < (2, 7):
        print "This is not valid version"
        sys.exit()

if sys.platform != "linux2":
print "This is not valid OS"
sys.exit()

os.chdir('/sys/block/')

#dev_list = ['sd.*','mmcblk*']


def size(dev):
    nr_sectors = open(dev+'/size').read().rstrip('\n')
    sect_size = open(dev+'/queue/hw_sector_size').read().rstrip('\n')

    # The sect_size is in bytes, so we convert it to GiB and then send it back
    return (float(nr_sectors)*float(sect_size))/(1024.0*1024.0*1024.0)


def device_detail():
        for dev in glob.glob('/sys/block/sd*'):
                vendor_name = open(dev+'/device/vendor','r').read().rstrip('\n')
                Read_link = os.readlink(dev).split('/')[4]
                print ('Device {0}:: Size {1} GB :: Vendor {2}:: Controller {3}'.format(dev, size (dev), vendor_name, Read_link))


if __name__ =='__main__':
        device_detail()


e.g  
Saved file as disk_info.py

[root@oralinux3 tmp]# ./disk_info.py
Device /sys/block/sda:: Size 20.0 GB :: Vendor VMware, :: Controller host2
Device /sys/block/sdc:: Size 1.0 GB :: Vendor VMware, :: Controller host2
Device /sys/block/sdb:: Size 1.0 GB :: Vendor VMware, :: Controller host2
Device /sys/block/sdd:: Size 1.0 GB :: Vendor VMware, :: Controller host2




How to exclude local disks from VxDMP

Excluding local disk from monitoring

[DEV][root@server1 bin]# vxdmpadm getctlr
LNAME     PNAME                                    VENDOR               CTLR-ID
=============================================================================================
c4        c4                                       -                    -
c0        c0                                       Emulex               10:00:00:90:fa:xx:xx:xx
c2        c2                                       Emulex               10:00:00:90:fa:yy:yy:yy
[DEV][root@server1 bin]# A
[DEV][root@server1 bin]# vxdmpadm getctlr | grep "c4"
c4        c4                                       -                    -

[DEV][root@server1 bin]# vxdmpadm getctlr | grep c4 | awk '{print $1}' | xargs -I {} vxdmpadm exclude vxvm ctlr={}
[DEV][root@server1 bin]# vxdmpadm getctlr
LNAME     PNAME                                    VENDOR               CTLR-ID
=============================================================================================
c0        c0                                       Emulex               10:00:00:90:fa:xx:xx:xx
c2        c2                                       Emulex               10:00:00:90:fa:yy:yy:yy

Above given solution will work from SF 5.0 onward....

Increase swap memory utilization

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char** argv) {
    int max = -1;
    int mb = 0;
    char* buffer;

    if(argc > 1)
        max = atoi(argv[1]);

    while((buffer=malloc(1024*1024)) != NULL && mb != max) {
        memset(buffer, 0, 1024*1024);
        mb++;
        printf("Allocated %d MB\n", mb);
        sleep(1);
    }      
return 0;
}
Save the file on Linux with filename.c
Your program name will be "memeater".
Compile your code as under:
gcc filename.c -o memeater --you could specify desired name here....
execute the code: "./memeater". Once it is done you will see progress like,
[root@oralinux3 tmp]# ./memeater
Allocated 1 MB
Allocated 2 MB
Allocated 3 MB
Allocated 4 MB
Allocated 5 MB
Allocated 6 MB
Allocated 7 MB
Allocated 8 MB
Allocated 9 MB
Allocated 10 MB
Allocated 11 MB
Allocated 12 MB
Allocated 13 MB
# top -M
top - 21:00:09 up  1:43,  2 users,  load average: 0.02, 0.01, 0.00
Tasks: 119 total,   1 running, 118 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.2%sy,  0.0%ni, 99.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  1867.559M total,  279.988M used, 1587.570M free,   55.551M buffers
Swap: 3999.992M total,   17.824M used, 3982.168M free,   34.516M cached