aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Pages: [1] 2

Author Topic: fun with Events  (Read 10163 times)

Ezeltje

  • Full Member
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 130
    • Home page
fun with Events
« on: December 01, 2006, 12:42:42 AM »

Have I been asleep or is the Events tab in the Preferences notebook new? I only noticed after compiling the CVS from a few days ago... I dunno, maybe it has been there for longer...

In any case, I was playing around a bit with it and wrote a little script called doneDL.sh which uses this new (?) feature to send you an email when a download has completed:

Code: [Select]
#!/bin/bash
#
# Enter your email address here:
eMail=

NameShort=$1
NameLong=$2
Hash=$3
Size=$4

{
echo aMule completed this download:
echo ------------------------------
echo
echo File: "$NameLong"
echo Hash: $Hash
echo -n "Time: "
date | awk '{print $4}'
echo Size: $Size bytes
echo
echo --------------------------------------------------------------------
cas
echo -n "Resident memory: "
echo $(ps u -C amule --no-headers | cut -d" " -f10) kB
echo -n "Virtual memory:  "
echo $(ps u -C amule --no-headers | cut -d" " -f9) kB
echo --------------------------------------------------------------------
} | mail -s "$NameShort" $eMail

To use it, enter your email address where indicated in the code, save the file somewhere in your path (also chmod +x), and add this to the field Core Events on the Events page:

doneDL.sh "%NAME" "%FILE" %HASH %SIZE

MLdonkey has an email notification feature similar to this, except it also reports the amount time the download took. It would be nice if this could be added as one of the % vars.
« Last Edit: December 01, 2006, 12:46:37 AM by Ezeltje »
Logged

phoenix

  • Evil respawning bird from aMule Dev Team
  • Developer
  • Hero Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 2503
  • The last shadow you'll ever see
RE: fun with Events
« Reply #1 on: December 01, 2006, 02:18:40 PM »

Quote
Originally posted by Ezeltje
Have I been asleep or is the Events tab in the Preferences notebook new? I only noticed after compiling the CVS from a few days ago... I dunno, maybe it has been there for longer...
You have been asleep. :P

Quote
Originally posted by Ezeltje
In any case, I was playing around a bit with it and wrote a little script called doneDL.sh which uses this new (?) feature to send you an email when a download has completed:
...
Nice script! Thanks!

Quote
Originally posted by Ezeltje
MLdonkey has an email notification feature similar to this, except it also reports the amount time the download took. It would be nice if this could be added as one of the % vars.
Well, I think that the problem here is how do we do that in a platform independent way. As far as I can tell, we don't store this information ourselves in met files. Of course, in Linux there is the part file creation date, that we can access through stat(), but that is probably not platform independent. There is an (undocumented?) function wxStat(), but to use it one would have to create a mess of #ifdefs in the code for each supported (?) platform.

There is, however, a tag in the met file that aMule does not currently use, which is called FT_DL_ACTIVE_TIME. I don't have the information here, but maybe that is the information you want. If I have some time I will see if that is true and if it is easy to integrate and keep this information.

Cheers!
Logged

Ezeltje

  • Full Member
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 130
    • Home page
RE: fun with Events
« Reply #2 on: December 01, 2006, 03:05:51 PM »

Quote
Originally posted by phoenix
Well, I think that the problem here is how do we do that in a platform independent way. As far as I can tell, we don't store this information ourselves in met files. Of course, in Linux there is the part file creation date, that we can access through stat(), but that is probably not platform independent. There is an (undocumented?) function wxStat(), but to use it one would have to create a mess of #ifdefs in the code for each supported (?) platform.

Hmmm, I see the problem.

FWIW, I tried writing a script do this by extracting the date and time the download was started, which, as you know, is recorded in the logfile like this:

Code: [Select]
2006-11-15 13:55:17: Downloading IPfilter.rev39.ShadowCast.rarThese I wrote to a separate file (since the logs get erased). I thought I could compare them with the entries that are logged when the downloads are done:
Code: [Select]
2006-12-01 13:55:17: Finished downloading: IPfilter.rev39.ShadowCast.rarThis would have worked, once I got the date math sorted out, except for the fact that I have the habit of cleaning up filenames; in my case, they almost never remain the same.

Now, if in addition to the file name  aMule would also write the hash of the file to logfile when the download starts, then I could get around this, since the hash is also available via the Events interface. Then, when my script is triggered by a finished download, it could look up the date and time the download was started via its hash in my file of start dates & times. Presto!

Do you follow me?

Quote
There is, however, a tag in the met file that aMule does not currently use, which is called FT_DL_ACTIVE_TIME. I don't have the information here, but maybe that is the information you want. If I have some time I will see if that is true and if it is easy to integrate and keep this information.

Thanks, that would also be helpful, if it is not too much trouble...
Logged

Vollstrecker

  • Administrator
  • Hero Member
  • *****
  • Karma: 67
  • Offline Offline
  • Posts: 1549
  • Unofficial Debian Packager
    • http://vollstreckernet.de
Re: fun with Events
« Reply #3 on: December 01, 2006, 03:13:58 PM »

The createion or start of a download, and the end if that, aren't an adequate way to find out, how long the files needed to be downloaded. Consider you are in a high queue rank and are waiting 2 hours and then the file get's finished in 2 Minutes, your calculated download time would be 2:02 which isn't really the info you are searching for. And what happens if you stop aMule, and start it 2 days or even longer later?
The only way to get the right info is a counter that counts the time the download is active. If the .met-file has this field, it's got. is this field thought for something else, it can by used for this, or the info has to go to an additional file.
Logged
Homefucking is killing prostitution

