Skip to content

Instantly share code, notes, and snippets.

@videlalvaro
Created August 31, 2011 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save videlalvaro/1184689 to your computer and use it in GitHub Desktop.
Save videlalvaro/1184689 to your computer and use it in GitHub Desktop.
Find Erlang nodes in the cluster
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -sname nodefinder
%% Usage:
%% chmod +x nodes.erl
%% ./nodes.erl 'somenode@host'
main([N]) ->
Node = list_to_atom(N),
case net_adm:ping(Node) of
pong ->
Nodes = rpc:call(Node, erlang, nodes, []),
io:format("Nodes: ~p~n", [lists:delete(node(), Nodes ++ [Node])]);
_ ->
io:format("Can't contact node: ~p~n", [Node])
end,
ok.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment