The xfnts_probe method checks the availability of the application and determines whether to fail over or restart the data service. The xfnts_monitor_start callback method starts this program, and the xfnts_monitor_stop callback method stops it.
/* * Copyright (c) 1998-2006 by Sun Microsystems, Inc. * All rights reserved. * * xfnts_probe.c - Probe for HA-XFS */ #pragma ident “@(#)xfnts_probe.c 1.26 01/01/18 SMI” #include <stdio.h> #include <stdlib.h> #include <strings.h> #include <unistd.h> #include <signal.h> #include <sys/time.h> #include <sys/socket.h> #include <strings.h> #include <rgm/libdsdev.h> #include “xfnts.h” /* * main(): * Just an infinite loop which sleep()s for sometime, waiting for * the PMF action script to interrupt the sleep(). When interrupted * It calls the start method for HA-XFS to restart it. * */ int main(int argc, char *argv[]) { int timeout; int port, ip, probe_result; scds_handle_t scds_handle; hrtime_t ht1, ht2; unsigned long dt; scds_netaddr_list_t *netaddr; char *hostname; if (scds_initialize(&scds_handle, argc, argv) != SCHA_ERR_NOERR) { scds_syslog(LOG_ERR, “Failed to initialize the handle.”); return (1); } /* Get the ip addresses available for this resource */ if (scds_get_netaddr_list(scds_handle, &netaddr)) { scds_syslog(LOG_ERR, “No network address resource in resource group.”); scds_close(&scds_handle); return (1); } /* Return an error if there are no network resources */ if (netaddr == NULL || netaddr->num_netaddrs == 0) { scds_syslog(LOG_ERR, “No network address resource in resource group.”); return (1); } /* * Set the timeout from the X props. This means that each probe * iteration will get a full timeout on each network resource * without chopping up the timeout between all of the network * resources configured for this resource. */ timeout = scds_get_ext_probe_timeout(scds_handle); for (;;) { /* * sleep for a duration of thorough_probe_interval between * successive probes. */ (void) scds_fm_sleep(scds_handle, scds_get_rs_thorough_probe_interval(scds_handle)); /* * Now probe all ipaddress we use. Loop over * 1. All net resources we use. * 2. All ipaddresses in a given resource. * For each of the ipaddress that is probed, * compute the failure history. */ probe_result = 0; /* * Iterate through the all resources to get each * IP address to use for calling svc_probe() */ for (ip = 0; ip < netaddr->num_netaddrs; ip++) { /* * Grab the hostname and port on which the * health has to be monitored. */ hostname = netaddr->netaddrs[ip].hostname; port = netaddr->netaddrs[ip].port_proto.port; /* * HA-XFS supports only one port and * hence obtain the port value from the * first entry in the array of ports. */ ht1 = gethrtime(); /* Latch probe start time */ scds_syslog(LOG_INFO, “Probing the service on “ “port: %d.”, port); probe_result = svc_probe(scds_handle, hostname, port, timeout); /* * Update service probe history, * take action if necessary. * Latch probe end time. */ ht2 = gethrtime(); /* Convert to milliseconds */ dt = (ulong_t)((ht2 - ht1) / 1e6); /* * Compute failure history and take * action if needed */ (void) scds_fm_action(scds_handle, probe_result, (long)dt); } /* Each net resource */ } /* Keep probing forever */ } |