Example to monitor ptpd2
QNX SDP8.0High Availability Framework Developer's GuideDeveloper
The following code snippet shows how to begin monitoring the ptpd2 process:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/netmgr.h>
#include <fcntl.h>
#include <ha/ham.h>
int main(int argc, char *argv[])
{
ham_entity_t *ehdl;
ham_condition_t *chdl;
ham_action_t *ahdl;
char *ptpd2_path = "/usr/sbin/ptpd2 -K";
ham_connect(0);
ehdl = ham_attach("ptpd2", 0, -1, ptpd2_path, 0);
if (ehdl != NULL) {
chdl = ham_condition(ehdl,CONDDEATH, "death", HREARMAFTERRESTART);
if (chdl != NULL) {
ahdl = ham_action_restart(chdl, "restart", ptpd2_path,
HREARMAFTERRESTART);
if (ahdl == NULL) {
printf("add action failed\n");
}
} else {
printf("add condition failed\n");
}
} else {
printf("add entity failed\n");
}
ham_disconnect(0);
exit(0);
}
Page updated: