Пример #1
0
void agentx_parse_agentx_timeout (const char *token, char *cptr)
{
    int x = netsnmp_string_time_to_secs (cptr);

    DEBUGMSGTL (("agentx/config/timeout", "%s\n", cptr));
    if (x == -1)
    {
        config_perror ("Invalid timeout value");
        return;
    }
    netsnmp_ds_set_int (NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_AGENTX_TIMEOUT, x * ONE_SEC);
}
Пример #2
0
void
parse_sched_periodic( const char *token, char *line )
{
    netsnmp_tdata_row       *row;
    struct schedTable_entry *entry;
    char   buf[24], tmpbuf[SPRINT_MAX_LEN];
    long   frequency;
    long   value;
    size_t tmpint;
    oid    variable[ MAX_OID_LEN], *var_ptr = variable;
    size_t var_len = MAX_OID_LEN;
    
    schedEntries++;
    sprintf(buf, "_conf%03d", schedEntries);

    DEBUGMSGTL(( "disman:schedule:conf", "periodic: %s %s\n", token, line));
    /*
     *  Parse the configure directive line
     */
    line = copy_nword(line, tmpbuf, sizeof(tmpbuf));
    frequency = netsnmp_string_time_to_secs(tmpbuf);
    if (frequency == -1) {
        config_perror("Illegal frequency specified");
        return;
    }

    line = read_config_read_data(ASN_OBJECT_ID, line, &var_ptr,   &var_len);
    if (var_len == 0) {
        config_perror("invalid specification for schedVariable");
        return;
    }
    /*
     * Skip over optional assignment in "var = value"
     */
    while (line && isspace((unsigned char)(*line)))
        line++;
    if (line && *line == '=' ) {
        line++;
        while (line && isspace((unsigned char)(*line))) {
            line++;
        }
    }
    line = read_config_read_data(ASN_INTEGER,   line, &value, &tmpint);
    
    /*
     * Create an entry in the schedTable
     */
    row   = schedTable_createEntry( "snmpd.conf", buf );
    if (!row || !row->data) {
        config_perror("create schedule entry failure");
        return;
    }
    entry = (struct schedTable_entry *)row->data;

    entry->schedInterval     = frequency;
    entry->schedValue        = value;
    entry->schedVariable_len = var_len;
    memcpy(entry->schedVariable, variable, var_len*sizeof(oid));

    entry->schedType         = SCHED_TYPE_PERIODIC;
    entry->schedStorageType  = ST_READONLY;  /* or PERMANENT */
    entry->flags             = SCHEDULE_FLAG_ENABLED |
                               SCHEDULE_FLAG_ACTIVE  |
                               SCHEDULE_FLAG_VALID;
    entry->session           = netsnmp_query_get_default_session();
    sched_nextTime( entry );
}