task.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2018 The OGP Development Team
  6. *
  7. * http://www.opengamepanel.org/
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. */
  24. // Setup the remote connection
  25. include_once("modules/status/config.php");
  26. if( isset($_GET['remote_server_id']) && $_GET['remote_server_id'] != "webhost")
  27. {
  28. require_once('includes/lib_remote.php');
  29. $rhost_id = $_GET['remote_server_id'];
  30. $remote_server = $db->getRemoteServer($rhost_id);
  31. $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key'], $remote_server['timeout']);
  32. $taskoutput = $remote->shell_action('get_tasklist', 'tasks');
  33. }else{
  34. if ($os == "windows" || $cygwin === true)
  35. {
  36. $taskoutput = array();
  37. $taskoutput["task"] = shell_exec ("tasklist /fo TABLE");
  38. }else{
  39. if($os == "linux"){
  40. $taskoutput = array();
  41. $taskoutput["task"] = shell_exec ("top -b -c -i -w512 -n2 -o+%CPU | awk '/^top/{i++}i==2' | grep 'PID' -A 30");
  42. }
  43. }
  44. }
  45. ?>