August 2014
M T W T F S S
 123
45678910
11121314151617
18192021222324
25262728293031

Categories

August 2014
M T W T F S S
 123
45678910
11121314151617
18192021222324
25262728293031

shell to get the process usage in MB

#!/bin/bash ps -A -o pid,rss,command | grep nginx | grep -v grep | awk ‘{total+=$2}END{printf(“nginx=%dMb\n”, total/1024)}’ ps -A -o pid,rss,command | grep php-fpm | grep -v grep | awk ‘{total+=$2}END{printf(“php-fpm=%dMb\n”, total/1024)}’ ps -A -o pid,rss,command | grep mysqld | grep -v grep | awk ‘{total+=$2}END{printf(“mysql=%dMb\n”, total/1024)}’ ps -A -o pid,rss,command | grep transmission-da | grep […]

TOP 12 ‘PS’ PERFORMANCE COMMANDS

TOP 12 ‘PS’ PERFORMANCE COMMANDS

admin@UM 02:03 AIX, Unix I use following ps commands in order to check for performance probelms: 1) Displaying top CPU_consuming processes:

# ps aux|head -1; ps aux|sort -rn +2|head -10 2) Displaying top 10 memory-consuming processes:

# ps aux|head -1; ps aux|sort -rn +3|head 3) Displaying process in order […]

LINUX MEMORY

Find Memory Usage

System memory used and free

Total Used and Free Memory in MBytes (in that order)

free -m|grep “buffers/cache”|cut -d”:” -f2 Memory by Process

Raw

ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS Human readable

ps -e -orss=,args= | sort -b -k1,1n | awk ‘{ split( “KB MB GB” , v […]

JMAP, HISTO, Thread Dump, CPU Utilization

Dear Reader,

In a production environment Java Profiling is not an option, we have seen multiple times that our CPU has reached almost 100% or even 300% sometime. That is really a panic scenario especially when you are handling production environment or at client place to check what went wrong.

Fortunately, Java comes with some […]

Bask quick learn

Bash Shell Shortcuts Special Shell Variables

Common environment variables

PATH – Sets the search path for any executable command. Similar to the PATH variable in MSDOS.

HOME – Home directory of the user.

MAIL – Contains the path to the location where mail addressed to the user is stored.

IFS – Contains a string […]

ZCAT Shell bash

How to display the contents of a gzip/gz file By Alvin Alexander. Last updated: Aug 6, 2011 Problem: You have a plain text file that has been compressed with the gzip command, and you’d like to display the file contents with the Unix/Linux cat or more commands.

Solution: Instead of using the cat or more […]

Grep, Awk, and Sed in bash

So, let’s consider the following log file:

www.three.com 10.15.101.11 1353280801 TEST 345 www.one.com 10.14.101.11 1353280801 TEST 343 www.three.com 1.10.11.71 1353280801 TEST 323 www.one.com 10.15.11.61 1353280801 TEST 365 www.two.com 10.10.11.51 1353290801 TEST 55 www.two.com 10.20.13.11 1353290801 REST 435 www.one.com 10.20.14.41 1353290801 REST 65 www.two.com 10.10.11.14 1353290801 REST 345 www.three.com 10.10.11.31 1354280801 REST 34 www.one.com 10.10.13.144 1354280801 […]

if condition-integer expression expected

if condition-integer expression expected

ADV1=94.3 Quantity=96.3 if [ $Quantity -eq $ADV1 ]; then echo “quantity is greter” fi

echo “” | nawk -v ADV1=94.3 -v Quantity=96.3 […]

Parsing – Logs

grep, cat, zgrep and zcat

More on log parsing, I’m taking notes on how to read log files and get the information that I need. On Linux environment, these tools are perfect: grep, cat, zgrep and zcat.

Extracting patterns with grep

We can extract information from a text file using grep. Example, we can extract […]

shell string comparison tests

shell string comparison tests Here are the operators for performing string comparison tests:

s1 Test if s1 is not the empty string s1 = s2 Test if s1 equals s2 s1 != s2 Test if s1 is not equal to s2 -n s1 Test if s1 has non-zero size -z s1 Test if s1 […]