goo blog サービス終了のお知らせ 

かけがえのない日々

なんややんや。にょろにょろ。

APACHE2 アクセスログフォーマット

2006年09月05日 | unix
gif,jpg,cssへのアクセスをログに記録しない

SetEnvIf Request_URI ".(gif)|(jpg)|(css)$" nolog


wormからのアクセスをログに記録しない対策)

SetEnvIf Request_URI "cmd.exe" nolog
SetEnvIf Request_URI "root.exe" nolog
SetEnvIf Request_URI "Admin.dll" nolog
SetEnvIf Request_URI "NULL.IDA" nolog
SetEnvIf Request_URI "^/_mem_bin/" nolog
SetEnvIf Request_URI "^/_vti_bin/" nolog
SetEnvIf Request_URI "^/c/" nolog
SetEnvIf Request_URI "^/d/" nolog
SetEnvIf Request_URI "^/msadc/" nolog
SetEnvIf Request_URI "^/MSADC/" nolog
SetEnvIf Request_URI "^/scripts/" nolog
SetEnvIf Request_URI "^/default.ida" nolog

WebDAVの脆弱性を狙った攻撃への対策
LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
 ↓
LogFormat "%h %l %u %t "%!414r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined


CustomLog logs/access_log combined

CustomLog logs/access_log combined env=!nolog ← env=!nologを追記


メールの存在確認

2006年07月21日 | unix
##メールの存在確認
> nslookup
> set type=mx
> example.com
Server: *******
Address: ***.***.*.*
example.com MX preference = 10,mail exchanger = mail.example.com
example.com nameserver = ns.example.com
mail.example.com internet address = ww.xx.yy.zz
ns.example.com internet address = ***.***.**.**


> telnet
Microsoft (R) Windows 2000 (TM) Version 5.00 (Build 2195)
Microsoft Telnet クライアントへようこそ Telnet Client Build 5.00.99201.1
エスケープ文字は 'CTRL+]' です
Microsoft Telnet> open mail.example.com 25
接続中: mail.example.com...

220 SMTP Server service ready;
helo my.example.com
250 mail.example.com
mail from: <>
250 OK
rcpt to: <joe@example.com>
250 OK
rcpt to: <bogus_sow5nt2df@example.com>
550 Mailbox unavailable <sow5nt2df@example.com>
quit
221 closing transmission channel

ボトルネック【I/O】

2006年05月04日 | unix
■ディスクI/Oボトルネックの測定(Linuxの場合)
# vmstat 1 5
   procs                      memory    swap          io     system         cpu
 r  b  w   swpd   free   buff  cache  si  so    bi    bo   in    cs  us  sy  id
 0  0  0   3604   3580  23580 187696   0   1     0     1    1     1   0   0   1
 0  0  0   3612   3580  23592 187636   0   8   148    96 1432   291   0   7  93
 0  0  0   3612   3484  23624 187756   0   0   312   332 1376   321   0  10  90
 0  0  0   3620   3456  23616 187772   0   8   164    80 1301   320   0   6  94
 0  0  0   3620   3600  23636 187772   0   0   488    64 1340   318   0   8  91

ここではbi/boの部分を見ます。bi: Blocks received from a block device (blocks/s).
, bo: Blocks sent to a block device (blocks/s)。どのくらいが適正値かというのは予算によります。一番お金をかけた場合だとストレージのキャッシュが十分に積まれていて、どんなにディスクにアクセスしてもbi/boが0というパターンになります。(きちんとディスクに書き込みを完了する前にドライブが書き込み完了を返す)


ボトルネック【ネットワーク】

2006年05月04日 | unix
■ネットワークボトルネックの測定(UNIXの場合)
# netstat -an | wc -l
3050

この数字がTCPコネクション数とほぼ同等です(厳密にはESTABLISHED,TIME_WAIT,FIN_WAIT等の総数。余計な部分は許容誤差ということで)。


ボトルネック【CPU】

2006年05月04日 | unix
■CPUボトルネックの測定(UNIXの場合)
# top
151 processes: 150 sleeping, 1 running, 0 zombie, 0 stopped
CPU0 states:  0.4% user,  0.5% system,  0.0% nice, 98.1% idle
CPU1 states:  0.1% user,  0.5% system,  0.0% nice, 98.4% idle
Mem:   513596K av,  442136K used,   71460K free,       0K shrd,   77992K buff
Swap: 1044184K av,   14120K used, 1030064K free                  208420K cached

CPU0と1の2個があって、それぞれidleが98%以上なので問題ないですね。

# w

12:08pm  up 171 days,  1:20,  1 user,  load average: 1.22, 1.02, 1.97

ロードアベレージは処理を待っているプロセスの平均数


ボトルネック【メモリ】

2006年05月04日 | unix
■メモリボトルネックの測定(Linuxの場合)
# top
151 processes: 150 sleeping, 1 running, 0 zombie, 0 stopped
CPU0 states:  0.4% user,  0.5% system,  0.0% nice, 98.1% idle
CPU1 states:  0.1% user,  0.5% system,  0.0% nice, 98.4% idle
Mem:   513596K av,  442136K used,   71460K free,       0K shrd,   77992K buff
Swap: 1044184K av,   14120K used, 1030064K free                  208420K cached

512MBのメモリを搭載しているマシンで、442M程度のメモリを使用していて70M程度のメモリしか空きがない、と読み取れますが、それは厳密には間違いです。もっと見てみましょう。

# free
             total       used       free     shared    buffers     cached
Mem:        513596     443556      70040          0      78340     209196
-/+ buffers/cache:     156020     357576
Swap:      1044184      14120    1030064

Linuxの場合空いるメモリはすべてCacheにまわそうとします。それがtopに出てくる数字です。では空いているメモリでCacheで使われている分を減らした分はどのくらいかを調べるにはfreeコマンドでの実行結果の2行目を見ます。これを見ると357MBくらい空いているのがわかります。よってこのマシンはメモリに大分余裕があると見ることができます。

※参考http://nosa.cocolog-nifty.com/sanonosa/cat1060251/index.html