Re: creating persistent directory

2012-06-27 Thread Harish Jadhav
Hello All,

Using SNMP_PERSISTENT_DIR variable, I am setting the directory path of 
my wish for 2 MIB directories.  The variable is set in multiple processes
and all processes will start almost at the same time.

Most of the time everything works fine as it creates the mib files under 
the directory which
I specified by 0 and 1. But sometimes it tries to create in 
c:\usr\snmp\persist\mib_indexes and during this it creates with indexes 
0,1, 2, 3 (May be as multiple processes started at same time,
it is creating multiple directories where 0 &2 are having same content, 
1&3 are having same content) and  it leads to crash(segmentation 
violation) one of the process.

Please let me know if any clue on this, as I have set this variable for 
all the processes.

Thanks
Harish



On 1/12/2012 2:39 PM, Harish Jadhav wrote:
> Thanks Dave.
>
> The thing is, due to some files under c:\usr\snmp\persist\mib_indexes, 
> it was causing my application to crash at snmp_init("myapps"). I am 
> loading mibs from
> two directories. In persistent folder I found 4 index files which 
> suppose to be 2 as I am loading only two directories.
>
> So, I deleted the folder c:\usr and restarted the application. It 
> created the  c:\usr\snmp\persist\mib_indexes folder again with 2 
> files. Then application seems to work fine.
> I am wondering what could be the reason for crash and why it created 4 
> files at the first instance.
>
> Please help me to understand.
>
> Thanks
> Harish
>
> On 1/12/2012 1:56 PM, Dave Shield wrote:
>> On 12 January 2012 06:01, Harish Jadhav  wrote:
>>> I have compiled netsnmp 5.7.1 for windows version
>>> I am loading mibs from my application directory in the code using
>>> setenv(mibdirs,path, 0) but it is creating the index files in
>>> c:\\usr\snmp\persist directory.
>> Yes - that is correct.
>>
>>> In ealier version, it is used to create the index in folders where 
>>> mibs are
>>> present( which is my appliation dir) but now it is creating a new 
>>> directory
>>> c:\\usr\snmp\persist.
>> This change was introduced about five years ago (see SVN revision 15693)
>> although the first release that used this approach was 5.5, which 
>> came out
>> in mid 2009.
>>
>> The relevant log message is:
>>  "Maintain MIB directory index files under /var/net-snmp
>>   (in line with File Hierarchy Standard specifications)
>>   See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=389434
>>   and discussion "MIBs in net-snmp" on coders list (Oct 2006)"
>>
>>
>> The problem was that under Unix-style systems (which is the traditional
>> focus of this problem), the MIB files could easily be present on a 
>> read-only
>> partition, so it might not be possible to create the .index files there.
>>
>> Given that these files are only ever used by the library, which doesn't
>> actually care where they reside - the cleanest solution was to move
>> them to the persistent directory (which is necessarily writable).
>>
>>
>>> How can I override this, please suggest.
>> There's not really an easy way to change this.
>> The simplest would probably be to set the persistent directory
>> (either globally as Bart suggests, or within the application).
>> If this is being done in a client application which has no real
>> use for the persistent directory at all, then it *might* work to
>> set the persistent directory to be on a non-existent drive, in
>> which case it would simply fail to create the .index files at all.
>> I haven't tested this, but it ought to work.
>>
>>
>> Alternatively - what is the problem about leaving the index
>> files in their new location?   I know it's a change from the old
>> (5.[0-4].x) behaviour, but does it really matter?
>>
>> Dave
>>
>>
>>
>


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users


Received response for SNMPv3 inform; but Agent still sending inform for the number of retries configured.(Stuck Please help...)

2012-06-27 Thread Suresh kumar


  
Hi Wes 

 
Please clarify issues seen in 2 and 3.
 
2. Also sending report SNMP-USER-BASED-SM-MIB::usmStatsNotInTimeWindows.0 (See 
EngineIDErrorPkt.pcap). updated System time on Agent; still error received.
3. V3 Inform received by Trap Receiver; response sent to agent but agent is 
sending inform again (retry = 1; See Inform-Retry.pcap).
 



 
Hi Dave I also attached trapdconfig(in zip file 7.z format) I’m using manage 
Engine MIB Browser for receiving Trap 
 


