예제 #1
0
/*
 * proc_probe
 *  probe the proc event and send to fms
 *
 * Input
 *  emp		event source module pointer
 *
 * Return val
 *  return the nvlist which contain the event.
 *  NULL if failed
 */
struct list_head *
proc_probe(evtsrc_module_t *emp)
{
	int			ret;
	char			*cfg_file;
	struct list_head	*fault;

	fault = nvlist_head_alloc();
	if ( fault == NULL ) {
		fprintf(stderr, "PROC: alloc list_head error\n");
		return NULL;
	}

	cfg_file = strdup(PROC_CONFIG_FILE);
	if ( config_init(cfg_file) ) {
		fprintf(stderr, "PROC: unable to initialize configure\n");
		return NULL;
	}
	
	ret = proc_check(fault);
	if ( ret )
		return NULL;
	else
		return fault;
}
예제 #2
0
/*
 * Periodic timeout.
 * Calling apache_service_check().
 */
struct list_head *
apache_probe(evtsrc_module_t *emp)
{
//      fmd_debug;
	struct list_head *head = nvlist_head_alloc();
	nvlist_t *nvl = nvlist_alloc();
	nvlist_add_nvlist(head, nvl);

	if(apache_service_check(nvl) != 0) {
		printf("Apache Module: failed to check apache service\n");
		return NULL;
	}

	return head;
}
예제 #3
0
파일: disk_evtsrc.c 프로젝트: kadoma/fms
struct list_head *
disk_probe(evtsrc_module_t * emp)
{
	struct list_head *head = nvlist_head_alloc();

	char fullpath[64] = {0};
    char buff[LINE_MAX] = {0};
    char fullclass[128] = {0};
    char cmd[128] = {0};
    
    sprintf(cmd, "df -h|awk '{print $1}'|grep '/dev'");
    FILE *fstream = popen(cmd,"r");
    if(fstream == NULL)
    {
        wr_log("stderr",WR_LOG_ERROR,"execute command failed: %s",strerror(errno));
		return NULL;
    }	
//avoid boot partition------start----
	char bootdev[64] = {0};
	char buff1[LINE_MAX] = {0};
	char cmd1[128] = {0};
	sprintf(cmd1, "df -h| grep '/boot'|awk '{print $1}'");
	FILE *fstream1 = popen(cmd1,"r");
	if(fstream1== NULL)
    {
        wr_log("stderr",WR_LOG_ERROR,"execute command failed: %s",strerror(errno));
		return NULL;
    }
	if(fgets(buff1, sizeof(buff1),fstream1) != NULL){
		memset(bootdev, 0, sizeof(bootdev));
		strncpy(bootdev, buff1, strlen(buff1)-1);
	}
//avoid boot partition------end----	
    while(fgets(buff, sizeof(buff),fstream) != NULL)
	{
	    memset(fullpath, 0, sizeof(fullpath));
		strncpy(fullpath, buff, strlen(buff)-1);

	    if(disk_space_check(fullpath) == 1 && strcmp(fullpath, bootdev) != 0)
	    {
		    memset(fullclass, 0, sizeof(fullclass));
		    sprintf(fullclass,"%s.disk.space-insufficient", FM_EREPORT_CLASS);
		    nvlist_t *nvl = nvlist_alloc();
            
		    if(nvl == NULL)
            {
		        wr_log("stderr",WR_LOG_ERROR, "DISK: out of memory\n");
				pclose(fstream);
			    return NULL;
		    }
            nvl->evt_id = 1;
		    disk_fm_event_post(head, nvl, fullclass, fullpath);
        }

        int len = strlen(fullpath);
        char n = fullpath[len - 1];
        int nn = atoi(&n);
        if(nn >= 1 && nn <= 9)
            fullpath[len -1] = '\0';
        
		if(disk_unhealthy_check(fullpath))
        {
			memset(fullclass, 0, sizeof(fullclass));
            sprintf(fullclass,"%s.disk.unhealthy", FM_EREPORT_CLASS);
            
            nvlist_t *nvl = nvlist_alloc();
			if(nvl == NULL) {
				wr_log("stderr",WR_LOG_ERROR,"DISK: out of memory\n");
				pclose(fstream);
				return NULL;
			}
            nvl->evt_id = 2;
			disk_fm_event_post(head, nvl, fullclass, fullpath);
		}
				
		if(disk_temperature_check(fullpath))
        {
		    memset(fullclass, 0, sizeof(fullclass));
			sprintf(fullclass,"%s.disk.over-temperature", FM_EREPORT_CLASS);
                
			nvlist_t *nvl = nvlist_alloc();
			if(nvl == NULL){
			    wr_log("stderr",WR_LOG_ERROR,"DISK: out of memory\n");
				pclose(fstream);
				return NULL;
			}
            // 3 temp fault
            nvl->evt_id = 3;
			disk_fm_event_post(head, nvl, fullclass, fullpath);
		}
    }
    pclose(fstream1);
	pclose(fstream);
	return head;
}