rsync は、UNIXシステムにおいて、差分符号化を使ってデータ転送量を最小化し、遠隔地間のファイルやディレクトリの同期を行う
apache benchを使ってみよう
[vagrant@localhost app]$ ab -n 10 -c 10 http://www.hpscript.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking www.hpscript.com (be patient)…..done
Server Software: nginx
Server Hostname: www.hpscript.com
Server Port: 80
Document Path: /
Document Length: 0 bytes
Concurrency Level: 10
Time taken for tests: 3.639 seconds
Complete requests: 10
Failed requests: 2
(Connect: 0, Receive: 0, Length: 2, Exceptions: 0)
Write errors: 0
Non-2xx responses: 10
Total transferred: 3040 bytes
HTML transferred: 1066 bytes
Requests per second: 2.75 [#/sec] (mean)
Time per request: 3638.692 [ms] (mean)
Time per request: 363.869 [ms] (mean, across all concurrent requests)
Transfer rate: 0.82 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 55 62 4.8 64 69
Processing: 732 2269 694.0 2483 2801
Waiting: 717 2256 690.2 2479 2787
Total: 787 2331 695.1 2538 2865
Percentage of the requests served within a certain time (ms)
50% 2538
66% 2754
75% 2792
80% 2855
90% 2865
95% 2865
98% 2865
99% 2865
100% 2865 (longest request)
以下が時間ですな。
Time per request: 3638.692 [ms] (mean)
Time per request: 363.869 [ms] (mean, across all concurrent requests)
これは結構使えるかも。
twilio
Twilioは音声通話、メッセージング(SMS/チャット)、ビデオなどの様々なコミュニケーション手段を、 アプリケーションやビジネスへ容易に組み込むことのできるクラウドAPIサービス
とりあえず、composerで入れてみます。
[vagrant@localhost app]$ php coposer.phar require twilio/sdk
Using version ^5.23 for twilio/sdk
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
– Installing dg/rss-php (v1.2): Downloading (100%)
– Installing twilio/sdk (5.23.1): Downloading (100%)
Writing lock file
Generating autoload files
PHPUnit
品質の良いプロダクトコードを書くことができるようになる。
use PHPUnit\Framework\TestCase; classs HogeTest extends TestCase { public function testHoge() { $stack = []; $this->assertEquals(0, count($stack)); } }
単体テストとは?
単体テスト(ユニットテストと呼ばれることもあります)は、プログラムを構成する比較的小さな単位(ユニット)が個々の機能を正しく果たしているかどうかを検証するテスト
通常、関数やメソッドが単体テストの単位(ユニット)となります。 プログラムが全体として正しく動作しているかを検証する結合テストは、開発の比較的後の段階でQAチームなどによって行なわれることが多いのとは対照的に、単体テストは、コード作成時などの早い段階で開発者によって実施されることが多いのが特徴
コードの内容をよく理解している開発者によって、コード作成と同時か直後に(または、『テスト駆動型開発』Test Driven Development:TDD と呼ばれる開発手法ではコードの作成よりも前に)テストケースが作成されるため、妥当性の高いテストケースを資産として残すことができ、後の拡張開発や改修時にも再利用できる
/etc/zabbix/zabbix_server.conf
/etc/zabbix/zabbix_server.conf
編集していきます。
DBName=zabbix DBUser=zabbix DBPassword=zabbixpassword DBSocket=/var/lib/mysql/mysql.sock
mysql.sockって何? /var/lib/mysqlにmysqlで作成したdatabase一覧がありますね。
zabbix serverを起動
[vagrant@localhost zabbix]$ sudo service zabbix-server start
Starting Zabbix server: [ OK ]
うお!
あ、これやってなかった。
yum install -y zabbix-web zabbix-web-mysql zabbix-web-japanese
こうか?
[vagrant@localhost src]$ cd /usr/share/doc/zabbix-web-3.0.22
[vagrant@localhost zabbix-web-3.0.22]$ cp httpd24-example.conf /etc/httpd/conf.d/zabbix.conf
cp: cannot create regular file `/etc/httpd/conf.d/zabbix.conf’: 許可がありません
[vagrant@localhost zabbix-web-3.0.22]$ sudo httpd24-example.conf /etc/httpd/conf.d/zabbix.conf
sudo: httpd24-example.conf: コマンドが見つかりません
[vagrant@localhost zabbix-web-3.0.22]$ sudo cp httpd24-example.conf /etc/httpd/conf.d/zabbix.conf
Internal Server Error
なぜ?
zabbixを入れていこう
まず、mysqlにログインして、databaseを作ります。
mysql> create database zabbix character set utf8;
Query OK, 1 row affected (0.03 sec)
zabbix, zabbix-server, zabbix-server-mysqlを入れる
yum install -y zabbix zabbix-server zabbix-server-mysql
パッケージ zabbix は利用できません。
パッケージ zabbix-server-pgsql-3.0.22-1.el6.x86_64 はインストール済みか最新バージョンです
パッケージ zabbix-server-mysql-3.0.22-1.el6.x86_64 はインストール済みか最新バージョンです
何もしません
??
zabix-agentをinstall
cd /usr/share/doc
[vagrant@localhost doc]$ cd zabbix-server-mysql-3.0.22
[vagrant@localhost zabbix-server-mysql-3.0.22]$ ls
AUTHORS COPYING ChangeLog NEWS README create.sql.gz
これ、あってんのか??
cat でsql文を読み込ませて、mysqlを実行
cat create.sql | mysq -u root -p zabbix
まじか、これ?
mysql> use zabbix
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+—————————-+
| Tables_in_zabbix |
+—————————-+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
| config |
| dbversion |
| dchecks |
| dhosts |
| drules |
| dservices |
| escalations |
| events |
| expressions |
| functions |
| globalmacro |
| globalvars |
| graph_discovery |
| graph_theme |
| graphs |
| graphs_items |
| group_discovery |
| group_prototype |
| groups |
| history |
| history_log |
| history_str |
| history_text |
| history_uint |
| host_discovery |
| host_inventory |
| hostmacro |
| hosts |
| hosts_groups |
| hosts_templates |
| housekeeper |
| httpstep |
| httpstepitem |
| httptest |
| httptestitem |
| icon_map |
| icon_mapping |
| ids |
| images |
| interface |
| interface_discovery |
| item_application_prototype |
| item_condition |
| item_discovery |
| items |
| items_applications |
| maintenances |
| maintenances_groups |
| maintenances_hosts |
| maintenances_windows |
| mappings |
| media |
| media_type |
| opcommand |
| opcommand_grp |
| opcommand_hst |
| opconditions |
| operations |
| opgroup |
| opinventory |
| opmessage |
| opmessage_grp |
| opmessage_usr |
| optemplate |
| profiles |
| proxy_autoreg_host |
| proxy_dhistory |
| proxy_history |
| regexps |
| rights |
| screen_user |
| screen_usrgrp |
| screens |
| screens_items |
| scripts |
| service_alarms |
| services |
| services_links |
| services_times |
| sessions |
| slides |
| slideshow_user |
| slideshow_usrgrp |
| slideshows |
| sysmap_element_url |
| sysmap_url |
| sysmap_user |
| sysmap_usrgrp |
| sysmaps |
| sysmaps_elements |
| sysmaps_link_triggers |
| sysmaps_links |
| timeperiods |
| trends |
| trends_uint |
| trigger_depends |
| trigger_discovery |
| triggers |
| users |
| users_groups |
| usrgrp |
| valuemaps |
+—————————-+
113 rows in set (0.00 sec)
zabbixを使おう
zabbixとは?
>Zabbixとは、サーバー、ネットワーク、アプリケーションを集中監視するためのオープンソースの統合監視ソフトウェアです。統合監視に必要な監視、障害検知、通知機能を備えています。多数のプラットフォームに対応したZabbixエージェントとSNMPに対応しているため、システム全体をZabbixひとつで監視することが可能です。
zabbix-agent.x86_64 : Zabbix Agent
zabbix-get.x86_64 : Zabbix Get
zabbix-java-gateway.x86_64 : Zabbix java gateway
zabbix-proxy-mysql.x86_64 : Zabbix proxy for MySQL or MariaDB database
zabbix-proxy-pgsql.x86_64 : Zabbix proxy for PostgreSQL database
zabbix-proxy-sqlite3.x86_64 : Zabbix proxy for SQLite3 database
zabbix-release.noarch : Zabbix repository configuration
zabbix-sender.x86_64 : Zabbix Sender
zabbix-server-mysql.x86_64 : Zabbix server for MySQL or MariaDB database
zabbix-server-pgsql.x86_64 : Zabbix server for PostgresSQL database
zabbix-web.noarch : Zabbix web frontend common package
zabbix-web-mysql.noarch : Zabbix web frontend for MySQL
zabbix-web-pgsql.noarch : Zabbix web frontend for PostgreSQL
zabbix-web-japanese.noarch : Japanese font settings for frontend
dev環境、staging環境を作っていこう
単純にDNSはサブドメインを設定するだけですね。
dev.hoge, stg.hogeのドメインを取得していきます。
デプロイはまた考えましょう。。
さあ、zabbix行きましょう。ossなので、vagrantにいれましょうかね。
さくら共有サーバーにansibleで命令
以下のように書く
-e ‘ansible_python_interpreter=/usr/local/bin/python’
インベントリファイルにip, username, passを書くと、
# ansible all -i hosts -m ping -e 'ansible_python_interpreter=/usr/local/bin/python' xx.xxx.xxx.xxx | SUCCESS => { "changed": false, "ping": "pong" } xx.xxx.xxx.xxx | SUCCESS => { "changed": false, "ping": "pong" }
うおおおおおおおおおおおおおおおおおおおおおおおおおおお
まじかーーーーーーーーーーーーーーーーー
ansible.cfg
[defaults] hostfile = ./hosts
# ansible all -m ping -e ‘ansible_python_interpreter=/usr/local/bin/python’
[DEPRECATION WARNING]: [defaults]hostfile option, The key is misleading as it
can also be a list of hosts, a directory or a list of paths , use [defaults]
inventory=/path/to/file|dir instead. This feature will be removed in version
2.8. Deprecation warnings can be disabled by setting deprecation_warnings=False
in ansible.cfg.
xx.xxx.xxx.xxx | SUCCESS => {
“changed”: false,
“ping”: “pong”
}
xx.xxx.xxx.xxx | SUCCESS => {
“changed”: false,
“ping”: “pong”
}