Skip to content

k2works/zabbix_introduction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zabbix入門

目的

Zabbixのインストール・設定の解説

前提

ソフトウェア バージョン 備考
OS X 10.8.5
Chef Development Kit 0.1.0
vagrant 1.6.0

構成

詳細

$ chef generate app zabbix_introduction
$ cd zabbix_introduction
$ git add .
$ git commit -am "セットアップ"
$ git create
$ git push origin master

zabbixのインストール

Zabbix SIAのyumレポジトリ登録

site-cookbooks/zabbix22/recipes/base.rb

Zabbixサーバのインストール

site-cookbooks/zabbix22/recipes/server.rb
site-cookbooks/zabbix22/recipes/database.rb

Webインターフェースのインストール

site-cookbooks/zabbix22/recipes/web.rb

zabbixエージェントのインストール

site-cookbooks/zabbix22/recipes/agent.rb

データベースのインストール

cookbooks/zabbix_introduction/Berksfile

cookbook "mysql"
cookbook "database"

プロビジョニング実行

$ cd cookbooks/zabbix_introduction
$ vagrant up --provision

名前解決に失敗する場合は以下を実行してい再度プロビジョニング実行

$ vagrant ssh
$ echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null

初期データ投入

$ vagrant ssh host1
$ cd /usr/share/doc/zabbix-server-mysql-2.2.5/create/
$ cat schema.sql images.sql data.sql | mysql -uzabbix -pzabbixpassword zabbix

プロビジョニング・初期データ投入が完了したら_http://192.168.33.10/zabbix/_にアクセスしてセットアップ。

Database name zabbix
User zabbix
Password zabbixpassword
ログインUsername Admin
ログインPassword zabbix

zabbixサーバーが起動していない場合はサービスを再起動する

$ vagrant ssh
$ sudo service zabbix-server restart

Zabbixのアップグレード

サーバーのアップグレード

$ service zabbix-server stop
$ mysqldump -u zabbix -p zabbix > /root/zabbix.dump
$ cp -r /etc/zabbix /root/zabbix-conf.backup
$ yum update zabbix zabbix-server zabbix-server-mysql zabbix-web zabbix-web-mysql
$ service zabbix-server start

エージェントのアップグレード

$ service zabbix-agent stop
$ cp /etc/zabbix/zabbix_agentd.conf /root
$ rpm -Fvh zabbix-agent-2.2.3.1.el6.JP.x86_64.rpm
$ yum update zabbix-agent
$ service zabbix-agent start

サーバー

site-cookbooks/zabbix22/templates/default/zabbix_server.conf.erb
site-cookbooks/zabbix22/templates/default/zabbix.conf.erb

サーバーにエージェントをインストールした場合Server=127.0.0.1

クライアント

site-cookbooks/zabbix22/templates/default/zabbix_agentd.conf.erb

Apache Webサーバの監視

コンテンツが正常に表示できなければWebサービスを再起動する

ウェブ監視の設定

001 002

トリガーの設定

003 004

アクションの設定

005 006 007 008

リモートコマンドの許可とsudoの設定

/etc/zabbix/zabbix_agentd.conf

EnableRemoteCommands=1

監視対象のサーバーで、rootユーザでvisudoコマンドを実行する

#Defaults requiretty
・・・
zabbix localhost=(root) NOPASSWD:/etc/init.d/httpd
zabbix ALL=NOPASSWD: ALL

Webサーバのコネクション数の監視

Apacheのステータス取得の設定

_/etc/httpd/mods-enabled/status.conf_が有効になっているか確認する

ユーザーパラメータの設定

/etc/zabbix/zabbix_agentd.conf

UserParameter=apache.con.num,sudo /usr/sbin/apachectl status|grep "requests currently being processed"|awk '{print $1}'
アイテムの設定

009

MySQLデータベースサーバの監視

MySQLデータベースにアクセスし、正常に値が取得できなければメールで通知する

ODBCの設定

/etc/odbcinst.ini
/etc/odbc.ini

アイテムの設定

010

トリガーの設定

011

アクションの設定

MySQLデータベースの負荷状況を監視する

MySQLデータベースサーバのステータス取得の設定
ユーザパラメータの設定

/etc/zabbix/zabbix_agentd.conf

UserParameter=mysql.threads_created,sudo /usr/bin/mysqladmin extended-status|grep Threads_created|awk '{print $4;}'
UserParameter=mysql.threads_running,sudo /usr/bin/mysqladmin extended-status|grep Threads_running|awk '{print $4;}'
UserParameter=mysql.connections,sudo /usr/bin/mysqladmin extended-status|grep Connections|awk '{print $4;}'
UserParameter=mysql.query_per_sec_avg,sudo /usr/bin/mysqladmin status|awk '{print $22;}'
UserParameter=mysql.max_connections,sudo /usr/bin/mysqladmin variables|grep max_connections|awk '{print $4;}'
UserParameter=mysql.thread_cache_size,sudo /usr/bin/mysqladmin variables|grep thread_cache_size|awk '{print $4;}'
アイテムの設定

MySQL Connections

012

MySQL max_connection

013

MySQL Query per sec avg

014

MySQL Threads_created

015

MySQL thread_cache_size

016

参照

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published