Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: Failed to connect to the agentx master agent ([NIL])

Tags:

snmp

net-snmp

I have installed net-snmp5.7.2 on my system, I have written my app_agent.conf for my application and

agentXSocket    udp:X.X.X.X:1610

and exported SNMPCONFIGPATH=path_to_app_agent.conf

I have also wrtten snmpd.conf in /usr/etc/snmp/snmp.conf

trap2sink  X.X.X.Y 
agentXSocket    udp:X.X.X.X:1610

I have two more snmpd.conf present in my /etc/snmp/ and /var/net-snmp/

Config from /etc/snmp:

com2sec notConfigUser  default       public
com2sec notConfigUser  v1            notConfigUser
com2sec notConfigUser  v1            notConfigUser
view    systemview    included   .1.3.6.1.2.1.1
view    systemview    included   .1.3.6.1.2.1.25.1.1
access notConfigGroup "" any noauth exact systemview none none 
pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat

Config from /var/net-snmp:

   setserialno 1322276014
   ifXTable .1 14:0 18:0x $
   ifXTable .2 14:0 18:0x $
   ifXTable .3 14:0 18:0x $
   engineBoots 14
   oldEngineID 0x80001f888000e17f6964b28450

I have started snmpd and snmptrapd. Now in my code I am calling

netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, 1);
init_agent("app_agent");
init_snmp("app_agent");

init_snmp is throwing a warning

Warning: Failed to connect to the agentx master agent ([NIL]):

I have no idea why?? Thanks in advance for any help

like image 440
Sudip Avatar asked Jan 16 '23 03:01

Sudip


1 Answers

This is basically saying the sub-agent you wrote failed to connect to NetSNMP master agent, as the message suggested. In Linux, by default agentx will attempt to make the connection via socket using /var/agentx/master. The following hint might help:

  1. Running your sub-agent under appropriate privilege that has access to sockets e.x. sudo
  2. Check socket setting in your snmpd.conf (which located varies) if not already specified, such as agentxsocket /var/agentx/master and agentxperms 777 777
  3. Restart NetSNMP for any change to take effect with sudo service snmpd restart; or as an option you can try stop the service with sudo service snmpd stop and run an instance with debugging mode snmpd -f -Lo -Dagentx which most likely will output useful information on sub-agent connection.
like image 166
James Liu Avatar answered Feb 26 '23 19:02

James Liu