• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • Last Modified:

How can I view the CPU and Resource usage of my Linux server without accessing it?

How can I view the CPU and Resource usage of my Linux server without accessing it?  I don't have access to the server but I do have FTP access and the ability to make updates to the .htaccess file.  So is it possible to view this information without access to the server?
0
davideo7
Asked:
davideo7
  • 4
  • 3
  • 3
  • +1
7 Solutions
 
Garry GlendownConsulting and Network/Security SpecialistCommented:
I guess you could add some CGI script via FTP to your server to call system tools and give you the output via HTTP ... e.g. something like:

#!/bin/sh
echo "Content-type: text/html"
echo
echo "<html><head /><body><pre>"
ps xa | sed "s/</\&lt;/g"
echo "--------------------------------------"
cat /proc/meminfo
echo "--------------------------------------"
cat /proc/cpuinfo
echo "</pre></body></html>"

Open in new window



0
 
farzanjCommented:
Good idea by Garry-G.

But you need some kind of access to the system  not just ftp.
Even to run CGI scripts, they have to be enabled/configured in the webserver and the system must be running a web server.

Alone using ftp, you would not be able to run a script.  CGI's are typically allowed in limited directories and ftp may not have access to those folders (from security viewpoint, should not).
0
 
Garry GlendownConsulting and Network/Security SpecialistCommented:
(as the .htaccess was mentioned, I assumed it's already running an HTTP server ...)
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
farzanjCommented:
Garry-G, yes, you are right. But, when you are trying to manage a server, you should a little more access.  Second, it still may not be possible to ftp and change permissions to the correctly execute using CGI.
0
 
davideo7Author Commented:
Garry-G: How would I create a file like that and than view it?
0
 
Garry GlendownConsulting and Network/Security SpecialistCommented:
Just edit it locally, transfer to the server CGI directory, set the execute rights (depends on the FTP tool you use - set the rights to octal 555 if you can't use some symbolic feature of the client) and then just call it e.g. with http://the.server.com/cgi-bin/myscript (path depends on the server configuration, file name depends on how you name it ...)
0
 
xtermCommented:
If you're using 3rd party hosting, you will not have access to upload anything to your server's cgi-bin directory - it is root accessible only.

Simply just create a new file called cpumem.php as I have it below, and upload it to your web root directory.

The go to http://yoursite.com/cpumem.php and you can see the memory & CPU & process usage on the server.
<?php

echo "<pre>";
system("free");
echo "<br>";
system("top -n1 -b");
echo "</pre>";
system("free");

?>

Open in new window

0
 
davideo7Author Commented:
xterm: The output of that page displayed nothing.


Actually I do have access to the CGI-BIN folder, I'll try the other methods


Garry-G: I did what you said but when I go to view that file I get this: 500 Internal Server Error

0
 
xtermCommented:
Your host may have disabled exec() commands if my code didn't ouput anything (you can verify by putting the debug commands above my echo statements).  Your web provider may not want to you to run these commands - you might want to ask them if they have their own status page somewhere that tells you all of this for your server.


ini_set('display_errors','1');
ini_set('display_startup_errors','1');
error_reporting(E_ALL | E_STRICT);

Open in new window

0
 
Garry GlendownConsulting and Network/Security SpecialistCommented:
Do other cgi-scripts work on the server? Does /bin/sh exist? (haven't seen a Linux system where it didn't)
Can you check the error-logfile from apache when you access the cgi? It should have some detail on why the cgi failed. (possibly at /var/log/apache/error.log)
0
 
davideo7Author Commented:
Garry-G: /bin/sh does exist
/var/log/apache/error.log does not exist


xterm: This is what that outputs:
Warning:  system() has been disabled for security reasons in /var/www/vhosts/vizzed.com/httpdocs/tester.php on line 8
0
 
xtermCommented:
You have safe_mode enabled in /etc/php.ini is why those commands don't work.

If you turn it off and set

safe_mode_exec_dir = /usr/bin

And then restart apache, you'll be able to execute those commands and my code will show you what you need.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now