> From: harda...@users.sourceforge.net
> To: skjaiswa...@hotmail.com
> CC: net-snmp-cod...@lists.sourceforge.net; 
> net-snmp-users@lists.sourceforge.net
> Subject: Re: Received response for SNMPv3 inform; but Agent still sending 
> inform for the number of retries configured.
> Date: Wed, 20 Jun 2012 08:12:48 -0700
> 
> Suresh kumar  writes:
> 
> > 1. Engine ID discovered correctly during discovery; but Agent still
> > incrementing usmStatsUnknownEngineIDs.0 (See EngineIDErrorPkt.pcap)
> > 2. Also sending report
> > SNMP-USER-BASED-SM-MIB::usmStatsNotInTimeWindows.0 (See
> > EngineIDErrorPkt.pcap). updated System time on Agent; still error
> > received.
> 
> These are actually normal. In the process of engineID discovery (and
> time discovery) the agent will receive a message with the wrong
> engineID, so the agent increments the count and sends back the real one.
> That's actually how engineID discovery works.
> 
> -- 
> Wes Hardaker
> Please mail all replies to net-snmp-cod...@lists.sourceforge.net
  

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users 
  

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users 
  --
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users


net-snmp-5.5-37 v3 users conf file

2012-06-27 Thread Pavan_Patel
Hi,

We are using net-snmp-5.5-37 and facing issue in configuring v3 users file. So 
to create the v3 users we don't use net-snmp command, instead we create v3 
users file from our application and place it as /var/lib/net-snmp/snmpd.conf. 
This file contains the createUser entries along with the engine id.

The issue we are facing is once we copy the snmpd.conf (inside 
/var/lib/net-snmp) and restart the snmpd daemon then net-snmp is overwriting 
our file with some other file, it looks like below:-

#
# net-snmp (or ucd-snmp) persistent data file.
#

# STOP STOP STOP STOP STOP STOP STOP STOP STOP
#
#   DO NOT EDIT THIS FILE 
#
# STOP STOP STOP STOP STOP STOP STOP STOP STOP

#
# DO NOT STORE CONFIGURATION ENTRIES HERE.
# Please save normal configuration tokens for snmpd in SNMPCONFPATH/snmpd.conf.
# Only "createUser" tokens should be placed here by snmpd administrators.
# (Did I mention: do not edit this file?)
#

I am not sure if this the normal behaviour or do we need to do something in 
configuration to prevent this? Or we are doing something terribly wrong.

Thanks,
Pavan
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users


x64 for Windows

2012-06-27 Thread Robert Nielsen
Greetings,

I would like to try your product, but I cannot find an x64 executable for
Windows. There is a link for the x86 version (Looking for the latest
version?
 Download net-snmp-5.6.1.1-1.x86.exe (4.2 MB)), but I was unable to find an
x64 version. If this exists, can you please send me a link where I can
download this?

 

Thanks -

 

 

Robert

 

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users


SNMPWALK to Mysql - Stuck with code :) Please help...

2012-06-27 Thread Christiaan Rademan

Greetings guys,

I am busy writing code, to run though some devices on a network and log 
and do a basic snmpwalk and log it to MySQL. I am fairly new to NET-SNMP 
API & C :-) The code is working so far, but I have a few things I am 
stuck with...


sprintf_objid = how do i only print the oid in numeric format? not the 
string value? (I want both to store string and numeric in two separate 
fields within mysql table) Is there a function or way I can find the 
original oid in numerical format?


Code attached, please advice...

--
Christiaan Rademan - JNCIE #661

Mobile: +27 83 419 2078
E-mail: christiaan.rade...@gmail.com

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include "knock.h"

#define NETSNMP_DS_WALK_INCLUDE_REQUESTED	1
#define NETSNMP_DS_WALK_PRINT_STATISTICS	2
#define NETSNMP_DS_WALK_DONT_CHECK_LEXICOGRAPHIC	3

char lockfile[256] = "/var/lock/snmp2mysql.lck";

struct host {
	char name[255];
	char community[255];
	char id[255];
} hosts[255];

struct sql_snmp {
	char node[255];
	char oid[255];
	char type[255];
	char value[255];
};

char server[255] = "";
char database[255] = "";
char sqluser[255] = "";
char sqlpass[255] = "";

