- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Multiple Core Monitoring script
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
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
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
10-18-2011 11:00 PM
10-18-2011 11:00 PM
Multiple Core Monitoring script
Hi
I have been asked to monitor the cores of the multicore processors on our linux app servers.
I have the below script which catches the info to a file. I pull this into an excel spread sheet and use the following formula to get the percentage of each core used.(1000*($DIFF_TOTAL-$DIFF_IDLE)/$DIFF_TOTAL)/10".
However when i do a ps there are multiple sessions of the script running. How would i get this to run infinitley collect the data but not spawn so many sessions?
#!/bin/bash
# script to capture the core statistics of the cpu's
#Wayne McN 18/10/2011
DAT=`date +"%Y%m%d"`
HOSTNAM=`hostname -s`
LOGDIR=/home/sys_logs
LOGNAM=$LOGDIR/${HOSTNAM}_cpu_core.$DAT
dtim=`date +"%T"`
CPU_NO=`cat /proc/stat | grep cpu | wc -l`
CPU=1
echo "$dtim" >> $LOGNAM
while [ $CPU -le $CPU_NO ] ;do
cat /proc/stat | awk 'NR == '$CPU' { print " ",$0 >> "'$LOGNAM'" } '
CPU=$[CPU+1]
done
sleep 1
# If the date has changed stop the process
CURDAT=`date +"%Y%m%d"`
if [ $DAT != $CURDAT ]
then
exit
fi
sh /home/sys_scripts/cpu_core_stats.sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2011 11:34 PM
10-18-2011 11:34 PM
Re: Multiple Core Monitoring script
Ok got it working.
now is there a way to do the cpu calculations within the script?
#!/bin/bash
# script to capture the core statistics of the cpu's
#Wayne McN 18/10/2011
DAT=`date +"%Y%m%d"`
HOSTNAM=`hostname -s`
LOGDIR=/home/sys_logs
LOGNAM=$LOGDIR/${HOSTNAM}_cpu_core.$DAT
#dtim=`date +"%T"`
while true ; do
dtim=`date +"%T"`
CPU_NO=`cat /proc/stat | grep cpu | wc -l`
CPU=1
echo "$dtim" >> $LOGNAM
while [ $CPU -le $CPU_NO ] ;do
cat /proc/stat | awk 'NR == '$CPU' { print " ",$0 >> "'$LOGNAM'" } '
CPU=$[CPU+1]
done
sleep 1
# If the date has changed stop the process
CURDAT=`date +"%Y%m%d"`
if [ $DAT != $CURDAT ]
then
exit
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2011 11:43 AM
10-19-2011 11:43 AM
Re: Multiple Core Monitoring script
>now is there a way to do the CPU calculations within the script?
What type of calculations?
(Note it would be very helpful if you indented the bodies of your two while loops so the control flow becomes more obvious.)