00001 /*************************************************************************** 00002 BSD License 00003 00004 Copyright (c) 2002, Intel Corporation 00005 All rights reserved. 00006 00007 Redistribution and use in source and binary forms, with or without 00008 modification, are permitted provided that the following conditions are met: 00009 00010 a.. Redistributions of source code must retain the above copyright notice, 00011 this list of conditions and the following disclaimer. 00012 b.. Redistributions in binary form must reproduce the above copyright notice, 00013 this list of conditions and the following disclaimer in the documentation 00014 and/or other materials provided with the distribution. 00015 c.. Neither the name of Intel Corporation nor the names of its contributors 00016 may be used to endorse or promote products derived from this software 00017 without specific prior written permission. 00018 00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00022 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 00023 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00024 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00025 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00026 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00027 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00028 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 00030 ****************************************************************************/ 00031 00032 #ifndef __AHM_LIB_H__ 00033 #define __AHM_LIB_H__ 00034 00035 #define REGISTRATION_DIRECTORY "/var/appmonitord" 00036 00037 #include "appHeartbeatMonitor.h" 00038 00039 extern int ahm_fifo_fd; 00040 00041 extern int errno; 00042 00043 struct internal_reg_info 00044 { 00045 /** The process identifier for the registering application */ 00046 pid_t pid; 00047 00048 /** The identifer used for this thread, which is unique among this 00049 application's threads */ 00050 unsigned long id; 00051 00052 /** This is the process name as it should appear in /proc. It 00053 should not contain any path, simply the executable name */ 00054 char process_name[STRING_LENGTH]; 00055 00056 /** The absolute path to the recovery script to be launched if/when 00057 the application misses a heartbeat */ 00058 char recovery_script[STRING_LENGTH]; 00059 00060 /** This is the registration file name */ 00061 char registration_file[STRING_LENGTH]; 00062 00063 /** the maximum amount of time to lapse between heartbeats. 00064 This is how frequently the daemon will expect the 00065 heartbeats.*/ 00066 unsigned long max_interval; 00067 00068 /** the minimum amount of time to lapse between heartbeats. 00069 This is the value used by the application to send 00070 heartbeats. An min,max interval is used to minimize 00071 false heartbeat failures */ 00072 unsigned long min_interval; 00073 00074 /** The absolute path of the heartbeat fifo */ 00075 char hb_fifo[STRING_LENGTH]; 00076 00077 /** The file descriptor of the open heartbeat fifo */ 00078 int hb_fifo_fd; 00079 00080 /** This is used to indicate when registration has failed. 00081 This value should be at least equal to the heartbeat service's 00082 registration interval. An application will initialize and 00083 then register, yet the heartbeat service may take up to X seconds 00084 to process the registration (as defined as startup of the 00085 service). This allows the client to wait a reasonable 00086 amount of time before considering registration as a failure. 00087 NOTE: at this time, this value is set using REGISTRAION_TIMEOUT. 00088 It will be determined later if we need to have this be 00089 set dynamically. */ 00090 unsigned long registration_timeout; 00091 00092 }; 00093 00094 /** private functions */ 00095 00096 int ok_to_send_heartbeat(int a_fd) ; 00097 int create_heartbeat_fifo(struct internal_reg_info **a_reginfo); 00098 int create_registration_file(struct internal_reg_info **a_reginfo); 00099 00100 00101 #endif /* __AHM_LIB_H__ */ 00102