IBM®
跳转到主要内容
    中国 [选择]    使用条款
 
 
Select a scope:Search for:    
    首页    产品    服务与解决方案     支持与下载    个性化服务    
跳转到主要内容

developerWorks 中国  >  Linux  >

Heartbeat client query program

developerWorks
文档选项

未显示需要 JavaScript 的文档选项


级别: 初级

IBM,

2002 年 8 月 01 日

IBM eServer Developer Domain is an ever-growing collection of content and resources for developers on IBM eServer hardware and related software. Dedicated to iSeries, pSeries, xSeries and zSeries developer content , IBM eServer Developer Domain offers articles, sample code, tutorials, how-tos, tools, news, case studies, discussion forums -- virtually anything developers want or need to help get their jobs done.
     1	/* taken from api_test.c in the heartbeat package, with thanx */
       
     2	#include <stdio.h>
     3	#include <stdlib.h>
     4	#include <string.h>
     5	#include <fcntl.h>
     6	#include <unistd.h>
     7	#include <errno.h>
     8	#include <signal.h>
     9	#include <sys/types.h>
    10	#include <sys/utsname.h>
    11	#include <sys/time.h>
    12	#include <sys/stat.h>
    13	#include <stdarg.h>
    14	#include <heartbeat.h>
    15	#include <hb_api_core.h>
    16	#include <hb_api.h>
       
       
    17	int
    18	main(int argc, char ** argv)
    19	{
    20	        unsigned        fmask;
    21	        ll_cluster_t*   hb;
       
    22	      (void)_heartbeat_h_Id;
    23	        (void)_ha_msg_h_Id;
       
       
    24	        hb = ll_cluster_new("heartbeat");
    25	        if (hb->llc_ops->signon(hb, NULL)!= HA_OK) {
    26	                fprintf(stderr, "Cannot sign on with heartbeat\n");
    27	                fprintf(stderr, "REASON: %s\n", hb->llc_ops->errmsg(hb));
    28	                exit(1);
    29	        }
       
    30	        /* here is where we ask for status */ 
    31	        fprintf(stdout, "%s\n" ,hb->llc_ops->node_status(hb, "slave5")); 
    32	        
    33	        if (hb->llc_ops->signoff(hb) != HA_OK) {
    34	                fprintf(stderr, "Cannot sign off from heartbeat.\n");
    35	                fprintf(stderr, "REASON: %s\n", hb->llc_ops->errmsg(hb));
    36	                exit(10);
    37	        }
    38	        if (hb->llc_ops->delete(hb) != HA_OK) {
    39	                fprintf(stderr, "REASON: %s\n", hb->llc_ops->errmsg(hb));
    40	                fprintf(stderr, "Cannot delete API object.\n");
    41	                fprintf(stderr, "REASON: %s\n", hb->llc_ops->errmsg(hb));
    42	                exit(11);
    43	        }
    44	        return 0;
    45	}
    



关于作者

IBM has authored this article




对本文的评价

太差! (1)
需提高 (2)
一般;尚可 (3)
好文章 (4)
真棒!(5)

建议?







回页首


IBM 公司保留在 developerWorks 网站上发表的内容的著作权。未经IBM公司或原始作者的书面明确许可,请勿转载。如果您希望转载,请通过 提交转载请求表单 联系我们的编辑团队。
    关于 IBM 隐私条约 联系 IBM 使用条款