Neat Dtrace idea...

  • Hi all,
    This is really more of a "can this be done" type question than
    anything but...
    I was looking for a way to monitor my time machine backups and,
    according to the law of finding the most complicated way of doing
    anything, I thought of dtrace...
    Then I thought of how great it would be to get a growlnotify message
    on backup start...

    Is it possible to have Dtrace execute an external program??

    I'm not familiar with Dtrace obviously.

    Cheers in advance,
    -Adam
  • On 12 Nov 2007, at 02:53, Adam Salter wrote:

    > Hi all,
    > This is really more of a "can this be done" type question than
    > anything but...
    > I was looking for a way to monitor my time machine backups and,
    > according to the law of finding the most complicated way of doing
    > anything, I thought of dtrace...

    That would actually be very easy.

    > Then I thought of how great it would be to get a growlnotify
    > message on backup start...
    >
    > Is it possible to have Dtrace execute an external program??

    No.

    Cheers,
    Graham.
  • On 12 Nov 2007, at 08:04, Graham J Lee wrote:

    > On 12 Nov 2007, at 02:53, Adam Salter wrote:
    >
    >> Hi all,
    >> This is really more of a "can this be done" type question than
    >> anything but...
    >> I was looking for a way to monitor my time machine backups and,
    >> according to the law of finding the most complicated way of doing
    >> anything, I thought of dtrace...
    >
    > That would actually be very easy.
    >
    >> Then I thought of how great it would be to get a growlnotify
    >> message on backup start...
    >>
    >> Is it possible to have Dtrace execute an external program??
    >
    > No.

    Actually it is, or at least it is according to the Sun docs I've been
    reading this morning. You just need to declare the script as
    destructive and then use the system() action.

    I don't know what the process that runs the backup is called, but this
    should do the job

    -------------
    #pragma D option destructive
    #pragma D option quiet

    syscall::execve:return
    /execname = "processname"/
    {
        system("growlnotify -m \"Backup Started\"");
    }
  • OK apparently the backup process is called backupd.
    but on trying to run the script I got:
    dtrace: failed to compile script backup_watch.dtrace: line 6: operator
    = can only be applied to a writable variable

    line 5 needs == (not =)

    > #pragma D option destructive
    > #pragma D option quiet
    >
    > syscall::execve:return
    > /execname == "backupd"/
    > {
    > system("growlnotify -m \"Backup Started\"");
    > }

    Thanks... haven't seen it work yet, but it's chugging away :)

    -Adam
  • Whoops! That's what you get for writing stuff into the mail directly.

    note that this won't work if the process is always running. It's triggered
    by the system call to start a new process with the name you specify.

    I can't check right now how TM works.

    On Nov 13, 2007 4:41 AM, Adam Salter <adam.q.salter...> wrote:

    > OK apparently the backup process is called backupd.
    > but on trying to run the script I got:
    > dtrace: failed to compile script backup_watch.dtrace: line 6: operator =
    > can only be applied to a writable variable
    >
    > line 5 needs == (not =)
    >
    > #pragma D option destructive
    > #pragma D option quiet
    >
    > syscall::execve:return
    > /execname == "backupd"/
    > {
    > system("growlnotify -m \"Backup Started\"");
    > }
    >
    >
    > Thanks... haven't seen it work yet, but it's chugging away :)
    >
    > -Adam
    >
  • ... and it appears growlnotify doesn't yet work on leopard :(

    backupd appears to only start as needed for backups.... Still code
    looks good and I'm confident it will work. Thanks for help :)

    One thing I did think was that growlnotify would be run as root...
    would I receive the notification? As noted it is purely theoretical
    atm since growlonotify doesn't work on Leopard.

    -Adam

    On 13/11/2007, at 8:16 PM, Paul Sargent wrote:

    > Whoops! That's what you get for writing stuff into the mail directly.
    >
    > note that this won't work if the process is always running. It's
    > triggered by the system call to start a new process with the name
    > you specify.
    >
    > I can't check right now how TM works.
    >
    > On Nov 13, 2007 4:41 AM, Adam Salter <adam.q.salter...> wrote:
    > OK apparently the backup process is called backupd.
    > but on trying to run the script I got:
    > dtrace: failed to compile script backup_watch.dtrace: line 6:
    > operator = can only be applied to a writable variable
    >
    > line 5 needs == (not =)
    >
    >> #pragma D option destructive
    >> #pragma D option quiet
    >>
    >> syscall::execve:return
    >> /execname == "backupd"/
    >>
    >> {
    >> system("growlnotify -m \"Backup Started\"");
    >> }
    >
    > Thanks... haven't seen it work yet, but it's chugging away :)
    >
    > -Adam
    >
  • On 14 Nov 2007, at 05:15, Adam Salter wrote:

    > ... and it appears growlnotify doesn't yet work on leopard :(

    Typical. It's always the "easy" bit that goes wrong.

    > One thing I did think was that growlnotify would be run as root...
    > would I receive the notification?

    Good point, but there are a couple of options in that case.

    1) change the command to su to the right account (i.e. 'su -c
    'command' user).
    2) Use the growl network interface for the message. (No idea about
    that one)
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today