[GE users] Script for accounting(8) file analysis

Andreas Haas Andreas.Haas at Sun.COM
Mon Jun 12 11:25:28 BST 2006


On Fri, 9 Jun 2006, Simon Gao wrote:

> Andreas,
>
> Your script works great.

:-)

> However, is it possible to add
> sorting into your script so when running with "-u", users
> are listed in descending order based on njobs or runtime?
> maybe another argument like "-s"?

Sure enough. See PrintableHash::print_all()

      def print_all(name)
         first = true
         self.keys.sort.each do |debitable|
            self[debitable].print_debitable(debitable, first, self.size, name)
            if first == true
               first = false
            end
         end
      end

where sorting is currently done for user/project/queue/etc.
I haven't tried, yet I believe changing it to

      def print_all(name)

         ary = Array.new
         self.each_pair { |k,v| ary.push([k,v]) }

         ary.sort!{ |x,y|  x[1].jobs <=> y[1].jobs }
         first = true
         ary.each { |v|
            v[1].print_debitable(v[0], first, self.size, name)
            if first == true
               first = false
            end
         }
      end

would already do part of what you want.

Regards,
Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe at gridengine.sunsource.net
For additional commands, e-mail: users-help at gridengine.sunsource.net




More information about the gridengine-users mailing list