• zabbix snmp监控


    zabbix snmp监控

    环境:
    CentOS 7.2
    net-snamp-5.7.2

    zabbix安装配置请参看

    一.安装配置net-snmp服务
    1.安装
    yum -y install net-snmp net-snmp-utils
    2.配置
    主配置文件/etc/snmp/snmpd.conf
    sed -i '/.1.3.6.1.2.1.25.1.1/i view    systemview    included   .1' /etc/snmp/snmpd.conf
    sed -i '/proc mountd/s/^#//' /etc/snmp/snmpd.conf
    sed -i '/proc ntalkd 4/s/^#//' /etc/snmp/snmpd.conf
    sed -i '/proc sendmail 10 1/s/^#//' /etc/snmp/snmpd.conf
    sed -i '/disk / 10000/s/^#//' /etc/snmp/snmpd.conf
    sed -i '/load 12 14 14/s/^#//' /etc/snmp/snmpd.conf
    3.启动
    systemctl start snmpd
    root@router:~#netstat -tunlp|grep snmpd
    tcp        0      0 127.0.0.1:199           0.0.0.0:*               LISTEN      33170/snmpd         
    udp        0      0 0.0.0.0:161             0.0.0.0:*                           33170/snmpd


    二.测试snmp
    root@router:~#snmpwalk -c public -v 2c 192.168.8.254 sysName
    SNMPv2-MIB::sysName.0 = STRING: router.example.com
    root@router:~#snmpwalk -c public -v 2c 192.168.8.254 .1.3.6.1.2.1.1.5
    SNMPv2-MIB::sysName.0 = STRING: router.example.com
    root@router:~#snmpwalk -c public -v 2c 192.168.8.254 .1.3.6.1.4.1.2021.4.11
    UCD-SNMP-MIB::memTotalFree.0 = INTEGER: 4337288 kB
    root@router:~#snmpwalk -c public -v 2c 192.168.8.254 memTotalFree
    UCD-SNMP-MIB::memTotalFree.0 = INTEGER: 4337012 kB


    三.snmpv3加密
    1.停snmpd
    systemctl stop snmpd
    提示:只有停止snmpd后/var/lib/net-snmp/snmpd.conf在创建用户时才能添加成功
    2.创建加密认证用户
    root@router:~#net-snmp-config --create-snmpv3-user -ro -a snmpsecret -x DES -X snmpsecret_des secure_user
    adding the following line to /var/lib/net-snmp/snmpd.conf:
       createUser secure_user MD5 "snmpsecret" DES snmpsecret_des
    adding the following line to /etc/snmp/snmpd.conf:
       rouser secure_user

    secure_user #用户名
    secret #md5密码,至少8位
    secret_des #des密码
    3.启动snmpd
    systemctl start snmpd


    四.snmpv3认证(noAuthNoPriv|authNoPriv|authPriv)
    1.noAuthNoPriv安全级别
    root@router:~#snmpwalk -v 2c -c public 127.0.0.1 .1.3.6.1.4.1.2021.4.11
    UCD-SNMP-MIB::memTotalFree.0 = INTEGER: 4298672 kB
    2.authNoPriv安全级别
    root@router:~#snmpwalk -v 3 -u secure_user -a MD5 -A snmpsecret -l AuthNoPriv 192.168.8.254 sysName
    SNMPv2-MIB::sysName.0 = STRING: router.example.com
    3.authPriv安全级别
    root@router:~#snmpwalk -v 3 -u secure_user -a MD5 -A snmpsecret -x DES -X snmpsecret_des -l authPriv 192.168.8.254 memTotalFree
    UCD-SNMP-MIB::memTotalFree.0 = INTEGER: 4317580 kB


    五.启用zabbix snmp监控
    1.启用snmp接口
    zabbix <wbr>snmp监控

    2.创建snmp监控项
    提示:在模板中创建监控项可以避免重复配置
    zabbix <wbr>snmp监控
    SNMPv2

    zabbix <wbr>snmp监控


    zabbix <wbr>snmp监控
    SNMPv3
    说明:Units采用网络通用单位Byte, 1024Byte正好是1KB
    成功启用后,SNMP的图标会变绿

    创建Graph
    zabbix <wbr>snmp监控

    zabbix <wbr>snmp监控

    补充:
    可以自定义一个OID,并重定向到外部脚本来监控服务项,这里监控80端口连接数
    1.脚本
    root@router:~#cat /root/http_connections.sh 
    #!/bin/bash
    nginxNum=$(ss -t -o state all sport = :80|wc -l)
    echo $nginxNum
    2.定义OID
    root@router:~#snmpwalk -v 2c -c public 127.0.0.1 .1.3.6.1.4.1.2021.5000
    UCD-SNMP-MIB::ucdavis.5000 = No Such Object available on this agent at this OID
    添加一个不存在的OID
    echo "extend .1.3.6.1.4.1.2021.5000 http_connections /root/http_connections.sh" >>/etc/snmp/snmpd.conf
    systemctl restart snmpd
    3.测试
    root@router:~#snmpwalk -v 2c -c public 127.0.0.1 .1.3.6.1.4.1.2021.5000
    UCD-SNMP-MIB::ucdavis.5000.1.0 = INTEGER: 1
    UCD-SNMP-MIB::ucdavis.5000.2.1.2.16.104.116.116.112.95.99.111.110.110.101.99.116.105.111.110.115 = STRING: "/root/http_connections.sh"
    UCD-SNMP-MIB::ucdavis.5000.2.1.3.16.104.116.116.112.95.99.111.110.110.101.99.116.105.111.110.115 = ""
    UCD-SNMP-MIB::ucdavis.5000.2.1.4.16.104.116.116.112.95.99.111.110.110.101.99.116.105.111.110.115 = ""
    UCD-SNMP-MIB::ucdavis.5000.2.1.5.16.104.116.116.112.95.99.111.110.110.101.99.116.105.111.110.115 = INTEGER: 5
    UCD-SNMP-MIB::ucdavis.5000.2.1.6.16.104.116.116.112.95.99.111.110.110.101.99.116.105.111.110.115 = INTEGER: 1
    UCD-SNMP-MIB::ucdavis.5000.2.1.7.16.104.116.116.112.95.99.111.110.110.101.99.116.105.111.110.115 = INTEGER: 1
    UCD-SNMP-MIB::ucdavis.5000.2.1.20.16.104.116.116.112.95.99.111.110.110.101.99.116.105.111.110.115 = INTEGER: 4
    UCD-SNMP-MIB::ucdavis.5000.2.1.21.16.104.116.116.112.95.99.111.110.110.101.99.116.105.111.110.115 = INTEGER: 1
    UCD-SNMP-MIB::ucdavis.5000.3.1.1.16.104.116.116.112.95.99.111.110.110.101.99.116.105.111.110.115 = STRING: "4"
    UCD-SNMP-MIB::ucdavis.5000.3.1.2.16.104.116.116.112.95.99.111.110.110.101.99.116.105.111.110.115 = STRING: "4"
    UCD-SNMP-MIB::ucdavis.5000.3.1.3.16.104.116.116.112.95.99.111.110.110.101.99.116.105.111.110.115 = INTEGER: 1
    UCD-SNMP-MIB::ucdavis.5000.3.1.4.16.104.116.116.112.95.99.111.110.110.101.99.116.105.111.110.115 = INTEGER: 0
    UCD-SNMP-MIB::ucdavis.5000.4.1.2.16.104.116.116.112.95.99.111.110.110.101.99.116.105.111.110.115.1 = STRING: "4"
    4.创建对应item
    OID: .1.3.6.1.4.1.2021.5000.4.1.2.16.104.116.116.112.95.99.111.110.110.101.99.116.105.111.110.115.1
    zabbix <wbr>snmp监控

    zabbix <wbr>snmp监控



  • 相关阅读:
    C# 时间+三位随机数
    dataGridView加行标识方法与制作
    MySql多列查询
    php 去掉字符串的最后一个字符
    DataTable 排序
    汇编第一个程序 Hello World (初学者与入门)
    C# 获取前一天,明天,本周,上周,本季度等!
    php 字符串中任意添加
    天涯论坛的经典回帖!!!
    系统时间同步
  • 原文地址:https://www.cnblogs.com/lixuebin/p/10814018.html
Copyright © 2020-2023  润新知