![]() ![]() |
Jun 4 2009, 04:47 PM
Post
#1
|
|
|
Celery ![]() Group: Members Posts: 23 Joined: 17-August 04 Member No.: 14,202 |
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! thanks Chris |
|
|
|
Jun 5 2009, 03:33 PM
Post
#2
|
|
|
Computer Chip ![]() ![]() ![]() Group: Members Posts: 682 Joined: 24-November 01 Member No.: 680 |
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. |
|
|
|
Jun 5 2009, 03:42 PM
Post
#3
|
|
|
Celery ![]() Group: Members Posts: 23 Joined: 17-August 04 Member No.: 14,202 |
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! thanks again! chris |
|
|
|
Jun 6 2009, 03:10 PM
Post
#4
|
|
![]() Fellow ![]() ![]() Group: Members Posts: 133 Joined: 18-June 05 From: Memphis, TN Member No.: 17,294 |
Good stuff guys!
Caddmngr ---- Looking forward to your finished script, this will be a very nice toy! -------------------- ~~Will work for BBQ~~~
|
|
|
|
Jun 7 2009, 12:10 PM
Post
#5
|
|
|
Celery ![]() Group: Members Posts: 23 Joined: 17-August 04 Member No.: 14,202 |
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 |
|
|
|
Jun 9 2009, 08:01 PM
Post
#6
|
|
|
Computer Chip ![]() ![]() ![]() Group: Members Posts: 682 Joined: 24-November 01 Member No.: 680 |
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. |
|
|
|
Jun 9 2009, 11:21 PM
Post
#7
|
|
|
Celery ![]() Group: Members Posts: 23 Joined: 17-August 04 Member No.: 14,202 |
thanks Squire, but I almost always would rather roll my own
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 |
|
|
|
![]() ![]() |
| Lo-Fi Version | Time is now: 21st November 2009 - 03:55 PM |