snmptrapd Time Out

jayshankar nair <[email protected]>
Newsgroups gmane.network.net-snmp.devel
Message-ID <CACdxR1SNPAbD1S-14kZQ3THikpNPCeVrnyfsS3nktUviooWuDQ@mail.gmail.com>
Hi,

I am running code similar to snmptrapd on linux server.  Currently there
are no traps receiving on the system. I am getting Time Out. Is it a valid
behavior to timeout if there are no traps .

while (netsnmp_running)
    {
        trapd_update_config();
        numfds = 0;

        /* Initialize the descriptors to null set */
        FD_ZERO(&readfds);
        FD_ZERO(&writefds);
        FD_ZERO(&exceptfds);

        block = 0;
        tvp = &timeout;
        timerclear(tvp);

        /* Set TimeOut as 5 sec */
        tvp->tv_sec = 10;
        tvp->tv_usec = 0;


        /* Setting values in absence of SNMP */
        snmp_select_info(&numfds, &readfds, tvp, &block);

        if (block == 1)
            tvp = NULL;    /* block without timeout */


        /* Adding an external event fds to read, write, excep fds.
         *  Returns biggest descriptor , when fd_sets ready for select(). */
        netsnmp_external_event_info(&numfds, &readfds, &writefds,
&exceptfds);

        /* Checking File Descriptor to Read */

        /* Call to select with return value from snmp_select_info */
        count = select(numfds, &readfds, &writefds, &exceptfds, tvp);

        gettimeofday(&Now, 0);
        /* IF found descriptor */
        if (count > 0)
        {
            netsnmp_dispatch_external_events(&count, &readfds, &writefds,
                    &exceptfds);
            /* If there any more events after external events then try SNMP
events */
            if (count > 0)
            {
                /*Reads each snmp socket that has inputs*/
                snmp_read(&readfds);
            }
        }
        else
            switch (count)
            {
                /* Cases depending number of descriptor */
                case 0:
  print ---->                  spLogErr("\n  TIME OUT");
                    snmp_timeout();
                    break;
                case -1:
                    spLogErr("\n Error at Select for Descriptor");
                    if (errno == EINTR)
                        continue;
                    snmp_log_perror("select");
                    netsnmp_running = 0;
                    break;
                default:
                    spLogErr("\n %s::%d Default Running", __FUNCTION__,
__LINE__);
                    fprintf(stderr, "select returned %d\n", count);
                    netsnmp_running = 0;
            }


Thanks & Regards
Jayshankar

_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.