Subscribe to RSS feed

Posts tagged with "addon"

SERVER : TorrentFlux and MRTG for TorrentFlux problems.

, , , ...

Hy.

I've ran into some problems, and i thought I'd share how i fixed them.

:idea:First of all, i had to restart the server, and after that the graphs in MRTG didn't want to update anymore. After a while I've discovered that there's a folder missing, the /var/lock/mrtg folder. This is the folder that mrtg writes its lock file (the file used to know it's running, so only 1 instance can run at a time).
In order to recreate it here's what i did :
sudo mkdir /var/lock/mrtg
sudo chown www-data:www-data /var/lock/mrtg
sudo chmod 777 /var/lock/mrtg

Now, since it seems that I have to run this each time I reboot the computer, its better to put it in the /etc/rc.local file, so just run
sudo editor /etc/rc.local
and insert the above lines before the exit 0 line.
Here's my file as it looks like now :
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# start No-Ip so that my web-name is updated correctly
/usr/local/bin/noip2

# create the lock file for MRTG, it seems to get lost each time i restart the computer
mkdir /var/lock/mrtg
chown www-data:www-data /var/lock/mrtg
chmod 777 /var/lock/mrtg

# start IPKungfu, so port forwarding and gateway work correctly
/usr/sbin/ipkungfu

exit 0


:idea:Second problem was that I've managed to block TorrentFlux so badly that i wasn't even able to log in. I've tried restarting the Apache server but that didn't help, so when I was about to give up on TorrentFlux (and that would have been a shame) I've found out how to fix my problem.
Luckily, the developers of TorrentFlux included a little application that can be used from the console to control TorrentFlux. The application's name is fluxcli.
First thing was that I needed to find where it is, for that use this :
locate fluxcli.php
, you should get something similar to this :
/var/www/torrentflux/bin/fluxcli.php

Now that we know where it is, lets execute it, for that do this :
cd /var/www/torrentflux/bin
php fluxcli.php repair

FluxCLI can be used for other things too, for example you can start/stop torrents.
If you want to see what exactly fluxcli can do, just run it without commands, you should see something similar to this :
fluxcli.php Revision 1958

Usage: fluxcli.php action [extra-args]

action:
 <transfers>   : print transfers.
 <netstat>     : print netstat.
 <start>       : start a transfer.
                 extra-arg : name of transfer as known inside torrentflux
 <stop>        : stop a transfer.
                 extra-arg : name of transfer as known inside torrentflux
 <start-all>   : start all transfers.
 <resume-all>  : resume all transfers.
 <stop-all>    : stop all running transfers.
 <reset>       : reset totals of a transfer.
                 extra-arg : name of transfer as known inside torrentflux
 <delete>      : delete a transfer.
                 extra-arg : name of transfer as known inside torrentflux
 <wipe>        : reset totals, delete torrent, delete torrent-data.
                 extra-arg : name of torrent as known inside torrentflux
 <inject>      : injects a transfer-file into tflux.
                 extra-arg 1 : path to transfer-meta-file
                 extra-arg 2 : username of fluxuser
 <watch>       : watch a dir and inject+start transfers into tflux.
                 extra-arg 1 : path to users watch-dir
                 extra-arg 2 : username of fluxuser
 <rss>         : download torrents matching filter-rules from a rss-feed.
                 extra-arg 1 : save-dir
                 extra-arg 2 : filter-file
                 extra-arg 3 : history-file
                 extra-arg 4 : rss-feed-url
 <xfer>        : xfer-Limit-Shutdown. stop all transfers if xfer-limit is met.
                 extra-arg 1 : time-delta of xfer to use : <all|total|month|week|day>
 <repair>      : repair of torrentflux. DONT do this unless you have to.
                 Doing this on a running ok flux _will_ screw up things.
 <maintenance> : call maintenance and repair all died transfers.
                 extra-arg 1 : restart died transfers (true/false)
 <dump>        : dump database.
                 extra-arg 1 : type : settings/users
 <filelist>    : print file-list.
                 extra-arg 1 : dir (if empty docroot is used)
 <checksums>   : print checksum-list.
                 extra-arg 1 : dir (if empty docroot is used)

