Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8749509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:42:22+00:00 2026-06-13T12:42:22+00:00

/* * Note: this file originally auto-generated by mib2c using * $ mib2c.create-dataset.conf */

  • 0
/*
 * Note: this file originally auto-generated by mib2c using
 *        $ mib2c.create-dataset.conf
 */

#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "poolTable.h"

/** Initialize the poolTable table by defining its contents and how it's structured */

int initialize_table_poolTable(void)
{
     const oid poolTable_oid[] = {1,3,6,1,4,1,21068,4,1};
     netsnmp_table_data_set *table_set;

     /* create the table structure itself */
     table_set = netsnmp_create_table_data_set("poolTable");
     table_set->allow_creation = 1;

     /********************* Adding indexes************************/   
     DEBUGMSGTL(("initialize_table_poolTable","adding indexes to table poolTable\n"));

     netsnmp_table_set_add_indexes(table_set,ASN_INTEGER,/* index:poolIndex*/0);

     DEBUGMSGTL(("initialize_table_poolTable","adding column types to table poolTable\n"));         


     netsnmp_table_set_multi_add_default_row(table_set,COLUMN_POOLINDEX, ASN_INTEGER, 0,
                                            NULL, 0,COLUMN_POOLINOCTETS, ASN_COUNTER, 0,
                                            NULL, 0,0);

     netsnmp_register_table_data_set(

                     netsnmp_create_handler_registration("poolTable",                                                  poolTable_handler,poolTable_oid,
                                           OID_LENGTH(poolTable_oid),
                                            HANDLER_CAN_RWRITE),
                                 table_set, NULL);

     int index=1; long data[2];

     FILE *fin;

     fin=fopen("/home/xx/data.txt","r");

     if(!fin)
     {
           snmp_log(LOG_ERR,"fopen failed in locating file\n");
           return -1;
     }

     while(!feof(fin))
     {
           while((fscanf(fin,"%ld %ld",&data[0],&data[1])) == 1)
           {
           }

           if(feof(fin) == 0)
           {          
                fillTableWithValues(table_set,index,data[0],data[1]);
           }
           index++;        
     }
     return;
}

void init_poolTable(void)
{
     initialize_table_poolTable();
}

int poolTable_handler(netsnmp_mib_handler               *handler,
                netsnmp_handler_registration      *reginfo,
                netsnmp_agent_request_info        *reqinfo,
                netsnmp_request_info              *requests) 
{
   return SNMP_ERR_NOERROR;
} 

void fillTableWithValues(netsnmp_table_data_set *table_set,int i,int Value1,int Value2)
{

     netsnmp_table_row *row;
     row = netsnmp_create_table_data_row();
     int index;
     index=i;
     netsnmp_table_row_add_index(row, ASN_INTEGER, &index,  sizeof(index));

     //setting a value to an integer column of my table
     int AValue = Value1;
     netsnmp_set_row_column(row, COLUMN_POOLINDEX, ASN_INTEGER, &AValue, sizeof(AValue));

     int BValue = Value2;
     netsnmp_set_row_column(row,COLUMN_POOLINOCTETS, ASN_COUNTER, &BValue, sizeof(BValue));

     netsnmp_table_dataset_add_row(table_set, row);
     netsnmp_register_auto_data_table(table_set, NULL);

}//end FillDaPathTableUp()

/********************************************************
Data.txt
*************************************************************
1 567
2 456
3 578
4 688
5 790
6 378
*************************************************************/

Above is my code for ‘table’.

I am compiling it as a “subagent” which is getting data from a file.

But my issue is it is taking the data from first time only.

The file “data.txt” is changing its values frequently but with snmpwalk I am only getting the same data every time.
How can I get the updated data ? Where am I making a mistake?
If it is possible with a for(;;)loop, then where should I add it?
Please help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:42:23+00:00Added an answer on June 13, 2026 at 12:42 pm

    It’s returning static values because you’re only reading the file during initialization of the whole system. You need to move the file-reading code into a separate function and call it on a regular basis, like during the actual request handling, using the cache handler routines to call it as needed, or by using snmp_alarm to trigger a timer to be called every once in a while to read and load the data (and delete the old data, of course).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I set a far future expire header for this file (take note of
Take a simple XML file formatted like this: <Lists> <List> <Note/> ... <Note/> </List>
this code is correct?? String note = text.txt; FileWriter file = new FileWriter(note); Scanner
Note this question was originally posted in 2009, before C++11 was ratified and before
I am using the JNotify project to listen to file system events. This depends
Note: Originally this question was asked for PostgreSQL, however, the answer applies to almost
So I was using File for the type originally but for type validation was
I have a header file like this: #ifndef __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__ #define __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__ #ifdef _DEBUG //
(Note: This is not a question about what is the best way with code
NOTE: This is a followup to my question here. I have a program that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.