net-snmp

Issues related to configuring your network
mickey0
Posts: 61
Joined: 2015/06/16 22:44:38

net-snmp

Post by mickey0 » 2019/02/16 23:44:36

Hello guys,

I need help. I had installed netsnmp through 'yum install net-snmp' and other library, devel, etc. Everything went fine since I dowloaded net-snmp 5.8 from here https://sourceforge.net/projects/net-s ... -snmp/5.8/, and installed it into /opt/net-snmp5-8 directory (typing sudo ./configure, sudo make, sudo make install)

I also typed 'systemctl restart snmpd' and it seems wroking but any snmp* command gives 'localhost not rensponfing'.

I find out that

Code: Select all

rpm -qa | grep snmp
net-snmp-gui-5.7.2-37.el7.x86_64
net-snmp-libs-5.7.2-37.el7.x86_64
net-snmp-utils-5.7.2-37.el7.x86_64
net-snmp-devel-5.7.2-37.el7.x86_64
net-snmp-perl-5.7.2-37.el7.x86_64
net-snmp-5.7.2-37.el7.x86_64
net-snmp-agent-libs-5.7.2-37.el7.x86_64
and

Code: Select all

snmpd --version
NET-SNMP version:  5.8
Web:               http://www.net-snmp.org/
Email:             net-snmp-coders@lists.sourceforge.net
I suspect that there are 2 different version working together or permission problem (I had to type sudo ./configure since without root password ./configure coudn't write into /opt)

my /etc/snmp/snmpd.conf file, at the moment, is this:

Code: Select all

# Map 'idv90we3rnov90wer' community to the 'ConfigUser'
# Map '209ijvfwer0df92jd' community to the 'AllUser'
#       sec.name        source          community
com2sec notConfigUser      default      public
com2sec AllUser         default         public

# Map 'ConfigUser' to 'ConfigGroup' for SNMP Version 2c
# Map 'AllUser' to 'AllGroup' for SNMP Version 2c
#                       sec.model       sec.name
group   notConfigGroup     v2c             notConfigUser
group   AllGroup        v2c             AllUser

# Define 'SystemView', which includes everything under .1.3.6.1.2.1.1 (or .1.3.6.1.2.1.25.1)
# Define 'AllView', which includes everything under .1
#                       incl/excl       subtree
view    SystemView      included        .1.3.6.1.2.1.1
view    SystemView      included        .1.3.6.1.2.1.25.1.1
view    AllView         included        .1      80
view    SystemView      included        system

# Give 'ConfigGroup' read access to objects in the view 'SystemView'
# Give 'AllGroup' read access to objects in the view 'AllView'
#                       context model   level   prefix  read            write   notify
access  notConfigGroup     ""      any     noauth  exact   SystemView      none    none
access  AllGroup        ""      any     noauth  exact   AllView         none    none

sysLocation Unknown (edit /etc/snmp/snmpd.conf)
sysContact Root  (configure /etc/snmp/snmp.local.conf)

Code: Select all

snmpwalk -v2c -c public localhost system
Timeout: No Response from localhost

Any advice, please?

Thanks a million.

mickey0
Posts: 61
Joined: 2015/06/16 22:44:38

Re: net-snmp - SOLVED

Post by mickey0 » 2019/02/17 13:23:24

Hello,

while restarting smpd with 'systemctl restart snmpd' SELinux alerts me with a message:

Code: Select all

SELinux is preventing /usr/sbin/snmpd from read access on the file /etc/snmp/snmpd.conf.

*****  Plugin restorecon (99.5 confidence) suggests   ************************

If you want to fix the label. 
/etc/snmp/snmpd.conf default label should be etc_t.
Then you can run restorecon. The access attempt may have been stopped due to insufficient permissions to access a parent directory in which case try to change the following command accordingly.
Do
# /sbin/restorecon -v /etc/snmp/snmpd.conf
So I typed /sbin/restorecon -v /etc/snmp/snmpd.conf and now snmpwalk works.
I've never used restorecon, so I don't know anything about it. I also have to find the old snmpd.conf file since it has been overwritten by a new one during net-snmp 5.8 installation (the old one had a lot of comments about how to write a snmpd.conf file).

I can now going to compile a new mib in the agent.
Any comments are well accepted.

Thanks.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: net-snmp

Post by TrevorH » 2019/02/17 15:36:18

Do not do source installs. We already supply working copies of net-snmp in the repos. You just overwrote it with your own. Expect it to break next time there is an update from CentOS.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

mickey0
Posts: 61
Joined: 2015/06/16 22:44:38

Re: net-snmp

Post by mickey0 » 2019/02/17 17:02:44

Hello,

I didn't quite get what you're saying because of my poor english. Are you saying that it was possible to get the source just typing "yum install" or similar?
BTW, I'm trying to build into the master agent a new MIB and I followed this: http://net-snmp.sourceforge.net/tutoria ... index.html
but I wasn't successful for some reason (I can't query the new mib). I'm not able to find what went wrong.
How can I find it out? How can I get the source for net-snmp 5.8 through YUM command, please? (with yum, I installed net-snmp version 5.7 )

