trans_watchdog
Forum » Forum / Torrent programs » trans_watchdog
Started by: fraterfrater
On: 1246096400|%e %b %Y, %H:%M %Z|agohover
Number of posts: 32
rss icon RSS: New posts
trans_watchdog
fraterfrater 1246096400|%e %b %Y, %H:%M %Z|agohover

Someone asked me to give a short list of what trans_watchdog is doing.
I never really took the time and just started writing and learning in the progress as I am just recently introduced into bash-scripting.

  • Check if transmission is running…
  • Check every minute if a torrent-file is placed in the watchdog
  • Sanitize the name of the torrent-file (replace diacritical character with their non-diacritical counterpart http://en.wikipedia.org/wiki/Diacritic) and remove special characters.
  • Add that torrent if it the maximum downloadable setting has not been reached (MAX_SIMULTANEOUS)
  • Every <INTERVAL> minutes (5) it will continue the script for more work (rest of this list)
  • It will stop if "unrar" is currently busy (to alleviate the worldbook and keep things quick and nasty)
  • If transmission is not running it will start transmission if KEEP_TRANSMISSION_RUNNING is set and then stop the script
  • If transmission is running but not responding it wil restart transmission (if KEEP_TRANSMISSION_RUNNING is set) and stop the script
  • If SUPERSOCIAL is set it will check if samba is busy (using top)
  • If $THROTTLE_DONTKILL is set as well, it will throttle transmission, otherwise it will stop it.
  • It will check a hourly schedule based on 2 arrays. One for weekdays and one for weekend (you can customize which days are weekend) and throttle transmission accordingly.
  • Every 3 hours it will turn transmission-daemon off if it's not handling torrents and KEEP_TRANSMISSION_RUNNING is set
  • If a torrent is downloaded it will pause the torrent, move it to the "finished dir", put a symbolic link instead of the torrent and unpause it.
  • If the torrent is rar-file or dir with rars, it will unrar its contents.
  • If unrarring is successfull and KEEPRAR is set to off it will delete the original file and remove the torrent from the list
  • It will mail you when the torrent is done
  • It will remove a torrent if its lifetime has exceeded a certain age MAX_SEEDTIME
  • It will remove a torrent if MAX_RATIO has been reached.
  • Getting rid of symbolic links if they are not used by transmission-daemon

It's doing some more.. Especially checking if everything is as it should be…

After a file has been downloaded I have a seperate script (running every hour) which automatically places AVI's and DVD's to a special directory where I can view them from my xbox (XBMC). These 2 scripts (mkdvd & mvmovie) do this after an extensive cleanup of the name also using a slightly modified IMDB-script because most torrents are infested with all kinds of ugly tags.
http://wd.mirmana.com/mvmovie
http://wd.mirmana.com/imdb
http://wd.mirmana.com/mkdvd

Please use a seperate thread if you have problems installing the script, but do come here if you have notes/problems about using it….

Last edited on 1246100734|%e %b %Y, %H:%M %Z|agohover By frater + Show more
Reply  |  Options
Unfold trans_watchdog by fraterfrater, 1246096400|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
anpe008anpe008 1246100494|%e %b %Y, %H:%M %Z|agohover

Thanks the detailed description! I think it helps a lot to understand the processes.
I added that thread to my guide.

Reply  |  Options
Unfold Re: trans_watchdog by anpe008anpe008, 1246100494|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
anpe008anpe008 1246106188|%e %b %Y, %H:%M %Z|agohover

It will mail you when the torrent is done

I think it is worth to mention that in order to mail the downloaded torrents it need the sendEmail as well, if i am correct.

This is where I stuck. Everything works now except the mailing functionality.
after cat /opt/etc/trans_watchdog.conf i have these settings:

MAILFROM=moc.liamg|XXX#moc.liamg|XXX
MAILSERVER=smtp.gmail.com
MAIL_TO=moc.liamg|XXX#moc.liamg|XXX

I have Sendmail as well next to trans_watchdog.

and i do not receive any emails although i have all the downloaded torrent file in the "downloded-dir".

After executing sendEmail with its parameters i have this error:

Jun 27 14:55:08 localhost sendEmail[29750]: ERROR => No TLS support! SendEmail can't load required libraries. (try installing Net::SSLeay and IO::Socket::SSL)

For authorization i need the TLS/SSH.

Does my perl installation have the IO::Socket::SSL and Net::SSLeay modules available?

Last edited on 1246108764|%e %b %Y, %H:%M %Z|agohover By anpe008 + Show more
Reply  |  Options
Unfold Re: trans_watchdog by anpe008anpe008, 1246106188|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
anpe008anpe008 1246113936|%e %b %Y, %H:%M %Z|agohover

I installed

"perl-io-socket-ssl - 0.999-1"
"perl-net-ssleay - 1.30-1"
"perl-crypt-ssleay - 0.55-1"

from optware and when i run sendEmail i receive:

Jun 27 16:40:55 localhost sendEmail[2232]: DEBUG => Connecting to smtp.gmail.com:465
Jun 27 16:40:55 localhost sendEmail[2232]: ERROR => Connection attempt to smtp.gmail.com:465 failed: IO::Socket::INET: Cannot assign requested address
Jun 27 16:40:55 localhost sendEmail[2232]: HINT => Try specifying a different mail relay with the -s option.

what is needed then?

Last edited on 1246114670|%e %b %Y, %H:%M %Z|agohover By anpe008 + Show more
Reply  |  Options
Unfold Re: trans_watchdog by anpe008anpe008, 1246113936|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
anpe008anpe008 1246117240|%e %b %Y, %H:%M %Z|agohover

OK. It works now. Thanks. :)

