Solved

bash script for cpu, memory, tcp connection

Posted on 2011-03-14
3
749 Views
Last Modified: 2012-06-27
Hi,

I need a bash script that could perform/ check the following on a Linux server,

1. CPU usage with top consuming processes
2. Memory allocation vs Memory available
3. I/O connection
4. TCP connections to apache
5. TCP connectons to Mysql
6. quick health check of mysql db.

would be helpful needed one bash script for above situation.

thanks in advance
0
Comment
Question by:luser9999
3 Comments
 
LVL 31

Accepted Solution

by:
farzanj earned 250 total points
ID: 35130569
Top two consuming processes
top -b -n1 | head -10 | tail -2

Memory Usage with top two consuming processes
top -b -n1 | head -10

Memory available vs. memory allocation
free -m

I/O connection
iostat or netstat -anptu

TCP connections to apache
netstat -entd | grep -i http

TCP connection for mysql
netstat -entd | grep -i mysql

If you want to include listening also, do netstat -antd, -entd would do established connections only

0
 
LVL 12

Assisted Solution

by:mccracky
mccracky earned 250 total points
ID: 35130944
If this is an ongoing concern, I'd set up cacti to constantly monitor and graph it.  But, rather than bash, it uses snmp.  See: http://www.cacti.net/
0
 

Author Closing Comment

by:luser9999
ID: 35276374
thanks
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now