<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Procfs on Amit Agarwal Linux Blog</title>
    <link>/tags/procfs/</link>
    <description>Recent content in Procfs on Amit Agarwal Linux Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Fri, 28 Dec 2012 01:23:46 +0000</lastBuildDate>
    
	<atom:link href="/tags/procfs/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Disable a few cores when you want to save power.</title>
      <link>/2012/12/28/disable-cores-save-power/</link>
      <pubDate>Fri, 28 Dec 2012 01:23:46 +0000</pubDate>
      
      <guid>/2012/12/28/disable-cores-save-power/</guid>
      <description>&lt;p&gt;If you have a lot of &lt;a class=&#34;zem_slink&#34; title=&#34;Central processing unit&#34; href=&#34;http://en.wikipedia.org/wiki/Central_processing_unit&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;CPU&lt;/a&gt; power and working on battery. If you do not need that much of power and would like to rather save some &lt;a class=&#34;zem_slink&#34; title=&#34;Batteries drain rates infographics&#34; href=&#34;http://blog.lenovo.com/products/when-will-batteries-last-the-work-week?cid=us|425522&#34; target=&#34;_blank&#34; rel=&#34;lenovo&#34;&gt;battery power&lt;/a&gt; by disabling some cpus then you can use the below script. This script disables cpus from 4 to 7. You can change the number in the &lt;a class=&#34;zem_slink&#34; title=&#34;For loop&#34; href=&#34;http://en.wikipedia.org/wiki/For_loop&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;for loop&lt;/a&gt;. You would need the &lt;a class=&#34;zem_slink&#34; title=&#34;Sudo&#34; href=&#34;http://www.sudo.ws&#34; target=&#34;_blank&#34; rel=&#34;homepage&#34;&gt;sudo&lt;/a&gt; to be setup or remove sudo and run the script as root. The script will show you the currently active cpu’s before and after disabling the CPU’s.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Linux hardware details.</title>
      <link>/2011/11/28/linux-hardware-details/</link>
      <pubDate>Mon, 28 Nov 2011 11:20:25 +0000</pubDate>
      
      <guid>/2011/11/28/linux-hardware-details/</guid>
      <description>&lt;p&gt;Here is one of the scripts that I found on the net while searching for something … Note the &lt;a class=&#34;zem_slink&#34; title=&#34;Uniform Resource Locator&#34; href=&#34;http://en.wikipedia.org/wiki/Uniform_Resource_Locator&#34; rel=&#34;wikipedia&#34;&gt;URL&lt;/a&gt; for the script in the Description.&lt;/p&gt;
&lt;pre class=&#34;brush: bash; gutter: true; first-line: 1&#34;&gt;#!/bin/bash -
#===============================================================================
#
#          FILE:  linux_hw.sh
#
#         USAGE:  ./linux_hw.sh
#
#   DESCRIPTION:  http://www.howtogeek.com/howto/solaris/get-the-processor-type-on-solaris/
#
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR: &lt;a class=&#34;zem_slink&#34; title=&#34;Amit Agarwal&#34; href=&#34;http://www.labnol.org/about/&#34; rel=&#34;homepage&#34;&gt;Amit Agarwal&lt;/a&gt; (aka), amit.agarwal@roamware.com
#       COMPANY: Roamware India Pvt Ltd
#       CREATED: 09/13/2011 03:57:34 PM IST
# Last modified: Sun Oct 30, 2011  04:59PM
#      REVISION:  ---
#===============================================================================