I will add it to my guide.

Unfold Re: trans_watchdog by anpe008anpe008, 1246117240|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
fraterfrater 1246117593|%e %b %Y, %H:%M %Z|agohover

Good to know you could help yourself
Do tell in your guide that this is only necessary if your outgoing SMTP-server needs SSL to connect.

In this case your target is a gmail-address and you should have used the INCOMING smtp-server of gmail, not the outgoing. Gmail will then accept the mail over unencrypted SMTP.

gmail-smtp-in.l.google.com.

You could have solved it as well by using your ISP's outgoing mailserver.
Most of the time they don't use SSL.

BTW… I will add those modules to my prep_whitelight……

Last edited on 1246118340|%e %b %Y, %H:%M %Z|agohover By frater + Show more
Unfold Re: trans_watchdog by fraterfrater, 1246117593|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
anpe008anpe008 1246120639|%e %b %Y, %H:%M %Z|agohover

OK.

"perl-crypt-ssleay - 0.55-1" is not needed just:

"perl-io-socket-ssl - 0.999-1"
"perl-net-ssleay - 1.30-1"


gmail-smtp-in.l.google.com.

Is it the incoming smtp-server of gmail?
What port is used for that: 587 as well?

Unfold Re: trans_watchdog by anpe008anpe008, 1246120639|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
fraterfrater 1246122041|%e %b %Y, %H:%M %Z|agohover

port 25 of course….
That's the port for normal SMTP-delivery

587 is normally used for authenticated SMTP.

# telnet gmail-smtp-in.l.google.com. 25
Trying 74.125.79.114...
Connected to gmail-smtp-in.l.google.com..
Escape character is '^]'.
220 mx.google.com ESMTP 24si2726729eyx.53
quit
221 2.0.0 closing connection 24si2726729eyx.53
Connection closed by foreign host.
Last edited on 1246122154|%e %b %Y, %H:%M %Z|agohover By frater + Show more
Unfold Re: trans_watchdog by fraterfrater, 1246122041|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
anpe008anpe008 1246138337|%e %b %Y, %H:%M %Z|agohover

BTW… I will add those modules to my prep_whitelight……

I think you have to add 2 variables (MAILUSERNAME, MAILPASSWORD) to the trans_watchdog as well in order to have sendEmail correctly.
If i install only the perl modules and I want to use authorization than i have to change the following line in trans_watchdog to give the username/password for authorization:
From:

