Beispiel #1
0
int
main(int argc, char **argv)
{
    int			err = 0;
    pmdaInterface	desc;

    __pmSetProgname(argv[0]);
    _isDSO = 0;

#if defined(BUG_5)
    /*
     * we don't grok PMDA_INTERFACE_77 ... 77 is arbitrary, just needs
     * to be bigger than currently valid and supported
     */
    pmdaDaemon(&desc, 77, pmProgname, BROKEN, _logFile,
	       _helpText);
#elif defined(VERSION_1)
    pmdaDaemon(&desc, PMDA_PROTOCOL_2, pmProgname, BROKEN, _logFile,
	       _helpText);
#else
    pmdaDaemon(&desc, PMDA_INTERFACE_2, pmProgname, BROKEN, _logFile,
	       _helpText);
#endif
    
    if (desc.status != 0) {
	fprintf(stderr, "pmdaDaemon() failed!\n");
	/*
	 * we're going to exit() now, but first, shut down file
	 * descriptors to reduce chances of a race with dbpmda's first
	 * PDU send, e.g. in qa/274
	 */
	fclose(stdin);
	fclose(stdout);
	exit(1);
    }

    if (pmdaGetOpt(argc, argv, "D:d:h:i:l:pu:6:", &desc, &err) != EOF)
    	err++;
   
    if (err)
    	usage();

    pmdaOpenLog(&desc);
    broken_init(&desc);
    pmdaConnect(&desc);
    pmdaMain(&desc);

    exit(0);
}
Beispiel #2
0
Datei: aix.c Projekt: Aconex/pcp
/*
 * Set up the agent if running as a daemon.
 */
int
main(int argc, char **argv)
{
    int			sep = __pmPathSeparator();
    pmdaInterface	desc;

    _isDSO = 0;
    __pmSetProgname(argv[0]);
    __pmGetUsername(&username);

    snprintf(mypath, sizeof(mypath), "%s%c" "aix" "%c" "help",
		pmGetConfig("PCP_PMDAS_DIR"), sep, sep);
    pmdaDaemon(&desc, PMDA_INTERFACE_3, pmProgname, AIX, "aix.log", mypath);

    pmdaGetOptions(argc, argv, &opts, &desc);
    if (opts.errors) {
	pmdaUsageMessage(&opts);
	exit(1);
    }
    if (opts.username)
	username = opts.username;

    pmdaOpenLog(&desc);
    aix_init(&desc);
    pmdaConnect(&desc);
    pmdaMain(&desc);
    exit(0);
}
Beispiel #3
0
/*
 * Set up the agent if running as a daemon.
 */
int
main(int argc, char **argv)
{
	int err = 0;
	char log_file[] = "pmda_ctdb.log";
	pmdaInterface dispatch;

	__pmSetProgname(argv[0]);

	pmdaDaemon(&dispatch, PMDA_INTERFACE_2, pmProgname, CTDB,
		   log_file, helpfile());

	if (pmdaGetOpt(argc, argv, "d:i:l:pu:?", &dispatch, &err) != EOF) {
		err++;
	}

	if (err) {
		usage();
	}

	pmdaOpenLog(&dispatch);
	pmda_ctdb_init(&dispatch);
	pmdaConnect(&dispatch);
	pmdaMain(&dispatch);

	exit(0);
}
Beispiel #4
0
Datei: pmda.c Projekt: Aconex/pcp
int
main(int argc, char **argv)
{
    int			c, sep = __pmPathSeparator();
    int			errflag = 0;
    char		helppath[MAXPATHLEN];

    _isDSO = 0;
    __pmSetProgname(argv[0]);
    __pmGetUsername(&username);

    sprintf(helppath, "%s%c" "darwin" "%c" "help",
		pmGetConfig("PCP_PMDAS_DIR"), sep, sep);
    pmdaDaemon(&dispatch, PMDA_INTERFACE_3, pmProgname, DARWIN, "darwin.log",
		helppath);

    while ((c = pmdaGetOpt(argc, argv, "D:d:i:l:pu:U:6:?", &dispatch, &errflag)) != EOF) {
	switch(c) {
	case 'U':
	    username = optarg;
	    break;
	default:
	    errflag++;
	}
    }
    if (errflag)
	usage();

    pmdaOpenLog(&dispatch);
    darwin_init(&dispatch);
    pmdaConnect(&dispatch);
    pmdaMain(&dispatch);
    exit(0);
}
Beispiel #5
0
/*
 * Set up the agent if running as a daemon.
 */