Ezeltje

  • Full Member
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 130
    • Home page
Re: fun with Events
« Reply #4 on: December 01, 2006, 04:01:37 PM »

I understand your point. To be honest, I am not really that interested in the exact amount of time needed to download a given file. As a piece of anecdotal information, the time it was in the DL queue is kinda nice to know. I am not performing statstical analysis or something....
Logged

Kry

  • Ex-developer
  • Retired admin
  • Hero Member
  • *****
  • Karma: -665
  • Offline Offline
  • Posts: 5795
Re: fun with Events
« Reply #5 on: December 01, 2006, 04:07:07 PM »

You gotta think of  "development time" versus "is it useful at all?".
Logged

Ezeltje

  • Full Member
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 130
    • Home page
RE: fun with Events
« Reply #6 on: December 01, 2006, 04:14:04 PM »

Quote
Originally posted by phoenix
Nice script! Thanks!
:D

Since I already made some fixes to it, I decided to put it on the wiki. Since there is no page for Events, I created a very rudimentary one:

http://www.amule.org/wiki/index.php/Events

(I gotta say: that captcha is a real PITA)

Maybe someone who knows more than me can explain what the difference is between a core command and a GUI command.

I hope that if other people write scripts using the events hooks, they will add them there.
Logged

phoenix

  • Evil respawning bird from aMule Dev Team
  • Developer
  • Hero Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 2503
  • The last shadow you'll ever see
RE: fun with Events
« Reply #7 on: December 02, 2006, 04:30:37 AM »

Quote
Originally posted by Ezeltje
Since I already made some fixes to it, I decided to put it on the wiki. Since there is no page for Events, I created a very rudimentary one:

http://www.amule.org/wiki/index.php/Events
Once again, thanks for your cooperation!

Quote
Originally posted by Ezeltje
(I gotta say: that captcha is a real PITA)
Unfortunatelly, we must use it or the wiki spammers won't leave us.

Quote
Originally posted by Ezeltje
Maybe someone who knows more than me can explain what the difference is between a core command and a GUI command.
Done.

Quote
Originally posted by Ezeltje
I hope that if other people write scripts using the events hooks, they will add them there.
So do I.

Cheers!
Logged

phoenix

  • Evil respawning bird from aMule Dev Team
  • Developer
  • Hero Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 2503
  • The last shadow you'll ever see
RE: fun with Events
« Reply #8 on: December 02, 2006, 08:13:59 PM »

Ezeltje,

Quote
Originally posted by Ezeltje
Do you follow me?

Quote
Originally posted by phoenix
There is, however, a tag in the met file that aMule does not currently use, which is called FT_DL_ACTIVE_TIME. I don't have the information here, but maybe that is the information you want. If I have some time I will see if that is true and if it is easy to integrate and keep this information.

Thanks, that would also be helpful, if it is not too much trouble...
Try tomorrow cvs code, please. I have added support for the FT_DL_ACTIVE_TIME tag and it's value can be seen in the file details dialog (middle button mouse click on the file name in the download queue).

On the user event side, I have added the variable DLACTIVETIME that can be used in a script. Also, I have updated the wiki to reflect the change.

Please, give us your feedback with your impressions.

Cheers!
Logged

Ezeltje

  • Full Member
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 130
    • Home page
Re: fun with Events
« Reply #9 on: December 03, 2006, 05:32:30 PM »

Works perfectly -- thanks!   :baby:
Logged

Ezeltje

  • Full Member
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 130
    • Home page
suggestion
« Reply #10 on: December 11, 2006, 11:06:46 PM »

I have a suggestion for two more events:
  • out of diskspace on "incoming" partition
  • out of diskspace on "temp" partition

What do you think?
Logged

wuischke

  • Developer
  • Hero Member
  • *****
  • Karma: 183
  • Offline Offline
  • Posts: 4292
Re: fun with Events
« Reply #11 on: December 11, 2006, 11:17:06 PM »

I like this idea, would be very useful. :)
Logged

phoenix

  • Evil respawning bird from aMule Dev Team
  • Developer
  • Hero Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 2503
  • The last shadow you'll ever see
Re: fun with Events
« Reply #12 on: December 16, 2006, 04:59:05 AM »

Hi folks,

Tomorrow's CVS tarball will have code for two new events:

1) Out of space on temporary partition;
2) Error upon completion (which also accounts for out of space on destination partition).

Please test and report!

Cheers!
Logged

Ezeltje

  • Full Member
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 130
    • Home page
Re: fun with Events
« Reply #13 on: December 16, 2006, 01:43:29 PM »

Phoenix, I just downloaded today's CVS and am getting a compile error, see:
http://forum.amule.org/thread.php?threadid=11817

It looks like it has something to do with the ActiveDLtime stuff, but I am no expert.

I look forward to trying out the new Events...
Logged

phoenix

  • Evil respawning bird from aMule Dev Team
  • Developer
  • Hero Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 2503
  • The last shadow you'll ever see
Re: fun with Events
« Reply #14 on: December 16, 2006, 03:07:11 PM »

Please, try it again, I believe you used an old tarball by mistake.

Cheers!
Logged
Pages: [1] 2