Send notifications from other platforms?

The Growl forums have moved to Google Groups, this forum is read only.
ibrewster
Harmless
Posts: 5
Joined: Fri May 15, 2009 9:04 pm

Send notifications from other platforms?

Postby ibrewster » Fri May 15, 2009 9:07 pm

I was wondering if there was a way to make use of Growl's network capabilities to send notifications to a mac from other platforms. Specifically, I am running a Nagios server on OpenBSD, and I would like to be able to pop-up messages on the admin's computer using growl for really urgent issues.Thanks.

User avatar
boredzo
Cocoaforge Admin
Posts: 796
Joined: Mon Dec 06, 2004 7:49 am
Contact:

Re: Send notifications from other platforms?

Postby boredzo » Sat May 16, 2009 1:20 am

Yes, there are several libraries that use the platform-independent UDP protocol to talk to Growl.

ibrewster
Harmless
Posts: 5
Joined: Fri May 15, 2009 9:04 pm

Re: Send notifications from other platforms?

Postby ibrewster » Mon May 18, 2009 5:26 pm

boredzo wrote:Yes, there are several libraries that use the platform-independent UDP protocol to talk to Growl.

Ok, note to self- be more explicit next time :grin: Ok, so now that I know it is possible, would anyone be able/willing to tell me how? Knowing it is UDP helps some, but I still have no clue what sort of UDP packet(s) to send, how to generate them, etc. Perhaps there is C++ code to something like the relevant portions of grwolnotify that would compile on other platforms that I can use? Or some sort of guide somewhere to writing applications that talk to Growl across the network? Thanks again!

User avatar
boredzo
Cocoaforge Admin
Posts: 796
Joined: Mon Dec 06, 2004 7:49 am
Contact:

Re: Send notifications from other platforms?

Postby boredzo » Mon May 18, 2009 5:34 pm

ibrewster wrote:Knowing it is UDP helps some, but I still have no clue what sort of UDP packet(s) to send, how to generate them, etc.


http://growl.info/documentation/developer/protocol.php

Perhaps there is C++ code to something like the relevant portions of grwolnotify that would compile on other platforms that I can use?


growlnotify is Cocoa. As far as I know, we don't have any C++ code anywhere in the Growl codebase.

ibrewster
Harmless
Posts: 5
Joined: Fri May 15, 2009 9:04 pm

Re: Send notifications from other platforms?

Postby ibrewster » Wed May 20, 2009 6:29 pm

Ok, after digging into the Growl SDK a bit, I found a python script, Growl.py, that will work. I had to take out the hooks for allowing "localhost" as the host, since it was trying to make a mac-specific connection in that case, but other than that it works. However, I do have a couple remaining issues/questions with it that hopefully can be answered- is this the right place to ask them, or should I take my questions about this python script elsewhere? If so, where? If not, my questions are the following:

1) what's the difference between the applicationIcon argument in the GrowlNotifer initialization, and the icon argument to the notify command?
2) specifying an image file using either of these arguments, although apparently supported based on the code and the argument names, does not seem to work. Am I just missing something here? I know the growlnotify command line tool has options for things like application icon, file icon, etc in addition to just an image file, perhaps it is looking for one of these?
3) Specifying sticky doesn't appear to have any affect.
4) The register command crashes with a "struct.error: required argument is not an integer" error.

So, anyone able to help me address these issues? Thanks in advance!

ibrewster
Harmless
Posts: 5
Joined: Fri May 15, 2009 9:04 pm

Re: Send notifications from other platforms?

Postby ibrewster » Wed May 20, 2009 7:53 pm

Well, answered my own question in regards to the icon (after spending some time looking at the link provide in the previous answer- thanks)- looks like the network notification protocol doesn't support that, which also means my first question (as to the difference between the icons) is moot. Still puzzled on the sticky bit though. It looks like the code sets the flags correctly, from what I can tell, but the message isn't sticky.

I did manage to fix the registration issue as well - turns out there was a typo in the code included with the SDK- to determine which notifications to enable, Growl needs a list of numbers encoded in the registration packet, but the code was trying to encode the actual strings.

User avatar
boredzo
Cocoaforge Admin
Posts: 796
Joined: Mon Dec 06, 2004 7:49 am
Contact:

Re: Send notifications from other platforms?

Postby boredzo » Wed May 20, 2009 7:58 pm

ibrewster wrote:1) what's the difference between the applicationIcon argument in the GrowlNotifer initialization, and the icon argument to the notify command?


The latter sets the icon of the notification.

2) specifying an image file using either of these arguments, although apparently supported based on the code and the argument names, does not seem to work.


Looking at the code, it appears you need to slurp the image data from the file and pass that.

I know the growlnotify command line tool has options for things like application icon, file icon, etc in addition to just an image file, perhaps it is looking for one of these?


growlnotify is written in Cocoa.

3) Specifying sticky doesn't appear to have any affect.


Could you modify the Growl.py file to write out the data to a file? If so, then please post that data file here. I can write a program to interpret it using Growl's structures.

4) The register command crashes with a "struct.error: required argument is not an integer" error.


Unlike some of the other APIs, the Python binding requires the defaultNotifications list to be of indexes into the all-notifications list, not of notification names. (The other APIs allow either way.)

ibrewster
Harmless
Posts: 5
Joined: Fri May 15, 2009 9:04 pm

Re: Send notifications from other platforms?

Postby ibrewster » Wed May 20, 2009 8:35 pm

boredzo wrote:
ibrewster wrote:
3) Specifying sticky doesn't appear to have any affect.


Could you modify the Growl.py file to write out the data to a file? If so, then please post that data file here. I can write a program to interpret it using Growl's structures.

well, the raw hex of the packet is:

Code: Select all

\x01\x01\x00\x01\x00\x04\x00\x0c\x00\x0e\x00\x07downtest messageThis is a testnagios3\x8c\x92\xd7\xee\xf0\xd2\x11\xabfw\xda4\x0e2\xa5\x97
Does that work?

4) The register command crashes with a "struct.error: required argument is not an integer" error.


Unlike some of the other APIs, the Python binding requires the defaultNotifications list to be of indexes into the all-notifications list, not of notification names. (The other APIs allow either way.)


Yep, figured that one out, it's working now. Thanks again!

User avatar
boredzo
Cocoaforge Admin
Posts: 796
Joined: Mon Dec 06, 2004 7:49 am
Contact:

Re: Send notifications from other platforms?

Postby boredzo » Wed May 20, 2009 10:22 pm

ibrewster wrote:
boredzo wrote:
ibrewster wrote:3) Specifying sticky doesn't appear to have any affect.


Could you modify the Growl.py file to write out the data to a file? If so, then please post that data file here. I can write a program to interpret it using Growl's structures.


well, the raw hex of the packet is:

Code: Select all

\x01\x01\x00\x01\x00\x04\x00\x0c\x00\x0e\x00\x07downtest messageThis is a testnagios3\x8c\x92\xd7\xee\xf0\xd2\x11\xabfw\xda4\x0e2\xa5\x97
Does that work?


That's not a file, but it'll suffice.

I wrote the tool I promised. Here's the Bitbucket repository and tip download.

From my perspective, it looks fine—the sticky bit appears to be set correctly, and my code is detecting it correctly. I'll have to look and see what Growl's doing—maybe it's reading the flags incorrectly (I had a hiccup with that).

If you want to try it out yourself, you'll have to write the notification data (what you hex-dumped earlier) to a file, then run that tool, giving it the path to the file. It'll ask you for the password for the hash check; you can read the source code to see that I'm not doing anything evil with it.

lkraav
Harmless
Posts: 4
Joined: Sat Jun 20, 2009 9:51 am

Re: Send notifications from other platforms?

Postby lkraav » Tue Aug 18, 2009 12:27 pm

im also experiencing that sticky bit has no effect using ruby-growl.


Return to “Growl”

Who is online

Users browsing this forum: No registered users