Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a web server running on my Mac and I'd like to be notified (via Growl for example) when someone accesses my server.

I searched for something like that in Automator but found nothing.

Do you know if this is possible ?

Thank you.

share|improve this question
Are you OK parsing the server logs or having a process watching for new network connections or would you like to have more serve functionality to add hooks and notifications to the web site? There easily 4 different ways to solve this problem that come to mind. – bmike Feb 3 '12 at 19:26
up vote 1 down vote accepted

The key is your access logs. Assuming your webserver is properly configured, each time a page is served it should provide some level of detail in the access logs. This can be turned off for sites with enourmous traffic loads, but for your bog standard (assuming) apache install on a local machine I imagine you are not looking as a massive load.

So, what you need is a method to examine the access log periodically (or real time) either by checking timestamps, or tailing the content etc. Once this is sorted, you need a way to push it into growl. Growlnotify is a command line utility that will accept output from other commands and use it as the basis to provide a graphical growl notification.

At this point you need to decide if you want a simple "You have visitors!" message, or something that includes the details, say which page was served to which IP address etc. That's your choice, and makes the code you need to write that bit more complex or simple.

Check the following example (sorry, I use ksh, you may need to modify):

while read access
growlnotify -t "HTTP_Access" -m "You have visitors!
done < /http/access/log/folder/log1.log

Obviously this will churn out far too much info and be generic, so you need to add your own special blend of a) configuring Apache to only log to the level you need, and b) filter out the entries anyway, possibly formatting while you go, e.g.:

while read access
formatted_access=`echo $access | grep -v "unwanted strings" | awk '{print "Time "$1", IP"$4}'`
count =`echo $formatted_access | wc -l`
case $count in
# No line matched criteria
growlnotify -t "HTTP_Access" -m $formatted_access
done < /http/access/log/folder/log1.log

Throw this into an automator service, and away you go.

share|improve this answer
Thanks a lot stuffle. In fact my server is Pow from 37signals that I use to run Rack an Rails apps. I'll try the growlnotify Gem and see what it does. If it's not satisfying, I'll use your script. Thanks again for giving me a complete and detailed answer. – OyoKooN Feb 3 '12 at 23:32
Note that it might not be syntactically perfect, but it's the right idea. Glad to help. – stuffe Feb 3 '12 at 23:43
If you intend to run this in the background over a long period of time it might also be worth to handle situations like log file rotation etc. – patrix Feb 4 '12 at 9:59

One of the most powerful methods of getting notifications from a web server is to build in support for webhooks. The fine folks behind this software stack have a nice blog that helps describe how this might work if you wanted to code this into the web site.

share|improve this answer
Thank you bmike. – OyoKooN Feb 3 '12 at 23:32
I'll investigate this solution further, seems interesting. – OyoKooN Feb 3 '12 at 23:38

Growl can probably do this for you automatically:

enter image description here

share|improve this answer
Thank you user1188152 but the Network panel in Growl seems to send notifications to other computers and not to detect access on the 80 port. – OyoKooN Feb 3 '12 at 23:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.