コード例 #1
0
ファイル: notifyme.c プロジェクト: Unidata/LDM
static void
usage(
        char *av0  /*  id string */
)
{
        (void)fprintf(stderr,
"Usage: %s [options] \t\nOptions:\n", av0);
        (void)fprintf(stderr,
"\t-v             Verbose, report each notification\n");
        (void)fprintf(stderr,
"\t-x             Debug mode\n");
        (void)fprintf(stderr,
"\t-l dest        Log to `dest`. One of: \"\" (system logging daemon), \"-\"\n"
"\t               (standard error), or file `dest`. Default is \"%s\"\n",
                log_get_default_destination());
        (void)fprintf(stderr,
"\t-h remote      Have \"remote\" send us data (default \"%s\")\n",
                DEFAULT_REMOTE);
        (void)fprintf(stderr,
"\t-f feedtype    Interested in products from feed \"feedtype\" (default %s)\n",
        s_feedtypet(DEFAULT_FEEDTYPE));
        (void)fprintf(stderr,
"\t-p pattern     Interested in products matching \"pattern\" (default \"%s\")\n",
                DEFAULT_PATTERN);
        (void)fprintf(stderr,
"\t-o offset      Set the \"from\" time offset secs before now\n");
        (void)fprintf(stderr,
"\t-t timeout     Set RPC timeout to \"timeout\" seconds (default %d)\n",
                DEFAULT_TIMEO);
        (void)fprintf(stderr,
"\t-T TotalTimeo  Give up after this many secs (default %d)\n",
                DEFAULT_TOTALTIMEO);
        exit(1);
}
コード例 #2
0
ファイル: mldm_sender_manager.c プロジェクト: dgaer/LDM
/**
 * Indicates if a particular multicast LDM sender is running.
 *
 * @pre                     Multicast LDM sender PID map is locked for writing.
 * @param[in]  feedtype     Feed-type of multicast group.
 * @param[out] pid          Process ID of the multicast LDM sender.
 * @param[out] port         Port number of the VCMTP TCP server.
 * @retval     0            The multicast LDM sender associated with the given
 *                          multicast group is running. `*pid` and `*port` are
 *                          set.
 * @retval     LDM7_NOENT   No such process.
 * @retval     LDM7_SYSTEM  System error. `log_start()` called.
 */
static Ldm7Status
mlsm_isRunning(
    const feedtypet       feedtype,
    pid_t* const          pid,
    unsigned short* const port)
{
    pid_t          msmPid;
    unsigned short msmPort;
    int   status = msm_get(feedtype, &msmPid, &msmPort);

    if (status == 0) {
        if (kill(msmPid, 0) == 0) {
            /* Can signal the process */
            *pid = msmPid;
            *port = msmPort;
        }
        else {
            /* Can't signal the process */
            uwarn("According to my information, the PID of the multicast LDM "
                  "sender associated with feed-type %s is %d -- but that "
                  "process can't be signaled by this process. I'll assume "
                  "the relevant multicast LDM sender is not running.",
                  s_feedtypet(feedtype), msmPid);
            (void)msm_remove(msmPid);   // don't care if it exists or not
            status = LDM7_NOENT;
        }
    }

    return status;
}
コード例 #3
0
static void
usage(const char *av0) /*  id string */
{
        (void)fprintf(stderr,
"Usage: %s [options]\nOptions:\n", av0);
        (void)fprintf(stderr,
"\t-v           Verbose, report each notification\n");
        (void)fprintf(stderr,
"\t-x           Debug mode\n");
        (void)fprintf(stderr,
"\t-w           Wait on region locks\n");
        (void)fprintf(stderr,
"\t-l dest      Log to `dest`. One of: \"\" (system logging daemon), \"-\"\n"
"\t             (standard error), or file `dest`. Default is \"%s\"\n",
                log_get_default_destination());
        (void)fprintf(stderr,
"\t-q queue     default \"%s\"\n", getDefaultQueuePath());
        (void)fprintf(stderr,
"\t-a age       Protect products younger than \"age\" hours (default %.4f)\n",
                DEFAULT_AGE);
        (void)fprintf(stderr,
"\t-i interval  loop, restart each \"interval\" seconds (default %d)\n",
                DEFAULT_INTERVAL);
        (void)fprintf(stderr,
"\t             interval of 0 means exit after one pass\n");
        (void)fprintf(stderr,
"\t-f feedtype  Delete products from feed \"feedtype\" (default %s)\n",
                s_feedtypet(DEFAULT_FEEDTYPE));
        (void)fprintf(stderr,
"\t-p pattern   Delete products matching \"pattern\" (default \"%s\")\n",
                DEFAULT_PATTERN);
        exit(1);
}
コード例 #4
0
/**
 * Returns the path of the memory-file corresponding to a server and a multicast
 * group.
 *
 * @param[in] servAddr  The address of the server associated with the multicast
 *                      group.
 * @param[in] feedtype  Feedtype of multicast group.
 * @retval    NULL      Failure. `log_start()` called.
 * @return              The path of the corresponding memory-file. The caller
 *                      should free when it's no longer needed.
 */
