Home
Developer Resources
QNX RTOS v4
QNX RTOS v4 Knowledge Base

QNX RTOS v4 Knowledge Base

Foundry27
Foundry27
QNX RTOS v4 project
Resources

QNX RTOS v4 Knowledge Base

Title How to check which nodes are up and what type of CPU is on each node from code
Ref. No. QNX.000009318
Category(ies) Network, Development, Configuration
Issue We want our application to show which nodes are up and what type of CPU is on each node.  Is there a function that will let our program find this information easily?


Solution Yes, there is such a function which will do this called qnx_osinfo(). With this function, an application can gather various pieces of system information, including node number, type of CPU, tick size, available free memory, and so on.

The following example uses qnx_osinfo() to display whether the specified node is up or down. If the node's up, the program will tell you what type of CPU it has and whether the node booted from network or from disk.

#include <stdio.h>
#include <sys/osinfo.h>

struct _osinfo osdata;
main(int argc, char *argv[])
{
x09int ret,node;
x09node=atoi(argv[1]);
x09ret=qnx_osinfo(node,&osdata);
x09printf("Node %4d status is: %sn",osdata.nodename,ret?"Down":"Up");
x09{
x09printf("CPU type isx09: %1dn",osdata.cpu);
x09printf("Booted from nodex09: %sn",osdata.bootsrc=78?"Net":"Disk");
x09}
}

The qnx_osinfo() function can return other information as well, see the /usr/include/sys/osinfo.h header file for more information on what is returned.

Also you might want to look at the qnx_psinfo() structre. It contains complementary information and the data structure is defined in /usr/include/sys/psinfo.h .