Solved

bash script for cpu, memory, tcp connection

Posted on 2011-03-14
3
752 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SMB share across internet 15 79
Upgrade BIOS / EUFI at Scale 4 68
Connect to CentOS (in a local VMWare VM) using Putty 7 133
Check for Linux process in script 7 65
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…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

680 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