Hi Niels,

First of all, thank you very much for your time and help. Taking into
account the tips you gave me, I made the following changes:
I changed the code so that the file opens and closes within each case
(MODE_GET or MODE_SET_ACTION).
I used fprintf function that you said, instead of snprintf and fputs, and
actually is simpler.
And when i open the file, I do so with the mode "r +" to be able to read
then the value.

After making these changes, the SET operation it works (which writes in a
text file), so then I added also the GET operation (which read in the same
text file) and it works too! :)

As for adding some debug output, I do not know where I can find the records.
For example, I understand that the next block of code writes debug messages:

DEBUGMSGTL (("example_scalar_int"
                "Initalizing int scalar example. Default value =% ld \ n",
                example1));

Also, I run the agent through the snmpd daemon, which runs the binary with
the following parameters:

SNMPDOPTS = '-Lsd-Lf / var / log / snmpd.log-p / var / run / snmpd.pid'

start-stop-daemon - quiet - start - oknodo - exec / usr / local / sbin /
snmpd \
- $ SNMPDOPTS

I have checked the log file and this is what i get:

$ cat /var/log/snmpd.log
getaddrinfo: start Name or service not known
Error opening specified endpoint "start"
Server Exiting with code 1

Considering all this, could you help me find where logs are being saved?
I'm running the agent correctly?

>From already, thank you very much again.
Greetings.
Juan I. Bússoli.


2013/6/26 Niels Baggesen <ni...@baggesen.net>

> Den 25-06-2013 18:03, Juan Bússoli skrev:
>
>
>  Could you help me to realize where the error is, and because it writes
>> the value to the text file?
>>
>
> Are you sure you are running the modified agent?
>
> Try adding some debug output to verify that you actually get into the case
> you expect.
>
> You will probably run out of file descriptors as you only close the file
> on a MODE_SET_ACTION.
>
> Why don't you just fprintf(filep, "%ld\n", example1); in stead of
> complication if with sprintf (which really should be snprintf) and fputs?
>
> You should probably open the file with mode "r+" if you want to be able to
> read a value from it.
>
> /Niels
>
> --
> Niels Baggesen -- @home -- Århus -- Denmark -- ni...@baggesen.net
> The purpose of computing is insight, not numbers  --  R W Hamming
>
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to