Jun 072009
 

from http://www.labradordata.ca/home/13
vpsinfo is a Linux server monitoring script, written in PHP, that provides web access to system status information. It gathers the output from several common Linux commands into one web page, providing a quick overview of the system’s current state.

While designed for use on a Linux Virtuozzo or OpenVZ VPS (Virtual Private Server), vpsinfo also works fine on a dedicated server. When installed on a dedicated machine VPS-specific information is automatically excluded.

Please note that on Virtuozzo v. 3 and OpenVZ servers the small beanc helper app is required to access VPS status information. The helper app is not required for Virtuozzo v. 2.6 servers.
vpsinfo shows the following output:

* Output from top;
* Processed /proc/user_beancounters (VPS resources);
* Output from netstat -nt (current TCP connections);
* Output from netstat -ntl (listening TCP ports);
* Output from pstree (tree view of running processes);
* Output from ls -a /tmp (and ls -al /tmp);
* Output from vnstat (an application that monitors traffic at the network interface) using its various commandline switches;
* Output from mytop (an application that monitors MySQL) or from mysqlreport (a perl script which generates a mysql status report);
* Status monitoring of daemon processes;
* Summary section showing:
o Values for oomguarpages and privvmpages (or free RAM and swap usage on a dedicated machine);
o Data transfer today through the network interface (from vnstat);
o Current number of TCP connections;
o Current number of Apache and MySQL threads, and MySQL queries (from mytop or mysqlreport)
o Disk usage.

Requirements

* Linux;
* PHP: vpsinfo was initially developed with v. 4.3.10 and should run fine with later releases;
* The beanc helper app if running on a Virtuozzo v. 3 or OpenVZ server;
* PHP safe mode off. Safe mode disables the ability to run programs outside the script directory (reference).

Optional Third-party Software
These applications are not required to run vpsinfo, but if installed they are used to gather additional information:

* vnstat: an application to monitor data transfer at the network interface. Highly recommended!
* mytop: an application similar to ‘top’ but which monitors a MySQL server.
* mysqlreport: a perl script that generates an analysis of MySQL performance.

Installation
Important! If you have a Virtuozzo v. 3 or OpenVZ VPS you must also install the beanc helper app.

1. Get the file (in the Download section below);
2. Edit the configuration variables at the top;
3. Save it with a .php extension and place it on your webserver.

I strongly recommend you place it in a password-protected directory. You should not be exposing this much server information to everyone on the web.

Configuration
If you use either mytop or mysqlreport, you must edit the MySQL connection information. Supply a valid MySQL database name, username & password.

mytop is installed as a system application. The mytop website and the README file in the downloadable package will provide installation information.

mysqlreport is a perl script which you place in the same directory as vpsinfo. Once you have it in place you must make it executable by the webserver user:

* If you are running phpsuexec, then the mysqlreport script should be owned by the account user and chmod 700.
* If you are not using phpsuexec, then the mysqlreport script should be owned by the webserver user (e.g., ‘nobody’) and chmod 700. Check your system to find the username which the webserver runs as. If you do not have sufficient previledges to change ownership of the script, then the script must be made world-executable, e.g., chmod 777.

Note: vpsinfo may fail to correctly execute mysqlreport if your MySQL password contains non-alphanumeric characters. If you get a “denied access to mysql” message, try a simpler alphanumeric password.
Other configuration items are optional and are explained in the configuration section of the script.

Download
Here is the script as a plain-text file:
vpsinfo.txt. Save it as “vpsinfo.php”.

 Posted by at 9:27 am