~ubuntu-branches/ubuntu/utopic/numactl/utopic-proposed

« back to all changes in this revision

Viewing changes to diff.numastat

  • Committer: Package Import Robot
  • Author(s): Ian Wienand
  • Date: 2012-11-15 12:20:29 UTC
  • mfrom: (1.3.9)
  • Revision ID: package-import@ubuntu.com-20121115122029-df53pmew2v1ydcsg
Tags: 2.0.8-1
New upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
diff -ruN numactl-2.0.8-rc5.orig/numastat numactl-2.0.8-rc5.new/numastat
 
2
--- numactl-2.0.8-rc5.orig/numastat     2012-08-23 15:50:37.000000000 -0400
 
3
+++ numactl-2.0.8-rc5.new/numastat      1969-12-31 19:00:00.000000000 -0500
 
4
@@ -1,91 +0,0 @@
 
5
-#!/usr/bin/perl
 
6
-# Print numa statistics for all nodes
 
7
-# Copyright (C) 2003,2004 Andi Kleen, SuSE Labs.
 
8
-#
 
9
-# numastat is free software; you can redistribute it and/or
 
10
-# modify it under the terms of the GNU General Public
 
11
-# License as published by the Free Software Foundation; version
 
12
-# 2.
 
13
-#
 
14
-# numastat is distributed in the hope that it will be useful,
 
15
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
17
-# General Public License for more details.
 
18
-
 
19
-# You should find a copy of v2 of the GNU General Public License somewhere
 
20
-# on your Linux system; if not, write to the Free Software Foundation,
 
21
-# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
 
22
-#
 
23
-# Example: NUMASTAT_WIDTH=80 watch -n1 numastat
 
24
-#
 
25
-
 
26
-# output width
 
27
-$WIDTH=80;
 
28
-if (defined($ENV{'NUMASTAT_WIDTH'})) {
 
29
-       $WIDTH=$ENV{'NUMASTAT_WIDTH'};
 
30
-} else {
 
31
-       use POSIX;
 
32
-       if (POSIX::isatty(fileno(STDOUT))) {
 
33
-               if (open(R, "resize |")) {
 
34
-                       while (<R>) {
 
35
-                               $WIDTH=$1 if /COLUMNS=(\d+)/;
 
36
-                       }       
 
37
-                       close R;
 
38
-               }
 
39
-       } else {
 
40
-               # don't split it up for easier parsing
 
41
-               $WIDTH=10000000;
 
42
-       }
 
43
-}
 
44
-$WIDTH = 32 if $WIDTH < 32;
 
45
-
 
46
-if (! -d "/sys/devices/system/node" ) {
 
47
-       print STDERR "sysfs not mounted or system not NUMA aware\n";
 
48
-       exit 1;
 
49
-}
 
50
-
 
51
-%stat = ();
 
52
-$title = "";
 
53
-$mode = 0;
 
54
-opendir(NODES, "/sys/devices/system/node") || exit 1;
 
55
-foreach $nd (readdir(NODES)) {
 
56
-       next unless $nd =~ /node(\d+)/;
 
57
-       # On newer kernels, readdir may enumerate the 'node(\d+) subdirs
 
58
-       # in opposite order from older kernels--e.g., node{0,1,2,...}
 
59
-       # as opposed to node{N,N-1,N-2,...}.  Accomodate this by
 
60
-       # switching to new mode so that the stats get emitted in
 
61
-       # the same order.
 
62
-        #print "readdir(NODES) returns $nd\n";
 
63
-       if (!$title && $nd =~ /node0/) {
 
64
-               $mode = 1;
 
65
-       }
 
66
-       open(STAT, "/sys/devices/system/node/$nd/numastat") ||
 
67
-                       die "cannot open $nd: $!\n";
 
68
-       if (! $mode) {
 
69
-               $title = sprintf("%16s",$nd) . $title;
 
70
-       } else {
 
71
-               $title = $title . sprintf("%16s",$nd);
 
72
-       }
 
73
-       @fields = ();
 
74
-       while (<STAT>) {
 
75
-               ($name, $val) = split;
 
76
-               if (! $mode) {
 
77
-                       $stat{$name} = sprintf("%16u", $val) . $stat{$name};
 
78
-               } else {
 
79
-                       $stat{$name} = $stat{$name} . sprintf("%16u", $val);
 
80
-               }
 
81
-               push(@fields, $name);
 
82
-       }
 
83
-       close STAT;
 
84
-}
 
85
-closedir NODES;
 
86
-
 
87
-$numfields = int(($WIDTH - 16) / 16);
 
88
-$l = 16 * $numfields;
 
89
-for ($i = 0; $i < length($title); $i += $l) {
 
90
-       print "\n" if $i > 0;
 
91
-       printf "%16s%s\n","",substr($title,$i,$l);
 
92
-       foreach (@fields) {
 
93
-               printf "%-16s%s\n",$_,substr($stat{$_},$i,$l);
 
94
-       }
 
95
-}