static char*
getSessionPath(
    const ServiceAddr* const servAddr,
    const feedtypet          feedtype)
{
    char*       path;
    char* const servAddrStr = sa_format(servAddr);

    if (servAddrStr) {
        path = ldm_format(256, "%s/%s_%s.yaml", getLdmLogDir(), servAddrStr,
                s_feedtypet(feedtype));
        free(servAddrStr);
    }

    return path;
}
コード例 #5
0
ファイル: UpFilter.c プロジェクト: Unidata/LDM
/*
 * Returns a string representation of an UpFilter.
 *
 * Arguments:
 *      upFilter        The UpFilter whose string representation is to be
 *                      returned.
 * Returns:
 *      NULL            Failure to create a string representation of "upFilter".
 *      else            A pointer to a string representation of "upFilter".
 */
const char*
upFilter_toString(
    UpFilter* const     upFilter)
{
    const char* string = NULL;          /* failure */

    if (NULL != upFilter) {
        if (upFilter->stringOutOfDate) {
            StringBuf* const        strBuf = upFilter->strBuf;
            const Element*          elt;

            if (0 == strBuf_setToString(strBuf, "{")) {
                for (elt = upFilter->head; elt != NULL; elt = elt->next) {
                    if (elt != upFilter->head)
                        (void)strBuf_appendString(strBuf, ", ");

                    (void)strBuf_appendString(strBuf, "{");
                    (void)strBuf_appendString(strBuf, s_feedtypet(elt->ft));
                    (void)strBuf_appendString(strBuf, ", (");
                    (void)strBuf_appendString(strBuf,
                        pat_getEre(elt->okPattern));
                    (void)strBuf_appendString(strBuf, ")");

                    if (NULL != elt->notPattern) {
                        (void)strBuf_appendString(strBuf, " - (");
                        (void)strBuf_appendString(strBuf,
                            pat_getEre(elt->notPattern));
                        (void)strBuf_appendString(strBuf, ")");
                    }

                    (void)strBuf_appendString(strBuf, "}");
                }

                (void)strBuf_appendString(strBuf, "}");

                upFilter->stringOutOfDate = 0;
            }                           /* string-buffer correctly started */
        }                               /* string representation out-of-date */

        string = strBuf_toString(upFilter->strBuf);
    }                                   /* NULL != upFilter */

    return string;
}
コード例 #6
0
static void
usage(
    char *av0 /*  id string */)
{
    (void)fprintf(stderr,
"Usage: %s [options] filename ...\n\tOptions:\n", av0);
    (void)fprintf(stderr,
"\t-v           Verbose, tell me about each product\n");
    (void)fprintf(stderr,
"\t-l dest      Log to `dest`. One of: \"\" (system logging daemon), \"-\"\n"
"\t             (standard error), or file `dest`. Default is \"%s\"\n",
                log_get_default_destination());
    (void)fprintf(stderr,
"\t-h remote    remote service host, defaults to \"localhost\"\n");
    (void)fprintf(stderr,
"\t-s seqno     set initial product sequence number to \"seqno\", defaults to 0\n");
    (void)fprintf(stderr,
"\t-f feedtype  assert your feed type as \"feedtype\", defaults to \"%s\"\n", s_feedtypet(DEFAULT_FEEDTYPE));
    exit(1);
}
コード例 #7
0
static void
usage(
        const char* const av0)
{
        log_error("Usage: %s [options] [config_file]\t\nOptions:\n", av0);
        log_error("Options:");
        log_error(
"\t-v           Log INFO-level messages, log each match (SIGUSR2 cycles)");
        log_error(
"\t-x           Log DEBUG-level messages (SIGUSR2 cycles)");
        log_error(
"\t-l dest      Log to `dest`. One of: \"\" (system logging daemon), \"-\"\n"
"\t             (standard error), or file `dest`. Default is \"%s\"\n",
                log_get_default_destination());
        log_error(
"\t-d datadir   cd(1) to \"datadir\" before interpreting pathnames in\n"
"\t             configuration-file (default: \"%s\")", getPqactDataDirPath());
        log_error(
"\t-q queue     Use product-queue \"queue\" (default: \"%s\")",
                getDefaultQueuePath());
        log_error(
"\t-p pattern   Only process products matching \"pattern\" (default: \"%s\")",
                DEFAULT_PATTERN);
        log_error(
"\t-f feedtype  Only process products from feed \"feedtype\" (default: %s)",
                s_feedtypet(DEFAULT_FEEDTYPE));
        log_error(
"\t-i interval  Loop, polling every \"interval\" seconds (default: %d)",
                DEFAULT_INTERVAL);
        log_error(
"\t-t timeo     Set write timeout for PIPE subprocs to \"timeo\" secs (default: %d)",
                DEFAULT_PIPE_TIMEO);
        log_error(
"\t-o offset    Start with products arriving \"offset\" seconds before now (default: 0)");
        log_error(
"\tconfig_file  Pathname of configuration-file (default: " "\"%s\")",
                getPqactConfigPath());
        exit(EXIT_FAILURE);
        /*NOTREACHED*/
}
コード例 #8
0
ファイル: notifyme.c プロジェクト: KeithLatteri/awips2
static void
usage(
        char *av0  /*  id string */
)
{
        (void)fprintf(stderr,
                "Usage: %s [options] \t\nOptions:\n", av0);
        (void)fprintf(stderr,
                "\t-v             Verbose, report each notification\n");
        (void)fprintf(stderr,
                "\t-x             Debug mode\n");
        (void)fprintf(stderr,
                "\t-l logfile     Send log info to file (default uses syslogd)\n");
        (void)fprintf(stderr,
                "\t-h remote      Have \"remote\" send us data (default \"%s\")\n",
                DEFAULT_REMOTE);
        (void)fprintf(stderr,
                "\t-f feedtype    Interested in products from feed \"feedtype\" (default %s)\n", s_feedtypet(DEFAULT_FEEDTYPE));
        (void)fprintf(stderr,
                "\t-p pattern     Interested in products matching \"pattern\" (default \"%s\")\n", DEFAULT_PATTERN);
        (void)fprintf(stderr,
                "\t-o offset      Set the \"from\" time offset secs before now\n");
        (void)fprintf(stderr,
                "\t-t timeout     Set RPC timeout to \"timeout\" seconds (default %d)\n",
                        DEFAULT_TIMEO);
        (void)fprintf(stderr,
                "\t-T TotalTimeo  Give up after this many secs (default %d)\n",
                        DEFAULT_TOTALTIMEO);
        exit(1);
}
コード例 #9
0
ファイル: UpFilter.c プロジェクト: Unidata/LDM
/*
 * Adds a filter-component to an upstream-filter.
 *
 * Arguments:
 *      upFilter        Pointer to the upstream-filter to which to add the 
 *                      component.
 *      feedtype        The feedtype of the filter-component.
 *      okPattern       Pointer to the "OK pattern" of the filter-component to 
 *                      be added.  Caller may free upon return.
 *      notPattern      Pointer to the "not pattern" of the filter-component to
 *                      be added.  May be NULL to indicate that such matching
 *                      should be disabled.  Caller may free upon return.
 * Returns:
 *      NULL            Success.
 *      else            Error object.
 */
