'OPEN_FLAGS_DASD', 0x4000 => 'OPEN_FLAGS_WRITE_THROUGH', 0x2000 => 'OPEN_FLAGS_FAIL_ON_ERROR', 0x1000 => 'OPEN_FLAGS_NO_CACHE', ); $modes_10_8 = array( 0x0300 => 'OPEN_FLAGS_RANDOMSEQUENTIAL', 0x0200 => 'OPEN_FLAGS_RANDOM', 0x0100 => 'OPEN_FLAGS_SEQUENTIAL', 0x0000 => 'OPEN_FLAGS_NO_LOCALITY', ); $mask_10_8 = 0x0700; // 0000'0111'0000'0000 $modes2 = array( 0x0080 => 'OPEN_FLAGS_NOINHERIT', 0x0040 => 'OPEN_SHARE_DENYNONE', 0x0030 => 'OPEN_SHARE_DENYREAD', 0x0020 => 'OPEN_SHARE_DENYWRITE', 0x0010 => 'OPEN_SHARE_DENYREADWRITE', ); $modes_2_0 = array( 0x0002 => 'OPEN_ACCESS_READWRITE', 0x0001 => 'OPEN_ACCESS_WRITEONLY', 0x0000 => 'OPEN_ACCESS_READONLY', ); $mask_2_0 = 0x0003; // 0000'0000'0000'0011 // file attributes $attrs = array( 0x0020 => 'FILE_ARCHIVED', 0x0010 => 'FILE_DIRECTORY', 0x0004 => 'FILE_SYSTEM', 0x0002 => 'FILE_HIDDEN', 0x0001 => 'FILE_READONLY', // 0x0000 => 'FILE_NORMAL' ); // priorities $priorities = array(1 => 'idle', 'regular', 'server', 'timecritical'); // ********** HTML blocks ***************************************************** $header = ' Process viewer %s '; $styles = ''; $footer = ' '; $table_spacer = '==== ==== ======= === ==== %s============ ============'."\n"; if ($show_getram) { $table_spacer = sprintf($table_spacer, '======== ======= '); } else { $table_spacer = sprintf($table_spacer, ''); } $table_header = "

\n". ''. ''. ''. ''. ''. ''. ''. '%s'. ''. ''. "\n".$table_spacer; if ($show_getram) { $table_header = sprintf($table_header, ''); } else { $table_header = sprintf($table_header, ''); } $table_footer = $table_spacer."
PID PPID Sess  Thr Prio CPU time  Name
Private Shared 
\n"; $back = "\n
<< back\n"; $zuko = 'zuko'; $theseus4 = 'theseus4'; // ========== start =========================================================== if ((strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/4') !== false) and !strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { $header = sprintf($header, ''); // do not show styles to Netscape } else { $header = sprintf($header, $styles); } // ********** if request to kill ********************************************** $k = intval($_GET['k']); $ka = $_GET['ka']; if ($k or strlen($ka)) { if ($_GET['sure'] == 'y') { if (!in_array($_SERVER['REMOTE_ADDR'], $allowed_to_kill)) { echo $header; echo "Go kill yourself, bro!\n
You are not allowed to kill processes on this box."; echo $back; echo $footer; die(); } $cmd = ''; if ($k) { $cmd = "$go_exe -k $k"; } if (strlen($ka)) { $cmd = "$go_exe -ka $ka"; } if (strlen($cmd)) { exec($cmd); } my_redirect($self); die(); } echo $header; $go = `$go_exe`; parse_go_procs($go, $proc); if ($k) { $name = ''; foreach ($proc as $a) { if (intval($a['pid']) == $k) { $name = trim($a['name']); break; } } if (strlen($name)) { echo "Are you sure you want to kill process with PID $k ($name)?\n"; echo '
   yes   '."\n"; echo '   no   '."\n"; } else { echo "Process with PID $k not found!"; echo $back; } } else { $count= 0; foreach ($proc as $a) { if (trim($a['name']) == $ka) { $count++; } } if ($count) { echo "Are you sure you want to kill all $ka processes (total: $count)?\n"; echo '
   yes   '."\n"; echo '   no   '."\n"; } else { echo "No $ka process(es) found!"; echo $back; } } echo $footer; die(); } // ********** if show more... ************************************************* if ($pid = intval($_GET['show'])) { echo $header; $cmd = sprintf('%s /P:%X', $pstat, $pid); echo "PSTAT information:\n"; $out = `$cmd`; if ($parse_pstat) { echo "
