1.31.2012

Solaris: send mail with attachment from Solaris command line


I like to use this function bellow in my profile to send files to my mail account as attachements; to use in your profile simply replace EMAIL@ADDRESS with your email address  on a mail enabled host:

function  mailme(){


        /usr/bin/uuencode $(echo $1) $(echo $1)|/usr/bin/mailx -s "mailme from $(/usr/bin/hostname)" EMAIL@ADDRESS
}

1.30.2012

Redhat: Swapfile

Steps needed to create a 1K swapfile:


[root@prod_app]~# df -h /local
Filesystem            Size  Used Avail Use% Mounted on
/dev/cciss/c1d0p7      26G   21G  4.1G  84% /local

[root@prod_app]~# dd if=/dev/zero of=/local/swapfile.1k bs=1024 count=1

[root@prod_app]~# mkswap /local/swapfile.1k

[root@prod_app]~# ls -l /local/swapfile.1k

[root@prod_app]~# swapon /local/swapfile.1k

Redhat: RPM commands

Installing a RPM
# rpm -ivh package-1.0-2.i386.rpm

Note: this installs the rpm package, version 1.0-2, i386 architecture 


Removing a RPM
# rpm -ev package

Display information about a package
# rpm -qi setup-2.5.37-1.3
Name : setup Relocations: (not relocatable) Version : 2.5.37 Vendor: Red Hat, Inc. Release : 1.3 Build Date: Mon 20 Jun 2005 04:40:37 PM EDT Install Date: Thu 15 Feb 2007 09:28:36 AM EST Build Host: decompose.build.redhat.com Group : System Environment/Base Source RPM: setup-2.5.37-1.3.src.rpm Size : 37056 License: public domain Signature : DSA/SHA1, Thu 30 Jun 2005 01:27:57 PM EDT, Key ID 219180cddb42a60e Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> Summary : A set of system configuration and setup files. Description : The setup package contains a set of important system configuration and setup files, such as passwd, group, and profile.


Display file associated with a package
# rpm -ql setup-2.5.37-1.3 
/etc/aliases 
/etc/bashrc 
/etc/csh.cshrc 
/etc/csh.login 
/etc/environment 
/etc/exports 
/etc/filesystems 
/etc/group 
/etc/host.conf 
/etc/hosts.allow 
/etc/hosts.deny 
/etc/inputrc 
/etc/motd 
/etc/passwd 
/etc/printcap 
/etc/profile 
/etc/profile.d 
/etc/protocols 
/etc/securetty 
/etc/services 
/etc/shells 
/usr/share/doc/setup-2.5.37 
/usr/share/doc/setup-2.5.37/uidgid


Locate which rpm a file comes from
# rpm -qf /etc/passwd 
setup-2.5.37-1.3


Display all installed packages
# rpm -qa|more 
basesystem-8.0-4 
beecrypt-3.1.0-6 
expat-1.95.7-4 
....

Article: Raspberry Pi

Can't wait for the release of RaspberryPi A new ARM GNU Linux computer, check it out!

1.25.2012

Article: Stuxnet

Very cool article on Stuxnet a must read

VCS: PanicSystemOnDGLoss

This is a configurable option that is on by default in the 5.0 version of VCS. If a disk group becomes completely invisible to a VCS node PanicSystemOnDGLoss option will panic the system immediately; the idea being it will improve recovery time as the service groups will start failing over to the remote side faster.

The down side - on extremely busy cluster nodes the DG agent can fail to complete in the allotted time and triger this option; which is how I learned about it. So, In the event that a cluster node appears to crash for seemingly no reason check the following URL for details.


To check if the VCS option is turned on, run the following command (1 is enabled, 0 is disabled):

# grep "boolean Panic" /etc/VRTSvcs/conf/config/types.cf
boolean PanicSystemOnDGLoss = 0

How to change the default value for PanicSystemOnDGLoss:
# haconf -makerw
# haattr -default DiskGroup PanicSystemOnDGLoss 0
# haconf -dump -makero

Confirm that both the temporary and persistent definitions have been reset to 0:
# haattr -display DiskGroup |grep Panic
PanicSystemOnDGLoss [boolean/scalar] = 0

# grep "boolean Panic" /etc/VRTSvcs/conf/config/types.cf
boolean PanicSystemOnDGLoss = 0


How to change the value for this attribute for individual DiskGroup resources:
In certain cases, it may be necessary to change this attribute to 1 for few selected DiskGroup resources.

# haconf -makerw
# hares -display DG_Res1 | grep PanicSystemOnDGLoss
DG_Res1 PanicSystemOnDGLoss global 0
# hares -modify DG_Res1 PanicSystemOnDGLoss 1
# hares -display DG_Res1 | grep PanicSystemOnDGLoss
DG_Res1 PanicSystemOnDGLoss global 1
# haconf -dump -makero


VXFS: Idle LUN Probing and NetApp


If you are seeing a LUN go online-offline over and over in your DMP log and you are using NetApp for your back end storage it might be due to Veritas' idle LUN probing feature.

The idle LUN probing sub-module of VXFS feature is designed to allow volume manager to establish state information for paths that are not current receiving any IO activity. However it does not work with NetApp arrays; to turn this option off on a system with NetApp LUNs issue the following command that is not system impacting. See the following URL for details:
           
# vxdmpadm settune dmp_probe_idle_lun=off

VCS: and the mount locked issue V-3-26360


V-3-26360 This error code is observed when attempting to umount a filesystem mounted under VCS control and is accompanied with the error text “file system /opt/oracle has been mount locked”. To umount the file system complete the following tasks:

            # /opt/VRTS/bin/umount -o mntunlock=VCS /opt/oracle

V-3-21705 This error code is observed when attempting to umount a VCS mount locked filesystem; which fails even with the previous mentioned “mntunlock” option. The workaround is to lock the file system again using fsadm with the same lock name and then attempt to umount the filesystem again.

            # fsadm -o mntunlock=VCS /nfsvol2 
# fsadm -o mntlock=VCS /nfsvol2 

# /opt/VRTS/bin/umount -o mntunlock=VCS /opt/oracle

1.24.2012

Solaris 10: Zone config save to zone path

Here is a script I wrote to save the configuration of a running zone to it's zone path. As all of our zones are running on sparse root on SAN devices, we can moves zones around via SRDF/RecoverPoint between datacenters or DG export/import locally). This script, which we run from cron ensures that we have a good zone configuration if we need to modify an old configuration on the new destination. Simple, but useful.

Google Doc Link

Solaris 10: Zones gathering network configuration

Here is a script I wrote to gather all the network configuration information for a system and all of it's supported zones. check it out.  You get a nice little print out of the Zone, the NIC used, IP address, broadcast address, netmask and the range of the subnet where the IP exists. We don't do a lot of class C networks so I don't really know how well this will work on a C.....


A word of caution: when I was playing around creating this script I whacked the entire network configuration of the server I was testing on. ifconfig is your friend but can also be a deadly enemy.....


Google Doc Link

Solaris 10: Service Summary

Here is a mini script that I wrote to summaries all the output of svcs command; not too useful, but check it out:

Google Doc Link

UNIX: Checking password expiration date /etc/shadow

Here is a script I wrote to check the expiration date of a password based on it's /etc/shadow entry. Truth be told - I jacked the awk statement from the web but it was such a long time ago I forget where. Anyway it will tell you if the password is expired or how many days until the password expires. I don't know what it would do if there was no password again; hmmmm

Google Doc Link

Solaris: check for a list of packages

We get a lot of requests from our security team to check our Solaris machines for some critical patch; which 99% of the time has already been obsoleted by another patch. These requests kept occurring so I created this simple script to see if the patch is installed, has been superseded or obsoleted. Check it out.

Google Doc Link

Solaris 10: Server Hardware Path to Physical location

Wrote a little script to determine the physical locations of devices in a SUN server based on the hardware path;   to assist in a datacenter move project I got involved with at work. It's a hack job for sure; the case statements are a little brute force in nature and probably could be cleaned up significantly. The functions for each server type probably would be better in their own files but never needed to get that in depth with it.

The script seems to work reasonable well in Solaris 10 for the servers we are using at work (mainly T and M series and some older E6900).  This wiki was super helpful in getting the script off the ground; and contains a lot of hardware path information if anyone wants to extend the script to run against other server types. Check it out, any input would be appreciated.

Google Doc Link