int
main(int argc, char **argv)
{
    int			c, err = 0;
    int			sep = __pmPathSeparator();
    pmdaInterface	dispatch;
    char		mypath[MAXPATHLEN];

    isDSO = 0;
    __pmSetProgname(argv[0]);
    __pmGetUsername(&username);

    snprintf(mypath, sizeof(mypath), "%s%c" "openbsd" "%c" "help",
		pmGetConfig("PCP_PMDAS_DIR"), sep, sep);
    pmdaDaemon(&dispatch, PMDA_INTERFACE_5, pmProgname, OPENBSD,
		"openbsd.log", mypath);

    while ((c = pmdaGetOpt(argc, argv, "D:d:i:l:pu:U:6:?", &dispatch, &err)) != EOF) {
	switch(c) {
	case 'U':
	    username = optarg;
	    break;
	default:
	    err++;
	}
    }
    if (err)
	usage();

    pmdaOpenLog(&dispatch);
    openbsd_init(&dispatch);
    pmdaConnect(&dispatch);
    pmdaMain(&dispatch);
    exit(0);
}
Beispiel #6
0
/*
 * Set up agent if running as daemon.
 */
int
main(int argc, char **argv)
{
    int sep = __pmPathSeparator();
    pmdaInterface dispatch;

    isDSO = 0;
    __pmSetProgname(argv[0]);

    snprintf(helppath, sizeof(helppath), "%s%c" "papi" "%c" "help",
	     pmGetConfig("PCP_PMDAS_DIR"), sep, sep);
    pmdaDaemon(&dispatch, PMDA_INTERFACE_6, pmProgname, PAPI, "papi.log", helppath);	
    pmdaGetOptions(argc, argv, &opts, &dispatch);
    if (opts.errors) {
	pmdaUsageMessage(&opts);
	exit(1);
    }
 
    pmdaOpenLog(&dispatch);
    papi_init(&dispatch);
    pmdaConnect(&dispatch);
    pmdaMain(&dispatch);

    free(ctxtab);
    free(papi_info);
    free(values);

    exit(0);
}
Beispiel #7
0
int
main(int argc, char **argv)
{
    int			err = 0;
    pmdaInterface	desc;

    __pmSetProgname(argv[0]);
    _isDSO = 0;

#if defined(BUG_5)
    /*
     * we don't grok PMDA_INTERFACE_77 ... 77 is arbitrary, just needs
     * to be bigger than currently valid and supported
     */
    pmdaDaemon(&desc, 77, pmProgname, BROKEN, _logFile,
	       _helpText);
#elif defined(VERSION_1)
    pmdaDaemon(&desc, PMDA_PROTOCOL_2, pmProgname, BROKEN, _logFile,
	       _helpText);
#else
    pmdaDaemon(&desc, PMDA_INTERFACE_2, pmProgname, BROKEN, _logFile,
	       _helpText);
#endif
    
    if (desc.status != 0) {
	fprintf(stderr, "pmdaDaemon() failed!\n");
	exit(1);
    }

    if (pmdaGetOpt(argc, argv, "D:d:h:i:l:pu:6:", &desc, &err) != EOF)
    	err++;
   
    if (err)
    	usage();

    pmdaOpenLog(&desc);
    broken_init(&desc);
    pmdaConnect(&desc);
    pmdaMain(&desc);

    exit(0);
}
Beispiel #8
0
int
main(int argc, char **argv)
{
    static char		helppath[MAXPATHLEN];
    char		*endnum;
    pmdaInterface	desc;
    long		minmem;
    int			c, err = 0, sep = __pmPathSeparator();

    __pmSetProgname(argv[0]);
    __pmGetUsername(&username);

    minmem = getpagesize();
    maxmem = (minmem > DEFAULT_MAXMEM) ? minmem : DEFAULT_MAXMEM;
    snprintf(helppath, sizeof(helppath), "%s%c" "logger" "%c" "help",
		pmGetConfig("PCP_PMDAS_DIR"), sep, sep);
    pmdaDaemon(&desc, PMDA_INTERFACE_5, pmProgname, LOGGER,
		"logger.log", helppath);

    while ((c = pmdaGetOpt(argc, argv, "D:d:l:m:s:U:?", &desc, &err)) != EOF) {
	switch (c) {
	    case 'm':
		maxmem = strtol(optarg, &endnum, 10);
		if (*endnum != '\0')
		    convertUnits(&endnum, &maxmem);
		if (*endnum != '\0' || maxmem < minmem) {
		    fprintf(stderr, "%s: invalid max memory '%s' (min=%ld)\n",
			    pmProgname, optarg, minmem);
		    err++;
		}
		break;

	    case 's':
		if (pmParseInterval(optarg, &interval, &endnum) < 0) {
		    fprintf(stderr, "%s: -s requires a time interval: %s\n",
			    pmProgname, endnum);
		    free(endnum);
		    err++;
		}
		break;

	    case 'U':
		username = optarg;
		break;

	    default:
		err++;
		break;
	}
    }

    if (err || optind != argc -1)
    	usage();

    pmdaOpenLog(&desc);
    logger_init(&desc, argv[optind]);
    pmdaConnect(&desc);
    loggerMain(&desc);
    event_shutdown();
    exit(0);
}
Beispiel #9
0
int
main(int argc, char **argv)
{
    static char         helppath[MAXPATHLEN];
    char                *endnum;
    pmdaInterface       desc;
    long                minmem;
    int                 c, err = 0, sep = __pmPathSeparator();

    minmem = getpagesize();
    maxmem = (minmem > DEFAULT_MAXMEM) ? minmem : DEFAULT_MAXMEM;
    __pmSetProgname(argv[0]);
    snprintf(helppath, sizeof(helppath), "%s%c" "systemd" "%c" "help",
                pmGetConfig("PCP_PMDAS_DIR"), sep, sep);
    pmdaDaemon(&desc, PMDA_INTERFACE_6, pmProgname, SYSTEMD,
                "systemd.log", helppath);

    while ((c = pmdaGetOpt(argc, argv, "D:d:l:m:s:U:f?", &desc, &err)) != EOF) {
        switch (c) {
            case 'm':
                maxmem = strtol(optarg, &endnum, 10);
                if (*endnum != '\0')
                    convertUnits(&endnum, &maxmem);
                if (*endnum != '\0' || maxmem < minmem) {
                    fprintf(stderr, "%s: invalid max memory '%s' (min=%ld)\n",
                            pmProgname, optarg, minmem);
                    err++;
                }
                break;

            case 's':
                if (pmParseInterval(optarg, &interval, &endnum) < 0) {
                    fprintf(stderr, "%s: -s requires a time interval: %s\n",
                            pmProgname, endnum);
                    free(endnum);
                    err++;
                }
                break;

            case 'U':
                username = optarg;
                break;

            case 'f':
                uid_gid_filter_p = 0;
                break;

            default:
                err++;
                break;
        }
    }

    if (err)
        usage();

    FD_ZERO (&fds);
    pmdaOpenLog(&desc);

    /* The systemwide journal may be accessed by the adm user (group);
       root access is not necessary. */
    __pmSetProcessIdentity(username);
    desc.comm.flags |= PDU_FLAG_AUTH;
    pmdaConnect(&desc);
    // After this point, systemd_init is allowed to take some extra time.
    systemd_init(&desc); // sets some fds
    systemdMain(&desc); // sets some more fds
    systemd_shutdown();
    exit(0);
}
Beispiel #10
0
Datei: pmda.c Projekt: Aconex/pcp
int
main(int argc, char **argv)
{
    int			err = 0;
    int			sep = __pmPathSeparator();
    char		*endnum;
    pmdaInterface	dispatch;
    int			n;
    int			i;
    int			c;
    char		helptext[MAXPATHLEN];

    __pmSetProgname(argv[0]);
    __pmGetUsername(&pmdausername);

    snprintf(helptext, sizeof(helptext), "%s%c" "cisco" "%c" "help",
		pmGetConfig("PCP_PMDAS_DIR"), sep, sep);
    pmdaDaemon(&dispatch, PMDA_INTERFACE_3, pmProgname, CISCO,
		"cisco.log", helptext);

    while ((c = pmdaGetOpt(argc, argv, "D:d:h:i:l:pu:6:" "CM:Nn:P:r:s:U:x:?", 
			   &dispatch, &err)) != EOF) {
	switch (c) {

	    case 'C':		/* parser checking mode (debugging) */
		pmDebug = DBG_TRACE_APPL0;
		parse_only++;
		break;

	    case 'N':		/* do not perform name lookups (debugging) */
		no_lookups = 1;
		break;

	    case 'n':		/* set program name, for parse (debugging) */
		pmProgname = optarg;
		break;

	    case 'P':		/* passwd */
		passwd = optarg;
		break;

	    case 'r':
		refreshdelay = (int)strtol(optarg, &endnum, 10);
		if (*endnum != '\0') {
		    fprintf(stderr, "%s: -r requires numeric (number of seconds) argument\n",
			    pmProgname);
		    err++;
		}
		break;

	    case 's':		/* command prompt */
		prompt = optarg;
		break;

	    case 'M':		/* username (for the PMDA) */
		pmdausername = optarg;
		break;

	    case 'U':		/* username (for the Cisco) */
		username = optarg;
		break;

	    case 'x':
		port = (int)strtol(optarg, &endnum, 10);
		if (*endnum != '\0') {
		    fprintf(stderr, "%s: -x requires numeric argument\n",
			    pmProgname);
		    err++;
		}
		break;

	    case '?':
		err++;
	}
    }

    n_intf = argc - optind;
    if (n_intf == 0 || err) {
	fprintf(stderr, 
	    "Usage: %s [options] host:{a|B|E|e|f|h|s}N[/M[.I]] [...]\n\n", 
	    pmProgname);
	fputs("Options:\n"
	      "  -d domain    use domain (numeric) for metrics domain of PMDA\n"
	      "  -i port      expect PMCD to connect on given inet port (number or name)\n"
	      "  -l logfile   redirect diagnostics and trace output to logfile\n"
	      "  -M username  user account to run PMDA under (default \"pcp\")\n"
	      "  -p           expect PMCD to supply stdin/stdout (pipe)\n"
	      "  -P password  default user-level Cisco password\n"
	      "  -r refresh   update metrics every refresh seconds\n"
	      "  -s prompt    Cisco command prompt [default >]\n"
	      "  -u socket    expect PMCD to connect on given unix domain socket\n"
	      "  -U username  Cisco username\n"
	      "  -x port      telnet port [default 23]\n"
	      "  -6 port      expect PMCD to connect on given ipv6 port (number or name)\n",
	      stderr);		
	exit(1);
    }

    /* force errors from here on into the log */
    if (!parse_only) {
	pmdaOpenLog(&dispatch);
	__pmSetProcessIdentity(pmdausername);
    } else {
	dispatch.version.two.text = NULL;
	dispatch.version.two.ext->e_helptext = NULL;
    }

    /*
     * build the instance domain and cisco data structures from the
     * command line arguments.
     */
    if ((_router = (pmdaInstid *)malloc(n_intf * sizeof(pmdaInstid))) == NULL) {
        __pmNoMem("main.router", n_intf * sizeof(pmdaInstid), PM_FATAL_ERR);
    }
    if ((intf = (intf_t *)malloc(n_intf * sizeof(intf_t))) == NULL) {
        __pmNoMem("main.intf", n_intf * sizeof(intf_t), PM_FATAL_ERR);
    }
    /* pre-allocated cisco[] to avoid realloc and ptr movement */
    if ((cisco = (cisco_t *)malloc(n_intf * sizeof(cisco_t))) == NULL) {
	__pmNoMem("main.cisco", n_intf * sizeof(cisco_t), PM_FATAL_ERR);
    }

    indomtab[CISCO_INDOM].it_numinst = n_intf;
    indomtab[CISCO_INDOM].it_set = _router;

    for (n = 0 ; optind < argc; optind++, n++) {
        char    *p = strdup(argv[optind]);
	char	*q;
	char	*myusername;
	char	*mypasswd;
	char	*myprompt;

	myprompt = strchr(p, '!');
	if (myprompt) {
	    /* save prompt for later */
	    *myprompt++ = '\0';
	}
	else
	    myprompt = NULL;
	mypasswd = strchr(p, '?');
	if (mypasswd) {
	    /* save user-level password for later */
	    *mypasswd++ = '\0';
	}
	else
	    mypasswd = passwd;
	myusername = strchr(p, '@');
	if (myusername) {
	    /* save username for later */
	    *myusername++ = '\0';
	}
	else
	    myusername = username;

        _router[n].i_inst = n;
        _router[n].i_name = strdup(p);

	if ((q = strchr(p, ':')) == NULL)
	    goto badintfspec;
	*q++ = '\0';
	for (i = 0; i < num_intf_tab; i++) {
	    if (strncmp(q, intf_tab[i].type, strlen(intf_tab[i].type)) == 0)
		break;
	}
	if (i == num_intf_tab)
            goto badintfspec;
	if (strcmp(intf_tab[i].type, "E") == 0) {
	    /*
	     * Cisco parser is case insensitive, so 'E' means "Ethernet"
	     * and 'F' means "Fddi", need to use "FastEthernet" here
	     */
	    q++;
	    intf[n].interface = (char *)malloc(strlen("FastEthernet")+strlen(q)+1);
	    if ((intf[n].interface = (char *)malloc(strlen("FastEthernet")+strlen(q)+1)) == NULL) {
		__pmNoMem("main.cisco", strlen("FastEthernet")+strlen(q)+1, PM_FATAL_ERR);
	    }
	    strcpy(intf[n].interface, "FastEthernet");
	    strcat(intf[n].interface, q);
	}
	else
	    intf[n].interface = q;

	for (i = 0; i < n_cisco; i++) {
	    if (strcmp(p, cisco[i].host) == 0)
		break;
	}
	if (i == n_cisco) {
	    __pmHostEnt	*hostInfo = NULL;

	    if (!no_lookups)
		hostInfo = __pmGetAddrInfo(p);

	    if (!hostInfo && parse_only) {
		FILE	*f;

		/*
		 * for debugging, "host" may be a file ...
		 */
		if ((f = fopen(p, "r")) == NULL) {
		    fprintf(stderr, "%s: unknown hostname or filename %s: %s\n",
			pmProgname, argv[optind], hoststrerror());
		    /* abandon this host (cisco) */
		    continue;
		}
		else {
		    fprintf(stderr, "%s: assuming file %s contains output from \"show int\" command\n",
			pmProgname, p);

		    cisco[i].host = p;
		    cisco[i].username = myusername != NULL ? myusername : username;
		    cisco[i].passwd = mypasswd != NULL ? mypasswd : passwd;
		    cisco[i].prompt = myprompt != NULL ? myprompt : prompt;
		    cisco[i].fin = f;
		    cisco[i].fout = stdout;
		    n_cisco++;
		}
	    } else if (!hostInfo) {
		fprintf(stderr, "%s: unknown hostname %s: %s\n",
			pmProgname, p, hoststrerror());
		/* abandon this host (cisco) */
		continue;
	    } else {
		cisco[i].host = p;
		cisco[i].username = myusername != NULL ? myusername : username;
		cisco[i].passwd = mypasswd != NULL ? mypasswd : passwd;
		cisco[i].prompt = myprompt != NULL ? myprompt : prompt;
		cisco[i].fin = NULL;
		cisco[i].fout = NULL;
		cisco[i].hostinfo = hostInfo;
		cisco[i].port = port;

		n_cisco++;
		fprintf(stderr, "Adding new host %s\n", p);
		fflush(stderr);
	    }
	}
	else {
	    if (cisco[i].username == NULL) {
		if (myusername != NULL)
		    /* username on 2nd or later interface ... applies to all */
		    cisco[i].username = myusername;
	    }
	    else {
		if (myusername != NULL) {
		    if (strcmp(cisco[i].username, myusername) != 0) {
			fprintf(stderr, 
				"%s: conflicting usernames (\"%s\" "
				"and \"%s\") for cisco \"%s\"\n",
				pmProgname, cisco[i].username, myusername, 
				cisco[i].host);
			exit(1);
		    }
		}
	    }
	    if (cisco[i].passwd == NULL) {
		if (mypasswd != NULL)
		    /* passwd on 2nd or later interface ... applies to all */
		    cisco[i].passwd = mypasswd;
	    }
	    else {
		if (mypasswd != NULL) {
		    if (strcmp(cisco[i].passwd, mypasswd) != 0) {
			fprintf(stderr, 
				"%s: conflicting user-level passwords (\"%s\" "
				"and \"%s\") for cisco \"%s\"\n",
				pmProgname, cisco[i].passwd, mypasswd, 
				cisco[i].host);
			exit(1);
		    }
		}
	    }
	    if (cisco[i].prompt == NULL) {
		if (myprompt != NULL)
		    /* prompt on 2nd or later interface ... applies to all */
		    cisco[i].prompt = myprompt;
	    }
	    else {
		if (myprompt != NULL) {
		    if (strcmp(cisco[i].prompt, myprompt) != 0) {
			fprintf(stderr, 
				"%s: conflicting user-level prompts (\"%s\" "
				"and \"%s\") for cisco \"%s\"\n",
				pmProgname, cisco[i].prompt, myprompt, 
				cisco[i].host);
			exit(1);
		    }
		}
	    }
	}

	intf[n].cp = cisco+i;
	/*
	 * special one-trip initialization for Frame-Relay over serial
	 * lines ... see grab_cisco()
	 */
	intf[n].bandwidth = -2;

	fprintf(stderr, "Interface %s(%d) is on host %s\n",
		 intf[n].interface, n, cisco[i].host);
	fflush(stderr);

        continue;

badintfspec:
        fprintf(stderr, "%s: bad interface specification \"%s\"\n", pmProgname, argv[optind]);
        fprintf(stderr, "      should be like sydcisco.sydney:s1 or b9u-cisco1-81.engr.sgi.com:f2/0\n");
        fprintf(stderr, "      or cisco.melbourne:e0?secret\n");
        exit(1);
    }

    if (n_cisco == 0) {
	fprintf(stderr, "%s: Nothing to monitor\n", pmProgname);
	exit(1);
    }

    if (parse_only) {
	fprintf(stderr, "Sleeping while sproc does the work ... SIGINT to terminate\n");
        cisco_init(&dispatch);
	for (i = 0; i < n_intf; i++)
	    intf[i].fetched = 0;
	pause();
    } else {
	/* set up connection to PMCD */
	cisco_init(&dispatch);
	pmdaConnect(&dispatch);
	pmdaMain(&dispatch);
    }

    cisco_done();
    exit(0);
}
Beispiel #11
0
/*
 * Set up the agent, running as a daemon.
 */
