Monday, July 26, 2010

vmstat command -free memory

#vmstat command -free memory

vmstat 5 2|awk '{print $5}'|sort |head -n 1|xargs echo "Free Memory in Kbytes is"

Solaris vmstat command



Fields explained.

kthr || Report the number of kernel threads in each of the three following states:

r || the number of kernel threads in run queue

b || the number of blocked kernel threads that are waiting for
resources I/O, paging, and so forth

w || the number of swapped out light-weight processes (LWPs) that are
waiting for processing resources to finish.

swap || available swap space (Kbytes)
free || size of the free list (Kbytes)

Solaris prstat command


Solaris prstat

Fields explained.

PID :- The process ID of the process.
RSS :- The resident set size of the process
STATE:- The state of the process
PRI :- The priority of the process. Larger numbers mean higher
priority.
NICE :- Nice value used in priority computation.
CPU :- The percentage of recent CPU time used by the process.

Thursday, July 15, 2010

sed command - 's' for Subtitution.

--------------------------------
The most useful `sed` utility is s i think. ie subtitution.

Here is one example.

1)
+$ echo "dim" | sed s/dim/light/
light
+$

if the syntax is wrong;

+$ echo "dim" | sed s/dim/light
sed: command garbled: s/dim/light

2)

+$ cat file1
boy

+$ sed s/boy/girl/ file1 > file2

+$ cat file2
girl

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

Wednesday, July 14, 2010

Network Link status Script

#!/bin/bash
#Scrit to check the link status.

#Date
date=`date |awk {'print $3"-"$2"-"$6"-"$4'}`
REPORT="/home/yourhome/network/report/report.log"
SUBJECT="Ping request fails on $date."

EMAILID="yourname@yourdomain.com"
EMAILFILE="/home/yourhome/network/email/email_file"
HOST="172.222.165.1"

#Ping to gateway.

COUNT=`ping -c 9 $HOST -w 10 |grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }'`

if [ $COUNT -gt 6 ]

then

echo "Link is up" >> /dev/null
exit 0
else

echo "Ping request failed on $date IST" >> $REPORT | mail -s "$SUBJECT" $EMAILID < $EMAILFILE
exit 1
fi

echo $?

Tuesday, July 13, 2010

Mailx -Sending mails with Attachment.

|Mailx Sending mails with attachment. (Script)|
--------------------------

#!/bin/bash
#Date
DATE=`date |awk '{print $3"-"$2"-"$6}'`

#copy the file for attaching.

/usr/bin/cp /home/yourhome/etc/postfix/tls_policy /tmp/tls_policy

#Here is your lines for attaching files with message body.
#`cat` file you need as a body of message. `uuencode` to attach and mailx to send.

(cat /etc/postfix/tls_plicy_report_mail

/opt/csw/bin/uuencode /tmp/tls_policy tls_policy.report

) | /usr/bin/mailx -s "Quarterly tls_policy Report dated $DATE" yourname@yourdomain.com

exit


####################################
#Where:

#+$ cat /etc/postfix/tls_policy_report_mail

#This is an automated email generated from POSTFIX server.
#Please find attached the tls_policy file from production for your compliance review.

#Regards,
#IT team.
#####################################
___________________________________________________