WARN|ERR|FAIL|CRIT

It is possible to specify up to 8 levels in the error log up to which level errors should be recorded. set to “LogLevel” to specify.

LogLevel to record.
The level that can be set are as follows.

Level Meaning
A serious error that the emerg server can not run.

-Errors: More serious than alert crit
-Crit; Serious error
-Error: Error
-Warn: Warning
-Notice: Notification message
-Info: Server information, information for debug debugging.

egrep i

egrep [option][search string pattern] filename

Search for files with a search string pattern and a command to output matching lines.
Search for [File] with [Search string pattern] and output matching lines.
You can use regular expressions more advanced than grep.

まず適すとファイルを作ります。
yahoo.txt

1	8411	東証1部	(株)みずほフィナンシャルグループ	03/20	175.5	+0.75%	+1.3	106,216,600	掲示板
2	5020	東証1部	JXTGホールディングス(株)	03/20	542.9	+0.37%	+2	42,028,800	掲示板
3	8306	東証1部	(株)三菱UFJフィナンシャル・グループ	03/20	573.3	-0.26%	-1.5	33,412,300	掲示板
4	3765	東証1部	ガンホー・オンライン・エンターテイメント(株)	03/20	405	+5.74%	+22	31,808,200	掲示板
5	4347	東証JQS	ブロードメディア(株)	03/20	94	+9.30%	+8	29,353,800	掲示板
6	4755	東証1部	楽天(株)	03/20	1,011	+4.12%	+40	22,479,800	掲示板
7	9973	東証JQS	(株)小僧寿し	03/20	62	+44.19%	+19	18,652,400	掲示板
8	8604	東証1部	野村ホールディングス(株)	03/20	409.9	-2.24%	-9.4	18,591,800	掲示板
9	3092	東証1部	(株)ZOZO	03/20	2,025	+1.25%	+25	18,435,700	掲示板
10	4565	マザーズ	そーせいグループ(株)	03/20	1,421	+15.91%	+195	18,249,700	掲示板

続いて、egrep -i

[vagrant@localhost tests]$ egrep -i "グループ" yahoo.txt
1       8411    東証1部 (株)みずほフィナンシャルグループ        03/20   175.5  +0.75%   +1.3    106,216,600     掲示板
3       8306    東証1部 (株)三菱UFJフィナンシャル・グループ  03/20   573.3  -0.26%   -1.5    33,412,300      掲示板
10      4565    マザーズ        そーせいグループ(株)    03/20   1,421   +15.91%+195     18,249,700      掲示板

ほう。

shell 文字列長のオプション -n

-n:文字列長が 0 より大なら真

#!/bin/sh

index="hoge"
if [ -n $index ]; then
	echo "文字列長が0より大です"
fi