ErrorObj*
upFilter_addComponent(
    UpFilter* const             upFilter,
    const feedtypet             feedtype,
    const Pattern* const        okPattern,
    const Pattern* const        notPattern)
{
    ErrorObj*   errObj = NULL;          /* success */
    Element*    elt;

    /*
     * Ensure that the given feedtype is disjoint from all feedtypes already
     * in the filter.
     */
    for (elt = upFilter->head; NULL != elt; elt = elt->next) {
        if (feedtype & elt->ft) {
            char        ftSpec[512];

            (void)sprint_feedtypet(ftSpec, sizeof(ftSpec), feedtype);

            errObj = ERR_NEW2(0, NULL,
                "Feedtype %s overlaps with feedtype %s",
                ftSpec, s_feedtypet(elt->ft));

            break;
        }
    }

    if (NULL == errObj) {
        size_t          nbytes = sizeof(Element);

        elt = (Element*)malloc(nbytes);

        if (NULL == elt) {
            errObj = ERR_NEW2(0, NULL, "Couldn't allocate %lu-bytes: %s",
                (unsigned long)nbytes, strerror(errno));
        }
        else {
            if ((errObj = pat_clone(&elt->okPattern, okPattern))) {
                errObj = ERR_NEW(0, errObj, "Couldn't clone \"OK\" pattern");
                free(elt);
            }
            else {
                if (NULL == notPattern) {
                    elt->notPattern = NULL;
                }
                else {
                    if ((errObj = pat_clone(&elt->notPattern, notPattern))) {
                        errObj = ERR_NEW(0, errObj,
                            "Couldn't clone \"not\" pattern");
                        pat_free(elt->okPattern);
                        free(elt);
                        elt = NULL;
                    }
                }

                if (elt) {
                    elt->ft = feedtype;
                    elt->next = upFilter->head;
                    upFilter->head = elt;
                    upFilter->stringOutOfDate = 1;
                    upFilter->count++;
                }
            }                           /* "elt->okPattern" allocated */
        }                               /* "elt" allocated */
    } // given feedtype is disjoint from those already in filter

    return errObj;
}
コード例 #10
0
ファイル: pqsurf.c プロジェクト: funnelfiasco/LDM
static void
usage(const char *av0) /*  id string */
{
        (void)fprintf(stderr,
                "Usage: %s [options] [confilename]\t\nOptions:\n",
                av0);
        (void)fprintf(stderr,
                "\t-v           Verbose, log each match (SIGUSR2 toggles)\n");
        (void)fprintf(stderr,
                "\t-x           Debug mode\n");
        (void)fprintf(stderr,
                "\t-l logfile   Send log info to file (default uses syslogd)\n");
        (void)fprintf(stderr,
                "\t-d datadir   cd to \"datadir\" before interpreting filenames in\n");
        (void)fprintf(stderr,
                "\t             conffile (default %s)\n",
                getPqsurfDataDirPath());
        (void)fprintf(stderr,
                "\t-q queue     default \"%s\"\n", getQueuePath());
        (void)fprintf(stderr,
                "\t-p pattern   Interested in products matching \"pattern\" (default \"%s\")\n", DEFAULT_PATTERN);
        (void)fprintf(stderr,
                "\t-f feedtype  Interested in products from feed \"feedtype\" (default %s)\n", s_feedtypet(DEFAULT_FEEDTYPE));
        (void)fprintf(stderr,
                "\t-i interval  loop, polling each \"interval\" seconds (default %d)\n", DEFAULT_INTERVAL);
        (void)fprintf(stderr,
                "\t-a age       Expire products older than \"age\" hours (default %.4f)\n", DEFAULT_AGE);
        (void)fprintf(stderr,
                "\t-t timeo     set write timeo for PIPE subprocs to \"timeo\" secs (default %d)\n", DEFAULT_PIPE_TIMEO);
        (void)fprintf(stderr,
                "\t-o offset    the oldest product we will consider is \"offset\" secs before now (default: most recent in output queue)\n");
        (void)fprintf(stderr,
                "\t-Q outQueue    default \"%s\"\n", getSurfQueuePath());
        (void)fprintf(stderr,
                "\t(default conffilename is %s)\n",
                getPqsurfConfigPath());
        exit(1);
}
コード例 #11
0
ファイル: ldmsend.c プロジェクト: KeithLatteri/awips2
static void
usage(
        char *av0 /*  id string */
)
{
        (void)fprintf(stderr,
                "Usage: %s [options] filename ...\n\tOptions:\n", av0);
        (void)fprintf(stderr,
                "\t-v           Verbose, tell me about each product\n");
        (void)fprintf(stderr,
                "\t-l logfile   log to a file rather than stderr\n");
        (void)fprintf(stderr,
                "\t-h remote    remote service host, defaults to \"localhost\"\n");
        (void)fprintf(stderr,
                "\t-s seqno     set initial product sequence number to \"seqno\", defaults to 0\n");
        (void)fprintf(stderr,
                "\t-f feedtype  assert your feed type as \"feedtype\", defaults to \"%s\"\n", s_feedtypet(DEFAULT_FEEDTYPE));
        exit(1);
}