예제 #1
0
int
snmp_subagent_example_client(int enable, void* cookie)
{
    static int value = 42;  /* default value */
    oid  example_oid[] =
        { 1, 3, 6, 1, 4, 1, 37538, 37538, 37538, 37538, 37538, 0 };

    netsnmp_register_int_instance("snmp_subagent_example_client_integer",
                                  example_oid,
                                  OID_LENGTH(example_oid),
                                  &value, NULL);
    return 0;
}
void
platform_int_register(int index, char* desc, int value)
{
    oid tree[] = { 1, 3, 6, 1, 4, 1, 42623, 1, 1, 1, 1, 1};
    tree[11] = index;

    int* v = aim_zmalloc(sizeof(value));
    *v = value;

    netsnmp_register_int_instance(desc,
                                  tree,
                                  OID_LENGTH(tree),
                                  v, NULL);
}
예제 #3
0
파일: scalar_int.c 프로젝트: AllardJ/Tomato
/*
 * our initialization routine, automatically called by the agent 
 * (to get called, the function name must match init_FILENAME())
 */
void
init_scalar_int(void)
{
    /*
     * the OID we want to register our integer at.  This should be a
     * fully qualified instance.  In our case, it's a scalar at:
     * NET-SNMP-EXAMPLES-MIB::netSnmpExampleInteger.0 (note the
     * trailing 0 which is required for any instantiation of any
     * scalar object) 
     */
    oid             my_registration_oid[] =
        { 1, 3, 6, 1, 4, 1, 8072, 2, 1, 1, 0 };

    /*
     * a debugging statement.  Run the agent with -Dexample_scalar_int to see
     * the output of this debugging statement. 
     */
    DEBUGMSGTL(("example_scalar_int",
                "Initalizing example scalar int.  Default value = %d\n",
                example1));

    /*
     * the line below registers our "example1" variable above as
     * accessible and makes it writable.  A read only version of the
     * same registration would merely call
     * register_read_only_int_instance() instead.
     * 
     * If we wanted a callback when the value was retrieved or set
     * (even though the details of doing this are handled for you),
     * you could change the NULL pointer below to a valid handler
     * function. 
     */
    netsnmp_register_int_instance("my example int variable",
                                  my_registration_oid,
                                  OID_LENGTH(my_registration_oid),
                                  &example1, NULL);

    DEBUGMSGTL(("example_scalar_int",
                "Done initalizing example scalar int\n"));
}
예제 #4
0
/*
 * our initialization routine, automatically called by the agent 
 * (to get called, the function name must match init_FILENAME()) 
 */
void
init_nstAgentSubagentObject(void)
{
    static oid      nstAgentSubagentObject_oid[] =
        { 1, 3, 6, 1, 4, 1, 8072, 2, 4, 1, 1, 2, 0 };

    /*
     * a debugging statement.  Run the agent with -DnstAgentSubagentObject to see
     * the output of this debugging statement. 
     */
    DEBUGMSGTL(("nstAgentSubagentObject",
                "Initializing the nstAgentSubagentObject module\n"));

    /*
     * the line below registers our variables defined above as
     * accessible and makes it writable.  A read only version of any
     * of these registration would merely call
     * register_read_only_int_instance() instead.  The functions
     * called below should be consistent with your MIB, however.
     * 
     * If we wanted a callback when the value was retrieved or set
     * (even though the details of doing this are handled for you),
     * you could change the NULL pointer below to a valid handler
     * function. 
     */
    DEBUGMSGTL(("nstAgentSubagentObject",
                "Initalizing nstAgentSubagentObject scalar integer.  Default value = %d\n",
                nstAgentSubagentObject));

    netsnmp_register_int_instance("nstAgentSubagentObject",
                                  nstAgentSubagentObject_oid,
                                  OID_LENGTH(nstAgentSubagentObject_oid),
                                  &nstAgentSubagentObject, NULL);

    DEBUGMSGTL(("nstAgentSubagentObject",
                "Done initalizing nstAgentSubagentObject module\n"));
}