function linux_hw_CPU {
	&lt;a class=&#34;zem_slink&#34; title=&#34;Typesetting&#34; href=&#34;http://en.wikipedia.org/wiki/Typesetting&#34; rel=&#34;wikipedia&#34;&gt;typeset&lt;/a&gt; num=0
	typeset name=&#34;&#34;
	typeset cores=&#34;&#34;
	name=&#34;$( cat &lt;a class=&#34;zem_slink&#34; title=&#34;Procfs&#34; href=&#34;http://en.wikipedia.org/wiki/Procfs&#34; rel=&#34;wikipedia&#34;&gt;/proc/cpuinfo&lt;/a&gt; | awk -F: &#39;
/vendor_id/ { vendor=$2 }
/model name/ { model=$2 }
/cpu &lt;a class=&#34;zem_slink&#34; title=&#34;Hertz&#34; href=&#34;http://en.wikipedia.org/wiki/Hertz&#34; rel=&#34;wikipedia&#34;&gt;MHz&lt;/a&gt;/ {
if( model ~ &#34;Hz&#34; ) {speed=&#34;&#34;} else { speed=$2? MHz&#34; };
print vendor, model, speed; }
		&#39; | tail -1
	)&#34;

        num=$(if [ -r /proc/vmware/cpuinfo ]; then awk &#39;/pcpu/ { print NF-1 }&#39; /proc/vmware/cpuinfo; else cat /proc/cpuinfo | &lt;a class=&#34;zem_slink&#34; title=&#34;Grep&#34; href=&#34;http://en.wikipedia.org/wiki/Grep&#34; rel=&#34;wikipedia&#34;&gt;grep&lt;/a&gt; processor| wc -l; fi)

	# ESX: mas info sobre logical/cores/packages
	if [ -r /proc/vmware/sched/ncpus ]
	then
		cores=$( echo $( cat /proc/vmware/sched/ncpus ) )
	fi

	echo $num $( echo &#34;$name ($cores)&#34; | enclose )
}

function enclose {
	tr -s &#34; &#34; | sed -e &#34;s/^/\&#34;/; s/$/\&#34;/; s/\&#34;\ /\&#34;/; s/\ \&#34;/\&#34;/&#34;
}

function linux_hw_CPU {

	typeset num=0
	typeset name=&#34;&#34;
	typeset cores=&#34;&#34;

	name=&#34;$(
		cat /proc/cpuinfo | awk -F: &#39;
/vendor_id/ { vendor=$2 }
/model name/ { model=$2 }
/cpu MHz/ {
if( model ~ &#34;Hz&#34; ) {speed=&#34;&#34;} else { speed=$2&#34; MHz&#34; };
print vendor, model, speed; }
		&#39; | tail -1
	)&#34;

	num=$(
		if [ -r /proc/vmware/cpuinfo ]
		then
			awk &#39;/pcpu/ { print NF-1 }&#39; /proc/vmware/cpuinfo
		else
			cat /proc/cpuinfo | grep processor| wc -l
		fi

	)

	if grep -q &#34;physical id&#34; /proc/cpuinfo || grep &#34;siblings&#34; /proc/cpuinfo
	then
		chip_count=$( grep &#34;physical id&#34; /proc/cpuinfo | sort -u | wc -l )
		chip_core=$( grep &#34;siblings&#34; /proc/cpuinfo | tail -1 | cut -d: -f2 )
		cores=&#34;($chip_count chips x $chip_core cores)&#34;
	fi

	# Blades HP con
	if [ -x /sbin/hpasmcli ]
	then
		chip_name=$( /sbin/hpasmcli -s &#34;SHOW &lt;a class=&#34;zem_slink&#34; title=&#34;Server (computing)&#34; href=&#34;http://en.wikipedia.org/wiki/Server_%28computing%29&#34; rel=&#34;wikipedia&#34;&gt;SERVER&lt;/a&gt;&#34; | grep &#34;Name&#34; | head -1 | cut -d: -f2 )
		chip_speed=$( /sbin/hpasmcli -s &#34;SHOW SERVER&#34; | grep &#34;Speed&#34; | head -1 | cut -d: -f2 )
		chip_core=$( /sbin/hpasmcli -s &#34;SHOW SERVER&#34; | grep &#34;Core&#34; | head -1 | cut -d: -f2 )
	fi

	# ESX: mas info sobre logical/cores/packages
	if [ -r /proc/vmware/sched/ncpus ]
	then
		cores=&#34;($( echo $( cat /proc/vmware/sched/ncpus ) ))&#34;
	fi

	# &lt;a class=&#34;zem_slink&#34; title=&#34;Linux&#34; href=&#34;http://www.kernel.org/&#34; rel=&#34;homepage&#34;&gt;Linux&lt;/a&gt; &lt;a class=&#34;zem_slink&#34; title=&#34;Itanium&#34; href=&#34;http://en.wikipedia.org/wiki/Itanium&#34; rel=&#34;wikipedia&#34;&gt;Itanium&lt;/a&gt; IA64
	if grep -q -i itanium /proc/cpuinfo
	then
		name=&#34;$(
		grep &#34;vendor&#34; /proc/cpuinfo | cut -d: -f2- | tail -1 ) $(
		grep &#34;arch &#34; /proc/cpuinfo | cut -d: -f2- | tail -1 ) $(
		grep &#34;family&#34; /proc/cpuinfo | cut -d: -f2- | tail -1 ) $(
		grep &#34;cpu MHz&#34; /proc/cpuinfo | cut -d: -f2- | cut -d. -f1 | tail -1 ) Mhz&#34;

		chip_count=$( grep &#34;physical id&#34; /proc/cpuinfo | sort -u | wc -l )
		chip_core=$( grep &#34;siblings&#34; /proc/cpuinfo | tail -1 | cut -d: -f2 )
		cores=&#34;($chip_count chips x $chip_core cores)&#34;
	fi

	echo $num $( echo &#34;$name $cores&#34; | enclose )
}

linux_hw_CPU&lt;/pre&gt;
&lt;h6 class=&#34;zemanta-related-title&#34; style=&#34;font-size: 1em;&#34;&gt;
  Related articles
&lt;/h6&gt;
&lt;ul class=&#34;zemanta-article-ul&#34;&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://weijianhui16.wordpress.com/2011/09/06/linux%e6%9f%a5%e7%9c%8b%e7%a1%ac%e4%bb%b6%e4%bf%a1%e6%81%af/&#34;&gt;linux??????&lt;/a&gt; (weijianhui16.wordpress.com)
  &lt;/li&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://singztechmusings.wordpress.com/2011/06/15/how-to-check-the-uptime-of-a-process-or-an-application-running-in-linux-machine-using-shell-script/&#34;&gt;How to check the uptime of a process (or an application) running in Linux machine using shell script?&lt;/a&gt; (singztechmusings.wordpress.com)
  &lt;/li&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://javarevisited.wordpress.com/2011/06/15/good-examples-of-grep-command-in-unix-and-linux/&#34;&gt;Some examples of grep command in unix&lt;/a&gt; (javarevisited.wordpress.com)
  &lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;zemanta-pixie&#34; style=&#34;margin-top: 10px; height: 15px;&#34;&gt;
  &lt;a class=&#34;zemanta-pixie-a&#34; title=&#34;Enhanced by Zemanta&#34; href=&#34;http://www.zemanta.com/&#34;&gt;&lt;img class=&#34;zemanta-pixie-img&#34; style=&#34;float: right;&#34; src=&#34;https://i1.wp.com/img.zemanta.com/zemified_e.png?w=688&#34; alt=&#34;Enhanced by Zemanta&#34; data-recalc-dims=&#34;1&#34; /&gt;&lt;/a&gt;
&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>Total upload and download on any interface.</title>
      <link>/2011/06/05/total-upload-download-interface/</link>
      <pubDate>Sun, 05 Jun 2011 01:29:21 +0000</pubDate>
      
      <guid>/2011/06/05/total-upload-download-interface/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;Something that I have been searching for a long time, finally some look inside the &amp;lt;a class=&amp;ldquo;zem_slink&amp;rdquo; title=&amp;ldquo;Procfs&amp;rdquo; rel=&amp;ldquo;wikipedia&amp;rdquo; href=&amp;ldquo;&lt;a href=&#34;http://en.wikipedia.org/wiki/Procfs%22&#34;&gt;http://en.wikipedia.org/wiki/Procfs&amp;quot;&lt;/a&gt; _mce_href=&amp;ldquo;&lt;a href=&#34;http://en.wikipedia.org/wiki/Procfs%22%3E/proc&#34;&gt;http://en.wikipedia.org/wiki/Procfs&amp;quot;&amp;gt;/proc&lt;/a&gt;&lt;/a&gt; got me what I wanted. Hope this will save someone’s day. So far, the only option I could think of was to run conky which becomes a little heave on some of the very old laptops I have to use sometimes 🙁&lt;/p&gt;
&lt;div class=&#34;codecolorer-container text solarized-light&#34; style=&#34;overflow:auto;white-space:nowrap;width:550px;&#34;&gt;
  &lt;table cellspacing=&#34;0&#34; cellpadding=&#34;0&#34;&gt;
    &lt;tr&gt;
      &lt;td class=&#34;line-numbers&#34;&gt;
        &lt;div&gt;
          1&lt;br /&gt;
        &lt;/div&gt;
      &lt;/td&gt;
&lt;pre&gt;&lt;code&gt;  &amp;lt;td&amp;gt;
    &amp;lt;div class=&amp;quot;text codecolorer&amp;quot;&amp;gt;
      &amp;amp;nbsp;cat /proc/net/dev|grep eth2|awk &#39;{print $2/1024/1024&amp;quot;&amp;amp;nbsp; &amp;quot;$10/1024/1024}&#39;
    &amp;lt;/div&amp;gt;
  &amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
  &lt;/table&gt;
&lt;/div&gt;&lt;h6 class=&#34;zemanta-related-title&#34; style=&#34;font-size: 1em;&#34; \_mce\_style=&#34;font-size: 1em;&#34;&gt;Related articles&lt;/h6&gt; 
&lt;ul class=&#34;zemanta-article-ul&#34;&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://jarneil.wordpress.com/2011/03/15/cpuspeed-slowing-you-down/&#34; _mce_href=&#34;http://jarneil.wordpress.com/2011/03/15/cpuspeed-slowing-you-down/&#34;&gt;CPUSPEED Slowing you down?&lt;/a&gt; (jarneil.wordpress.com)
  &lt;/li&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://lingpipe-blog.com/2011/05/26/interface-curmudgeons/&#34; _mce_href=&#34;http://lingpipe-blog.com/2011/05/26/interface-curmudgeons/&#34;&gt;Interface Curmudgeons versus Gestures&lt;/a&gt; (lingpipe-blog.com)
  &lt;/li&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://michaeldaranto.wordpress.com/2011/05/28/alias-in-bashrc/&#34; _mce_href=&#34;http://michaeldaranto.wordpress.com/2011/05/28/alias-in-bashrc/&#34;&gt;Alias in .bashrc&lt;/a&gt; (michaeldaranto.wordpress.com)
  &lt;/li&gt;
&lt;/ul&gt;&lt;div class=&#34;zemanta-pixie&#34; style=&#34;margin-top: 10px; height: 15px;&#34; \_mce\_style=&#34;margin-top: 10px; height: 15px;&#34;&gt;&lt;a class=&#34;zemanta-pixie-a&#34; title=&#34;Enhanced by Zemanta&#34; href=&#34;http://www.zemanta.com/&#34; \_mce\_href=&#34;http://www.zemanta.com/&#34;&gt;&lt;img class=&#34;zemanta-pixie-img&#34; style=&#34;border: medium none; float: right;&#34; \_mce\_style=&#34;border: medium none; float: right;&#34; src=&#34;https://i1.wp.com/img.zemanta.com/zemified\_e.png?w=688&#34; \_mce\_src=&#34;https://i1.wp.com/img.zemanta.com/zemified\_e.png?w=688&#34; alt=&#34;Enhanced by Zemanta&#34; data-recalc-dims=&#34;1&#34;/&gt;&lt;/a&gt;&lt;br \_mce\_bogus=&#34;1&#34;/&gt;&lt;/div&gt;</description>
    </item>
    
  </channel>
</rss>
