OpenVZ Server Status Script
This script generates an HTML report that provides a status overview of an OpenVZ VPS.
This version of the script is no longer maintained. A new version is available here.
The script is written in bash and is designed to be run as a cronjob by the root user. It generates a simple HTML page as shown in the screenshot at left. There are a few gazillion scripts floating around the web that perform a similar function, and I don't claim this script is any better :)
Actually, I didn't even set out to write a 'server status' script. The project began as an exercise in bash scripting, doing such things as creating and iterating through arrays and using functions. And because of this the script does lots of things the hard way :)
For instance, we could easily write a script that generates an 'uptime' report like this:
#!/bin/bash echo `uptime` > report
The hard way of doing it is to read /proc/uptime, perform the arithmetic and format the output. That's what I've done -- not because I like doing things the hard way but as a learning exercise.
If you'd like to view the code, here's a link: /files/scripts/status.sh.txt.
Setup
Decide where you want to put the script. I usually create a directory /root/scripts for things like this. Then, to install the script:
[root@vps] cd /root/scripts [root@vps] wget http://linux.dashed.ca/files/scripts/status.sh.txt [root@vps] mv status.sh.txt status.sh [root@vps] chmod 700 status.sh [root@vps] vi status.sh
...and edit the script settings. The only thing you must change is the path for the HTML report. Comments in the script explain the other settings.
Next, create a root cronjob to run the script:
[root@vps] crontab -e
...and add a line like this to run it every 5 minutes:
*/5 * * * * /root/scripts/status.sh
You can adjust the interval to your liking -- every 10 minutes, or 30 minutes, etc.
Comments and suggestions for improvement are welcome!
But what this does is really a nice job. I like the seperate html file.
Good luck.
Another thing, if this is a cgi, maybe we can accumulate the results over time. Particularly the traffic information, maybe we can get the traffic since boot time.