Zabbix Implementation Monitoring | Zabbix Monitoring Example

Keywords: Zabbix RPM MySQL MariaDB

I. overview

zabbix is an enterprise-level open source solution based on WEB interface to provide distributed system monitoring and network monitoring functions. zabbix can monitor all kinds of network parameters to ensure the safe operation of the server system, and provide flexible notification mechanism to enable system administrators to quickly locate and solve various problems. zabbix consists of two parts, zabbix server and optional component zabbix agent. zabbix server can provide remote server/network status monitoring, data collection and other functions through SNMP, zabbix agent, ping, port monitoring and other methods. It can run on Linux, Solaris, HP-UX, AIX, Free BSD, Open BSD, OS X and other platforms.

2. Implementation and application of zabbix

server1:172.25.28.1 rhel7.3

server2:172.25.28.2 rhel6.3

[root@server1 ~]# ls

fping-3.10-1.el7.x86_64.rpm

iksemel-1.4-2.el7.centos.x86_64.rpm

zabbix-agent-3.4.6-1.el7.x86_64.rpm

zabbix-get-3.4.6-1.el7.x86_64.rpm

zabbix-java-gateway-3.4.6-1.el7.x86_64.rpm

zabbix-proxy-mysql-3.4.6-1.el7.x86_64.rpm

zabbix-server-mysql-3.4.6-1.el7.x86_64.rpm

zabbix-web-3.4.6-1.el7.noarch.rpm

zabbix-web-mysql-3.4.6-1.el7.noarch.rpm

php-mbstring-5.4.16-42.el7.x86_64.rpm

php-bcmath-5.4.16-42.el7.x86_64.rpm

[root@server1 ~]# yum install -y zabbix-server-mysql-3.4.6-1.el7.x86_64.rpm zabbix-web-3.4.6-1.el7.noarch.rpm  zabbix-web-mysql-3.4.6-1.el7.noarch.rpm fping-3.10-1.el7.x86_64.rpm  iksemel-1.4-2.el7.centos.x86_64.rpm  php-*

Installed:

  fping.x86_64 0:3.10-1.el7                    iksemel.x86_64 0:1.4-2.el7.centos     

  php-bcmath.x86_64 0:5.4.16-42.el7            php-mbstring.x86_64 0:5.4.16-42.el7   

  zabbix-server-mysql.x86_64 0:3.4.6-1.el7     zabbix-web.noarch 0:3.4.6-1.el7       

  zabbix-web-mysql.noarch 0:3.4.6-1.el7      

[root@server1 ~]# yum install mariadb-server -y

[root@server1 ~]# systemctl start mariadb

[root@server1 ~]# mysql_secure_installation

[root@server1 ~]# mysql -predhat

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 10

Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;

Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'westos';

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> Bye

[root@server1 ~]# cd /usr/share/doc/zabbix-server-mysql-3.4.6/

[root@server1 zabbix-server-mysql-3.4.6]# ls

AUTHORS  ChangeLog  COPYING  create.sql.gz  NEWS  README

[root@server1 zabbix-server-mysql-3.4.6]# zcat create.sql.gz | mysql -u zabbix -p zabbix

Enter password:

[root@server1 zabbix-server-mysql-3.4.6]# cd /etc/zabbix/

[root@server1 zabbix]# vim zabbix_server.conf

Password Local Connection

[root@server1 zabbix]# cd /etc/httpd/conf.d/

[root@server1 conf.d]# vim zabbix.conf

[root@server1 conf.d]# systemctl start zabbix-server

[root@server1 conf.d]# systemctl start httpd

[root@server1 ~]# yum install -y zabbix-agent-3.4.6-1.el7.x86_64.rpm

[root@server1 ~]# systemctl start zabbix-agent

Client access:


Note: The default login user is Admin password is zabbix

Enable host

1. Monitor Host

server2:

[root@server2 ~]# rpm -ivh zabbix-agent-3.4.6-1.el6.x86_64.rpm

warning: zabbix-agent-3.4.6-1.el6.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY

Preparing...                ########################################### [100%]

   1:zabbix-agent           ########################################### [100%]

[root@server2 ~]# cd /etc/zabbix/

zabbix_agentd.conf  zabbix_agentd.d

[root@server2 zabbix]# vim zabbix_agentd.conf

Note: Serr2 must be parsed

[root@server2 zabbix]# /etc/init.d/zabbix-agent start

Starting Zabbix agent:                                     [  OK  ]

[root@server2 zabbix]# netstat -antlp

Active Internet connections (servers and established)

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name  

tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      895/sshd           

tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      971/master         

tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      1433/zabbix_agentd 

tcp        0      0 172.25.28.2:22              172.25.28.250:59098         ESTABLISHED 1355/sshd          

tcp        0      0 :::22                       :::*                        LISTEN      895/sshd           

tcp        0      0 ::1:25                      :::*                        LISTEN      971/master         

tcp        0      0 :::10050                    :::*                        LISTEN      1433/zabbix_agentd 

Method 1:

1. ZBS must be green

2. Enable automatic discovery in configuration > action > automatic discovery

 

3. Configuration > Automatic Discovery

Click Local network

Modification Scope Start Update

4. Waiting to be discovered

Method two:

1. Discontinue automatic discovery

2. Disable automatic discovery rules

3. Stop hosting and delete hosts

4. Create a host

Template > Selection

Start with small additions and then large additions

