公司要实施一个部级的项目,我们公司的提供的产品要对接下客户的一个平台监控平台,该监控平台使用snmp,我们公司的产品不支持snmp,所以由我负责在现网实施snmp,记录这次现网

一、生成编译规则

1、下载snmp的tar包

2、解压

[root@localhost admin]# tar -zxvf net-snmp-5.7.1.tar.gz

  

drwxr-xr-x 18  1274  1274    4096 Sep 28  2011 net-snmp-5.7.1
-rw-rw-r-- 1 admin admin 6110619 Jul 23 14:37 net-snmp-5.7.1.tar.gz

  

3、生成编译规则

./configure --prefix=/usr/local/snmp --with-mib-modules='ucd-snmp/diskio ip-mib/ipv4InterfaceTable'

  

4、点击回车

5、点击回车:1、default version of-snmp-version:

6、点击回车:Systemcontact information(配置该设备的联系人):

7、点击回车:System location (该设备的位置):

8、点击回车:Location to write logfile (日志文件位置): /var/log/snmpd.log

9、点击回车:Location to Write persistent(数据存储目录): /var/net-snmp

10、编译规则生成完成

二、安装

1、编译并安装

make  &&  make install

  

2、编译安装完成

3、在snmp安装目录创建配置文件路径

[root@localhost snmp]# mkdir etc
[root@localhost snmp]# pwd
/usr/local/snmp
[root@localhost snmp]# ll
total 8
drwxr-xr-x 2 root root 4096 Jul 23 14:57 bin
drwxr-xr-x 2 root root 6 Jul 23 14:59 etc
drwxr-xr-x 3 root root 21 Jul 23 14:57 include
drwxr-xr-x 2 root root 4096 Jul 23 14:57 lib
drwxr-xr-x 2 root root 34 Jul 23 14:57 sbin
drwxr-xr-x 4 root root 27 Jul 23 14:57 share

  

4、在源文件目录下拷贝配置文件到安装的etc目录

[root@localhost snmp]# scp /home/admin/net-snmp-5.7.1/EXAMPLE.conf /usr/local/snmp/etc/snmpd.conf
You have mail in /var/spool/mail/root
[root@localhost snmp]# ll
total 8
drwxr-xr-x 2 root root 4096 Jul 23 14:57 bin
drwxr-xr-x 2 root root 23 Jul 23 15:01 etc
drwxr-xr-x 3 root root 21 Jul 23 14:57 include
drwxr-xr-x 2 root root 4096 Jul 23 14:57 lib
drwxr-xr-x 2 root root 34 Jul 23 14:57 sbin
drwxr-xr-x 4 root root 27 Jul 23 14:57 share
[root@localhost snmp]# cd etc/

  

[root@localhost etc]# ll
total 8
-rw-r--r-- 1 root root 6993 Jul 23 15:01 snmpd.conf

  

5、编辑配置文件

a、配置允许网络访问按照截图中的方式修改

b、选择v2c SNMP协议的版本按照截图中的方式修改

c、设置访问权限按照截图中的方式修改

三、启动和调试

1、启动

[root@localhost etc]# /usr/local/snmp/sbin/snmpd -c /usr/local/snmp/etc/snmpd.conf

  

2、检查进程和端口

[root@localhost etc]# netstat -an |grep -w 161
[root@localhost etc]# ps auxf |grep -w snmp
root 26440 0.0 0.0 112708 980 pts/0 S+ 15:10 0:00 | \_ grep --color=auto -w snmp

  

[root@localhost etc]# ps auxf |grep snmp
root 3327 0.0 0.0 112708 956 pts/0 S+ 15:11 0:00 | \_ grep --color=auto snmp
root 1696 0.2 0.0 187880 5164 ? S 15:11 0:00 /usr/local/snmp/sbin/snmpd -c /usr/local/snmp/etc/snmpd.conf
[root@localhost etc]# netstat -anu |grep 161
udp 0 0 0.0.0.0:161 0.0.0.0:*
[root@localhost etc]#

  

3、添加到开机启动项中

4、添加防火墙规则

firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 1 -s 10.87.18.101/24 -p udp --dport=161 -j ACCEPT

  

[root@localhost init.d]# firewall-cmd --reload

  

5、测试

6、附上oid

