[avahi] Avahi Signalling that it is going offline??
Linus Lüssing
linus.luessing at web.de
Fri Feb 3 00:14:24 PST 2012
On Mon, Jan 30, 2012 at 12:39:27PM -0700, Nathanael D. Noblet wrote:
> Hello
>
> I have a few devices that have a .service file in
> /etc/avahi/services. It works well I can see the service etc.
> However my administration app which is using avahi to detect
> machines coming online/offline in a link-local setup never knows
> when they disappear because they are always there. The devices
> offering the service are portable so go to sleep and move around on
> the network. So I'm wondering if there is a way the avahi-daemon can
> signal that the service/device is going offline so I get the
> notifications? When I first started and had an actual app listening
> it was just somewhat built in when you unregistered, however now it
> never does that.
>
> I'm basically using the service to help detect when the devices are
> online since the service I want to use is always there when the
> devices are available. If that makes any sense.
Hi Nathanael,
For something similiar I'm just using avahi-browse and some ugly
bash-foo, don't know whether that's what you are looking for, too:
~~ snip ~~
#!/bin/sh
BROWSE_CMD="avahi-browse -p _snmp._tcp"
add_event() {
echo "add_event for $1"
# Add your actions here
}
del_event() {
echo "del_event for $1"
# Add your actions here
}
parser() {
local hostname="`echo "$1" | cut -f4 -d";" | sed "s/.*032//"`"
if [ "`echo $1 | cut -f1 -d';'`" = "+" ]; then
add_event "$hostname"
elif [ "`echo $1 | cut -f1 -d';'`" = "-" ]; then
del_event "$hostname"
fi
}
$BROWSE_CMD | { while read foo; do parser "$foo"; done }
~~~~
So if your device is going offline, just stop the avahi-daemon
on that device first and your listener using avahi-browse / this script
should be able to notice this and react immediately.
Or for any other language more sophisticated than bash see:
http://avahi.org/wiki/Bindings
Cheers, Linus
>
> Thoughts?
> --
> Nathanael d. Noblet
> t 403.875.4613
> _______________________________________________
> avahi mailing list
> avahi at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/avahi
>
More information about the avahi
mailing list