- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Scripting CPU and memory usage
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2009 09:11 AM
тАО08-17-2009 09:11 AM
Does anyone have a nice universal script (meaning no special software needed like glance, etc) that will give a nice quick summary of percentage of memory and CPU usage that can be emailed? Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2009 10:52 AM
тАО08-17-2009 10:52 AM
Re: Scripting CPU and memory usage
$ top -n 1 | grep -e ^Cpu -e ^Mem
provides this output:
Cpu(s): 0.2% us, 0.7% sy, 0.0% ni, 98.6% id, 0.2% wa, 0.0% hi, 0.3% si
Mem: 1024248k total, 990548k used, 33700k free, 130372k buffers
which can be piped into your mail agent to send via email or can be further massaged with combination of awk/sed/cut commands to make the output you wish to see.
Hope this helps
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2009 11:49 AM
тАО08-17-2009 11:49 AM
Re: Scripting CPU and memory usage
CPU used: 23%
Memory used: 23%
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2009 11:55 PM
тАО08-17-2009 11:55 PM
Re: Scripting CPU and memory usage
Getting email reports once per minute/hour/day seems me almost useless - you don't see any trends in this way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-18-2009 05:13 AM
тАО08-18-2009 05:13 AM
Solution#!/bin/bash
cpuidle=`top -n 1 | grep ^Cpu | cut -d"," -f4| cut -d"%" -f1|cut -d" " -f2`
cpuused=`echo 100-$cpuidle | bc`
memtotal=`top -n 1 | grep ^Mem |awk {'print $3'}|cut -d"k" -f1`
memused=`top -n 1 | grep ^Mem |awk {'print $5'}|cut -d"k" -f1`
mempct=`echo "(${memused}*100)/${memtotal}"| bc`
echo "CPU Used: ${cpuused}%"
echo "Memory Used: ${mempct}%")
If you putt all of the above in a script, run it and pipe it to your mailer, you will receive the desired output
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-18-2009 05:18 AM
тАО08-18-2009 05:18 AM
Re: Scripting CPU and memory usage
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-18-2009 06:29 AM
тАО08-18-2009 06:29 AM