# freebsd-lib.pl # Functions for parsing freebsd ps output use IO::Handle; sub list_processes { local($pcmd, $line, $i, %pidmap, @plist); $pcmd = @_ ? "-p $_[0]" : ""; open(PS, "ps -axwwww -o pid,ppid,user,vsz,%cpu,time,nice,tty,ruser,rgid,pgid,lstart,lim,command $pcmd |"); for($i=0; $line=<PS>; $i++) { chop($line); if ($line =~ /ps -axwwww/ || $line =~ /^\s*PID/) { $i--; next; } $line =~ /^\s*(\d+)\s+(\d+)\s+(\S+)\s+(\d+)\s+([\d\.]+)\s+(\S+)\s+(-?\d+)\s+(\S+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(-|\S+\s+\S+\s+\d+\s+\S+\s+\d+|\d+)\s+(\S+)\s+(.*)$/; $plist[$i]->{"pid"} = $1; $plist[$i]->{"ppid"} = $2; $plist[$i]->{"user"} = $3; $plist[$i]->{"size"} = "$4 kB"; $plist[$i]->{"bytes"} = $4*1024; $plist[$i]->{"cpu"} = $5; $plist[$i]->{"time"} = $6; $plist[$i]->{"nice"} = $7; $plist[$i]->{"_tty"} = $8; $plist[$i]->{"_ruser"} = $9; $plist[$i]->{"_rgroup"} = getgrgid($10); $plist[$i]->{"_pgid"} = $11; $plist[$i]->{"_stime"} = $12; $plist[$i]->{"_lim"} = $13 eq "-" ? "Unlimited" : $13; $plist[$i]->{"args"} = $14; } close(PS); return @plist; } # 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; } foreach $ia (keys %text) { if ($ia =~ /^freebsd(_\S+)/) { $info_arg_map{$1} = $text{$ia}; } } @nice_range = (-20 .. 20); $has_fuser_command = 0; # get_new_pty() # Returns the filehandles and names for a pty and tty sub get_new_pty { local @ptys; opendir(DEV, "/dev"); @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 (); } # close_controlling_pty() # Disconnects this process from it's controlling PTY, if connected sub close_controlling_pty { if (open(DEVTTY, "</dev/tty")) { # Special ioctl to disconnect (TIOCNOTTY) ioctl(DEVTTY, 536900721, 0); close(DEVTTY); } } # open_controlling_pty(ptyfh, ttyfh, ptyfile, ttyfile) # Makes a PTY returned from get_new_pty the controlling TTY (/dev/tty) for # this process. sub open_controlling_pty { local ($ptyfh, $ttyfh, $pty, $tty) = @_; # Call special ioctl to attach /dev/tty to this new tty (TIOCSCTTY) ioctl($ttyfh, 536900705, 0); } # get_memory_info() # Returns a list containing the real mem, free real mem, swap and free swap # (In kilobytes). sub get_memory_info { my $sysctl = {}; my $sysctl_output = &backquote_command("/sbin/sysctl -a 2>/dev/null"); return ( ) if ($?); foreach my $line (split(/\n/, $sysctl_output)) { if ($line =~ m/^([^:]+):\s+(.+)\s*$/s) { $sysctl->{$1} = $2; } } return ( ) if (!$sysctl->{"hw.physmem"}); my $mem_inactive = $sysctl->{"vm.stats.vm.v_inactive_count"} * $sysctl->{"hw.pagesize"}; my $mem_cache = $sysctl->{"vm.stats.vm.v_cache_count"} * $sysctl->{"hw.pagesize"}; my $mem_free = $sysctl->{"vm.stats.vm.v_free_count"} * $sysctl->{"hw.pagesize"}; my ($swapinfo_output) = &backquote_command("/usr/sbin/swapinfo"); my ($swap_total, $swap_free) = (0, 0); foreach my $line (split(/\n/, $swapinfo_output)) { if ($line =~ /^(\S+)\s+(\d+)\s+(\d+)\s+(\d+)/) { $swap_total += $2 * 1024; $swap_free += $4 * 1024; } } return ( $sysctl->{"hw.physmem"} / 1024, ($mem_inactive + $mem_cache + $mem_free) / 1024, $swap_total, $swap_free ); } # os_get_cpu_info() # Returns a list containing the 5, 10 and 15 minute load averages, and the # CPU mhz, model, vendor, cache and count sub os_get_cpu_info { local $out = &backquote_command("uptime"); local @load; if ($out =~ /load\s+(average|averages):\s+([0-9\.]+),\s+([0-9\.]+),\s+([0-9\.]+)/) { @load = ($2, $3, $4); } else { return ( ); } $out = &backquote_command("sysctl hw.model hw.ncpu"); if ($out =~ /hw.model:\s+(\S+)\s+(\S.*\S)\s+\@\s+(\S+)/) { push(@load, $3, $2, $1, undef); } elsif ($out =~ /hw.model:\s+(\S+)\s+(\S.*\S)/) { push(@load, undef, $2, $1, undef); } else { return @load; } if ($out =~ /hw.ncpu:\s+(\d+)/) { push(@load, $1); } return @load; } # get_cpu_io_usage() # Returns a list containing CPU user, kernel and idle time # blocks in and out sub get_cpu_io_usage { my $out = &backquote_command("vmstat 0.1 2 2>/dev/null"); if ($?) { $out = &backquote_command("vmstat 1 2 2>/dev/null"); } return ( ) if ($?); my @lines = split(/\r?\n/, $out); my @w = split(/\s+/, $lines[$#lines]); shift(@w) if ($w[0] eq ''); return ( $w[-3], $w[-2], $w[-1], 0, 0, undef, undef ); } 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 |
|