zoukankan      html  css  js  c++  java
  • zabbix学习

    snmp 默认监控upd161端口 tcp 也有
    [root@bogon ~]# netstat -nlutp|grep snmp
    tcp 0 0 127.0.0.1:199 0.0.0.0:* LISTEN 7601/snmpd
    udp 0 0 0.0.0.0:161 0.0.0.0:* 7601/snmpd

    [root@bogon ~]# cat /etc/snmp/snmpd.conf 
    rocommunity oldboy 192.168.86.3
    
    
    snmp 原理
    http://www.ibm.com/developerworks/cn/linux/l-cn-snmp/
    
    snmpget -v2c -c oldboy 192.168.86.3 1.3.6.1.4.1.2021.10.1.3.1
    snmpget -v2c -c oldboy 192.168.86.3 1.3.6.1.2.1.1.3.0
    http://www.debianadmin.com/linux-snmp-oids-for-cpumemory-and-disk-statistics.html
    
    uptime系统负载的解释
    the system load averages for the
           past 1, 5, and 15 minutes.
    
    top
    P cpu 排序,M内存排序
    top vmstat mpstat
    
    硬盘
    iotop
    顺序io 
    随机io
    
    网络
    iftop
    测试网络ip等
    阿里测
    奇云测http://ce.cloud.360.cn/
    
    
     yum install -y pcre-devel openssl-devel gcc glibc
    
    ./configure --user=www --group=www --prefix=/usr/local/nginx-1.10.1/ --with-http_stub_status_module --with-http_ssl_module
    
    
    nginx配置状态监控
    http://wiki.jiankongbao.com/doku.php/%E6%96%87%E6%A1%A3:%E5%AE%89%E5%85%A8%E6%8C%87%E5%BC%95#nginx_监控
    
    zabbix IPMI snmp jvm    server-agent模式
    
    
    yum install zabbix-server zabbix-web zabbix-server-mysql zabbix-web-mysql mariadb-server mariadb zabbix-agent -y
    
    
    自定义监控项
    [root@Zabbix-sever ~]# cat /etc/zabbix/zabbix_agentd.d/nginx.conf 
    UserParameter=nginx.active,/usr/bin/curl -s http://192.168.86.3:8080/nginx-status|awk 'NR==1{print $NF}' 
    重启zabbix-agent(注意看报错,这里修改)
    在sever端使用zabbix_get测试获取
    [root@Zabbix-sever ~]# zabbix_get -s 192.168.86.3 -p 10050 -k "nginx.active"
    1
    
    smokeping 监控宝就是这样分布式监控,从各个站点ping然后统计在一起
    piwik 流量分析系统
    
    
    
    权限只能分给用户组Permissions can be assigned for user groups only.
    创建用户,选择用户角色
    报警媒介
    action
    添加新主机 后,要确认权限分配
    
    
    交换机上添加snmp
    config t
    snmp-server community public ro
    
    ipmi 使用自定义item,
    
    
    yum install -y zabbix-java-gateway.x86_64 java-1.8.0
    vim /etc/zabbix/zabbix_java_gateway.conf 
    vi /etc/zabbix/zabbix_server.conf 
     systemctl restart zabbix-server.service 
    
    
    cd /usr/local/src
    wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.0.39/bin/apache-tomcat-8.0.39.tar.gz
    tar xf apache-tomcat-8.0.39.tar.gz 
    mv apache-tomcat-8.0.39  /usr/local/
    ln -s /usr/local/apache-tomcat-8.0.39/ /usr/local/tomcat
    /usr/local/tomcat/bin/startup.sh 
    
    
    jmx 三种类型,1无密码认证,2用户名密码验证3,ssl
    
    
    /usr/local/tomcat/bin
    catalina.sh 
    CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote
      -Dcom.sun.management.jmxremote.port=8888
      -Dcom.sun.management.jmxremote.ssl=false
      -Dcom.sun.management.jmxremote.authenticate=false
      -Djava.rmi.server.hostname=192.168.86.7"
    
    ./shutdown.sh
    ./startup.sh
    
    server端systemctl start zabbix-java-gateway.service zabbix-agent
    
    systemctl start zabbix-server.service zabbix-agent.service mariadb.service httpd.service  
    
    
    
    UserParameter=linux_status[*],/etc/zabbix/zabbix_agentd.d/zabbix_linux_plugin.sh "$1" "$2" "$3"
    *传参数
    
    
    AlertScriptsPath=/usr/lib/zabbix/alertscripts
    
    短信通知
    http://www.alidayu.com/
    
    超过300个   使用主动模式
    
    
    
    
     yum provides "*libmysqlclient.so.18*"
    
    --> Finished Dependency Resolution
    Error: Package: zabbix-proxy-mysql-3.0.7-1.el6.x86_64 (zabbix)
               Requires: libmysqlclient.so.16(libmysqlclient_16)(64bit)
    Error: Package: zabbix-proxy-sqlite3-3.0.7-1.el6.x86_64 (zabbix)
               Requires: libnetsnmp.so.20()(64bit)
    Error: Package: zabbix-proxy-mysql-3.0.7-1.el6.x86_64 (zabbix)
               Requires: libnetsnmp.so.20()(64bit)
    Error: Package: zabbix-proxy-mysql-3.0.7-1.el6.x86_64 (zabbix)
               Requires: libmysqlclient.so.16()(64bit)
     You could try using --skip-broken to work around the problem
     You could try running: rpm -Va --nofiles --nodigest
    
    
    最终原因是由于
     rpm -ihv http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
    装了6的rpm应该装7的zabbix repo
    
    install proxy
    [root@node2 zabbix]# yum install -y zabbix-proxy zabbix-proxy-mysql mariadb-server
    
    proxy end
    create database zabbix_proxy character set utf8;
    
    grant all on zabbix_proxy.* to zabbix@localhost identified by 'zabbix_proxy';
    
    grant all on zabbix_proxy.* to zabbix_proxy@localhost identified by 'zabbix_proxy'; 
    
    
    
    [root@node2 zabbix]# cd /usr/share/doc/zabbix-proxy-mysql-3.0.7/
    
    [root@node2 zabbix-proxy-mysql-3.0.7]# zcat schema.sql.gz |mysql -uzabbix_proxy -p zabbix_proxy
    
    
    
    [root@node2 zabbix-proxy-mysql-3.0.7]# egrep -v '^$|^#' /etc/zabbix/zabbix_proxy.conf
    Server=192.168.3.3
    Hostname=zabbix-proxy
    LogFile=/var/log/zabbix/zabbix_proxy.log
    LogFileSize=0
    PidFile=/var/run/zabbix/zabbix_proxy.pid
    DBName=zabbix_proxy
    DBUser=zabbix_proxy
    DBPassword=zabbix_proxy
    SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
    Timeout=4
    ExternalScripts=/usr/lib/zabbix/externalscripts
    LogSlowQueries=3000
    [root@node2 zabbix-proxy-mysql-3.0.7]# systemctl stop zabbix-agent.service
    [root@node2 zabbix-proxy-mysql-3.0.7]# systemctl start zabbix-proxy
    
    
    
    active mode conf
    [root@node2 zabbix]# egrep -v '^$|^#' zabbix_agentd.conf
    PidFile=/var/run/zabbix/zabbix_agentd.pid
    LogFile=/var/log/zabbix/zabbix_agentd.log
    LogFileSize=0
    StartAgents=0
    ServerActive=192.168.3.3
    Hostname=node2.com
    Include=/etc/zabbix/zabbix_agentd.d/*.conf
    
    passive mode conf
    [root@node1 /etc/zabbix]# egrep -v '^$|^#' zabbix_agentd.conf
    PidFile=/var/run/zabbix/zabbix_agentd.pid
    LogFile=/var/log/zabbix/zabbix_agentd.log
    LogFileSize=0
    Server= 192.168.3.3
    Hostname=node1.com
    Include=/etc/zabbix/zabbix_agentd.d/*.conf
    
    
    
    curl -s -X POST -H 'Content-Type:application/json' -d '
    {
        "jsonrpc": "2.0",
        "method": "user.login",
        "params": {
            "user": "zhangsan",
            "password": "123123"
        },
        "id": 1
    }
    ' http://192.168.86.3/zabbix/api_jsonrpc.php
    
    
    curl -s -X POST -H 'Content-Type:application/json' -d '
    {
        "jsonrpc": "2.0",
        "method": "host.get",
        "params": {
            "output": ["host"]
        },
        "auth": "a590ceaa744f3c0b4fed04e52e2575b1",
        "id": 1
    }
    ' http://192.168.86.3/zabbix/api_jsonrpc.php|python -m json.tool
    
    zabbix_get 使用,需要在zabbix_agent.conf中写入server的值,然后在server上执行get命令
    [root@node1 ~]# zabbix_get -s 192.168.3.3 -p 10050 -k "system.cpu.load[all,avg1]"
    0.270000
    如果不是server执行的话:就会出现以下错误
    [root@node1 ~]# zabbix_get -s 192.168.3.4 -p 10050 -k "system.cpu.load[all,avg1]"
    zabbix_get [46203]: Check access restrictions in Zabbix agent configuration
    
    
    vfs.fs.size[/,total].
    
    agent.ping.nodata(15s)
    
    
    zabbix_get -s 192.168.3.4 -p 10050 -k "icmpping"
  • 相关阅读:
    服务器被黑

    ZXW说
    抽象类
    URL参数加密解密过程
    SqlServer 跨服务器 DML
    发布
    C#操作XML小结
    定时指执程序
    SQL语句判断数据库、表、字段是否存在
  • 原文地址:https://www.cnblogs.com/WisWang/p/6537336.html
Copyright © 2011-2022 走看看