Help - Search - Members - Calendar
Full Version: Re-create the Plesk "server -> system statistics" page
The Planet Forums > Control Panels > Plesk
caddmngr
Hey everyone...

I like the server -> system statistics page of Plesk, and was thinking of how friggin cool it would be if there was a remote version of it, if you will - an external page that mimics the stats on the plesk page, I guess is what I mean.

I'd like to put it on my iGoogle page as a widget and be able to monitor my server visually without logging into plesk and hitting the page's refresh link over and over.

Does anyone know of a tool that exists already? Or how simple could we write such a tool? I'm a veteran php / perl developer, but all for b2b web apps, never a server interaction tool like this.

Any input and feedback is appreciated! Maybe it would be something lots of people would use! icon_smile.gif

thanks
Chris
Squire
I guess the question becomes what data you want to show up somewhere else. All of the stuff you're looking at in that statistics page can be retrieved right from the server itself, outside of Plesk. Thus you could save whatever data you needed in whatever format you wanted to a plain text file, then call that into your iGoogle. Or anywhere else you wanted it for that matter.

To get ya started, here's a little shell script I've called load.sh that will grab text strings for the load average for last 5, 10 and 15 minutes, just like you'd see if you ran top via shell. It writes the three values to three php variables into a file I've called load.php. I variablized them so if someone happens across my load.php page they'll see nothing. But I can use another php page to include the load.php file and grab the variables.

CODE
#!/bin/bash
#
# -----------------------------------------------------------------

        TEMPFILE="$(mktemp)"
        FTEXT='load average:'

# get first 5 min load
F5M="$(uptime | awk -F "$FTEXT" '{ print $2 }' | cut -d, -f1)"
# 10 min
F10M="$(uptime | awk -F "$FTEXT" '{ print $2 }' | cut -d, -f2)"
# 15 min
F15M="$(uptime | awk -F "$FTEXT" '{ print $2 }' | cut -d, -f3)"

echo ${F5M}
echo ${F10M}
echo ${F15M}

# The following will create the file load.php in the current directory when run manually
# or at /root/load.php when run from a cron job.
echo "<?php" > load.php
echo "\$loadavg5="$F5M";" >> load.php
echo "\$loadavg10="$F10M";" >> load.php
echo "\$loadavg15="$F15M";" >> load.php
echo "?>" >> load.php

exit


If you run it manually in shell (eg sh ./load.sh) it'll echo the three values to the screen and save them to the load.php file. If you set it up as a cron job the load.php will default to get saved at /root/load.php if you don't tell the script otherwise. So you'd want to either save it somewhere else that's web accessible or move it after it gets saved.
caddmngr
That's some helpful info, Squire, thanks!

yes, I was able to start a page similar, but ran into a problem with commands like "top", "who", and "users".

I tried messing with sudo, but what a pain in the @%^ that is!

anyway... when my script is done, I will post it here in case anyone has the same desire to monitor server resources on igoogle, like me! icon_smile.gif

thanks again!
chris
ElviCities
Good stuff guys!
Caddmngr ---- Looking forward to your finished script, this will be a very nice toy! icon_smile.gif
caddmngr
can anyone help me to run root commands and retrieve the output, such as the "top" command, from php?

I have all the basics graphing out and stuff, and looking cool and compact, but I really want to include some process, mail, and user info - but need to execute as root. How can I most easily do this from a php web script?

thanks!
chris
Squire
So you're wanting to do it from php?

Check out some of the script repository sites. I'm not sure any of the scripts will have exactly the things you want (Users is the one I don't remember seeing specifically) but there are free scripts out there you can probably borrow some ideas from. One place I know I've seen such scripts is the PHP Resource Index. Though you'll probably find other examples at any of the script repository sites.
caddmngr
thanks Squire, but I almost always would rather roll my own icon_smile.gif

here's what I have so far, and I'm running a cron job that is executing 'last -n 12', 'top', 'users', and a few others and saving the output to a datafile that I'll be parsing to include a few more tidbits of useful info.

anyway... check out the screen shot of my igoogle page with the widget in place - I welcome any ideas!! (of course, once its done, I'll pass the code onto anyone interested!)



thanks
Chris
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.