int
main(int argc, char **argv)
{
    int			sep = __pmPathSeparator();
    int			c;
    int			i;
    char		namebuf[30];
    char		mypath[MAXPATHLEN];

    __pmSetProgname(argv[0]);
    __pmGetUsername(&username);

    if (getcwd(startdir, sizeof(startdir)) == NULL) {
	fprintf(stderr, "%s: getcwd() failed: %s\n",
	    pmProgname, pmErrStr(-oserror()));
	exit(1);
    }

    snprintf(mypath, sizeof(mypath), "%s%c" "mailq" "%c" "help",
		pmGetConfig("PCP_PMDAS_DIR"), sep, sep);
    pmdaDaemon(&dispatch, PMDA_INTERFACE_2, pmProgname, MAILQ,
		"mailq.log", mypath);

    while ((c = pmdaGetOptions(argc, argv, &opts, &dispatch)) != EOF) {
	switch (c) {
	case 'b':
	    if (mailq_histogram(opts.optarg) < 0)
		opts.errors++;
	    break;

	case 'r':
	    regexstring = opts.optarg;
	    c = regcomp(&mq_regex, regexstring, REG_EXTENDED | REG_NOSUB);
	    if (c != 0) {
		regerror(c, &mq_regex, mypath, sizeof(mypath));
		pmprintf("%s: cannot compile regular expression: %s\n",
			pmProgname, mypath);
		opts.errors++;
	    }
	    break;
	}
    }

    if (opts.optind == argc - 1)
	queuedir = argv[opts.optind];
    else if (opts.optind != argc)
	opts.errors++;

    if (opts.errors) {
	pmdaUsageMessage(&opts);
	exit(1);
    }

    if (opts.username)
	username = opts.username;

    if (histo == NULL) {
	/* default histo bins, if not already done above ... */
	numhisto = 7;
	histo = (histo_t *)malloc(numhisto * sizeof(histo[0]));
	if (histo == NULL) {
	     __pmNoMem("histo", numhisto * sizeof(histo[0]), PM_FATAL_ERR);
	}
	histo[0].delay = 7 * 24 * 3600;
	histo[1].delay = 3 * 24 * 3600;
	histo[2].delay = 24 * 3600;
	histo[3].delay = 8 * 3600;
	histo[4].delay = 4 * 3600;
	histo[5].delay = 1 * 3600;
	histo[6].delay = 0;
    }
    else {
	/* need to add last one and sort on descending time */
	numhisto++;
	histo = (histo_t *)realloc(histo, numhisto * sizeof(histo[0]));
	if (histo == NULL) {
	     __pmNoMem("histo", numhisto * sizeof(histo[0]), PM_FATAL_ERR);
	}
	histo[numhisto-1].delay = 0;
	qsort(histo, numhisto, sizeof(histo[0]), compare_delay);
    }

    _delay = (pmdaInstid *)malloc(numhisto * sizeof(_delay[0]));
    if (_delay == NULL)
	__pmNoMem("_delay", numhisto * sizeof(_delay[0]), PM_FATAL_ERR);

    for (i = 0; i < numhisto; i++) {
	time_t	tmp;
	_delay[i].i_inst = histo[i].delay;
	histo[i].count = 0;
	if (histo[i].delay == 0)
	    sprintf(namebuf, "recent");
	else if (histo[i].delay < 60)
	    sprintf(namebuf, "%d-secs", (int)histo[i].delay);
	else if (histo[i].delay < 60 * 60) {
	    tmp = histo[i].delay / 60;
	    if (tmp <= 1)
		sprintf(namebuf, "1-min");
	    else
		sprintf(namebuf, "%d-mins", (int)tmp);
	}
	else if (histo[i].delay < 24 * 60 * 60) {
	    tmp = histo[i].delay / (60 * 60);
	    if (tmp <= 1)
		sprintf(namebuf, "1-hour");
	    else
		sprintf(namebuf, "%d-hours", (int)tmp);
	}
	else {
	    tmp = histo[i].delay / (24 * 60 * 60);
	    if (tmp <= 1)
		sprintf(namebuf, "1-day");
	    else
		sprintf(namebuf, "%d-days", (int)tmp);
	}
	_delay[i].i_name = strdup(namebuf);
	if (_delay[i].i_name == NULL) {
	     __pmNoMem("_delay[i].i_name", strlen(namebuf), PM_FATAL_ERR);
	}
    }

    indomtab[DELAY_INDOM].it_numinst = numhisto;
    indomtab[DELAY_INDOM].it_set = _delay;

    pmdaOpenLog(&dispatch);
    mailq_init(&dispatch);
    pmdaConnect(&dispatch);
    pmdaMain(&dispatch);

    exit(0);
}