/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Utilities/ReleaseScripts/scripts/cmssmap
93 строки
3 KB
David Mendez
Removed CVS Keywords from Utilites
19 сен 2013, 18:07
19 сен 2013, 18:07
c2b8052
Код
Авторство
О чём код?
#!/usr/bin/env perl # # # Script to present, in a simpler format, the smap numbers for a given # from /proc/<pid>/smaps. The script is run as: # # cmssmap <pid> # # where <pid> is the unix process id of the process to examine. # # Peter Elmer, Princeton University 13 July, 2008 # ############################################################################# # # Options # use Getopt::Long; my $brieffmt; my $unused; my $noheader; GetOptions("brief|b" => \$brieffmt, "noheader|n" => \$noheader, "unused|u" => \$unused); # # Find the appropriate file in /proc # $thepid = shift; chomp($thepid); # (Should check that a pid was provided) $procsmaps = "/proc/".$thepid."/smaps"; # (Should check that the file exists) # # Get SCRAM runtime envvars in order to simply printout # $baserel = $ENV{CMSSW_BASE}; $testrel = $ENV{CMSSW_RELEASE_BASE}; $scramarch = $ENV{SCRAM_ARCH}; $cmspath = $ENV{CMS_PATH}; $baselibdir = $baserel."/lib/".$scramarch."/"; $testlibdir = $testrel."/lib/".$scramarch."/"; $basebindir = $baserel."/bin/".$scramarch."/"; $testbindir = $testrel."/bin/".$scramarch."/"; # # Parse the smaps file and print # open(PROCSMAPS,"$procsmaps"); if ($unused && !$noheader) { printf("%8s %8s %8s %s\n", "SIZE", "RSS", "UNUSED", "NAME"); } else { printf("%8s %8s %s\n", "SIZE", "RSS", "NAME"); } while ($line = <PROCSMAPS>) { ($a1,$a2,$a3,$a4,$a5,$thelib) = split(' ',$line); if ($brieffmt) { # Shorten the library paths # Remove the directory structure for CMSSW and externals for simplicity $thelib =~ s/$baselibdir//g; $thelib =~ s/$testlibdir//g; $thelib =~ s/$basebindir//g; $thelib =~ s/$testbindir//g; # These two should be last. There are two to deal with the non-standard # structure of the SW area at CERN. $thelib =~ s/$cmspath\/sw\/$scramarch\///g; $thelib =~ s/$cmspath\/$scramarch\///g; } # Now the next 8 entries should be of the form: # Size: 8 kB # Rss: 8 kB # Shared_Clean: 0 kB # Shared_Dirty: 0 kB # Private_Clean: 0 kB # Private_Dirty: 8 kB # Swap: 0 kB (this field only in SLC5 kernels) # Pss: 0 kB (this field only in SLC5 kernels) $procsize = <PROCSMAPS>; chomp($procsize); $procrss = <PROCSMAPS>; chomp($procrss); $procshrclean = <PROCSMAPS>; chomp($procshrclean); $procshrdirty = <PROCSMAPS>; chomp($procshrdirty); $procprivclean = <PROCSMAPS>; chomp($privclean); $procprivdirty = <PROCSMAPS>; chomp($procprivdirty); $procswap = <PROCSMAPS>; chomp($procswap); $procpss = <PROCSMAPS>; chomp($procpss); ($a1,$vsize,$a3) = split(' ',$procsize); ($a1,$rss,$a3) = split(' ',$procrss); #print $vsize." ".$rss." ".$thelib."\n"; if ($unused) { printf("%7uK %7uK %7uK %s\n", $vsize, $rss, $vsize-$rss, $thelib); } else { printf("%7uK %7uK %s\n", $vsize, $rss, $thelib); } }