CPU Statistics 
Load 
1 minute Load: .1.3.6.1.4.1.2021.10.1.3.1 
5 minute Load: .1.3.6.1.4.1.2021.10.1.3.2 
15 minute Load: .1.3.6.1.4.1.2021.10.1.3.3 
CPU 
percentage of user CPU time: .1.3.6.1.4.1.2021.11.9.0 
raw user cpu time: .1.3.6.1.4.1.2021.11.50.0 
percentages of system CPU time: .1.3.6.1.4.1.2021.11.10.0 
raw system cpu time: .1.3.6.1.4.1.2021.11.52.0 
percentages of idle CPU time: .1.3.6.1.4.1.2021.11.11.0 
raw idle cpu time: .1.3.6.1.4.1.2021.11.53.0 
raw nice cpu time: .1.3.6.1.4.1.2021.11.51.0 
Memory Statistics 
Total Swap Size: .1.3.6.1.4.1.2021.4.3.0 
Available Swap Space: .1.3.6.1.4.1.2021.4.4.0 
Total RAM in machine: .1.3.6.1.4.1.2021.4.5.0 
Total RAM used: .1.3.6.1.4.1.2021.4.6.0 
Total RAM Free: .1.3.6.1.4.1.2021.4.11.0 
Total RAM Shared: .1.3.6.1.4.1.2021.4.13.0 
Total RAM Buffered: .1.3.6.1.4.1.2021.4.14.0 
Total Cached Memory: .1.3.6.1.4.1.2021.4.15.0 Disk Statistics 
The snmpd.conf needs to be edited. Add the following (assuming a machine with a single '/' partition): 
disk / 100000 (or) 
includeAllDisks 10% for all partitions and disks 
The OIDs are as follows 
Path where the disk is mounted: .1.3.6.1.4.1.2021.9.1.2.1 
Path of the device for the partition: .1.3.6.1.4.1.2021.9.1.3.1 
Total size of the disk / partion (kBytes): .1.3.6.1.4.1.2021.9.1.6.1 
Available space on the disk: .1.3.6.1.4.1.2021.9.1.7.1 
Used space on the disk: .1.3.6.1.4.1.2021.9.1.8.1 
Percentage of space used on disk: .1.3.6.1.4.1.2021.9.1.9.1 
Percentage of inodes used on disk: .1.3.6.1.4.1.2021.9.1.10.1 
System Uptime: .1.3.6.1.2.1.1.3.0 
Examples 
These Commands you need to run on the SNMP server 
Get available disk space for / on the target host 
# Snmpget-v 1-c "community" target_name_or_ip .1.3.6.1.4.1.2021.9.1.7.1 
this will return available disk space for the first entry in the 'disk' section of snmpd.conf; replace 1 with n for the nth entry 
Get the 1-minute system load on the target host 
# Snmpget-v 1-c "community" target_name_or_ip .1.3.6.1.4.1.2021.10.1.3.1 
Get the 5-minute system load on the target host 
# Snmpget-v 1-c "community" target_name_or_ip .1.3.6.1.4.1.2021.10.1.3.2 
Get the 15-minute system load on the target host 
# Snmpget-v 1-c "community" target_name_or_ip .1.3.6.1.4.1.2021.10.1.3.3 
Get amount of available swap space on the target host 
# Snmpget-v 1-c "community" target_name_or_ip .1.3.6.1.4.1.2021.4.4.

  