\n".parse_pstat_output($out); } else { echo "
\n$out
"; } echo "\n


"; $cmd = sprintf('%s %X', $psfiles, $pid); echo "\nPSFILES information:\n"; $out = `$cmd`; if ($parse_psfiles) { echo "

\n".parse_psfiles_output($out); } else { echo "
\n$out
"; } echo $back; echo $footer; die(); } // ********** if show `go` output ********************************************* $sort = $_GET['sort']; $sortby = array('PID' => 'sort_by_pid', 'PPID' => 'sort_by_ppid', 'Sess' => 'sort_by_sess', 'Thr' => 'sort_by_thr', 'Prio' => 'sort_by_prio', 'PrivMem' => 'sort_by_privmem', 'ShMem' => 'sort_by_shmem', 'CPU' => 'sort_by_cpu', 'Name' => 'sort_by_name'); echo $header; $go = `$go_exe`; go_proc_report($go); go_uptime_report($go); if ($expose_zuko) { zuko_uptime_report($zuko_uptime); } parse_go_procs($go, $proc); if ($show_getram) { $ths_mem_report = parse_getram($ths_getram, $mem); } $n = sizeof($proc); if (strlen($sortby[$sort])) { usort($proc, $sortby[$sort]); if (($sort == 'CPU') or ($sort == 'Name')) { for ($i=0;$i<$n;$i++) { $proc[$i]['name'] = trim($proc[$i]['name']); } } } ?>