sendEmail -s ${MAILSERVER} -f ${MAILFROM} -t ${MAIL_TO} -o tls=no -o message-file="${INFO}" -u "${IP}: ${TORRENTNAME} torrent finished" -q

To somthing like:

sendEmail -s ${MAILSERVER} -f ${MAILFROM} -t ${MAIL_TO} -o tls=auto-o message-file="${INFO}" -u "${IP}: ${TORRENTNAME} torrent finished" -q -xu ${MAILUSERNAME} -xp ${MAILPASSWORD}

Last edited on 1246138413|%e %b %Y, %H:%M %Z|agohover By anpe008 + Show more
Unfold Re: trans_watchdog by anpe008anpe008, 1246138337|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
fraterfrater 1246144921|%e %b %Y, %H:%M %Z|agohover

I already thought it was strange you already had it working…
But why aren't you just using the incoming mailserver?

You can even make the mailserver empty and then it will address the incoming mailserver automatically…..
Why are you making it so hard for yourself?

Unfold Re: trans_watchdog by fraterfrater, 1246144921|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
anpe008anpe008 1246179185|%e %b %Y, %H:%M %Z|agohover

I have tried it but received this when i run sendEmail alone:

Jun 28 10:48:15 localhost sendEmail[23767]: ERROR => Received: 550-5.7.1 [84.74.89.39] The IP you're using to send mail is not authorized to, 550-5.7.1 send email directly to our servers. Please use the SMTP relay at your, 550-5.7.1 service provider instead. Learn more at http://mail.google, 550 5.7.1 .com/support/bin/answer.py?answer=10336 23si5766300bwz.52

I run:

sendEmail -f username(@)gmail.com -t username(@)gmail.com -u "TEST1" -m "TEST" -s gmail-smtp-in.l.google.com:25

http://mail.google.com/support/bin/answer.py?answer=10336

"'The IP you're using to send email is not authorized…'
In order to prevent spam, Gmail refuses mail when the sending IP address does not match the sending domain. To send mail from your server to Gmail, we suggest using the SMTP relay provided by your ISP. Please note that we are unable to whitelist IP addresses or otherwise make exceptions at this time."

Last edited on 1246179316|%e %b %Y, %H:%M %Z|agohover By anpe008 + Show more
Unfold Re: trans_watchdog by anpe008anpe008, 1246179185|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
fraterfrater 1246180485|%e %b %Y, %H:%M %Z|agohover

I'm doing the anti-spam techniques at the ISP I work for so this sounds quite familiar…
BTW…. I CAN use my own IP to send email even if I use my gmail-address as from-address….
You could change the from address to the one you're given by your provider…

You can also do an "nslookup <your wan-ip>".
You will the get the reverse DNS of your wan IP which is the domain of your provider's IP-space on the Internet.
If you use <yourname>@<yourispdomain> as your from-address it may work…

But still… Why are you not using your ISP's outgoing mailserver?

Unfold Re: trans_watchdog by fraterfrater, 1246180485|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
anpe008anpe008 1246189390|%e %b %Y, %H:%M %Z|agohover

Haven not registered yet. So i do not have an email account yet.
The point is works now. Thanks.

Unfold Re: trans_watchdog by anpe008anpe008, 1246189390|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
fraterfrater 1246297338|%e %b %Y, %H:%M %Z|agohover

I have noticed that ever since I introduced "mktemp" in my script it is creating files temporary files in /tmp which are never deleted again. Please download trans_watchdog again to get this fixed.

You should manually delete these files.
This can be done with this command

cd /tmp
rm -f tmp*

You may already have so many files that this command fails with this error-message: "rm: Argument list too long"
You can then use this command which takes a while to complete….

cd /tmp
find . -name 'tmp*' | xargs rm
Reply  |  Options
Unfold Re: trans_watchdog by fraterfrater, 1246297338|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
arryoarryo 1246376444|%e %b %Y, %H:%M %Z|agohover

This is very nice wrap up but I suggest you should also include the installation procedure too. Because what I saw is just a file (trans_watchdog), I downloaded it but I don't know where should I put that file and how to activate it

Thanks

