freeBSD与openBSD下SNMP服务的安装与配置

freeBSD与openBSD下SNMP服务的安装与配置

 

一、freeBSD安装SNMP服务

 

1、检查主机是否已经安装SNMP服务

 

使用命令: pkg info |grep snmp  

检查是否安装net-snmp*

2、安装配置SNMP服务

2.1 安装SNMP服务

方法一:在线安装

freeBSD与openBSD默认不安装rpm工具,可以通过freeBSD的ports方式在线安装rpm工具,然后安装公司提供的snmp agent的rpm包,但是在线安装rpm工具时需要提供多个系统库文件,编译失败率比较高,因此不采用该方式

第一步:通过ports方式安装snmp

切换至root用户,执行 :
#cd /usr/ports/net-mgmt/net-snmp/ 
#make install clean
根据系统提示完成在线安装
     
      方法二:snmp源代码编译安装
#scp root@192.168.0.174:源代码文件绝对路径  .   //“.”代表当前目录
#tar xvzf net-snmp-5.5.2.1.tar.gz
#cd net-snmp-5.5.2.1
#./configure
#make
#make install
 
方法三:
#pkg add net-snmp
2.2 配置SNMP服务
编辑/etc/rc.conf文件,完成snmp自启动环境
添加如下内容:
 
snmpd_enable="YES"
snmpd_flags="-a /var/run/snmpd.pid"
snmptrapd_enable="YES"
snmptrapd_flags="-a -p /var/run/snmptrapd.pid
 
2.3生成snmp.conf配置文件
先删除snmp原始配置文件,执行以下命令生成符合监控要求的snmpd.conf
# snmpconf -g basic_setup
运行后会出现一个询问菜单,按如下步骤进行回答:
code:[copy to clipboard]do you want to configure the information returned in 
the system mib group (contact info, etc)? (default = y): y
the location of the system: shenzhen, china
the contact information: master@emerson.com
do you want to properly set the value of the sysservices.0 oid (if you don't know, just say no)? (default = y): y
does this host offer physical services (eg, like a repeater) [answer 0 or 1]: 1
does this host offer datalink/subnetwork services (eg, like a bridge): 0
does this host offer internet services (eg, supports ip): 1
does this host offer end-to-end services (eg, supports tcp): 1
does this host offer application services (eg, supports smtp): 1
do you want to configure the agent's access control? (default = y): y
do you want to allow snmpv3 read-write user based access (default = y): n
do you want to allow snmpv3 read-only user based access (default = y): n
do you want to allow snmpv1/v2c read-write community access (default = y): n
do you want to allow snmpv1/v2c read-only community access (default = y): y
the community name to add read-only access for: public
the hostname or network address to accept this community name from [return for all]: (return)
the oid that this community should be restricted to [return for no-restriction]: (return)
do you want to configure where and if the agent will send traps? (default = y): n
do you want to configure the agent's ability to monitor various aspects of your system? (default = y): y
do you want to configure the agents ability to monitor processes? (default = y): y
name of the process you want to check on: sshd(需要监控的进程)
maximum number of processes named ' sshd' that should be running [default = 0]: 1
minimum number of processes named ' sshd' that should be running [default = 0]: 0
do another proc line? (default = y): n
do you want to configure the agents ability to monitor disk space? (default = y): y
enter the mount point for the disk partion to be checked on: /
enter the minimum amount of space that should be available on /var: %100
do another disk line? (default = y): y
enter the mount point for the disk partion to be checked on: /var
enter the minimum amount of space that should be available on /var: %100
do another disk line? (default = y): y
enter the mount point for the disk partion to be checked on: /usr
enter the minimum amount of space that should be available on /usr: %100
do another disk line? (default = y): y
enter the mount point for the disk partion to be checked on: /home
enter the minimum amount of space that should be available on /home: %100
do another disk line? (default = y): n
do you want to configure the agents ability to monitor load average? (default = y): y
enter the maximum allowable value for the 1 minute load average: 12
enter the maximum allowable value for the 5 minute load average: 12
enter the maximum allowable value for the 15 minute load average: 12
do another load line? (default = y): n
do you want to configure the agents ability to monitor file sizes? (default = y): n(如果想监控文件的大小,可以选y)
 
 上述命令执行完成后会在/usr/local/share/snmp目录下生成snmp.conf

 

3、启动SNMP服务

安装SNMP服务成功后,使用命令:/usr/local/etc/rc.d/snmpd start

提示:Startingsnmpd ,则启动snmp服务成功。

 

4、验证SNMP服务

(1)使用snmptranslate命令,查看snmp工具是否可以使用:

如上,查出了部分oid,则表示snmp工具可以正常使用。

 

(2)本地通过localhost测试

 

5、远程主机测试

使用命令:  snmpwalk-v 2c -c public 192.168.0.175 | head

得到如下所示的结果:

 

 

6、关于配置文件的说明

freeBSD与openBSD为UNIX衍生版本,其snmp服务配置文件与linux衍生系统的snmp服务配置的定义方式有区别,若有兴趣可以对两配置文件进行比对

 

 

 

7、查看防火墙状态

APEXNetManager中管理安装装有freeBSD操作系统的设备时,需要关闭防火墙,以下是对防火墙的一些操作。

 

FreeBSD与openBSD默认未启用防火墙,需要在/etc/rc.conf文件中添加

1、配置FreeBSD防火墙
ee /etc/rc.conf #编辑,在最后添加
firewall_enable="yes" #开启防火墙
net.inet.ip.fw.verbose=1 #启用防火墙日志功能
net.inet.ip.fw.verbose_limit=5 #启用防火墙日志功能
natd_enable="YES" # 开启防火墙NAT功能
natd_interface="rl0"
natd_flags="-dynamic -m"
firewall_script="/etc/ipfw.rules" #自定义防火墙规则路径
esc,回车,再按a保存配置

 

然后启用防火墙

/etc/rc.d/ipfwstart

 

关闭防火墙

/etc/rc.d/ipfwstop

 

二、 openBSD安装snmp服务

1、检查是否安装snmp服务

#pkg_info |grepsnmp

 

2、安装配置snmp服务

1.      安装snmp服务

#export  PKG_PATH= ftp://ftp.openbsd.com/pub/OpenBSD/5.3/packages/i386/

#pkg_add  net-snmp

 

2.      配置snmp服务

(1)#vi  /etc/rc.conf

(2)将snmpd_flags=“no”改为 snmpd_flags=“”;将pf=YES改为pf=NO

(3)运行snmpconf -g basic_setup生成snmp配置  //与freeBSD配置snmp一样
 (4)将生成在/usr/local/share/snmp目录下的snmpd.conf文件替换到/etc/snmp/目录下

 

 (5) #/etc/rc.d/netsnmpd start   //启动snmp服务

 

3.snmp服务验证与freeBSD的snmp验证一样


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
FreeBSD操作系统设计与实现》是一本介绍FreeBSD操作系统的权威性书籍。该书籍全面解析了FreeBSD操作系统的设计原理与实现细节,深入讲解了FreeBSD操作系统的核心概念、功能模块和体系结构。 《FreeBSD操作系统设计与实现》一书主要分为五个部分:系统概述、进程管理、存储管理、文件系统和设备驱动。每个部分都对应着FreeBSD操作系统的一个重要方面,详细介绍了相应的设计原理和实现方式。 在系统概述部分,该书首先对FreeBSD操作系统的历史背景、发展过程和基本特性进行了介绍。然后,深入剖析了FreeBSD操作系统的体系结构,包括内核模块的组织结构、进程通信机制、虚拟内存管理和网络子系统等。 在进程管理部分,该书详细讨论了FreeBSD操作系统的进程管理机制,包括进程的创建、调度与退出,进程间的通信和同步方法,以及线程管理和多核支持等。 存储管理部分着重介绍了FreeBSD操作系统的存储管理机制。主要包括物理内存管理、页表管理、虚拟内存系统和缓存管理等内容。同时,该书还对FreeBSD中常用的文件系统如UFS和ZFS进行了深入讲解。 在文件系统部分,该书介绍了FreeBSD操作系统的文件系统层次结构、文件系统缓存和文件系统的操作接口。同时,还讨论了FreeBSD中的文件系统实现原理和常用的文件系统类型。 最后,设备驱动部分详细说明了FreeBSD操作系统的设备管理机制和驱动框架。该书介绍了设备驱动的注册、初始化和操作方式,并讨论了常见设备的驱动实现方法。 总之,《FreeBSD操作系统设计与实现》是一本全面系统地介绍FreeBSD操作系统的权威书籍。它对FreeBSD操作系统的设计原理和实现细节进行了深入剖析,对于对操作系统设计和实现有兴趣的读者来说是一本非常有价值的参考资料。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值