Ubuntu 16.10: ウェブベースシステムモニタツールのZabbixをインストールする


Table of Contents

1 Zabbixをインストールする

以下のスクリプトでZabbix serverとZabbix agentをインストールします。Zabbix agentのホスト名(Configuration -> Hosts -> Create HostのHost name)はlocalhostで登録してください。

MYSQL_PASSWDはMySQLのrootのパスワードに、ZABBIX_PASSWDはMySQLのzabbixユーザのパスワードに使います。

#!/bin/shset -eMYSQL_VERSION=5.7[ -z “${MYSQL_PASSWD}” ] && MYSQL_PASSWD=mysql[ -z “${ZABBIX_PASSWD}” ] && ZABBIX_PASSWD=zabbixzabbix_install(){ cat <<EOF | sudo debconf-set-selectionsmysql-server-${MYSQL_VERSION} mysql-server/root_password password ${MYSQL_PASSWD}mysql-server-${MYSQL_VERSION} mysql-server/root_password_again password ${MYSQL_PASSWD}EOF sudo apt install -y zabbix-server-mysql zabbix-frontend-php php-mysql libapache2-mod-php sudo a2enconf zabbix-frontend-php timezone=$(cat /etc/timezone) sudo sed -e ‘s/^post_max_size = .*/post_max_size = 16M/g’ -e ‘s/^max_execution_time = .*/max_execution_time = 300/g’ -e ‘s/^max_input_time = .*/max_input_time = 300/g’ -e “s:^;date.timezone =.*:date.timezone = “${timezone}”:g” -i /etc/php/7.0/apache2/php.ini cat <<EOF | sudo mysql -uroot -p${MYSQL_PASSWD}create database zabbix;grant all privileges on zabbix.* to zabbix@localhost identified by ‘${ZABBIX_PASSWD}’;exitEOF for sql in schema.sql.gz images.sql.gz data.sql.gz; do zcat /usr/share/zabbix-server-mysql/”${sql}” | sudo mysql -uzabbix -p${ZABBIX_PASSWD} zabbix; done sudo sed -e ‘s/# ListenPort=.*/ListenPort=10051/g’ -e “s/# DBPassword=.*/DBPassword=${ZABBIX_PASSWD}/g” -i /etc/zabbix/zabbix_server.conf # Skip setup.php cat <<EOF | sudo tee /etc/zabbix/zabbix.conf.php<?php// Zabbix GUI configuration file.global $DB;$DB[‘TYPE’] = ‘MYSQL’;$DB[‘SERVER’] = ‘localhost’;$DB[‘PORT’] = ‘0’;$DB[‘DATABASE’] = ‘zabbix’;$DB[‘USER’] = ‘zabbix’;$DB[‘PASSWORD’] = ‘${ZABBIX_PASSWD}’;// Schema name. Used for IBM DB2 and PostgreSQL.$DB[‘SCHEMA’] = ”;$ZBX_SERVER = ‘localhost’;$ZBX_SERVER_PORT = ‘10051’;$ZBX_SERVER_NAME = ”;$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;?>EOF sudo a2enmod ssl sudo a2ensite default-ssl # https://bugs.launchpad.net/ubuntu/+source/zabbix/+bug/1692845 Z=http://archive.ubuntu.com/ubuntu/pool/universe/z wget -q -O – ${Z}/zabbix/zabbix_2.4.7+dfsg.orig.tar.xz | tar Jxf – sudo rm -f /usr/share/zabbix/js/prototype.js sudo cp zabbix-2.4.7/frontends/php/js/prototype.js /usr/share/zabbix/js/ rm -rf zabbix-2.4.7 sudo systemctl enable apache2 zabbix-server sudo systemctl restart apache2 zabbix-server # This Hostname is used for Host name in # Configuration -> Hosts -> Create Host. sudo apt install -y zabbix-agent sudo sed -e “s/^Hostname=.*/Hostname=localhost/g” -i /etc/zabbix/zabbix_agentd.conf}zabbix_install

2 Zabbixへアクセスする

以下のどちらかのURLにアクセスします。https経由の場合は証明書を例外的に許可してください。

http://<server>/zabbixhttps://<server>/zabbix

UsernameにAdmin、Passwordにzabbixを入力します(このパスワードはZABBIX_PASSWDとは別のものです)。

0001_Zabbix.png

Android | Linux | SDL - Narrow Escape