Reply  |  Options
Unfold Re: trans_watchdog by arryoarryo, 1246376444|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
fraterfrater 1246379622|%e %b %Y, %H:%M %Z|agohover

I have helped anpe with installing the trans_watchdog on his worldbook.
He wrote a tutorial to install the watchdog.

http://mybookworld.wikidot.com/forum/t-165210/how-to-set-up-wd-mbwe-white-light-properly-transmission-1-72-automate-and-manage-torrents

Reply  |  Options
Unfold Re: trans_watchdog by fraterfrater, 1246379622|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
arryoarryo 1246462266|%e %b %Y, %H:%M %Z|agohover

Thank you, I didn't check that thread before because i thought it only applies to White Light while i'm using Blue ring

Reply  |  Options
Unfold Re: trans_watchdog by arryoarryo, 1246462266|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
Pro90Pro90 1248795481|%e %b %Y, %H:%M %Z|agohover

Hi!

although I have the trans_watchdog script running which should take care of user rights, it seems that i don't have the rights to move downloaded files under Windows Vista. How can that problem be solved???

Reply  |  Options
Unfold Re: trans_watchdog by Pro90Pro90, 1248795481|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
anpe008anpe008 1248802227|%e %b %Y, %H:%M %Z|agohover

I had the same problem. I run another 10 min cron job to apply the access rights on my "Downloaded" folder (/shares/Public/WWW/Qtorrent):

chmod -R 777 /shares/Public/WWW/Qtorrent

Reply  |  Options
Unfold Re: trans_watchdog by anpe008anpe008, 1248802227|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
fraterfrater 1248813503|%e %b %Y, %H:%M %Z|agohover

777 gives the files all the rights to everyone (rwxrwxrwx)

I deliberately give no executable rights because they are treated as the hidden flag in samba.
I give them rw-rw-r—

chmod -R ug-x+rwX  /shares/internal/PUBLIC
chmod -R ug-x+rwX  /shares//Public/Shared*
chown -R www-data:www-data /shares/internal/PUBLIC
chown -R nobody:jewab  /shares//Public/Shared*

This makes me think you didn't set the proper user (chown)
This can be done in /opt/etc/trans_watchdog.conf

for bluering:

TW_DATAGROUP=www-data
TW_DATAUSER=www-data

for whitelight:

TW_DATAGROUP=jewab
TW_DATAUSER=nobody
Reply  |  Options
Unfold Re: trans_watchdog by fraterfrater, 1248813503|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
fraterfrater 1249037317|%e %b %Y, %H:%M %Z|agohover

.

Last edited on 1249037400|%e %b %Y, %H:%M %Z|agohover By frater + Show more
Reply  |  Options
Unfold Re: trans_watchdog by fraterfrater, 1249037317|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
arryoarryo 1249390589|%e %b %Y, %H:%M %Z|agohover

Hi Frater,

If I don't want to move my torrent after finish downloading and I dont want to use mail option. What should I do to turn off those options?

Thanks

Reply  |  Options
Unfold Re: trans_watchdog by arryoarryo, 1249390589|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
fraterfrater 1249395058|%e %b %Y, %H:%M %Z|agohover

If TW_MAILERSERVICE is empty it will not try to mail.

Moving the torrent is the reason why I wrote this script. It is not designed to be optionally turned off.
Why don't you want to do this?

What DO you want the watchdog to do?

You may consider putting an extra "_exit" in.
This way the script only does the 1-minute part (automatically adding a torrent).

# Only run rest of code every 5 minutes
[ ! "$((${MINUTE}%${TW_INTERVAL}))" == "0" ] && _exit
_exit
# Only run rest of code every 5 minutes
[ ! "$((${MINUTE}%${TW_INTERVAL}))" == "0" ] && _exit
Reply  |  Options
Unfold Re: trans_watchdog by fraterfrater, 1249395058|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
arryoarryo 1249396312|%e %b %Y, %H:%M %Z|agohover

Since I can download my specific type of torrent go to my desired folder (using transmission Remote), I don't need that option anymore. Your program takes care of the user authorization problem. I don't know why my transmission always makes my download torrent as root, therefore I can't delete/move from samba

