strange behaviour with net_kernel:monitor_nodes

luvish satija <>
Thu Jun 30 13:58:50 CEST 2005


Hello all,
  I am trying to make a simple network monitor. For
that I ran a program consising of the following code
(this is the concept which i'll be using in my
monitor) 


-module(mon).
-export([monitor/0,start/0]).

start() ->
net_kernel:connect_node(),
net_kernel:connect_node(),
spawn(mon,monitor,[]).

monitor() ->
case net_kernel:monitor_nodes(true) of
   ok ->
    receive
     {nodedown, Node}->
       io:format("THE ~p NODE HAS BEEN DOWN and nodes
is ~p.~n",[Node, nodes()])
    end,
   monitor();
  Other ->
   io:format("unable to start monitor")
end.

      Firstly i started ,  and then i
started my mon. To test, I first killed  and
then  I got the following output:

luvish $ erl -sname mon
Erlang (BEAM) emulator version 5.1 [source]

Eshell V5.1  (abort with ^G)
()1> mon:start().
<0.41.0>
THE  NODE HAS BEEN DOWN and nodes is [].
THE  NODE HAS BEEN DOWN and nodes is [].
THE  NODE HAS BEEN DOWN and nodes is [].
()2>

   Now the problem is that I'm getting the nodedown
message for  two times which is certainly not
desirable. Becuse if some node gets down, then action
should be taken only once. Note that second time, the
value of nodes() is [], so logically, nobody is
connected to  now but still third line is
printed. 
   Am i missing something or more then one nodedown
messages are sent (then a should also show the same
behaviour)? Please help me to resolve this confusion.

Thanks in advance,
/luvish 


		
__________________________________________________________
How much free photo storage do you get? Store your friends 'n family snaps for FREE with Yahoo! Photos http://in.photos.yahoo.com



More information about the erlang-questions mailing list