/[monit]/monit/spawn.c
ViewVC logotype

Diff of /monit/spawn.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.30 by hauk, Fri Aug 15 23:46:23 2003 UTC revision 1.31 by hauk, Tue Sep 2 02:05:49 2003 UTC
# Line 80  Line 80 
80  /* -------------------------------------------------------------- Prototypes */  /* -------------------------------------------------------------- Prototypes */
81    
82    
 static void set_monit_environment(Service_T s);  
83  static void exec_alert_mail(Service_T s, Command_T c);  static void exec_alert_mail(Service_T s, Command_T c);
84    static void set_monit_environment(Service_T s, const char *event);
85    
86    
87  /* ------------------------------------------------------------------ Public */  /* ------------------------------------------------------------------ Public */
# Line 93  static void exec_alert_mail(Service_T s, Line 93  static void exec_alert_mail(Service_T s,
93   * registred interest for restart alerts.   * registred interest for restart alerts.
94   * @param P A Service object   * @param P A Service object
95   * @param C A Command object   * @param C A Command object
96     * @param E An optional event string, specifying why this function was
97     * called. May be NULL.
98   */   */
99  void  spawn(Service_T S, Command_T C) {  void  spawn(Service_T S, Command_T C, const char *E) {
100        
101    pid_t pid;    pid_t pid;
102    sigset_t mask, save;    sigset_t mask, save;
# Line 159  void  spawn(Service_T S, Command_T C) { Line 161  void  spawn(Service_T S, Command_T C) {
161          }          }
162        }        }
163    
164        set_monit_environment(S);        set_monit_environment(S, E);
165                
166        if(! Run.isdaemon) {        if(! Run.isdaemon) {
167          redirect_stdfd();          redirect_stdfd();
# Line 238  static void exec_alert_mail(Service_T s, Line 240  static void exec_alert_mail(Service_T s,
240   * Setup the environment with special MONIT_xxx variables. The program   * Setup the environment with special MONIT_xxx variables. The program
241   * executed may use such variable for various purposes.   * executed may use such variable for various purposes.
242   */   */
243  static void set_monit_environment(Service_T s) {  static void set_monit_environment(Service_T s, const char *event) {
244      
245    int i, j;    int i, j;
246    char buf[10][STRLEN];    char buf[10][STRLEN];
247    char *date= get_RFC822date(NULL);    char *date= get_RFC822date(NULL);
248      
249    i= 0;    i= 0;
250        
251    snprintf(buf[i++], STRLEN, "MONIT_DATE=%s", date);    snprintf(buf[i++], STRLEN, "MONIT_DATE=%s", date);
252    snprintf(buf[i++], STRLEN, "MONIT_SERVICE=%s", s->name);    snprintf(buf[i++], STRLEN, "MONIT_SERVICE=%s", s->name);
253    snprintf(buf[i++], STRLEN, "MONIT_HOST=%s", Run.localhostname);    snprintf(buf[i++], STRLEN, "MONIT_HOST=%s", Run.localhostname);
254      snprintf(buf[i++], STRLEN, "MONIT_EVENT=%s", event?event:"No Event");
255        
256    if(s->type == TYPE_PROCESS) {    if(s->type == TYPE_PROCESS) {
257      snprintf(buf[i++], STRLEN, "MONIT_PROCESS_PID=%d", is_process_running(s));      snprintf(buf[i++], STRLEN, "MONIT_PROCESS_PID=%d", is_process_running(s));

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.31

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26