Skip to content
Advertisement

.txt file is no longer written to by snmptrapd daemon after opening and closing with ifstream in C++

I am running Net-Snmp (environment is a virtual machine running Linux Mint OS 11) and have configured it to send trap information to a text file that I have called trapd.txt.

If I reboot the VM, any trap that is generated is sent to the file no problem. However If I run a C++ program using ifstream to open it and then close it no trap information can be written to it again until I reboot.

When I generate a trap during this state I will sometimes even see the trapd.txt file flicker in the GUI as if it tried to write but failed. This situation happens if I do a clean reboot and run the following code and it alone:

JavaScript

Clearly this code is not changing permissions or the SNMP configuration files. The only reason I can think that would prevent trap information from coming in afterwards is that the ifstream is not actually getting closed all the way.

If you have any ideas for a fix or a work around or any insight whatsoever I will be extremely grateful! This is a fairly important to me…

Here’s my snmp.conf file:

JavaScript

snmptrapd.conf:

JavaScript

snmpd.conf:

JavaScript

Advertisement

Answer

The problem’s origin was actually from the editing and saving of the file itself by myself using gedit. While I still do not understand why this would cause the issue I can work around it by not editing the file. Thanks to everyone who replied.

Advertisement