# sysv-lib.pl # Functions for parsing sysv-style ps output $has_stime = $gconfig{'os_type'} eq 'solaris'; $has_task = $gconfig{'os_type'} eq 'solaris' && $gconfig{'os_version'} >= 10; $has_zone = $gconfig{'os_type'} eq 'solaris' && $gconfig{'os_version'} >= 10; # list_processes([pid]*) sub list_processes { local($line, $dummy, @w, $i, $_, $pcmd, @plist); foreach (@_) { $pcmd .= " -p $_"; } if (!$pcmd) { $pcmd = " -e"; } $ENV{'COLUMNS'} = 10000; # needed on AIX local @cols = ( "user","ruser","group","rgroup","pid","ppid","pgid","pcpu","vsz", "nice","etime","time", ($has_stime ? ("stime") : ( )), ($has_task ? ("taskid") : ( )), ($has_zone ? ("zone") : ( )), "tty","args" ); open(PS, "ps -o ".join(",", @cols)." $pcmd |"); $dummy = <PS>; for($i=0; $line=<PS>; $i++) { chop($line); $line =~ s/^\s+//g; @w = split(/\s+/, $line); if ($line =~ /ps -o user,ruser/) { # Skip ps command $i--; next; } $plist[$i]->{"pid"} = $w[4]; $plist[$i]->{"ppid"} = $w[5]; $plist[$i]->{"user"} = $w[0]; $plist[$i]->{"cpu"} = "$w[7] %"; $plist[$i]->{"size"} = "$w[8] kB"; $plist[$i]->{"bytes"} = $w[8]*1024; local $ofs = 0; if ($has_stime) { $plist[$i]->{"_stime"} = $w[12+$ofs]; $plist[$i]->{"_stime"} =~ s/_/ /g; $ofs++; } if ($has_task) { $plist[$i]->{"_task"} = $w[12+$ofs]; $ofs++; } if ($has_zone) { $plist[$i]->{"_zone"} = $w[12+$ofs]; $ofs++; } $plist[$i]->{"time"} = $w[11]; $plist[$i]->{"nice"} = $w[9] =~ /\d+/ ? $w[9]-20 : $w[9]; $plist[$i]->{"args"} = @w<14+$ofs ? "defunct" : join(' ', @w[13+$ofs..$#w]); $plist[$i]->{"_group"} = $w[2]; $plist[$i]->{"_ruser"} = $w[1]; $plist[$i]->{"_rgroup"} = $w[3]; $plist[$i]->{"_pgid"} = $w[6]; $plist[$i]->{"_tty"} = $w[12+$ofs] =~ /\?/ ? $text{'edit_none'} : "/dev/$w[12+$ofs]"; } close(PS); return @plist; } # find_mount_processes(mountpoint) # Find all processes under some mount point sub find_mount_processes { local($out); $out = `fuser -c $_[0] 2>/dev/null`; $out =~ s/^\s+//g; $out =~ s/\s+$//g; return split(/\s+/, $out); } # find_file_processes([file]+) # Find all processes with some file open sub find_file_processes { local($out, $files); $files = join(' ', map { quotemeta($_) } map { glob($_) } @_); $out = &backquote_command("fuser $files 2>/dev/null"); $out =~ s/^\s+//g; $out =~ s/\s+$//g; return split(/\s+/, $out); } # renice_proc(pid, nice) sub renice_proc { return undef if (&is_readonly_mode()); local $out = &backquote_logged("renice $_[1] -p $_[0] 2>&1"); if ($?) { return $out; } return undef; } # get_new_pty() # Returns the filehandles and names for a pty and tty sub get_new_pty { if (!-e "/dev/ptyp0") { # Must use IO::Pty :( &error("IO::Pty Perl module is not installed"); } else { # Need to search through pty files opendir(DEV, "/dev"); local @ptys = map { "/dev/$_" } (grep { /^pty/ } readdir(DEV)); closedir(DEV); local ($pty, $tty); foreach $pty (@ptys) { open(PTY, "+>$pty") || next; local $tty = $pty; $tty =~ s/pty/tty/; open(TTY, "+>$tty") || next; local $old = select(PTY); $| = 1; select(TTY); $| = 1; select($old); return (*PTY, *TTY, $pty, $tty); } return (); } } $has_trace_command = $gconfig{'os_type'} eq 'solaris' && &has_command("truss"); # open_process_trace(pid, [&syscalls]) # Starts tracing on some process, and returns a trace object sub open_process_trace { local $fh = time().$$; local $sc; if (@{$_[1]}) { $sc = "-t ".join(",", @{$_[1]}); } local $tpid = open($fh, "truss $sc -i -p $_[0] 2>&1 |"); $line = <$fh>; return { 'pid' => $_[0], 'tpid' => $tpid, 'fh' => $fh }; } # close_process_trace(&trace) # Halts tracing on some trace object sub close_process_trace { kill('TERM', $_[0]->{'tpid'}) if ($_[0]->{'tpid'}); close($_[0]->{'fh'}); } # read_process_trace(&trace) # Returns an action structure representing one action by traced process, or # undef if an error occurred sub read_process_trace { local $fh = $_[0]->{'fh'}; local @tm = localtime(time()); while(1) { local $line = <$fh>; return undef if (!$line); if ($line =~ /^([^\(]+)\((.*)\)(\s*=\s*(\-?\d+)|\s+(Err\S+))?/) { local $action = { 'time' => time(), 'call' => $1, 'rv' => $4 ne "" ? $4 : $5 }; local $args = $2; local @args; while(1) { if ($args =~ /^[ ,]*(\{[^}]*\})(.*)$/) { # A structure in { } push(@args, $1); $args = $2; } elsif ($args =~ /^[ ,]*"([^"]*)"\.*(.*)$/) { # A quoted string push(@args, $1); $args = $2; } elsif ($args =~ /^[ ,]*\[([^\]]*)\](.*)$/) { # A square-bracket number push(@args, $1); $args = $2; } elsif ($args =~ /^[ ,]*\<([^\>]*)\>(.*)$/) { # An angle-bracketed string push(@args, $1); $args = $2; } elsif ($args =~ /[ ,]*([^, ]+)(.*)$/) { # Just a number push(@args, $1); $args = $2; } else { last; } } $action->{'args'} = \@args; return $action; } } } # os_get_cpu_info() # Returns a list containing the 5, 10 and 15 minute load averages sub os_get_cpu_info { local $out = `uptime 2>&1`; if ($out =~ /load average:\s+(\S+),\s+(\S+),\s+(\S+)/) { return ($1, $2, $3); } else { return ( ); } } # get_memory_info() # Returns a list containing the real mem, free real mem, swap and free swap # (In kilobytes). sub get_memory_info { if (!&has_command("kstat")) { return ( ); } local %stat; foreach my $s ("physmem", "freemem", "zone_memory_cap") { local $out = &backquote_command("kstat -p -m unix -s $s"); if ($out =~ /\s+(\d+)/) { $stat{$s} = $1; } } if ($stat{'zone_memory_cap'} > $stat{'physmem'}) { delete($stat{'zone_memory_cap'}); } local ($swaptotal, $swapfree); &open_execute_command(SWAP, "swap -l", 1); while(<SWAP>) { if (/^\S+\s+\d+,\d+\s+\d+\s+(\d+)\s+(\d+)/) { $swaptotal += $1; $swapfree += $2; } } close(SWAP); local $pagesize = &backquote_command("pagesize 2>/dev/null"); $pagesize = int($pagesize)/1024; $pagesize ||= 8; # Fallback return (($stat{'zone_memory_cap'} || $stat{'physmem'})*$pagesize, $stat{'freemem'}*$pagesize, $swaptotal/2, $swapfree/2); } foreach $ia (keys %text) { if ($ia =~ /^sysv(_\S+)/) { $info_arg_map{$1} = $text{$ia}; } } delete($info_arg_map{'_stime'}) if (!$has_stime); @nice_range = (-20 .. 19); $has_fuser_command = 1; 1;
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
help | Folder | 0755 |
|
|
images | Folder | 0755 |
|
|
lang | Folder | 0755 |
|
|
BorderPanel.class | File | 1.73 KB | 0644 |
|
BorderPanel.java | File | 1.02 KB | 0644 |
|
CHANGELOG | File | 1.58 KB | 0644 |
|
CbButton.class | File | 4.68 KB | 0644 |
|
CbButton.java | File | 5.31 KB | 0644 |
|
CbButtonCallback.class | File | 137 B | 0644 |
|
CbButtonGroup.class | File | 675 B | 0644 |
|
CbScrollbar.class | File | 4.2 KB | 0644 |
|
CbScrollbar.java | File | 7.62 KB | 0644 |
|
CbScrollbarArrow.class | File | 1.9 KB | 0644 |
|
CbScrollbarCallback.class | File | 164 B | 0644 |
|
LineInputStream.class | File | 1.74 KB | 0644 |
|
LineInputStream.java | File | 2.08 KB | 0644 |
|
Makefile | File | 67 B | 0644 |
|
MultiColumn.class | File | 9.55 KB | 0644 |
|
MultiColumn.java | File | 12.55 KB | 0644 |
|
MultiColumnCallback.class | File | 200 B | 0644 |
|
StringJoiner.class | File | 783 B | 0644 |
|
StringSplitter.class | File | 1.2 KB | 0644 |
|
StringSplitter.java | File | 2.02 KB | 0644 |
|
Tracer.class | File | 3.99 KB | 0644 |
|
Tracer.java | File | 2.98 KB | 0644 |
|
Util.class | File | 4.34 KB | 0644 |
|
Util.java | File | 3.15 KB | 0644 |
|
acl_security.pl | File | 1.53 KB | 0755 |
|
cgi_args.pl | File | 280 B | 0755 |
|
config-ALL-linux | File | 84 B | 0644 |
|
config-aix | File | 83 B | 0644 |
|
config-freebsd | File | 86 B | 0644 |
|
config-hpux | File | 83 B | 0644 |
|
config-irix | File | 83 B | 0644 |
|
config-macos | File | 84 B | 0644 |
|
config-netbsd | File | 86 B | 0644 |
|
config-openbsd | File | 86 B | 0644 |
|
config-openserver | File | 83 B | 0644 |
|
config-osf1 | File | 82 B | 0644 |
|
config-solaris | File | 83 B | 0644 |
|
config-unixware | File | 83 B | 0644 |
|
config-windows | File | 86 B | 0644 |
|
config.info | File | 512 B | 0644 |
|
config.info.ca | File | 635 B | 0644 |
|
config.info.cs | File | 555 B | 0644 |
|
config.info.de | File | 509 B | 0644 |
|
config.info.es | File | 341 B | 0644 |
|
config.info.fa | File | 679 B | 0644 |
|
config.info.fr | File | 382 B | 0644 |
|
config.info.hu | File | 521 B | 0644 |
|
config.info.it | File | 576 B | 0644 |
|
config.info.ja | File | 553 B | 0644 |
|
config.info.nl | File | 513 B | 0644 |
|
config.info.no | File | 513 B | 0644 |
|
config.info.pl | File | 517 B | 0644 |
|
config.info.pt_BR | File | 486 B | 0644 |
|
config.info.ru | File | 891 B | 0644 |
|
config.info.sv | File | 320 B | 0644 |
|
config.info.tr | File | 570 B | 0644 |
|
config.info.uk | File | 759 B | 0644 |
|
config.info.zh | File | 253 B | 0644 |
|
config.info.zh_TW | File | 303 B | 0644 |
|
cpan_modules.pl | File | 73 B | 0755 |
|
defaultacl | File | 38 B | 0644 |
|
edit_proc.cgi | File | 4.17 KB | 0755 |
|
freebsd-lib.pl | File | 4.5 KB | 0755 |
|
hpux-lib.pl | File | 2.62 KB | 0755 |
|
index.cgi | File | 466 B | 0755 |
|
index_cpu.cgi | File | 1.3 KB | 0755 |
|
index_run.cgi | File | 1.07 KB | 0755 |
|
index_search.cgi | File | 6.48 KB | 0755 |
|
index_size.cgi | File | 1.26 KB | 0755 |
|
index_tree.cgi | File | 1.5 KB | 0755 |
|
index_user.cgi | File | 1.11 KB | 0755 |
|
index_zone.cgi | File | 1.34 KB | 0755 |
|
kill_proc.cgi | File | 738 B | 0755 |
|
kill_proc_list.cgi | File | 860 B | 0755 |
|
killtail.cgi | File | 316 B | 0755 |
|
linux-lib.pl | File | 18.45 KB | 0755 |
|
log_parser.pl | File | 1.05 KB | 0755 |
|
macos-lib.pl | File | 4.45 KB | 0755 |
|
module.info | File | 289 B | 0644 |
|
module.info.af | File | 0 B | 0644 |
|
module.info.af.auto | File | 119 B | 0644 |
|
module.info.ar | File | 0 B | 0644 |
|
module.info.ar.auto | File | 163 B | 0644 |
|
module.info.be | File | 0 B | 0644 |
|
module.info.be.auto | File | 213 B | 0644 |
|
module.info.bg | File | 0 B | 0644 |
|
module.info.bg.auto | File | 226 B | 0644 |
|
module.info.ca | File | 118 B | 0644 |
|
module.info.ca.auto | File | 28 B | 0644 |
|
module.info.cs | File | 28 B | 0644 |
|
module.info.cs.auto | File | 112 B | 0644 |
|
module.info.da | File | 0 B | 0644 |
|
module.info.da.auto | File | 119 B | 0644 |
|
module.info.de | File | 96 B | 0644 |
|
module.info.de.auto | File | 23 B | 0644 |
|
module.info.el | File | 0 B | 0644 |
|
module.info.el.auto | File | 217 B | 0644 |
|
module.info.es | File | 26 B | 0644 |
|
module.info.es.auto | File | 101 B | 0644 |
|
module.info.eu | File | 0 B | 0644 |
|
module.info.eu.auto | File | 145 B | 0644 |
|
module.info.fa | File | 0 B | 0644 |
|
module.info.fa.auto | File | 230 B | 0644 |
|
module.info.fi | File | 0 B | 0644 |
|
module.info.fi.auto | File | 127 B | 0644 |
|
module.info.fr | File | 34 B | 0644 |
|
module.info.fr.auto | File | 123 B | 0644 |
|
module.info.he | File | 0 B | 0644 |
|
module.info.he.auto | File | 171 B | 0644 |
|
module.info.hr | File | 0 B | 0644 |
|
module.info.hr.auto | File | 132 B | 0644 |
|
module.info.hu | File | 25 B | 0644 |
|
module.info.hu.auto | File | 109 B | 0644 |
|
module.info.it | File | 31 B | 0644 |
|
module.info.it.auto | File | 105 B | 0644 |
|
module.info.ja | File | 27 B | 0644 |
|
module.info.ja.auto | File | 154 B | 0644 |
|
module.info.ko | File | 34 B | 0644 |
|
module.info.ko.auto | File | 127 B | 0644 |
|
module.info.lt | File | 0 B | 0644 |
|
module.info.lt.auto | File | 147 B | 0644 |
|
module.info.lv | File | 0 B | 0644 |
|
module.info.lv.auto | File | 131 B | 0644 |
|
module.info.ms | File | 120 B | 0644 |
|
module.info.ms.auto | File | 24 B | 0644 |
|
module.info.mt | File | 0 B | 0644 |
|
module.info.mt.auto | File | 147 B | 0644 |
|
module.info.nl | File | 27 B | 0644 |
|
module.info.nl.auto | File | 90 B | 0644 |
|
module.info.no | File | 28 B | 0644 |
|
module.info.no.auto | File | 95 B | 0644 |
|
module.info.pl | File | 29 B | 0644 |
|
module.info.pl.auto | File | 108 B | 0644 |
|
module.info.pt | File | 27 B | 0644 |
|
module.info.pt.auto | File | 107 B | 0644 |
|
module.info.pt_BR | File | 0 B | 0644 |
|
module.info.pt_BR.auto | File | 148 B | 0644 |
|
module.info.ro | File | 0 B | 0644 |
|
module.info.ro.auto | File | 138 B | 0644 |
|
module.info.ru | File | 25 B | 0644 |
|
module.info.ru.auto | File | 179 B | 0644 |
|
module.info.sk | File | 0 B | 0644 |
|
module.info.sk.auto | File | 133 B | 0644 |
|
module.info.sl | File | 0 B | 0644 |
|
module.info.sl.auto | File | 126 B | 0644 |
|
module.info.sv | File | 25 B | 0644 |
|
module.info.sv.auto | File | 91 B | 0644 |
|
module.info.th | File | 0 B | 0644 |
|
module.info.th.auto | File | 325 B | 0644 |
|
module.info.tr | File | 30 B | 0644 |
|
module.info.tr.auto | File | 123 B | 0644 |
|
module.info.uk | File | 0 B | 0644 |
|
module.info.uk.auto | File | 217 B | 0644 |
|
module.info.ur | File | 0 B | 0644 |
|
module.info.ur.auto | File | 193 B | 0644 |
|
module.info.vi | File | 0 B | 0644 |
|
module.info.vi.auto | File | 168 B | 0644 |
|
module.info.zh | File | 24 B | 0644 |
|
module.info.zh.auto | File | 91 B | 0644 |
|
module.info.zh_TW | File | 30 B | 0644 |
|
module.info.zh_TW.auto | File | 97 B | 0644 |
|
open_files.cgi | File | 2.57 KB | 0755 |
|
openbsd-lib.pl | File | 1.81 KB | 0755 |
|
osf-lib.pl | File | 2.44 KB | 0755 |
|
prefs.info | File | 53 B | 0644 |
|
proc-lib.pl | File | 15.8 KB | 0755 |
|
rbac-mapping | File | 126 B | 0644 |
|
renice_proc.cgi | File | 617 B | 0755 |
|
run.cgi | File | 1.38 KB | 0755 |
|
safeacl | File | 35 B | 0644 |
|
syslog_logs.pl | File | 336 B | 0755 |
|
sysv-lib.pl | File | 6.12 KB | 0755 |
|
tail.cgi | File | 750 B | 0755 |
|
trace.cgi | File | 2.4 KB | 0755 |
|
windows-lib.pl | File | 1.25 KB | 0755 |
|