Process listview unsorted)'; } ?>:'. '%d '. // pid '%d '. // ppid '%s '. // sess1 '%s '. // sess2 ' %s '. // thr '%s '. // prio '%s'. // possible mem report '%s '. // cpu '%s'. // name ''."\n"; $tmpl2 = '%s %s '; // priv mem, sh mem for ($i=0;$i<$n;$i++) { $curr_pid = $proc[$i]['pid']; $out = sprintf($tmpl, $self, $curr_pid, $curr_pid, $curr_pid, $proc[$i]['ppid'], $proc[$i]['sess1'], $proc[$i]['sess2'], $self, urlencode(trim($proc[$i]['name'])), trim($proc[$i]['name']), $proc[$i]['thr'], say_prio($proc[$i]['prio']), $proc[$i]['prio'], '%s', $proc[$i]['cpu'], $self, $curr_pid, str_replace(' ', ' ', $proc[$i]['name'])); if ($show_getram) { if (!strlen($privmem = $mem[$curr_pid]['privmem'])) { $privmem = '- - -'; } if (!strlen($shmem = $mem[$curr_pid]['shmem'])) { $shmem = '- - -'; } printf($out, sprintf($tmpl2, $privmem, $shmem)); } else { printf($out, ''); } } echo $table_footer; if ($expose_zuko) { zuko_mem_report($zuko_mem); } if ($show_getram) { echo $ths_mem_report; } echo $footer; // ========== end ============================================================= // ********** funcs ************************************************************* // show number of processes & threads from `go` output function go_proc_report(&$go) { preg_match('/ (\d+) Processes with (\d+)/', $go, $m); list($match, $numproc, $numthr) = $m; echo "\nThere are $numproc processes with $numthr threads.\n"; } // show uptime from `go` output function go_uptime_report(&$go) { preg_match('/uptime is (\d+)d (\d+)h (\d+)m (\d+)s/', $go, $m); list($match, $day, $hour, $min, $sec) = $m; if (intval($day)) { printf("
System uptime is %d days %02d:%02d:%02d\n", $day, $hour, $min, $sec); } else { printf("
System uptime is %02d:%02d:%02d\n", $hour, $min, $sec); } } // parse `go.exe` output to $proc array function parse_go_procs(&$go, &$proc) { preg_match_all('/(\d+)\s+(\d+)\s([0-9A-F]+) (\w+)\s+(\d+)\s+([0-9A-F]+)\s+([.:0-9]+) (\s*[\S]+)/m', $go, $matches); // 0: match // 1: P-ID // 2: PPID // 3: Sess 1 // 4: Sess 2 // 5: Thr // 6: Prio // 7: CPU Time // 8: Name list($match, $pid, $ppid, $sess1, $sess2, $thr, $prio, $cpu, $name) = $matches; $n = sizeof($match); for ($i=0;$i<$n;$i++) { $proc[$i]['pid'] = intval($pid[$i]); $proc[$i]['ppid'] = intval($ppid[$i]); $proc[$i]['sess1'] = $sess1[$i]; $proc[$i]['sess2'] = $sess2[$i]; $proc[$i]['thr'] = $thr[$i]; $proc[$i]['prio'] = $prio[$i]; $proc[$i]['cpu'] = $cpu[$i]; $proc[$i]['name'] = $name[$i]; if (intval($pid[$i]) == 1) { $proc[$i]['name'] = 'SYSINIT'; } // go.exe bug } } function parse_getram($ths_getram, &$mem) { GLOBAL $theseus4; $cmd = "$ths_getram 1 0"; $ths = `$cmd`; preg_match_all('/^(\d+)\s+([.\d]+)M\s+([.\d]+)M\s+([.\d]+)\s+([.\d]+)\s+/m', $ths, $matches); // 0: match // 1: pid // 2: priv mem (Mb) // 3: sh mem (Mb) // 4: priv mem (pages) // 5: sh mem (pages) list($match, $pid, $privmem, $shmem, $privpages, $shpages) = $matches; $n = sizeof($pid); for ($i=0;$i<$n;$i++) { $key = intval($pid[$i]); $mem[$key] = array('privmem' => $privmem[$i], 'shmem' => $shmem[$i], 'privpages' => $privpages[$i], 'shpages' => $shpages[$i]); } // find summary preg_match_all('/^\s+([.\d]+)M\s+(|[.0-9]+M)\s+(\d+)\s+(|[.0-9]+)\s+(.*)/m', $ths, $matches); // 251.355M 68.570M 64347 17554 Total RAM used // 191.570M 49042 Free RAM available // -------- ------- // 511.496M 130943 Total RAM (Prvt+Shr+Free) list($match, $privmem, $shmem, $privpages, $shpages, $name) = $matches; $out = "
\n\n"; $out .= ''."\n"; $out .= ''."\n"; $n = sizeof($match); for ($i=0;$i<$n;$i++) { $pm = substr($privmem[$i], 0, -1).' Mb'; if (strlen($sm = $shmem[$i])) { $sm = substr($sm, 0, -1).' Mb'; } else { $sm = ' '; } $out .= sprintf("\n", trim($name[$i]), $pm, $sm, $privpages[$i], $shpages[$i]); } $out .= "
'.$theseus4.' memory report:Count in Megabytes    Count in Pages 
 Private  Shared   Private  Shared 
%s  %s  %s   %s  %s 
\n"; return $out; } // show zuko uptime report function zuko_uptime_report($zuko_uptime) { GLOBAL $zuko; preg_match('/(\d+)d (\d+)h (\d+)m (\d+)s/', `$zuko_uptime`, $m); list($match, $day, $hour, $min, $sec) = $m; if (intval($day)) { printf("
$zuko says system uptime is %d days %02d:%02d:%02d\n", $day, $hour, $min, $sec); } else { printf("
$zuko says system uptime is %02d:%02d:%02d\n", $hour, $min, $sec); } } // show zuko mem report function zuko_mem_report($zuko_mem) { GLOBAL $zuko; $out = "
$zuko memory report:\n\n"; preg_match_all('/^(.+) :\s+([.\d]+) Mb\s+\((\d+)/m', `$zuko_mem`, $matches); // match // type of memory // Mb // kb list($match, $name, $mb, $kb) = $matches; $n = sizeof($match); for ($i=0;$i<$n;$i++) { $out .= sprintf("\n", trim($name[$i]), $mb[$i], $kb[$i]); } $out .= "
%s  %s Mb  (%s kb)
\n"; echo $out; } // parse PSFILES output function parse_pstat_output($in) { preg_match('/([0-9a-f]{4})\s+([0-9a-f]{4})\s+([0-9a-f]{2})\s+(\S+)(.*)Thread.*Semaphores(.*)/ism', $in, $matches); list($match, $pid, $ppid, $sid, $process, $dlls, $threads) = $matches; $tmpl = "
\n".
            "Process:  %s\n".
            "PID:      %d\n".
            "PPID:     %d\n".
            "Session:  0x%s\n".
            "
