Heartbeat client query program
     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  }