55 |
#include <unistd.h> |
#include <unistd.h> |
56 |
#endif |
#endif |
57 |
|
|
58 |
|
#ifdef HAVE_NETINET_IP_ICMP_H |
59 |
|
#include <netinet/ip_icmp.h> |
60 |
|
#endif |
61 |
|
|
62 |
#include "monitor.h" |
#include "monitor.h" |
63 |
#include "alert.h" |
#include "alert.h" |
64 |
#include "event.h" |
#include "event.h" |
65 |
#include "socket.h" |
#include "socket.h" |
66 |
|
#include "net.h" |
67 |
#include "monit_device.h" |
#include "monit_device.h" |
68 |
#include "monit_process.h" |
#include "monit_process.h" |
69 |
|
|
98 |
static int check_process_resources(Service_T, Resource_T, char *); |
static int check_process_resources(Service_T, Resource_T, char *); |
99 |
static int check_process_connection(Service_T, Port_T, char *); |
static int check_process_connection(Service_T, Port_T, char *); |
100 |
|
|
101 |
|
static int check_icmp_connection(Service_T, Icmp_T, char *); |
102 |
|
|
103 |
static int check_device(Service_T); |
static int check_device(Service_T); |
104 |
static int check_device_resources(Service_T, Device_T, char *); |
static int check_device_resources(Service_T, Device_T, char *); |
105 |
|
|
493 |
*/ |
*/ |
494 |
static int check_remote_host(Service_T s) { |
static int check_remote_host(Service_T s) { |
495 |
|
|
496 |
|
Icmp_T icmp; |
497 |
Port_T pp; |
Port_T pp; |
498 |
char report[STRLEN]={0}; |
char report[STRLEN]={0}; |
499 |
|
|
514 |
} |
} |
515 |
} |
} |
516 |
|
|
517 |
|
/* Test each icmp type in the service's icmplist */ |
518 |
|
for(icmp= s->icmplist; icmp; icmp= icmp->next) { |
519 |
|
if(!check_icmp_connection(s, icmp, report)) { |
520 |
|
icmp->is_available= FALSE; |
521 |
|
icmp->event_flag= TRUE; |
522 |
|
if(! eval_actions(icmp->action, s, report, "icmp", |
523 |
|
EVENT_CONNECTION)) { |
524 |
|
return FALSE; |
525 |
|
} |
526 |
|
} else { |
527 |
|
icmp->is_available= TRUE; |
528 |
|
} |
529 |
|
} |
530 |
|
|
531 |
return TRUE; |
return TRUE; |
532 |
|
|
533 |
} |
} |
653 |
} |
} |
654 |
|
|
655 |
|
|
656 |
|
/** |
657 |
|
* Returns TRUE if the ICMP test succeeded otherwise FALSE. |
658 |
|
*/ |
659 |
|
static int check_icmp_connection(Service_T s, Icmp_T i, char *report) { |
660 |
|
|
661 |
|
if(i->type == ICMP_ECHO && !icmp_echo(s->path, i->timeout)) { |
662 |
|
|
663 |
|
snprintf(report, STRLEN, "'%s' failed ICMP test [%s]", s->name, |
664 |
|
icmpnames[i->type]); |
665 |
|
|
666 |
|
return FALSE; |
667 |
|
|
668 |
|
} |
669 |
|
|
670 |
|
DEBUG("'%s' succeeded testing ICMP [%s]\n", s->name, icmpnames[i->type]); |
671 |
|
|
672 |
|
return TRUE; |
673 |
|
|
674 |
|
} |
675 |
|
|
676 |
|
|
677 |
/** |
/** |
678 |
* Returns TRUE if the process state (e.g. Zombie) test succeeded |
* Returns TRUE if the process state (e.g. Zombie) test succeeded |
679 |
* otherwise FALSE. |
* otherwise FALSE. |