5, add

6, waiting

Method three:

1. Delete existing hosts

2. Automatically register and create actions

3. Define the name

4, add operation (small word)

5. Modify operation type to add host

6. Click Add (Small Words)

7. Similarly, click New Add to Host Group Selection

8. The same way to add a template Association

9. Add (small words)

10, add (big characters)

11, waiting

 

Method 4: API interface

https://www.zabbix.com/documentation/3.4/manual/api

[root@server1 ~]# systemctl start zabbix-agent

1,[root@server1 ~]# vim zabbix-api.sh

curl -s -X POST -H 'Content-Type:application/json' -d '

{

    "jsonrpc": "2.0",

    "method": "user.login",

    "params": {

        "user": "Admin",

        "password": "redhat"

    },

    "id": 1,

    "auth": null

}' http://172.25.28.1/zabbix/api_jsonrpc.php | python -m json.tool

[root@server1 ~]# chmod +x zabbix-api.sh

[root@server1 ~]# ./zabbix-api.sh

{

    "id": 1,

    "jsonrpc": "2.0",

    "result": "288a283c7a467b2df2529326c2e77e0d"

}

//Get "result": "288a283c7a467b2df2529326c2e77e0d", which is very important and must be consistent

2,[root@server1 ~]# vim zabbix-api.sh

curl -s -X POST -H 'Content-Type:application/json' -d '

{

    "jsonrpc": "2.0",

    "method": "host.get",

    "params": {

        "output": [

            "hostid",

            "host"

        ],

        "selectInterfaces": [

            "interfaceid",

            "ip"

        ]

    },

    "id": 2,

    "auth": "2e71445ea0ae33cb19be5a77dfb439a5"

}' http://172.25.28.1/zabbix/api_jsonrpc.php | python -m json.tool

[root@server1 ~]# ./zabbix-api.sh

{

    "id": 2,

    "jsonrpc": "2.0",

    "result": [

        {

            "host": "Zabbix server",

            "hostid": "10084",

            "interfaces": [

                {

                    "interfaceid": "1",

                    "ip": "127.0.0.1"

                }

            ]

        },

        {

            "host": "server2",

            "hostid": "10254",

            "interfaces": [

                {

                    "interfaceid": "2",

                    "ip": "172.25.28.2"

                }

            ]

        }

    ]

}

3,Delete host

[root@server1 ~]# vim zabbix-api.sh

curl -s -X POST -H 'Content-Type:application/json' -d '

{

    "jsonrpc": "2.0",

    "method": "host.delete",

    "params": [

        "10254"

    ],

    "id":2,

    "auth": "288a283c7a467b2df2529326c2e77e0d"

}' http://172.25.28.1/zabbix/api_jsonrpc.php | python -m json.tool



[root@server1 ~]# ./zabbix-api.sh

{

    "id": 2,

    "jsonrpc": "2.0",

    "result": {

        "hostids": [

            "10254"

        ]

    }

}

//Browser Monitor View Host Deleted

4,Add host

[root@server1 ~]# vim zabbix-api.sh

curl -s -X POST -H 'Content-Type:application/json' -d '

{

    "jsonrpc": "2.0",

    "method": "host.create",

    "params": {

        "host": "server2",

        "interfaces": [

            {

                "type": 1,

                "main": 1,

                "useip": 1,

                "ip": "172.25.28.2",

                "dns": "",

                "port": "10050"

            }

        ],

        "groups": [

            {

                "groupid": "2"

            }

        ],

        "templates": [

            {

                "templateid": "10001"

            }

        ],

       "inventory_mode":0,

       "inventory":{

       "macaddress_a": "01234",

       "macaddress_b": "56768"

       }

       },

    "id": 2,

    "auth": "2e71445ea0ae33cb19be5a77dfb439a5"

}' http://172.25.28.1/zabbix/api_jsonrpc.php | python -m json.tool



[root@server1 ~]# ./zabbix-api.sh

{

    "id": 2,

    "jsonrpc": "2.0",

    "result": {

        "hostids": [

            "10254"

        ]

    }

}

Browser View:

The method of groupid determination:

Click on linux servers

groupid appears in the browser address bar

Tempeid determination method is the same (search filtering can also be used)

 

Second, monitor apache services

1. Add Host

2, click server2

3, Template > Selection

Add > Update

 

3. Monitoring database

[root@server1 ~]# cd /etc/zabbix/zabbix_agentd.d/

[root@server1 zabbix_agentd.d]# vim userparameter_mysql.conf

[root@server 1 zabbix_agent d.d]# cd/var/lib/zabbix] does not have this directory and needs to be established

-bash: cd: /var/lib/zabbix: No such file or directory

[root@server1 zabbix_agentd.d]# mkdir /var/lib/zabbix

[root@server 1 zabbix_agent d.d]# cd/var/lib/zabbix/ Create hidden configuration files

[root@server1 zabbix]# vim .my.cnf

[mysql]

user=root

password=redhat  Database login password

socket=/var/lib/mysql/mysql.sock



[mysqladmin]

user=root

password=redhat

socket=/var/lib/mysql/mysql.sock

//Both users are mentioned in userparameter_mysql.conf and need to write related statement blocks.

 

[root@server1 zabbix_agentd.d]# systemctl restart zabbix-agent

Browser Add Template Update

Observation of database operation

Posted by carefree on Sat, 11 May 2019 12:49:35 -0700