Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

how can I get the node name in a vms cluster using c program?

 
likuair_1
Advisor

how can I get the node name in a vms cluster using c program?

There are two alpha computer in my cluster,and I want to get the master computer's node name and tcp/ip address in the vms cluster,are there any sys$ or lib$ function that can be called by c program?
5 REPLIES
Steven Schweda
Honored Contributor

Re: how can I get the node name in a vms cluster using c program?

I didn't think that a VMS cluster had a
"master" computer. Why do you think that it
has one?

You can use sys$getsyi() to get some
cluster-related data. See, for example:

http://h71000.www7.hp.com/doc/732FINAL/4527/4527pro_005.html#jun_312

Getting _the_ IP address may be more
complicated, as a node may have more than
one, and the cluster node name may not be
related to the IP host name (although they
are normally related).

Is there some problem which you are trying
to solve?
Thomas Ritter
Respected Contributor

Re: how can I get the node name in a vms cluster using c program?

My way is to link against the exec. Something like this.


$ cc node_name
$ link/sysexe node_name



*/

#include
#include

/*
** External data storage references.
*/

extern unsigned int SCS$GB_NODENAME;


int main()
{
char nodename[6];

strncpy(nodename,(char * ) &SCS$GB_NODENAME,6);
nodename[5] = '\0'; /* Terminate the string */

printf("%s \n",nodename);

}/*main*/

Steven Schweda
Honored Contributor

Re: how can I get the node name in a vms cluster using c program?

Or, if you're really desperate for amusement:

alp $ type clu.c
/* 2006-10-12 SMS.
* Cluster node info demo.
*/

#include
#include

#include
#include
#include
#include

/* GETxxx item descriptor structure. */
typedef struct
{
short buf_len;
short itm_cod;
void *buf;
int *ret_len;
} xxx_item_t;

main()
{
int csi;
int sts;
char *p;

/* Storage for data returned by sys$getsyi(). */
static int buf_nn_used;
static char buf_nn[ 9];
static int buf_hw_used;
static char buf_hw[ 61];
static int csid;

/* Item list structure to get various cluster data using sys$getsyi(). */
struct
{
xxx_item_t syi_scsnode_itm; /* SCS node name. */
xxx_item_t syi_hw_name_itm; /* Hardware model name. */
xxx_item_t syi_node_csid_itm; /* Cluster system ID. */
int term;
} syi_itm_lst =
{ { sizeof buf_nn, SYI$_SCSNODE, &buf_nn, &buf_nn_used },
{ sizeof buf_hw, SYI$_HW_NAME, &buf_hw, &buf_hw_used },
{ sizeof buf_hw, SYI$_NODE_CSID, &csid, NULL },
0
};

csi = -1; /* Cluster ID wildcard. */

for (sts = SS$_NORMAL; sts == SS$_NORMAL; )
{
sts = sys$getsyiw( 0, /* Event flag. */
&csi, /* Cluster system ID. */
NULL, /* Node name (not used). */
&syi_itm_lst, /* Ilem list. */
0, /* IOSB (not used). */
0, /* AST address (not used). */
0); /* AST parameter (not used). */

if ((sts& STS$M_SEVERITY) == STS$K_SUCCESS)
{
/* NUL-terminate the SCS name, and trim any trailing spaces. */
buf_nn[ buf_nn_used] = '\0';
if ((p = strchr( buf_nn, ' ')) != NULL)
*p = '\0';

/* NUL-terminate the hw name. */
buf_hw[ buf_hw_used] = '\0';

/* Print the results. */
printf( " >%s< %.*s>%s< %%x%08x.\n",
buf_nn, (8- strlen( buf_nn)), " ", buf_hw, csid);
}
}
}

alp $ cc clu
alp $ link clu
alp $ run clu
>ALP< >COMPAQ Professional Workstation XP1000< %x00010001.
>ALP2< >COMPAQ Professional Workstation XP1000< %x00010006.
alp $


Of course, the IP data are not available
here.
Jan van den Ende
Honored Contributor

Re: how can I get the node name in a vms cluster using c program?

likuair,

if by "master node", you mean "founding node", you might even get info about a node that long ago left the cluster...

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Robert Gezelter
Honored Contributor

Re: how can I get the node name in a vms cluster using c program?

likuair,

I would strongly recommend the use of the system services to obtain the information.

Using the system services almost guarantees that your program will run against multiple releases of the system.

Programs that directly access the executive and its data structures will require re-linking on upgrades. This is a serious drawback, particularly when the information is available in a completely release independent way.

- Bob Gezelter, http://www.rlgsc.com