[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
[vagrant@localhost tests]$ ./test.sh
文字列長が0より大です

#!/bin/sh

index=""
if [ -n $index ]; then
	echo "文字列長が0より大です"
fi

[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
[vagrant@localhost tests]$ ./test.sh
文字列長が0より大です

あれええええええええええええええええええ??

ERROR 1068 (42000): Multiple primary key defined

ERROR 1068 (42000): Multiple primary key defined
複合primary keyで書こうとするとエラーになった。

create table hoge(
	submit_no int not null,
	seq_no int not null,
	report_file_name varchar(128),
	create_userid char(20) not null,
	create_date date not null,
	update_userid char(20),
	update_date date,
	primary key(submit_ms_no, seq_no)	
);

mysql> describe hoge;
+———————-+————–+——+—–+———+——-+
| Field | Type | Null | Key | Default | Extra |
+———————-+————–+——+—–+———+——-+
| submit_no | int(11) | NO | PRI | NULL | |
| seq_no | int(11) | NO | PRI | NULL | |
| report_img_file_name | varchar(128) | YES | | NULL | |
| create_userid | char(20) | NO | | NULL | |
| create_date | date | NO | | NULL | |
| update_userid | char(20) | YES | | NULL | |
| update_date | date | YES | | NULL | |
+———————-+————–+——+—–+———+——-+
7 rows in set (0.00 sec)

なるほど。。create文がそもそも違うのね。

MySQLで複数のPrimary Key

一つのテーブルで複数のprimary keyって設定できるの?

submit_noとseq_noでprimary keyを設定するとします。

create table rep_image_info(
	submit_no int not null primary key,
	seq_no int not null primary key,
	report varchar(128),
	create_user char(20),
	create_date date,
	update_user char(20),
	update_date date	
);

この場合、submit_noとseq_noの組み合わせに対して主キーを持つようです。なるほどにゃー
よって、二つでだけでなく、三つ、四つのprimary keyもあるわけですね。

SLA

SLA is an abbreviation of Service Level Agreement, which is an agreement on the level of service (definition, scope, content, achievement goals, etc.) established between the provider of the service and its users. This is a statement to the extent that the service provider can guarantee the quality to the contractor.

SLAs are often used mainly for communication services, cloud services, rental servers, etc. We define service definition and guarantee items such as communication speed and upper limit of use stop time, and if the service quality falls below the guarantee value of SLA, reduction of charge will be performed.

ELB access log

ELBでアクセスログが取得できる。

2014-03-07T07:25:38.285777Z elber 130.0.237.XX:37522 172.31.4.218:80 0.000066 0.00105 0.000037 404 404 0 570 "GET http://54.249.27.XX:80/actus4/ HTTP/1.1"
2014-03-07T07:26:43.731149Z elber 77.50.22.XXX:53477 172.31.4.218:80 0.000053 0.000866 0.000053 200 200 0 10 "GET http://54.249.27.XX:80/ HTTP/1.0"
2014-03-07T07:26:44.410747Z elber 77.50.22.XXX:53656 172.31.4.218:80 0.000052 0.000853 0.000039 404 404 0 168 "GET http://54.249.27.XX:80/foltia/ HTTP/1.0"
2014-03-07T07:26:45.084730Z elber 77.50.22.XXX:53839 172.31.4.218:80 0.000061 0.000874 0.000035 404 404 0 168 "GET http://54.249.27.XX:80/epgrec/do-record.sh HTTP/1.0"
2014-03-07T07:28:12.386207Z elber 189.206.75.XX:64289 172.31.4.218:80 0.000062 0.000924 0.000035 404 404 0 168 "GET http://54.249.27.XX:80/manager/html HTTP/1.1"

問題は、項目。

timestamp
The time accessed by the Client. UTC time, recorded in ISO 8601 format.
2014-02-15T23: 39: 43. 945958 Z

Name of ELB
ELB Name: test-loadbalancer

Client
Port Client IP address and port number
192.168.131.39.2817

Backend
port IP address and port number of the instance to which communication was distributed by ELB. This will tell you which server it was assigned to 10.0.0.0:80

request_processing_time
The time between the ELB receiving a request from the client and sending the request to the instance
0.000073

backend_processing_time
The time it takes for the ELB to send a request to an instance and the instance returns a response.
0.001048

response_processing_time
The time from when the ELB receives a response from an instance to when it returns a response to the client.
0.000057

elb_status_code
response status code.
200

backend_status_code
Response status code of the instance to which the ELB sent the request.
200

received_bytes
Size of received request (bytes)
0

sent_bytes
Size of sent request (bytes)
29

request
request from a client
“GET http://www.example.com:80/HTTP/1.1”

User Agent perspective

How to investigate user agent?
As an example, the user agent for IE9 is described as follows.

Mozilla / 5.0 (compatible;MSIE 9.0; Windows NT 6.1; Trident/5.0)

Application name
It corresponds to the “Mozilla” part. It is used in the sense that it has the function of the type of browser or its application.

Application Version
In the “5.0” part after Mozilla, it indicates the version of the application.

Platform token
It corresponds to the “Windows NT 6.1” part. It will be the display about OS.

Version Token
It corresponds to the part of “MISE 9.0”.Displaying browser version.

Compatibility Flags
It corresponds to the “Compatible” part. It shows the compatibility with Internet Explore.

Rendering engine
It corresponds to the part of “Trident/5.0”. Shows software that causes the browser to display the requested content.

Internet Explore
ver.11

Mozilla / 5.0 (Windows NT 6.3; ARM; Trident / 7.0; Touch; MALNJS; rv: 11.0) like Gecko

ver.10

Mozilla / 5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW 64; Trident / 6.0)

Chrome

Mozilla / 5.0 (Windows NT 5.1) AppleWebKit / 535.11 (KHTML, like Gecko) Chrome / 17.0.963.79 Safari / 535.11

Firefox

Mozilla / 5.0 (Windows NT 6.1; rv: 11.0) Gecko / 20100101 Firefox / 11.0

Safari

Mozilla / 5.0 (Macintosh; U; Intel Mac OS X; en-jp) AppleWebKit / 523.12 (KHTML, like Gecko) Version / 3.0.4 Safari / 523.12

Android

Mozilla / 5.0 (Linux; Android 4.4.2; 302KC Build / 101.0.2c00) AppleWebKit / 537.36 (KHTML, like Gecko) Version / 4.0 Chrome / 30.0.0.0 Mobile Safari / 537.36 YJApp-ANDROID jp.co.yahoo.android. ybrowser / 1.7.5

なるほど、内容よく見ると、どのブラウザか一発でわかりますね。まあ、一般的にユーザーエージェントは偽装されるのであまり意味ないかもしれませんが。そういえば、IPって偽装できるんでしょうか??? Chrome Extensionで、Hotspot Shieldを使えば偽装できるようですが。。

ELB http 460

What is HTTP 460 on ELB
The load balancer received a request from a client, but the client closed the connection with the load balancer before the idle timeout expired.

Check if the client timeout period is longer than the load balancer idle timeout period. Before the client timeout period expires, make sure that target returns a response to the client, or if the client supports it, increase the client timeout period to match the load balancer idle timeout.

301 redirect and 302 redirect

The 301 redirect is “permanent redirect” and “permanent transfer”, while the 302 redirect is “temporary redirect” and “temporary transfer”.

Consider that a URL set to 301 redirect will not appear in the index. However, the 301 redirect takes over the information of the transfer source (old URL) to the transfer destination (new URL).