Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(empty($_GET['show'])) { die("access denied"); }
- if($_GET['get'] == "true") {
- # http://wiki.vpslink.com/Linux_Command_Reference:_ps
- //$ps = shell_exec("ps aux | grep -v -E '[0-9]{0,} \[.*\]$'");
- $ps = shell_exec("ps aux");
- $ps = explode("\n", $ps);
- unset($ps[0]);
- $return = "<pre>";
- $return .= "<table style='width:100%;'>";
- $return .= "<tr>";
- $return .= "<th>User</th>";
- $return .= "<th>PID</th>";
- $return .= "<th>CPU</th>";
- $return .= "<th>Mem</th>";
- //$return .= "<th>VSZ</th>";
- //$return .= "<th>TTY</th>";
- //$return .= "<th>Ste</th>";
- $return .= "<th>Start</th>";
- $return .= "<th>Command</th>";
- $return .= "</tr>";
- $count=0;
- foreach($ps as $part) {
- if(strlen($part)<1) continue; else $count++;
- $user = shell_exec("echo \"".$part."\" | awk '{print $1}'");
- $pid = shell_exec("echo \"".$part."\" | awk '{print $2}'");
- $cpu = shell_exec("echo \"".$part."\" | awk '{print $3}'");
- $mem = shell_exec("echo \"".$part."\" | awk '{print $4}'");
- //$vsz = shell_exec("echo \"".$part."\" | awk '{print $5}'");
- //$tty = shell_exec("echo \"".$part."\" | awk '{print $7}'");
- //$state = shell_exec("echo \"".$part."\" | awk '{print $8}'");
- $start = shell_exec("echo \"".$part."\" | awk '{print $9}'");
- $command = shell_exec("echo \"".$part."\" | awk '{print $11}'");
- preg_match("/".preg_quote(trim($command), "/")."(.*)$/", $part, $matches);
- $command = $command." ".$matches[1];
- $return .= "<tr>";
- $return .= "<td style='font-size:10px;'>".htmlentities($user)."</td>";
- $return .= "<td style='font-size:10px;'>".htmlentities($pid)."</td>";
- $return .= "<td style='font-size:10px;'>".htmlentities($cpu)."</td>";
- $return .= "<td style='font-size:10px;'>".htmlentities($mem)."</td>";
- //$return .= "<td style='font-size:10px;'>".htmlentities($vsz)."</td>";
- //$return .= "<td style='font-size:10px;'>".htmlentities($tty)."</td>";
- //$return .= "<td style='font-size:10px;'>".htmlentities($state)."</td>";
- $return .= "<td style='font-size:10px;'>".htmlentities($start)."</td>";
- $return .= "<td style='font-size:10px;'>".htmlentities($command)."</td>";
- $return .= "</tr>";
- }
- $return .= "</table>";
- $return = "Es laufen ".$count." Prozesse. (Kernelprozesse ausgenommen!)".$return;
- $return .= "</pre>";
- echo $return;
- die();
- }
- ?>
- <html>
- <head>
- <title>Prozessliste</title>
- <style type="text/css">
- pre { font-family: Arial; }
- #content { position: absolute; left: 40px; }
- </style>
- <script type="text/javascript">
- function createAjaxRequest() {
- var xmlHttp;
- if ( window.XMLHttpRequest ) {
- xmlHttp = new XMLHttpRequest();
- } else if ( window.ActiveXObject ) {
- xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
- } else {
- alert("AJAX wird von Ihrem Browser leider nicht unterstuetzt!\nBitte aktualisieren Sie Ihren Browser!");
- }
- return xmlHttp;
- }
- function load()
- {
- var reqObj = createAjaxRequest();
- reqObj.open('GET', 'prozlist.php?get=true&show=true', true);
- reqObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- reqObj.send();
- reqObj.onreadystatechange = function(){
- if (reqObj.readyState == 4) {
- document.getElementById('prozlist').innerHTML = reqObj.responseText;
- }
- }
- reload();
- }
- function reload() {
- window.setTimeout("load();", 5*1000);
- }
- </script>
- </head>
- <body onLoad="load();">
- Aktualisierung erfolgt jede 5 Sekunden.<br />
- <input type="button" value=" Manuele Aktualisierung " onclick="load();"><br />
- <br />
- <font size="3"><b>Prozessliste</b></font><br />
- <div id="content"><span id="prozlist"></span></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment