How to: Send Growl notifications from router (Python)

Discussion in 'Tomato Firmware' started by philess, May 6, 2013.

  1. philess

    philess Networkin' Nut Member

    What is Growl?

    Growl is a desktop notification app displaying Balloon-popups with information about
    various events. Growl is mostly home on Mac´s but there is also a Windows version.
    Growl can tell you when a download has finished, a new email has arrived and much more.
    It can also forward messages over network from one computer to another, so you
    can have your downloads running on one computer in the bedroom, while you are browsing
    the web on another computer in the living room, receiving Growl messages if a download
    has finished. You could also forward them as push-notification to your iPhone using "Boxcar".

    More info & Mac app download:
    Growl for Windows:
    Growl for Linux:


    Display style can be customized in the desktop app, also options like display-duration
    and which corner of your desktop it should appear and much more. These screenshots
    are just very basic examples.

    I think this is a nice alternative or addition to email notifications from scripts running on Tomato.
    I will not get into too much detail about Growl itself here (assuming most people who
    read the topic title already know Growl) and instead focus on the simple steps to
    make it possible to have your Tomato router send you notifications.

    - Python 2.5 or higher (tested with 2.5 and 2.7)
    - SSH & (S)FTP access to your router

    If you arent already, connect to your router over SSH.

    I am assuming you are doing this install from your /tmp directory.
    cd /tmp
    Download & install setuptools
    (Check your Python version with "python -V". If you are using a different
    version than 2.7 in this example, get the download link for the setuptools
    from and proceed accordingly)
    chmod +x setuptools-0.6c11-py2.7.egg
    After installation has completed successfully:
    rm -rf setuptools-0.6c11-py2.7.egg

    Download & install pip
    tar xvzf pip-1.2.tar.gz
    rm -rf pip-1.2.tar.gz
    cd pip-1.2
    python install
    After installation has completed successfully:
    cd ..
    rm -rf pip-1.2/

    Download & install gntp
    Download the .ZIP from here:
    (Doesnt seem to be possible with wget@tomato, download it on
    your computer and upload the .zip to /tmp on your router)

    rm -rf
    cd gntp-master
    python install
    After installation has completed successfully:
    cd ..
    rm -rf gntp-master/

    Create the following files, change the mentioned lines to your own setup
    (If you are using Windows, pay attention to CR/LF, i recommend using Notepad++ or UltraEdit)
    import gntp.notifier
    growl = gntp.notifier.GrowlNotifier(
            applicationName = "Tomato",
            notifications = ["Info"],
            defaultNotifications = ["Info"],
            hostname = "",
            password = "password"
    Required: Change the IP to the IP of your computer that should later receive the notifications.
    Required: Change the password to the Growl-password you have set on your computer.
    Optional: applicationName is how the App will show up towards the receiver.
    Optional: notifications is the category it should register, it is fine to just have one.
    Optional: defaultNotifications is the default category to use for messages.
    import gntp.notifier
    import sys
    # USAGE: python <IP-or-HOSTNAME> <TITLE> <TEXT>
    # these settings must be the same as used previously
    # when registering with
    # if you dont want to use IP from commandline,
    # replace sys.argv[1], with your IP
    growl = gntp.notifier.GrowlNotifier(
            applicationName = "Tomato",
            notifications = ["Info"],
            defaultNotifications = ["Info"],
            hostname = sys.argv[1],
            password = "password"
    # Send message
            noteType = "Info",
            # priority can be used in the client to handle
            # messages differently, otherwise can be ignored
            priority = 1,
            # title is the message title (subject/header)
            title = sys.argv[2],
            # description is the message text (body)
            description = sys.argv[3],
            # If sticky is True, the message will stay onscreen until
            # you click on it. Can be useful for very important messages.
            sticky = False,
            # optional:
            # provide callback url when growl message is clicked
            # example: open browser & view TomatoUSB webinterface
            # callback = "",
            # optional:
            # send along a icon for the mesage
            # note: i never got this working with a local file, only this example:
            # icon = "",
    Required: Edit the top part exactly the same as in!
    The lower part can be ignored, but it is explained what each setting does.

    Optional step:
    I have two files to call from scripts. One sends standard messages that will disappear after
    a few seconds. The other is for important events (High CPU load, Temperature, etc) and will
    send sticky messages that will stay onscreen until you click on them.
    If you want this too, duplicate the created from above as
    but change the setting to "sticky = True,".

    Upload the created and to your router, for example to /opt


    This is only required ONCE.
    Or if you want to use different applicationName or categories for the messages.
    python /opt/
    On your computer there should be a notification "Application Tomato has registered"
    Now you can send notifications using to that computer.

    Sending notifications

    python /opt/ "Hello" "Hello World"
    Should give you a notification with the title "Hello" and the text "Hello World" on your receiving computer.


    From now on you can send these messages from your scripts or WebUI.

    For example in Webui, Administration/Scripts/WAN UP:
    python /opt/ "WAN UP" "WAN is up with IP $(nvram get wan_ipaddr)"

    Or if you have certain things being done from Scheduler:
    echo "15" > /proc/net/expire_early
    python /opt/ "Conntrack" "Idle connections have been dropped."

    Or whenever someone connects to your OpenVPN Tomato server:
    Add to OpenVPN custom configuration:
    script-security 3 system
    client-connect /opt/
    client-disconnect /opt/
    python /opt/growl/ OpenVPN "$common_name connected from $untrusted_ip"
    exit 0
    python /opt/growl/ OpenVPN "$common_name disconnected"
    exit 0
    (Dont forget to "chmod +x")

    I hope this can be useful or atleast fun to play with for someone. Enjoy.
    Any input is very welcome!
    blackwind likes this.
  2. occamsrazor

    occamsrazor Network Guru Member

    This will take some time for me to get my head around the installation process, but looks great. Growl is a super system....
  3. philess

    philess Networkin' Nut Member

    It may look complicated because i wanted to make this how-to pretty much fool-proof, but it really isnt.
    Its just installing setuptools.egg, pip (python package manager), the gntp-master and then registering
    from I usually get through all steps in way less than 10 minutes.
  4. MercuryV

    MercuryV Networkin' Nut Member

  5. philess

    philess Networkin' Nut Member

    True, but when i tried some months ago i couldnt get it working on Tomato.
  6. MercuryV

    MercuryV Networkin' Nut Member

    What's about python script on router as sender + Linux port of Growl on desktop as receiver?
    philess likes this.
  7. philess

    philess Networkin' Nut Member

    Oh yes, true. I didnt think about that :) Thank you.
  8. Sean Rhodes

    Sean Rhodes Networkin' Nut Member

    Hi philess,

    How do you add multiple recipients? Do you have to send for each ip address on the network, or can you have multiple hostname IP addresses?

    I sent the from my iMac and got a return notification from the router OK, but I also have a mac-mini and windows pc both running growl as well. They all see each other through the growl network, but only my iMac receives notification.

    My assumption was they all should receive the notification?
  9. Hi philess,

    thanks for your awesome guide! I finally can get notified by my pfsense router, if the cpu gets hot. I tried php-growl and net:smtp:tls email notifications before, but could get nothing to work. Your guide just works and is easy to understand. Two thumps up.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice