Apr 24 2014 
Support Center » Knowledgebase » Linux VPS » How do I install MRTG on my Plesk VPS?
 How do I install MRTG on my Plesk VPS?
Solution The following install guide is taken from the Plesk forum:

Thanks to ryanz - it has been adapted for install onto a Plesk virtual private server:

**IMPORTANT**
Before you start you must open a ticket and request the MRTG template to be installed into your virtual private server.

1. Decide where you want mrtg to run from.
Typically - http://www.yourdomain.com/mrtg/mrtg.html
2. Once you've decided star with this:
Note: Everything starting with >> is a terminal command, and everything between ---- lines is code. Replace "yourdomain.com" with the domain you decided on in point 1.
Everything in { } should be in one line and don't add the { }

You have a few choices, you can stay in the location you are and issue absolute path commands or you can move to that new directory and work from there. For the purpose of this we will remain where we are and issue absolute path commands so you get familiar with the path structure.
3. Create the folder mrtg in "yourdomain.com"
>> mkdir /home/httpd/vhosts/"yourdomain.com"/httpdocs/mrtg
4. Create the file mrtg.cfg in this new mrtg folder and add the code to it.
>> pico /home/httpd/vhosts/"yourdomain.com"/httpdocs/mrtg/mrtg.cfg

Inside that file type the following code:
-----------------------------------------
{WorkDir: /home/httpd/vhosts/"yourdomain.com"/httpdocs/mrtg}
{Target[mrtg]: `/home/httpd/vhosts/"yourdomain.com"/httpdocs/mrtg/getstats.sh`}
MaxBytes[mrtg]: 25000000
Title[mrtg]: Traffic and Load Analysis for "yourdomain.com"
PageTop[mrtg]: Traffic and Load Analysis for "yourdomain.com"
XSize[mrtg]: 400
YSize[mrtg]: 200

Options[mrtg]: growright, bits
-----------------------------------------
To save and exit pico do this:

Press Ctrl X
Press Y for Yes
Press Enter
5. Create the file getstats.sh in this new mrtg folder and add the code to it.
>> pico /home/httpd/vhosts/"yourdomain.com"/httpdocs/mrtg/getstats.sh

Inside that file type the following code:
-----------------------------------------
#!/bin/sh
# Get transmit and receive bytes.
#
INFO=`grep venet0 /proc/net/dev | tr -s ' ' ' ' | cut -d: -f2`
RECEIVE=`echo $INFO | cut -d" " -f1`
TRANSMIT=`echo $INFO | cut -d" " -f9`
# Get uptime.
#
UPTIME=`uptime | tr -s ' ' ' ' | cut -d" " -f4-`
# Final output to MRTG
#
echo $RECEIVE
echo $TRANSMIT
echo $UPTIME
echo "yourdomain.com"
-----------------------------------------
To save and exit pico do this:

Press Ctrl X
Type Y for Yes
Press Enter
6. Change the permissions of both these new files as follows:
>> {chmod 755 /home/httpd/vhosts/"yourdomain.com"/httpdocs/mrtg/mrtg.cfg}
>> {chmod 755 /home/httpd/vhosts/"yourdomain.com"/httpdocs/mrtg/getstats.sh}
7. Change the owner permissions of the new folder mrtg as follows:
>> {chown -R "username": psacln /home/httpd/vhosts/"yourdomain.com"/httpdocs/mrtg}
Where "username" is the ftp username of "yourdomain.com"
8. Add a cron job to have mrtg run and updated every 5 minutes.
>> pico /var/spool/cron/root

Add this line at the end:
{*/5 * * * * /usr/bin/mrtg /home/httpd/vhosts/"yourdomain.com"/httpdocs/mrtg/mrtg.cfg}

Save with ctrl o and then run:
>> crontab /var/spool/cron/root
9. Everything should be setup and complete, type this command to start mrtg:
>> {/usr/bin/mrtg /home/httpd/vhosts/"yourdomain.com"/httpdocs/mrtg/mrtg.cfg}

You might notice a few errors the first time around but this is "normal" give it a few minutes and try again.
10. Check your mrtg stats in your browser by going to:
http://www.yourdomain.com/mrtg/mrtg.html


Article Details
Article ID: 65
Created On: Jan 23 2009 03:51 PM

 This answer was helpful  This answer was not helpful

 Back
 Login [Lost Password] 
Email:
Password:
Remember Me:
 
 Search
 Article Options
Home | Register | Knowledgebase
Language:

Help Desk Software By Kayako eSupport v3.60.02