void snmpwalk(char mib[50],char debug, int *insert_c, struct sql_snmp *insert, struct sql_snmp *insert2, struct snmp_session *sp, struct host *hp)
{
	int running;

	int status;
	int count;
	netsnmp_pdu *pdu, *response;
	netsnmp_variable_list *vars;
	oid name[MAX_OID_LEN];
	size_t name_length;
	oid root[MAX_OID_LEN];
	size_t rootlen;

	char objid[255];
	char value[255];
	char test[255];
	char *value_type;
	char *value_data;

	int a;

	oid objid_mib[7]; 
	if (strcmp(mib,"system") == 0)
	{
		objid_mib[0] = 1;
		objid_mib[1] = 3;
		objid_mib[2] = 6;
		objid_mib[3] = 1;
		objid_mib[4] = 2;
		objid_mib[5] = 1;
		objid_mib[6] = 1;
	}
	if (strcmp(mib,"interfaces") == 0)
	{
		objid_mib[0] = 1;
		objid_mib[1] = 3;
		objid_mib[2] = 6;
		objid_mib[3] = 1;
		objid_mib[4] = 2;
		objid_mib[5] = 1;
		objid_mib[6] = 2;
	}

	for (a = 0; a < *insert_c; a++)
	{
		insert2++;
	}

	memmove(root, objid_mib, sizeof(objid_mib));
	rootlen = sizeof(objid_mib) / sizeof(oid);

	memmove(name, root, rootlen * sizeof(oid));
	name_length = rootlen;

	running = 1;

	while (running)
	{
		pdu = snmp_pdu_create(SNMP_MSG_GETNEXT);
		snmp_add_null_var(pdu, name, name_length);

		status = snmp_synch_response(sp, pdu, &response);
		if (status == STAT_SUCCESS)
		{
			if (response->errstat == SNMP_ERR_NOERROR)
			{
for (vars = response->variables; vars;
vars = vars->next_variable)
{
	if ((vars->name_length < rootlen) || (memcmp(root, vars->name, rootlen * sizeof(oid)) != 0))
	{
		running = 0;
		continue;
	}
	snprint_objid(objid,255,vars->name, vars->name_length);
	snprint_value(value,255,vars->name, vars->name_length, vars);
	snprint_variable(test,255,vars->name, vars->name_length, vars);
	value_type = strtok(value,":");
	value_data = strtok(NULL,"");
	if (value_data)
	{
		if (value_type)
		{
			if (value_type[strlen(value_type) - 1] == '\n')
			{
value_type[strlen(value_type) - 1] = '\0';
			}

			if (debug == 'Y')
			{
printf("Testing %s\n",test);
printf("Node: [%s] %s Obj: %s Type: (%x) %s Value:%s\n",hp->id,hp->name,objid,vars->type,value_type,value_data);
			}

			strcpy(insert2->node,hp->id);
			strcpy(insert2->oid,objid);
			strcpy(insert2->type,value_type);
			strcpy(insert2->value,value_data);  
			insert2++;
			(*insert_c)++;
		}
	}

	if ((vars->type != SNMP_ENDOFMIBVIEW) &&
	(vars->type != SNMP_NOSUCHOBJECT) &&
	(vars->type != SNMP_NOSUCHINSTANCE))
	{
		if (snmp_oid_compare(name, name_length,
		vars->name,
		vars->name_length) >= 0)
		{
			fprintf(stderr, "ERROR: OID not increasing: ");
			fprint_objid(stderr, name, name_length);
			fprintf(stderr, " >= ");
			fprint_objid(stderr, vars->name,
			vars->name_length);
			fprintf(stderr, "\n");
			running = 0;
		}
		memmove((char *) name, (char *) vars->name,
		vars->name_length * sizeof(oid));
		name_length = vars->name_length;
	}
	else
	{
		running = 0;
	}
}
			}
			else
			{
running = 0;
if (response->errstat == SNMP_ERR_NOSUCHNAME)
{
	printf("End of MIB\n");
}
else
{
	fprintf(stderr, "ERROR in packet.\nReason: %s\n",
	snmp_errstring(response->errstat));
	if (response->errindex != 0)
	{
		fprintf(stderr, "Failed object: ");
		for (count = 1, vars = response->variables;
		vars && count != response->errindex;
		vars = vars->next_variable, count++)
		{
			if (vars)
			{
fprint_objid(stderr, vars->name,
vars->name_length);
fprintf(stderr, "\n");
			}
		}
	}
}
			}
		}
		else if (status == STAT_TIMEOUT)
		{
			fprintf(stderr, "Timeou