clu_info, clu_get_info, clu_free_info,
clu_get_memb_by_name, clu_get_memb_by_id, clu_free_memb -
Gets information about a cluster and its members
#include <sys/clu.h>
int clu_info(
int clu_info_type,
... ); int clu_info(
CLU_INFO_MEMBSTATE,
size_t memb_array_size,
char *member_array ); int clu_info(
CLU_INFO_LIMITS,
struct clu_limits *limits ); int clu_info(
CLU_INFO_CLU_NAME,
char *name,
size_t size ); int clu_info(
CLU_INFO_INTERNAME_BY_ID,
memberid_t memberid,
char *intername,
size_t size ); int clu_info(
CLU_INFO_INTERNAME_BY_NAME,
char *hostname,
char *intername,
size_t size ); int clu_info(
CLU_INFO_HOSTNAME_BY_ID,
memberid_t memberid,
char *hostname_out,
size_t size ); int clu_info(
CLU_INFO_NODENAME_BY_ID,
memberid_t memberid,
char *nodename,
size_t size ); int clu_info(
CLU_INFO_NODENAME_BY_NAME,
char *hostname,
char *nodename,
size_t size ); int clu_info(
CLU_INFO_MEMBERID_BY_NAME,
char *hostname,
memberid_t *memberid_out ); int clu_info(
CLU_INFO_MEMBLIST,
char **namelist,
size_t *array_size,
size_t name_length ); int clu_info(
CLU_INFO_MY_ID,
memberid_t *my_memberid ); int clu_get_info(
struct clu_gen_info **clu_gen_ptr ); void
clu_free_info(
struct clu_gen_info **clu_gen_ptr ); int
clu_get_memb_by_name(
char *hostname,
struct clu_member_info **clu_memb_ptr ); int
clu_get_memb_by_id(
memberid_t memberid,
struct clu_member_info **clu_memb_ptr ); int
clu_free_memb(
struct clu_member_info **clu_memb_ptr );
Cluster Library (libclu)
One of the information constants defined in <sys/clu.h>:
CLU_INFO_MEMBSTATE, CLU_INFO_LIMITS, CLU_INFO_CLU_NAME,
CLU_INFO_INTERNAME_BY_ID, CLU_INFO_INTERNAME_BY_NAME,
CLU_INFO_HOSTNAME_BY_ID, CLU_INFO_NODENAME_BY_ID,
CLU_INFO_NODENAME_BY_NAME, CLU_INFO_MEMBERID_BY_NAME,
CLU_INFO_MEMBLIST, CLU_INFO_MY_ID. These constants specify
the type of cluster query being made. Number of elements
in the namelist array. String containing the host name
used to specify the cluster member for which to retrieve
information. Pointer to a caller-allocated buffer that
holds a string, which clu_info() fills with the host name
of the specified member. Pointer to a caller-allocated
buffer that holds a string, which clu_info() fills with
the interconnect host name. A caller-allocated structure
of type struct clu_limits, which clu_info() will fill with
the minimum supported member ID, the maximum supported
member ID, and the maximum supported number of members in
a cluster. Number of elements in the member_array array.
Pointer to a caller-allocated character array that will
hold information about each member's state. The size of
the array should be CLU_MAX_MEMBERID + 1. The element of
the array that matches the member ID of a member will contain
that member's current state: CLU_MEMB_NOT_CONF (-1),
CLU_MEMB_CONF_DOWN (0), or CLU_MEMB_CONF_UP (1). For
example, member_array[2] will contain the state of member
2. Member ID of the cluster member for which to retrieve
information. Pointer to a variable of type memberid_t
which will be set to the member ID of the specified member.
Pointer to a variable of type memberid_t which will
be set to the member ID of the running cluster member.
Pointer to a caller-allocated buffer that holds a string,
which clu_info() will fill with the cluster name. Pointer
to a caller-allocated array that will hold the host names
of all members in the cluster. The caller-allocated size
of each string element of namelist. Pointer to a callerallocated
buffer that holds a string, which clu_info()
fills with the Connection Manager (CNX) node name of the
specified member. The size of the member array, member_array.
Address of a pointer to a structure of type
struct clu_gen_info, which clu_get_info() will load with
cluster information. (Use clu_free_info() to free the memory
allocated for the structure.) Address of a pointer to
a structure of type struct clu_member_info, which
clu_get_memb_by_name() and clu_get_memb_by_id() will load
with specific member information. (Use clu_free_memb() to
free the memory allocated for the structure.)
When called from a member of a cluster, the clu_info()
function returns specific cluster status information when
the following options are specified: CLU_INFO_MEMBSTATE -
returns the following information about each cluster member's
state: up, down, or not configured. CLU_INFO_LIMITS
- returns the following information on member IDs and supported
members: Minimum supported member ID Maximum supported
member ID Maximum supported number of members in a
cluster CLU_INFO_CLU_NAME - returns the cluster name.
CLU_INFO_INTERNAME_BY_ID - returns the cluster interconnect
host name given a specific member ID.
CLU_INFO_INTERNAME_BY_NAME - returns the cluster interconnect
host name given a specific host name.
CLU_INFO_MEMBERID_BY_NAME - returns the member ID given a
specific host name. CLU_INFO_HOSTNAME_BY_ID - returns the
member host name given a specific member ID.
CLU_INFO_NODENAME_BY_ID - returns the Connection Manager
(CNX) node name given a specific member ID.
CLU_INFO_NODENAME_BY_NAME - returns the CNX node name
given a specific host name. CLU_INFO_MEMBLIST - returns a
list of host names for all members in the cluster.
CLU_INFO_MY_ID - returns the member ID for the member on
which it is run.
When called from a member of a cluster, the clu_get_info()
function returns a structure containing general information
about the cluster and its members. The information
includes: The name of the cluster and the number of members
configured in the cluster. The device name and number
of votes of the quorum disk, if configured. For each
member, its member ID, host name, cluster interconnect IP
name, and current state (UP or DOWN).
When called from a system that is not a cluster member,
the clu_get_info() function returns -1 (CLU_NOT_CONFIGURED).
If a member of the cluster is down, or a member's
/etc/rc.config file contains illegal values, the values
returned by string pointers can be NULL.
Note that the clu_get_info function does not require allocated
structures. While the clu_info function accepts
pointers to caller-allocated structures, the clu_get_info
function accepts a pointer to a structure.
The clu_free_info() function frees the memory allocated
for a clu_gen_info structure. The clu_gen_info structure
is defined in <sys/clu.h>.
Use the clu_get_memb_by_name() and clu_get_memb_by_id()
functions to return information about a cluster member.
The clu_get_memb_by_name() function returns a structure
containing the host name of a cluster member, while the
clu_get_memb_by_id() function returns a structure containing
the member ID of a cluster member.
The clu_free_memb() function frees the memory allocated
for a clu_member_info structure. The clu_member_info
structure is defined in <sys/clu.h>.
The clu_get_info() and clu_free_info() functions return
one of the following values: Successful completion. System
is not configured to be in a cluster. Called from a
system that is not a cluster member. There is no memory
for the interface. Cannot determine the value of the
sysconfigtab memberid attribute. Cannot query Connection
Manager (CNX) subsystem. The input to member_array is not
large enough.
The clu_info(), clu_get_memb_by_name(),
clu_get_memb_by_id(), and clu_free_memb() functions return
one of the following values: Successful completion. The
operation was unsuccessful. Check errno to determine the
error.
The following code fragments show typical calling
sequences for the clu_info() options:
CLU_INFO_MEMBSTATE:
size_t size = 256; char marray[256];
clu_info(CLU_INFO_MEMBSTATE, size, marray);
CLU_INFO_LIMITS:
struct clu_limits limits; clu_info(CLU_INFO_LIMITS, &limits);
CLU_INFO_CLU_NAME:
char name[MAXHOSTNAMELEN]; clu_info(CLU_INFO_CLU_NAME,
name, sizeof(name));
CLU_INFO_INTERNAME_BY_ID:
memberid_t memberid = 2; char intername[MAXHOSTNAMELEN];
clu_info(CLU_INFO_INTERNAME_BY_ID, memberid, intername,
sizeof(intername));
CLU_INFO_INTERNAME_BY_NAME:
char *hostname = "my_member"; char intername[MAXHOSTNAMELEN];
clu_info(CLU_INFO_INTERNAME_BY_NAME, hostname,
intername, sizeof(intername));
CLU_INFO_MEMBERID_BY_NAME:
char *hostname = "my_member"; memberid_t memberid_out;
clu_info(CLU_INFO_MEMBERID_BY_NAME, hostname, &memberid_out);
CLU_INFO_HOSTNAME_BY_ID:
memberid_t memberid = 2; char hostname_out[MAXHOSTNAMELEN];
clu_info(CLU_INFO_HOSTNAME_BY_ID, memberid, hostname_out,
sizeof(hostname_out));
CLU_INFO_NODENAME_BY_ID:
memberid_t memberid = 2; char nodename[MAXHOSTNAMELEN];
clu_info(CLU_INFO_NODENAME_BY_ID, memberid, nodename,
sizeof(nodename));
CLU_INFO_NODENAME_BY_NAME:
char *hostname = "my_member"; char nodename[MAXHOSTNAMELEN];
clu_info(CLU_INFO_NODENAME_BY_NAME, hostname, nodename,
sizeof(nodename));
CLU_INFO_MEMBLIST:
struct clu_limits limits; char **namelist; size_t size;
int i; clu_info(CLU_INFO_LIMITS, &limits); size = limits.max_membid;
namelist = (char **)calloc(size,sizeof(char
*)); for(i=0;i<size;i++) {
namelist[i] = (char *)calloc(MAXHOSTNAMELEN,sizeof(char));
namelist[i][0] = ' '; } clu_info(CLU_INFO_MEMBLIST,
namelist, &size, MAXHOSTNAMELEN);
CLU_INFO_MY_ID:
memberid_t my_memberid; clu_info(CLU_INFO_MY_ID, &my_memberid);
The following code fragment shows a typical calling
sequence for the clu_get_info() function:
#include <sys/clu.h>
int retval = 0; int i = 0; struct clu_gen_info *clugenptr;
clugenptr = NULL;
retval = clu_get_info(&clugenptr);
switch (retval) {
case 0: break;
case CLU_NOT_MEMBER:
case CLU_NO_CLUSTER_NAME:
case CLU_NO_MEMBERID:
case CLU_CNX_ERROR:
fprintf(stderr, "clu_get_info error0);
exit(1);
default:
exit(1);
}
if (clugenptr == NULL)
exit(1);
for (i = 0; i <= clugenptr->clu_num_of_members -1; i++) {
/* print or use the returned info; for example: */
printf("member hostname is %s0, clugenptr->memblist[i].hostname);
}
clu_free_info(&clugenptr);
The following code fragment shows a typical calling
sequence for the clu_get_memb_by_id() function
(clu_get_memb_by_name() is similar):
#include <sys/clu.h> #include <errno.h>
memberid_t memberid = 2; struct clu_member_info *membinfo
= NULL; if (clu_get_memb_by_id(2, &membinfo)) {
fprintf(stderr, "Error! Return code of %d0, errno);
exit(1); } printf("Member cluster version is %s0, membinfo->clu_version);
clu_free_memb(&membinfo);
Run-time configuration file for each cluster member.
Commands: clu_get_info(8)
Files: rc.config(8)
clu_info(3)
[ Back ] |