<?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: more scripting help on calculations in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/more-scripting-help-on-calculations/m-p/3805575#M99981</link>
    <description>&lt;!--!*#--&gt;Hi Lawrenzo:&lt;BR /&gt;&lt;BR /&gt;If you want to quickly summarize the utilization (total characters) by user within any filesystem, I'd use Perl.  Something like this should do:&lt;BR /&gt;&lt;BR /&gt;# cat ./userutil&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;#@(#)userutil $ Summarize by user total file sizes - JRF $&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;use File::Basename;&lt;BR /&gt;use File::Find;&lt;BR /&gt;&lt;BR /&gt;my  %util;&lt;BR /&gt;my ($uid, $size, $name);&lt;BR /&gt;my  $path = @ARGV ? shift : ".";&lt;BR /&gt;&lt;BR /&gt;sub wanted {&lt;BR /&gt;    return unless -f;&lt;BR /&gt;    ($uid, $size) = ((stat($_))[4,7]);&lt;BR /&gt;    return unless $uid &amp;gt; 10;&lt;BR /&gt;    $util{$uid}+=$size;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;File::Find::find(\&amp;amp;wanted, $path);&lt;BR /&gt;for $uid (keys %util) {&lt;BR /&gt;    $name = getpwuid($uid);&lt;BR /&gt;    $name = $uid unless defined $name;&lt;BR /&gt;    printf "%8s  %10d\n",$name,$util{$uid};&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;Users whose 'uid' is less than ten (10) are skipped.  This eliminates files owned by "root" and "bin", in particular.&lt;BR /&gt;&lt;BR /&gt;Only files, not directories, are examined.  Run the script passing a directory (filesystem), e.g. "/home":&lt;BR /&gt;&lt;BR /&gt;# ./userutil /tmp&lt;BR /&gt; spfmweb         175&lt;BR /&gt;    oper        5026&lt;BR /&gt;     jrf          48&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Wed, 14 Jun 2006 07:11:41 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2006-06-14T07:11:41Z</dc:date>
    <item>
      <title>more scripting help on calculations</title>
      <link>https://community.hpe.com/t5/operating-system-linux/more-scripting-help-on-calculations/m-p/3805568#M99974</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I have a filesystem where the data is all over the place and no archiving or housekeeping has happened for some time.  I have a definitive list of all files / data users etc.  &lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;# This script will check a file where find . -xargs |ls -ld |sort -rnk 5 &amp;gt; usrdump.lst&lt;BR /&gt;# is run and the definitive list has been created.&lt;BR /&gt;&lt;BR /&gt;# Create list of unique users - you can store this in an array, or better in a temp file.&lt;BR /&gt;&lt;BR /&gt;cat usrdump.lst | tail +1 |awk '{print $3}' |sort |uniq &amp;gt; usrlist.log&lt;BR /&gt;&lt;BR /&gt;# for each user in list above print file size and add it up&lt;BR /&gt;&lt;BR /&gt;for usrname in `awk '{print $1}' usrlist.log`&lt;BR /&gt;do&lt;BR /&gt;        echo " checking user $usrname"&lt;BR /&gt;        filesize_count=0&lt;BR /&gt;        for filesize in `grep "$usrname " usrdump.lst |awk '{print $5}'`&lt;BR /&gt;        do&lt;BR /&gt;                filesize_count=$filesize_count+$filesize&lt;BR /&gt;        done&lt;BR /&gt;        echo "$usrname\ttotal\t$filesize"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;the problem I have is that the usrdump file is over 120mb and the system runs out of memory:&lt;BR /&gt;&lt;BR /&gt;--&amp;gt; ./filesystemcounter.sc&lt;BR /&gt; checking user cronlog&lt;BR /&gt;./filesystemcounter.sc[15]: 0403-029 There is not enough memory available now.&lt;BR /&gt;&lt;BR /&gt;there is 16gb of memory in the system.&lt;BR /&gt;&lt;BR /&gt;Anyone have a better solution to calculate the filesystem usage for all users accessing the FS?&lt;BR /&gt;&lt;BR /&gt;Many Thanks again.</description>
      <pubDate>Wed, 14 Jun 2006 04:38:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/more-scripting-help-on-calculations/m-p/3805568#M99974</guid>
      <dc:creator>lawrenzo</dc:creator>
      <dc:date>2006-06-14T04:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: more scripting help on calculations</title>
      <link>https://community.hpe.com/t5/operating-system-linux/more-scripting-help-on-calculations/m-p/3805569#M99975</link>
      <description>Hi Lawrenzo,&lt;BR /&gt;&lt;BR /&gt;How about someting like this.&lt;BR /&gt;&lt;BR /&gt;# du -ks * /home | awk '{ print int($1/1024+.5)" MB"" "$2}'&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Robert-Jan</description>
      <pubDate>Wed, 14 Jun 2006 04:48:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/more-scripting-help-on-calculations/m-p/3805569#M99975</guid>
      <dc:creator>Robert-Jan Goossens</dc:creator>
      <dc:date>2006-06-14T04:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: more scripting help on calculations</title>
      <link>https://community.hpe.com/t5/operating-system-linux/more-scripting-help-on-calculations/m-p/3805570#M99976</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You can do&lt;BR /&gt;&lt;BR /&gt;for i in `awk '{print $1}' usrlist.log`&lt;BR /&gt;do&lt;BR /&gt;echo "$i uses \c"&lt;BR /&gt;find ./ -type f -user $i | xargs ls -l | awk 'BEGIN {tot=0} {tot+=$5} END {print tot/1024,"KB"}'&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Ninad</description>
      <pubDate>Wed, 14 Jun 2006 05:03:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/more-scripting-help-on-calculations/m-p/3805570#M99976</guid>
      <dc:creator>Ninad_1</dc:creator>
      <dc:date>2006-06-14T05:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: more scripting help on calculations</title>
      <link>https://community.hpe.com/t5/operating-system-linux/more-scripting-help-on-calculations/m-p/3805571#M99977</link>
      <description>Thanks robert-jan this gives some idication on file sizes however there has been no housekeepig policy for some time here and everything is a bit f a mess.  Some users have no idea of files dumped in the area because it is done through an application.&lt;BR /&gt;&lt;BR /&gt;I have the lsit of all files &lt;BR /&gt;&lt;BR /&gt;# find . -xargs |ls -ld |sort -rnk 5 &amp;gt; usrdump.lst&lt;BR /&gt;&lt;BR /&gt;however I need to then name and shame the users who have the most fs usage and I want to use the sript to prove this.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 14 Jun 2006 05:04:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/more-scripting-help-on-calculations/m-p/3805571#M99977</guid>
      <dc:creator>lawrenzo</dc:creator>
      <dc:date>2006-06-14T05:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: more scripting help on calculations</title>
      <link>https://community.hpe.com/t5/operating-system-linux/more-scripting-help-on-calculations/m-p/3805572#M99978</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;for USER in `awk '{print $1}' usrlist.log`&lt;BR /&gt;&lt;BR /&gt;do&lt;BR /&gt;echo " checking user $USER"&lt;BR /&gt;&lt;BR /&gt;echo "$USER \c"; find . -type f -user $USER -xdev|xargs ll|awk '{ x += $5 } END { print "total bytes: " x }'&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Enrico</description>
      <pubDate>Wed, 14 Jun 2006 05:20:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/more-scripting-help-on-calculations/m-p/3805572#M99978</guid>
      <dc:creator>Enrico P.</dc:creator>
      <dc:date>2006-06-14T05:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: more scripting help on calculations</title>
      <link>https://community.hpe.com/t5/operating-system-linux/more-scripting-help-on-calculations/m-p/3805573#M99979</link>
      <description>ok this is great stuff however the search function onthe actual server will significantly increase the load.&lt;BR /&gt;&lt;BR /&gt;I was hoping I could interogate the usrdump.lst file to work out the sizes.&lt;BR /&gt;&lt;BR /&gt;is that possible also?&lt;BR /&gt;&lt;BR /&gt;TY&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Jun 2006 05:22:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/more-scripting-help-on-calculations/m-p/3805573#M99979</guid>
      <dc:creator>lawrenzo</dc:creator>
      <dc:date>2006-06-14T05:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: more scripting help on calculations</title>
      <link>https://community.hpe.com/t5/operating-system-linux/more-scripting-help-on-calculations/m-p/3805574#M99980</link>
      <description>I dont think it is a seperate load on your system compared to the find you will be running to get the userdump.lst file.&lt;BR /&gt;Any how try this&lt;BR /&gt;&lt;BR /&gt;for user in `awk '{print $1}' usrlist.log`&lt;BR /&gt;do&lt;BR /&gt;echo "$user uses \c"&lt;BR /&gt;grep $user usrdump.lst | awk 'BEGIN {tot=0} {tot+=$5} END {print tot/1024,"KB"}'&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Ninad</description>
      <pubDate>Wed, 14 Jun 2006 05:45:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/more-scripting-help-on-calculations/m-p/3805574#M99980</guid>
      <dc:creator>Ninad_1</dc:creator>
      <dc:date>2006-06-14T05:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: more scripting help on calculations</title>
      <link>https://community.hpe.com/t5/operating-system-linux/more-scripting-help-on-calculations/m-p/3805575#M99981</link>
      <description>&lt;!--!*#--&gt;Hi Lawrenzo:&lt;BR /&gt;&lt;BR /&gt;If you want to quickly summarize the utilization (total characters) by user within any filesystem, I'd use Perl.  Something like this should do:&lt;BR /&gt;&lt;BR /&gt;# cat ./userutil&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;#@(#)userutil $ Summarize by user total file sizes - JRF $&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;use File::Basename;&lt;BR /&gt;use File::Find;&lt;BR /&gt;&lt;BR /&gt;my  %util;&lt;BR /&gt;my ($uid, $size, $name);&lt;BR /&gt;my  $path = @ARGV ? shift : ".";&lt;BR /&gt;&lt;BR /&gt;sub wanted {&lt;BR /&gt;    return unless -f;&lt;BR /&gt;    ($uid, $size) = ((stat($_))[4,7]);&lt;BR /&gt;    return unless $uid &amp;gt; 10;&lt;BR /&gt;    $util{$uid}+=$size;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;File::Find::find(\&amp;amp;wanted, $path);&lt;BR /&gt;for $uid (keys %util) {&lt;BR /&gt;    $name = getpwuid($uid);&lt;BR /&gt;    $name = $uid unless defined $name;&lt;BR /&gt;    printf "%8s  %10d\n",$name,$util{$uid};&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;Users whose 'uid' is less than ten (10) are skipped.  This eliminates files owned by "root" and "bin", in particular.&lt;BR /&gt;&lt;BR /&gt;Only files, not directories, are examined.  Run the script passing a directory (filesystem), e.g. "/home":&lt;BR /&gt;&lt;BR /&gt;# ./userutil /tmp&lt;BR /&gt; spfmweb         175&lt;BR /&gt;    oper        5026&lt;BR /&gt;     jrf          48&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 14 Jun 2006 07:11:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/more-scripting-help-on-calculations/m-p/3805575#M99981</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-06-14T07:11:41Z</dc:date>
    </item>
  </channel>
</rss>