\n"; $out = sprintf($tmpl, $process, hexdec($pid), hexdec($ppid), $sid); preg_match_all('/\s+(\S.*)/m', $dlls, $matches); list($match, $dlls) = $matches; $out .= "\n"; $out .= ''."\n"; foreach ($dlls as $dll) { list($dll, $memname) = preg_split('/\s+/', $dll); $out .= ""; } $out .= "\n
Run-time link libraries Shared memory names
$dll $memname
\n"; $out .= "
Threads\n"; preg_match_all('/\s+(\S.*)/m', $threads, $matches); list($match, $threads) = $matches; $out .= "\n"; $out .= ''."\n"; $tmpl = ''. // thread id ''. // prio ''. // state ''. // block "\n"; // sem foreach ($threads as $thread) { list($tid, $prio, $state, $block, $sem) = preg_split('/\s+/', $thread); $out .= sprintf($tmpl, $tid, say_prio($prio), $prio, $state, $block, $sem); } $out .= "\n
ID Priority State Block ID Owned Semaphores
%d %s %s %s %s 
"; return $out; } // parse PSFILES output function parse_psfiles_output($in) { preg_match_all('/([0-9a-f]{4}) ([0-9a-f]{4}) ([0-9a-f]{4})([0-9a-f]{4}| no )\s*([0-9a-f]{8}|)\s*([0-9a-f]{8}|)\s*([0-9a-f]{8}|)\s*([0-9a-f]{4}|)\s*([0-9a-f]{4}|)\s*(.*)/m', $in, $matches); // pid Hdl SFN refs flags mode size hvpb attr name list($match, $pid, $Hdl, $SFN, $refs, $flags, $mode, $size, $hvpb, $attr, $name) = $matches; $out = "\n"; $out .= ''."\n"; $tmpl = ''. ''. // Hdl ''. // SFN ''. // refs ''. // flags ''. // mode ''. // size ''. // hvpb ''. // attr ''. // name "\n"; $n = sizeof($match); for ($i=0;$i<$n;$i++) { $out .= sprintf($tmpl, $Hdl[$i], hexdec($Hdl[$i]), $SFN[$i], $refs[$i], hexdec($refs[$i]), $flags[$i], $mode[$i], say_mode($mode[$i]), $size[$i], nice_decimal(hexdec($size[$i])), $hvpb[$i], $attr[$i], say_attr($attr[$i]), trim($name[$i])); } $out .= '
Hdl SFN refs flags mode size hvpb attr name 
 %d  %s  %d  %s %s %s  %s %s%s
