determine the status of all nodes on the network
#include <sys/name.h> int qnx_net_alive( char *buf, int buflen );
This function determines the status of all nodes on the network. It does this by sending a message to the first nameloc name locator it encounters. The nameloc command polls the network, looking for names, and thus knows the status of all nodes.
The arguments are as follows:
If no nameloc is found, all nids are reported as up.
On a network with more than one media (for example, arcnet and ethernet), nameloc reports as up only the nodes it can talk to. Therefore, run nameloc on a node with lots of network cards, such as a server.
Confusion can result when multiple namelocs are running, some on nodes that can or can't see other nodes.
Remember that qnx_net_alive() returns the best guess of the nodes' status, as determined by nameloc. This information cannot be guaranteed to be correct, given the hardware-independent way that nameloc collects this information.
There are always timing windows: for example, a node is just turned on, but reported as down by qnx_net_alive(), or a node is just turned off, but reported as up.
The valid length of the buffer as returned by nameloc.
#include <stdio.h> #include <stdlib.h> #include <sys/name.h> main(argc, argv) int argc; char *argv[]; { int I; int num_nids; static char buffer[500]; if ((num_nids=qnx_net_alive(buffer,500)) == -1) { printf("qnx_net_alive() failed\n"); exit(1); } /* zero-based */ for(I=1; I < num_nids+1; I++){ printf("%3d %s\n", I, buffer[I] ? "up" : "down"); } }
QNX
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
nameloc utility