记录一次线上实施snmp的更多相关文章

  1. Linux(2)---记录一次线上服务 CPU 100%的排查过程

    Linux(2)---记录一次线上服务 CPU 100%的排查过程 当时产生CPU飙升接近100%的原因是因为项目中的websocket时时断开又重连导致CPU飙升接近100% .如何排查的呢 是通过 ...

  2. 记录一次线上bug

    记录一次线上bug,总的来说就是弱网和重复点击.特殊值校验的问题. 测试场景一:        在3g网络或者使页面加载速度需要两秒左右的时候,输入学号,提交学生的缴费项目,提交完一个 学生的缴费后, ...

  3. 原创 记录一次线上Mysql慢查询问题排查过程

    背景 前段时间收到运维反馈,线上Mysql数据库凌晨时候出现慢查询的报警,并把原始sql发了过来: --去除了业务含义的sql update test_user set a=1 where id=1; ...

  4. 【JVM】记录一次线上SWAP偏高告警的故障分析过程

    近期遇到一个堆外内存导致swap飙高的问题,这类问题比较罕见,因此将整个排查过程记录下来了 现象描述 最近1周线上服务器时不时出现swap报警(swap超过内存10%时触发报警,内存是4G,因此swa ...

  5. 记录一次线上yarn RM频繁切换的故障

    周末一大早被报警惊醒,rm频繁切换 急急忙忙排查 看到两处错误日志 错误信息1 ervation <memory:0, vCores:0> 2019-12-21 11:51:57,781 ...

  6. 记录一次线上OOM调优经历

    现状: k8s 的一个pod 有32G内存,每秒产生新对象的峰值在900Mb ---- 1900Mb(根据jstat计算Eden区获得) . 修改之前的参数 就一个命令行参数是-Xmx31g; 我修改 ...

  7. 【Java分享客栈】从线上环境摘取了四个代码优化记录分享给大家

    前言 因为前段时间新项目已经完成目前趋于稳定,所以最近我被分配到了公司的运维组,负责维护另外一个项目,包含处理客户反馈的日常问题,以及对系统缺陷进行优化. 经过了接近两周的维护,除了日常问题以外,代码 ...

  8. 记录一次linux线上服务器被黑事件

    1.原因:本来在家正常休息了,我们放在上海托管机房的线上服务器突然蹦了远程不了,服务启动不了,然后让上海机房重启了一次,还是直接挂了,一直到我远程上才行. 2.现象:远程服务器发现出现这类信息 Hi, ...

  9. 一次线上Mysql数据库崩溃事故的记录

    文章简介 工作这几年,技术栈在不断更新,项目管理心得也增加了不少,写代码的速度也在提升,感觉很欣慰,毕竟是在一直进步,但是过程中也有许许多多的曲折,也踩过了数不尽的坑坑洼洼,从一个连百度都不知道用的萌 ...

随机推荐

  1. elasticsearch集群配置 (Tobe Continue)

    elasticsearch集群配置 (Tobe Continue)   准备 首先需要在每个节点有可以正常启动的单节点elasticsearch   elasticsearch集群配置仅需要在elas ...

  2. 从零开始使用 Webpack 搭建 Vue3 开发环境

    从零开始使用 Webpack 搭建 Vue3 开发环境 创建项目 首先需要创建一个空目录,在该目录打开命令行,执行 npm init 命令创建一个项目,这个过程会提示输入一些内容,完成后会自动生成一个 ...

  3. vue中v-model父子组件通信

    有这样的需求,父组件绑定v-model,子组件输入更改父组件v-model绑定的数值.是怎么实现的呢? 实际上v-model 只是语法糖而已. <input v-model="inpu ...

  4. tensorflw-gpu 运行 。py程序出现gpu不匹配的问题

    安装好了tensorflow-gpu版本,然后程序中写好了 with tf.device('/gpu:0'):   但是python3 .py程序时还是有错误. 报错为: 2018-04-24 12: ...

  5. Quartz.Net系列(十六):Misfire策略在SimpleScheduler和CronScheduler中的使用

    1.场景 ①因为工作线程都在忙碌,所以导致某些Trigger得不到触发 也就是默认10个工作线程而我有15个Trigger同时触发 这就导致有5个不能被触发,而不幸的是Trigger所关联的Job执行 ...

  6. GPO - General GPO Settings(1)

    Prohibit access to Control Panel and PC settings Disable GPO for Administrators and /or User Groups  ...

  7. P1433 吃奶酪(洛谷)状压dp解法

    嗯?这题竟然是个绿题. 这个题真的不(很)难,我们只是不会计算2点之间的距离,他还给出了公式,这个就有点…… 我们直接套公式去求出需要的值,然后普通的状压dp就可以了. 是的状压dp. 这个题的数据加 ...

  8. xenomai内核解析之信号signal(一)---Linux信号机制

    版权声明:本文为本文为博主原创文章,转载请注明出处.如有错误,欢迎指正.博客地址:https://www.cnblogs.com/wsg1100/ 目录 1. Linux信号 1.1注册信号处理函数 ...

  9. 【Python学习笔记一】基础环境安装:idea+python

    IDEA 安装 1.下载IDEA   官网下载地址: https://www.jetbrains.com/idea/ 2.安装的时候配置基本选择默认配置就行 参考链接:https://blog.csd ...

  10. vue : 自定义脚手架提示

    做项目做烦了就想找点乐子. 比如,我们可以自定义脚手架提示.  webpack.dev.conf.js  54-78 行 module.exports = new Promise((resolve, ...