examples:
fluxcli.php transfers
fluxcli.php netstat
fluxcli.php start foo.torrent
fluxcli.php stop foo.torrent
fluxcli.php start-all
fluxcli.php resume-all
fluxcli.php stop-all
fluxcli.php reset foo.torrent
fluxcli.php delete foo.torrent
fluxcli.php wipe foo.torrent
fluxcli.php inject /path/to/foo.torrent fluxuser
fluxcli.php watch /path/to/watch-dir/ fluxuser
fluxcli.php rss /path/to/rss-torrents/ /path/to/filter.dat /path/to/filter.hist http://www.example.com/rss.xml
fluxcli.php xfer month
fluxcli.php repair
fluxcli.php maintenance true
fluxcli.php dump settings
fluxcli.php dump users
fluxcli.php filelist /var/www
fluxcli.php checksums /var/www

As you can see, it states clearly that you should not run fluxcli repair unless you really have to. So unless you get blocked out or something just dont use it bigsmile I had to use it since I wasn't even able to log in, and it did repair my torrentflux. THe only thing is that i had to restart all torrents, but that was to be expected.

Happy downloding and graphing:cool:

SERVER : Install CACTI (or at least try to :-))

, , , ...

"CACTI is a complete network graphing solution designed to harness the power of RRDTool's data storage and graphing functionality. Cacti provides a fast poller, advanced graph templating, multiple data acquisition methods, and user management features out of the box. All of this is wrapped in an intuitive, easy to use interface that makes sense for LAN-sized installations up to complex networks with hundreds of devices."

So, lets start installing CACTI.
First thing to do, is install its package, for that do
sudo apt-get install cacti

Of course, you'll have to be prepared to wait some time, as it needs to download about 6-8Mb of data.

At the beginning of the installation, you'll get a warning that the "Include path for PHP has changed", we'll deal with that later on, so just press the OK button.
After a while, you'll see another message, it asks you if you want to automatically add the database needed by cacti. Since we're installing it the first time, we should press Yes.
You'll be asked about the password of your root user (not the system root user but the MySQL root user) so you should enter that passwordthen press OK, on the next screen it will ask for a password for CACTI, just let it create a random password and use that one, so press OKon the next screen it will ask what kind of webserver you're using, in our case is Apache2, so select that one.

If you get the following error : "mysql said: ERROR 1049 (42000): Unknown database 'cacti'" then open up your phpMyAdmin and create a new table with the cacti name. After you've created the cacti database, come back to the installer, press OK and then retry. It will jump back to the question if cacti should autoconfigure, just answer yes, enter the MySQL root user password and leave the cacti password empty.

If everything went OK, you should be returned at the prompt and see this :
dbconfig-common: flushing administrative password

Creating config file /etc/cacti/apache.conf with new version
 * Reloading apache 2.0 configuration...                                   [ ok ]



Now we need to open up a webpage to configure cacti, for that, open up a browser window with http://your_server_ip/cacti and you should see this page : just press the Next > > button.
On the next window make shore you select New Install and press Next > >
On the next screen you should have something similar with this image :
If everything seems to be ok then press the Finish button.
Now you'll get to the login screen. First time you should log in with admin as both username and password
Because of security considerations, it will now ask you to change the password for the admin user, so enter a password you can remember and then press Save.

