<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Multiple Core Monitoring script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/multiple-core-monitoring-script/m-p/5366115#M53277</link>
    <description>&lt;P&gt;Ok got it working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;now is there a way to do the cpu calculations within the script?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#!/bin/bash&lt;BR /&gt;# script to capture the core statistics of the cpu's&lt;BR /&gt;#Wayne McN 18/10/2011&lt;/P&gt;&lt;P&gt;DAT=`date +"%Y%m%d"`&lt;BR /&gt;HOSTNAM=`hostname -s`&lt;BR /&gt;LOGDIR=/home/sys_logs&lt;BR /&gt;LOGNAM=$LOGDIR/${HOSTNAM}_cpu_core.$DAT&lt;BR /&gt;#dtim=`date +"%T"`&lt;/P&gt;&lt;P&gt;while true ; do&lt;/P&gt;&lt;P&gt;dtim=`date +"%T"`&lt;BR /&gt;CPU_NO=`cat /proc/stat | grep cpu | wc -l`&lt;BR /&gt;CPU=1&lt;/P&gt;&lt;P&gt;echo "$dtim" &amp;gt;&amp;gt; $LOGNAM&lt;BR /&gt;while [ $CPU -le $CPU_NO ] ;do&lt;BR /&gt;cat /proc/stat | awk 'NR ==&amp;nbsp; '$CPU' { print " ",$0 &amp;gt;&amp;gt;&amp;nbsp; "'$LOGNAM'" } '&lt;BR /&gt;CPU=$[CPU+1]&lt;BR /&gt;done&lt;BR /&gt;sleep 1&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;# If the date has changed stop the process&lt;BR /&gt;&amp;nbsp; CURDAT=`date +"%Y%m%d"`&lt;BR /&gt;&amp;nbsp; if [ $DAT != $CURDAT ]&lt;BR /&gt;&amp;nbsp; then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit&lt;BR /&gt;&amp;nbsp; fi&lt;/P&gt;&lt;P&gt;done&lt;/P&gt;</description>
    <pubDate>Wed, 19 Oct 2011 06:34:29 GMT</pubDate>
    <dc:creator>Boerbokrib</dc:creator>
    <dc:date>2011-10-19T06:34:29Z</dc:date>
    <item>
      <title>Multiple Core Monitoring script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/multiple-core-monitoring-script/m-p/5366081#M53276</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been asked to monitor the cores of the multicore processors on our linux app servers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;# script to capture the core statistics of the cpu's&lt;BR /&gt;#Wayne McN 18/10/2011&lt;/P&gt;&lt;P&gt;DAT=`date +"%Y%m%d"`&lt;BR /&gt;HOSTNAM=`hostname -s`&lt;BR /&gt;LOGDIR=/home/sys_logs&lt;BR /&gt;LOGNAM=$LOGDIR/${HOSTNAM}_cpu_core.$DAT&lt;BR /&gt;dtim=`date +"%T"`&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;CPU_NO=`cat /proc/stat | grep cpu | wc -l`&lt;BR /&gt;CPU=1&lt;/P&gt;&lt;P&gt;echo "$dtim" &amp;gt;&amp;gt; $LOGNAM&lt;BR /&gt;while [ $CPU -le $CPU_NO ] ;do&lt;BR /&gt;cat /proc/stat | awk 'NR ==&amp;nbsp; '$CPU' { print " ",$0 &amp;gt;&amp;gt;&amp;nbsp; "'$LOGNAM'" } '&lt;BR /&gt;CPU=$[CPU+1]&lt;BR /&gt;done&lt;BR /&gt;sleep 1&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;# If the date has changed stop the process&lt;BR /&gt;&amp;nbsp; CURDAT=`date +"%Y%m%d"`&lt;BR /&gt;&amp;nbsp; if [ $DAT != $CURDAT ]&lt;BR /&gt;&amp;nbsp; then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit&lt;BR /&gt;&amp;nbsp; fi&lt;/P&gt;&lt;P&gt;sh /home/sys_scripts/cpu_core_stats.sh&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2011 06:00:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/multiple-core-monitoring-script/m-p/5366081#M53276</guid>
      <dc:creator>Boerbokrib</dc:creator>
      <dc:date>2011-10-19T06:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Core Monitoring script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/multiple-core-monitoring-script/m-p/5366115#M53277</link>
      <description>&lt;P&gt;Ok got it working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;now is there a way to do the cpu calculations within the script?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#!/bin/bash&lt;BR /&gt;# script to capture the core statistics of the cpu's&lt;BR /&gt;#Wayne McN 18/10/2011&lt;/P&gt;&lt;P&gt;DAT=`date +"%Y%m%d"`&lt;BR /&gt;HOSTNAM=`hostname -s`&lt;BR /&gt;LOGDIR=/home/sys_logs&lt;BR /&gt;LOGNAM=$LOGDIR/${HOSTNAM}_cpu_core.$DAT&lt;BR /&gt;#dtim=`date +"%T"`&lt;/P&gt;&lt;P&gt;while true ; do&lt;/P&gt;&lt;P&gt;dtim=`date +"%T"`&lt;BR /&gt;CPU_NO=`cat /proc/stat | grep cpu | wc -l`&lt;BR /&gt;CPU=1&lt;/P&gt;&lt;P&gt;echo "$dtim" &amp;gt;&amp;gt; $LOGNAM&lt;BR /&gt;while [ $CPU -le $CPU_NO ] ;do&lt;BR /&gt;cat /proc/stat | awk 'NR ==&amp;nbsp; '$CPU' { print " ",$0 &amp;gt;&amp;gt;&amp;nbsp; "'$LOGNAM'" } '&lt;BR /&gt;CPU=$[CPU+1]&lt;BR /&gt;done&lt;BR /&gt;sleep 1&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;# If the date has changed stop the process&lt;BR /&gt;&amp;nbsp; CURDAT=`date +"%Y%m%d"`&lt;BR /&gt;&amp;nbsp; if [ $DAT != $CURDAT ]&lt;BR /&gt;&amp;nbsp; then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit&lt;BR /&gt;&amp;nbsp; fi&lt;/P&gt;&lt;P&gt;done&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2011 06:34:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/multiple-core-monitoring-script/m-p/5366115#M53277</guid>
      <dc:creator>Boerbokrib</dc:creator>
      <dc:date>2011-10-19T06:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Core Monitoring script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/multiple-core-monitoring-script/m-p/5366825#M53278</link>
      <description>&lt;P&gt;&amp;gt;now is there a way to do the CPU calculations within the script?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What type of calculations?&lt;/P&gt;&lt;P&gt;(Note it would be very helpful if you indented the bodies of your two while loops so the control flow becomes more obvious.)&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2011 18:43:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/multiple-core-monitoring-script/m-p/5366825#M53278</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-10-19T18:43:00Z</dc:date>
    </item>
  </channel>
</rss>