Kind regards

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: net-snmp

Post by TrevorH » 2019/02/17 17:12:59

You replaced our version of net-snmp with your own, built from source. This is not supported and not advisable. You should undo what you did and then reinstall net-snmp to get back to our version.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

mickey0
Posts: 61
Joined: 2015/06/16 22:44:38

Re: net-snmp

Post by mickey0 » 2019/02/17 18:48:54

OK, I can do it.
I did it only because I followed this http://net-snmp.sourceforge.net/tutoria ... index.html and it says to put .c and .h into /agent/ directory and recompile it. But I can't find the source files.
Does my old net-snmp 5.7 has an /agent/ directory with source file? Can I recompile it?

Thanks.

EDIT ************************************
Actually I still have the old version but snmp command uses the 5.8 version:

Code: Select all

ls -l /usr/sbin/snmpd  /usr/local/sbin/snmpd 
-rwxr-xr-x. 1 root root 65784 Feb 17 16:06 /usr/local/sbin/snmpd
-rwxr-xr-x. 1 root root 31888 Oct 31 00:53 /usr/sbin/snmpd
[ /etc/snmp] # /usr/sbin/snmpd --version

NET-SNMP version:  5.7.2
Web:               http://www.net-snmp.org/
Email:             net-snmp-coders@lists.sourceforge.net
I do not have idea how to make 5.7 version working instead of 5.8 (I deleted rm -Rf /opt/net-snmp-5.8/ directory but snmpd5.8 is still working)

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: net-snmp

Post by TrevorH » 2019/02/17 22:00:09

CentOS doesn't ship anything at all that installs under /usr/local. Most source installations use make install to install and make uninstall to uninstall.

Use rpm -Va net-snmp\* to get a list of files that do not match what rpm expects them to be. Use rpm -qf on those files to discover which package they belong to and use yum reinstall on each package.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

mickey0
Posts: 61
Joined: 2015/06/16 22:44:38

Re: net-snmp

Post by mickey0 » 2019/02/18 21:52:32

Hello,
I re-installed netsnmp 5.8 with 'make' 'make install'; later I typed 'make uninstall'.
Now it seems that there's no net-snmp 5.8 no more (there's the /opt/net-snmp-5.8 directory though; I think I can remove safely now?).
Here the output:

Code: Select all

rpm -Va net-snmp\*
SM5....T.  c /etc/snmp/snmpd.conf
.M.......  c /etc/snmp/snmptrapd.conf
And this:

Code: Select all

snmpd --version
NET-SNMP version:  5.7.2
Web:               http://www.net-snmp.org/
Email:             net-snmp-coders@lists.sourceforge.net
There isn't any more 'snmpd' into /usr/local/sbin/ directory.
This above it is the previous version, right? Everything seems sorted out.
Now I have the problem to build a sub-agent for snmp; it seems simple but apparently I can't do it.
I followed exactly this http://net-snmp.sourceforge.net/tutoria ... index.html but that MIB seems not be working.
I put this two lines at the end of /etc/snmp/snmpd.conf file:

Code: Select all

master agentx
#agentAddress udp:161,udp6:[::1]:161 # I tried to comment and uncomment this but nothing change.
#agentAddress udp:127.0.0.1:161
Then I typed:

Code: Select all

[#user] sudo systemctl restart snmpd
[#user] sudo ./mysubagent
[#user] snmpget -v2c -cpublic localhost NET-SNMP-TUTORIAL-MIB::nstAgentSubagentObject.0
NET-SNMP-TUTORIAL-MIB::nstAgentSubagentObject.0 = No Such Object available on this agent at this OID
There's no any difference launching or not launching mysubagent. The response is the same.
I can't find any solution on internet.
Any hint well accepted.

Regards.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: net-snmp

Post by TrevorH » 2019/02/18 22:53:03

Perhaps this is what you're looking for? https://access.redhat.com/documentation ... -extending
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

mickey0
Posts: 61
Joined: 2015/06/16 22:44:38

Re: net-snmp

Post by mickey0 » 2019/03/06 19:23:02

Hello,

yes it is one possibility but I am trying to buld my own sub-agent in a language, like C. I'm trying to do it but I have this problem:

Code: Select all

[user~] # mib2c

ERROR: You don't have the SNMP perl module installed.  Please obtain
this by getting the latest source release of the net-snmp toolkit from
http://www.net-snmp.org/download/ .  Once you download the source and
unpack it, the perl module is contained in the perl/SNMP directory.
See the README file there for instructions.
and yum response in this way:

Code: Select all

[user~] # sudo yum install perl-Net-SNMP
Package perl-Net-SNMP-6.0.1-7.el7.noarch already installed and latest version
Nothing to do
What's the matter? Any help, please?

Post Reply