idea If you can see the statistics but don't see any picture in CACTI, you might not have the php4-mysql or php5-mysql module installed or configured propertly. To check if the mysql module has really been added, you can check it with this :
php -m | grep mysql
you should get an answer similar to this :
PHP Warning:  mime_magic: type regex            BEGIN[[:space:]]*[{]    application/x-awk invalid in Unknown on line 0
mysql

If you don't get the above answer, then maybe your php4-mysql or php5-mysql module is not installed. You can force to install it with
apt-get install php4-mysql php5-mysql php5-mysqli

Now you should try this :
sudo dpkg-reconfigure php4-mysql
and answer Yes to the question if "Should MySQL be added to /etc/php4/cli/php.ini?"
Now do the same for PHP5, so run
sudo dpkg-reconfigure php5-mysql
and answer Yes to the question " Should MySQL be added to /etc/php5/apache2/php.ini?". You might get a second question "Should MySQL be added to /etc/php5/cgi/php.ini?" asnwer Yes to that one too.
Now we need to tell the Apache webserver to reload the settings, so just run this :
sudo apache2ctl restart

Now you should finally see your images.

idea Don't worry if at the beginning you see the images but there's no data just the grids, just leave some time (about 15-20 minutes) and then check the graphs again. After all, CACTI needs some time to pass in order to make the statistics.

Happy graphing.

P.S. I'm not going to tell you how to add new graphs, you should experiment, or simply look at the CACTI documentation for more info Here

SERVER : Install MRTG for TorrentFlux

, , , ...

Now that I've installed torrent flux, i wanted to see some graphs with the upload/download speeds, so i could see just how fast I'm downloading.

For that i need to install MRTG (for more info look at this site).

So, run this commands in the shell
apt-get install mrtg mrtgutils mrtg-contrib
It will ask you if you really want to install it since it will need to download about 8Mb of files, just answer with Y.
After the installation is done, it will ask you if you want to let only the MRTG user read the config file, you should answer with Yes
After a few seconds you end up back at the prompt with
Setting up mrtg (2.14.3-1) ...

Setting up mrtg-contrib (2.14.3-1) ...
lines above the prompt.
This means that we've installed MRTG.

Now lets configure TorrentFlux to use the MRTG.

Go to the folder where you downloaded and extracted the torrentflux archive and there's an addons/mrtg folder, get into it. If you've extracted the file in your home folder, simply execute this :
cd ~/torrentflux-b4rt_1.0-alpha5/addons/mrtg
.

Now, if you look inside (for example with ls command, you'll see a few files :
flux-mrtg.conf       
fluxpoller.pl  
mrtg.flux.examples.cfg
flux-mrtg-update.sh  
mrtg.flux.cfg


Now we need to customize this files to suit our needs.
First, we need to modify the flux-mrtg.conf file.
editor flux-mrtg.conf

now modify the FLUXPATH to be the folder where you set TorrentFlux to download the files to (in my case it's /mnt/d/Torrents) you should leave the rest of the settings as they are.
You should end up with something similar to this :
# $Id: flux-mrtg.conf 672 2006-09-10 12:29:05Z b4rt $

# set all lines after "CHANGEME" (get a list with: "grep -A 1 CHANGEME this")

# flux-path (aka "Path" in flux-settings)
# CHANGEME
FLUXPATH="/mnt/d/Torrents/"

# path to mrtg-conf-file.
# wherever this is, ensure directory is writable for the user running this
# script (-> user running mrtg) (mrtg creates a lockfile at its conf-file(s))
# CHANGEME
CONFFILE="/etc/mrtg/mrtg.flux.cfg"

# where is mrtg
# CHANGEME
BIN_MRTG="/usr/bin/mrtg"


Now we need to modify the mrtg.flux.cfg file too so execute
sudo editor mrtg.flux.cfg
and search for
Target[traffic]: `/usr/local/bin/fluxpoller.pl traffic /usr/local/torrentflux mrtg`
you must modify the /usr/local/torrentflux to be the folder you've set for the downloads, in my case it will be
Target[traffic]: `/usr/local/bin/fluxpoller.pl traffic /mnt/d/Torrents mrtg`


Now we need to create the folder where MRTG will save its data, for that execute this commands :
sudo mkdir /usr/local/torrentflux
sudo mkdir /usr/local/torrentflux/.mrtg
sudo chown -R www-data:www-data /usr/local/torrentflux
sudo chmod -R 777 /usr/local/torrentflux

This will create the folder, make it writable and owned by the Apache user (www-data).


Now we need to copy the files to their right place.
For that, execute this commands :
sudo mkdir /etc/mrtg
sudo cp flux-mrtg.conf /etc/mrtg
sudo cp mrtg.flux.cfg /etc/mrtg
sudo cp flux-mrtg-update.sh /usr/local/bin/
sudo cp fluxpoller.pl /usr/local/bin/



Now the MRTG should be configured, we should try it out, so execute this :
/usr/local/bin/flux-mrtg-update.sh /etc/mrtg/flux-mrtg.conf

If you get the following error :
-----------------------------------------------------------------------
ERROR: Mrtg will most likely not work properly when the environment
       variable LANG is set to UTF-8. Please run mrtg in an environment
       where this is not the case. Try the following command to start:

       env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.flux.cfg
-----------------------------------------------------------------------
then we need to modify flux-mrtg-update.sh, so execute this
sudo editor /usr/local/bin/flux-mrtg-update.sh

Now go to the last line and edit it to look like this :
# invoke mrtg for flux
env LANG=C $BIN_MRTG $CONFFILE | tee -a $FLUXPATH/.mrtg/mrtg.log
save the file, exit and try it again
/usr/local/bin/flux-mrtg-update.sh /etc/mrtg/flux-mrtg.conf


You should get some errors that it can't remove or rename some files, that's ok
09-01-2007 18:29:52, Rateup WARNING: /usr/bin/rateup could not read the primary log file for traffic
09-01-2007 18:29:52, Rateup WARNING: /usr/bin/rateup The backup log file for traffic was invalid as well
09-01-2007 18:29:52, Rateup WARNING: /usr/bin/rateup Can't remove traffic.old updating log file
09-01-2007 18:29:52, Rateup WARNING: /usr/bin/rateup Can't rename traffic.log to traffic.old updating log file
09-01-2007 18:29:52, Rateup WARNING: /usr/bin/rateup could not read the primary log file for connections
09-01-2007 18:29:52, Rateup WARNING: /usr/bin/rateup The backup log file for connections was invalid as well
09-01-2007 18:29:52, Rateup WARNING: /usr/bin/rateup Can't remove connections.old updating log file
09-01-2007 18:29:52, Rateup WARNING: /usr/bin/rateup Can't rename connections.log to connections.old updating log file
09-01-2007 18:29:52, Rateup WARNING: /usr/bin/rateup could not read the primary log file for loadavg
09-01-2007 18:29:52, Rateup WARNING: /usr/bin/rateup The backup log file for loadavg was invalid as well
09-01-2007 18:29:52, Rateup WARNING: /usr/bin/rateup Can't remove loadavg.old updating log file
09-01-2007 18:29:52, Rateup WARNING: /usr/bin/rateup Can't rename loadavg.log to loadavg.old updating log file
just run the aboce command 3 times and after that it should execute without giving any warning at all.

Now look in the mrtg folder (/var/www/mrtg) and there should be 2 INC files and some PNG files.
ls /var/www/mrtg
should return something like this :
connections-day.png    connections-year.png  loadavg-week.png  mrtg-r.png       traffic-month.png
connections.inc        loadavg-day.png       loadavg-year.png  mrtg-ti.png      traffic-week.png
connections-month.png  loadavg.inc           mrtg-l.png        traffic-day.png  traffic-year.png
connections-week.png   loadavg-month.png     mrtg-m.png        traffic.inc

Now we also need to tell torrentflux where to look for those images, for that you should do
sudo rm -r /var/www/torrentflux/mrtg/
cd /var/www/torrentflux
ln -s /var/www/mrtg
this will create a simbolyc link so that /var/www/torrentflux/mrtg will actually be /var/www/mrtg

Now we need to make shore the poller will be called periodically to update the data, so we need to add a new cron entry. (Cron is a program that executes commnds on a timed bases).
So, for that you need to edit the Cron settings for the Apache Web user (www-data in Ubuntu), so execute this :
sudo crontab -e -u www-data
in the editor paste this information
# invoke mrtg-update every 5 mins
*/5 * * * * /usr/local/bin/flux-mrtg-update.sh /etc/mrtg/flux-mrtg.conf> /var/log/mrtg/mrtg_cron.log

In some cases the script doesn't have access to some folders, so we should give it access.
For that you'll need to do the following
sudo chown www-data:www-data /var/lock/mrtg/
sudo chown www-data:www-data /var/www/mrtg
mkdir /var/log/mrtg
sudo chown www-data:www-data /var/log/mrtg
sudo chown -R www-data:www-data /mnt/d/Torrents/.mrtg

Now, if everything went well you'll have a working MRTG, so when you press the Graph button on FluxTorrent's main page you'll end up with some nice graphics, something like :

Of course, the image shows a very small amount of traffic accounting, after all i just started MRTG, in time it will be completely filled. You just have to wait for some time to pass before the graphic will be really visible, after all, the first graphic is updated every 5 minutes, the second every 30 minutes, the next one every 2 hours and the last one once a day.

idea If you have images showing up, but do not get any data in the image, and you did wait at least 20-30 minutes, then there could be 2 reasons.
  1. You don't have any traffic. You should make shore you're downloding or uploading something, or you won't get any traffic, after all, your traffic is 0
  2. You didn't set the correct folder for where you're downloding to.


To check if the path has been correctly set, open up the mrtg.flux.cfg file and search for
Target[traffic]: `/usr/local/bin/fluxpoller.pl traffic /mnt/d/Torrents mrtg`
, copy the text between the ' signs and execute it in a console. You should get a response like :
17408
28672
14:26,  1 user
server_name

If the first 2 rows are 0 then either you've got no connection, or the path is wrong. The path must be the path that's set in TorrentFlux, to see what's the path, go to the torrentflux page on your server, press the admin button (upper right corner - red rectangle in the picture), press the Server button (green rectangle in the piture) and look at what's set in Path (pink rectangle in the picture).
If the path set here is different than what you had in the mrtg.flux.cfg file, please copy this path and replace the path from the file.