'; return $out; } // sorting functions function sort_by_pid($a, $b) { return (intval($a['pid']) < intval($b['pid'])) ? -1 : 1; } function sort_by_ppid($a, $b) { if (intval($a['ppid']) == intval($b['ppid'])) { return (intval($a['pid']) < intval($b['pid'])) ? -1 : 1; } return (intval($a['ppid']) < intval($b['ppid'])) ? -1 : 1; } function sort_by_sess($a, $b) { if ($a['sess1'] == $b['sess1']) { if ($a['sess2'] == $b['sess2']) { return (intval($a['pid']) < intval($b['pid'])) ? -1 : 1; } return ($a['sess2'] < $b['sess2']) ? -1 : 1; } return ($a['sess1'] < $b['sess1']) ? -1 : 1; } function sort_by_thr($a, $b) { if (intval($a['thr']) == intval($b['thr'])) { return (intval($a['pid']) < intval($b['pid'])) ? -1 : 1; } return (intval($a['thr']) > intval($b['thr'])) ? -1 : 1; } function sort_by_prio($a, $b) { if ($a['prio'] == $b['prio']) { return (intval($a['pid']) < intval($b['pid'])) ? -1 : 1; } return ($a['prio'] > $b['prio']) ? -1 : 1; } function sort_by_privmem($a, $b) { GLOBAL $mem; $mema = (float)$mem[$a['pid']]['privmem']; $memb = (float)$mem[$b['pid']]['privmem']; if ($mema == $memb) { return ($a['pid'] < $b['pid']) ? -1 : 1; } return ($mema > $memb) ? -1 : 1; } function sort_by_shmem($a, $b) { GLOBAL $mem; $mema = (float)$mem[$a['pid']]['shmem']; $memb = (float)$mem[$b['pid']]['shmem']; if ($mema == $memb) { return ($a['pid'] < $b['pid']) ? -1 : 1; } return ($mema > $memb) ? -1 : 1; } function sort_by_cpu($a, $b) { preg_match('/(\d+):(\d{2}):(\d{2})\.(\d{2})/', $a['cpu'], $m); list($match, $h, $m, $s, $th) = $m; $a1 = 60*60*$h + 60*$m + $s + $th/100; preg_match('/(\d+):(\d+):(\d+)\.(\d+)/', $b['cpu'], $m); list($match, $h, $m, $s, $th) = $m; $b1 = 60*60*$h + 60*$m + $s + $th/100; if ($a1 == $b1) { return (intval($a['pid']) < intval($b['pid'])) ? -1 : 1; } return ($a1 > $b1) ? -1 : 1; } function sort_by_name($a, $b) { if (trim($a['name']) == trim($b['name'])) { return (intval($a['pid']) < intval($b['pid'])) ? -1 : 1; } return (trim($a['name']) < trim($b['name'])) ? -1 : 1; } // redirection function my_redirect($url, $code = 302) { if ($code == 303) { preg_match('/^HTTP\/(\d)\.(\d)/', $_SERVER['SERVER_PROTOCOL'], $m); if (intval($m[1])*10+intval($m[2]) < 11) { $code = 302; } } if ($code == 303) { Header($_SERVER['SERVER_PROTOCOL'].' 303 See Other'); } else { Header($_SERVER['SERVER_PROTOCOL'].' 302 Found'); } if (substr($url, 0, 1) == '/') { $url = 'http://'.$_SERVER['HTTP_HOST'].$url; } elseif (!strpos($url, '://')) { preg_match('/(.+?)[^\/]+$/', $_SERVER['REQUEST_URI'], $m); $url = 'http://'.$_SERVER['HTTP_HOST'].$m[1].$url; } Header('Location: '.$url); ?> Oops!

Ваш браузер не понимает HTTP redirect (status code: ).
Следуйте по этой ссылке.


Your browser does not understand HTTP redirect (status code: ).
Follow this link. $name) { if (($mode & $bit) == $bit) { $out .= ' '.$name.' 
'; } } foreach ($modes_10_8 as $bit => $name) { if ((($mode & $mask_10_8) & $bit) == $bit) { $out .= ' '.$name.' 
'; break; } } foreach ($modes2 as $bit => $name) { if (($mode & $bit) == $bit) { $out .= ' '.$name.' 
'; } } foreach ($modes_2_0 as $bit => $name) { if ((($mode & $mask_2_0) & $bit) == $bit) { $out .= ' '.$name.' '; break; } } return $out; } // return ulAttribute function say_attr($str) { GLOBAL $attrs; if (!strlen($str)) { return ' - - -'; } $attr = hexdec($str); if (!$attr) { $out = ' FILE_NORMAL '; } else { $out = ''; foreach ($attrs as $bit => $name) { if (($attr & $bit) == $bit) { $out .= ' '.$name.' 
'; } } $out = substr($out, 0, -4); } return $out; } // 02xx -> regular+xx function say_prio($str) { GLOBAL $priorities; return $priorities[(intval($str[1]))].'+'.substr($str, -2); } // 1234567 -> 1,234,567 function nice_decimal($a, $separator = ',') { $a = strval($a); $out = ''; for($i=strlen($a);$i>3;$i-=3) { $out = $separator.substr($a, $i-3, 3).$out; } return substr($a, 0, $i).$out; } // Dmitry Ban, ban at ram.ru ?>