Reply  |  Options
Unfold Re: trans_watchdog by arryoarryo, 1249396312|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
TroteljTrotelj 1252743580|%e %b %Y, %H:%M %Z|agohover

Can some one please tell me how these things work:

SCHEDULE_WEEKEND=([0]="0" [1]="0" [2]="1" [3]="1" [4]="1" [5]="1" [6]="1" [7]="$
SCHEDULE_WORKDAY=([0]="1" [1]="1" [2]="1" [3]="1" [4]="1" [5]="1" [6]="1" [7]="$
...
WORKDAY=([0]="0" [1]="1" [2]="1" [3]="1" [4]="1" [5]="1" [6]="0")
Reply  |  Options
Unfold Re: trans_watchdog by TroteljTrotelj, 1252743580|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
fraterfrater 1252752411|%e %b %Y, %H:%M %Z|agohover

It's the scheduler for throttling or full speed (0 = throttle, 1 = full speed)
They represent the hours…

0 = 00h
1 = 01h
.
.
22 = 22h
23 = 23h

There are 2 Arrays. 1 for workdays and 1 for weekend….

The Array WORKDAY defines which day is a Weekend and which day is a Workday…..

0 = Sunday
1 = Monday
2 = Tuesday
3 = Wednesday
.
6 = Saturday

Last edited on 1252752457|%e %b %Y, %H:%M %Z|agohover By frater + Show more
Reply  |  Options
Unfold Re: trans_watchdog by fraterfrater, 1252752411|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
TroteljTrotelj 1252774830|%e %b %Y, %H:%M %Z|agohover

Thank you for your explenation. =)

How about these things:

TW_FULL_THROTTLE_DOWN=0
TW_FULL_THROTTLE_UP=300
...
TW_SCHEDULE_THROTTLE_DOWN=2000
TW_SCHEDULE_THROTTLE_UP=200
...
TW_THROTTLE_DOWN=100
TW_THROTTLE_UP=1

The first couple throtle for "full speed" aka 1 in the scheduler?
the second couple throtle for 0 in the scheduler?
and the third stands for?

Reply  |  Options
Unfold Re: trans_watchdog by TroteljTrotelj, 1252774830|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
fraterfrater 1252781737|%e %b %Y, %H:%M %Z|agohover

The third is throttling when samba is busy.
You can have transmission killed when samba is busy or have it throttled so it doesn't use too much cpu.

Reply  |  Options
Unfold Re: trans_watchdog by fraterfrater, 1252781737|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
iceeticeet 1258399291|%e %b %Y, %H:%M %Z|agohover

Hey Frater, thanks for the excellent script. It's working great for me. The only issue I have is that it is not automatically deleting the *.torrent.transmission files in the watchdog folder after max seedtime or max ratio is reached. It removes the torrents from transmission's list, but those files still remain. Is there any way to make them delete those as well?

Unfold Re: trans_watchdog by iceeticeet, 1258399291|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
gilegile 1262902799|%e %b %Y, %H:%M %Z|agohover

Same here, I still have the *.torrent.transmission files in the watchdog folder.
What I am also curious is that there were no symbolic links and the torrents still appear in the transmission menu, I did play with the max seed time, but they are still seeding.

Anything I can debug? I tried setting the debug to 2 or 5 to gain more info, but that hasn't helped me much in this issue.

Reply  |  Options
Unfold Re: trans_watchdog by gilegile, 1262902799|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
thinlizzythinlizzy 1264747799|%e %b %Y, %H:%M %Z|agohover

hi! i dont't want that watchdog sets the upload speed!
how can i do that?

thanx

Reply  |  Options
Unfold Re: trans_watchdog by thinlizzythinlizzy, 1264747799|%e %b %Y, %H:%M %Z|agohover
Re: trans_watchdog
fraterfrater 1264836379|%e %b %Y, %H:%M %Z|agohover

Easiest is to set all upload speeds to the same value.

Reply  |  Options
Unfold Re: trans_watchdog by fraterfrater, 1264836379|%e %b %Y, %H:%M %Z|agohover
New Post
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License