Hatena::ブログ(Diary)

”アウトプットしろ” とか本に書いてあったから。。『アウしろブログ』 RSSフィード Twitter

2011-06-12 〜続〜 ログ調査時に役立つであろうコマンド達の組み合わせ このエントリーを含むブックマーク

前回に引き続きログ調査時に役立つ合わせ技を少々

grep した結果の前後 N(以下 2行で説明) 行を表示

$ grep hoge /usr/local/apache/log/access_log -C 2

grep した結果の後 N 行を表示 (After)

$ grep hoge /usr/local/apache/log/access_log -A 2

grep した結果の前 B 行を表示 (Before)

$ grep hoge /usr/local/apache/log/access_log -B 2

grep した結果の前後 N 行を表示 -C 2 と同等

$ grep hoge /usr/local/apache/log/access_log -B 2 -A 2

grep した結果の行数を表示

$ grep hoge /usr/local/apache/log/access_log -c

4 ← 行数

or 検索

$ grep -E 'hoge|fuga' /usr/local/apache/log/access_log

or

$ egrep 'hoge|fuga' /usr/local/apache/log/access_log

こっちの方がいいかもという噂が

それではちょっとした連携技

$ egrep 'hoge|fuga' /usr/local/apache/log/access_log -C 3 | awk '{print $1}' > egrep_ip.txt

トラックバック - http://d.hatena.ne.jp/QURULI/20110612

2011-06-10 tail コマンドによる ログ調査 + awk このエントリーを含むブックマーク

「ログ調査するときによく使うコマンド組み合わせ」(tail, awk)


tail でリアルタイムにログを見る

> tail -s 0 -f /apache/log/access_log(error_log)

-f オプション --follow ファイルが大きくなるたびに追加されたデータを出力

-s オプション --sleep-interval リアルタイム表示しているファイルのチェックを指定した秒数間隔でチェックします。

awk と組み合わせる。

例えば下記の様なログの場合

> tail -s 0 -f /apache/log/access_log | awk {'print $6'}

 

"GET

"GET

"GET

"GET

"POST

トラックバック - http://d.hatena.ne.jp/QURULI/20110610

2011-06-08 〜 VLAN 基本設定 〜 このエントリーを含むブックマーク

前回に引き続きスイッチを触った際の主に VLAN 周りの事を書きます。

今回は実際に VLAN を作成する所まで行います。 ・・・眠い

まずはシリアル接続 ※MacBook Air 11in

> screen /dev/tty.usbserial-* 9600

特権モードに移行

> enable ※enと省略してもOK

console# enable

Global Config モード? から VLAN データベースへ入る。

console# config ※coと省略してもOK

console(config)# vlan database

VLAN を作成してみます。

console(config-vlan)# vlan 2

console(config-vlan)# vlan 3

console(config-vlan)# vlan 4

console(config-vlan)# vlan 5

console(config-vlan)# end

現在の状況を確認。

Vlan Name Ports Type Authorization

        • ----------------- --------------------------- ------------ -------------

1     1   g(1-48),ch(1-8)   other   Required

2     2   Permanent   Required

3     3   permanent   Required

4     4    permanent   Required

5     5    permanent   Required

作成した VLAN へポートを属させる、と共に g1 をトランクポートにしてみます。

console# config

console(config)# interface ethernet g1

console(config-if)#

console(config-if)# switchport mode trunk

console(config-if)# switchport trunk

console(config-if)# switchport trunk allowed vlan add 3

console(config-if)# switchport trunk allowed vlan add 5

現在の状況を確認。

console(config-vlan)# end

console# show vlan

Vlan Name Ports Type Authorization

---- ----------------- --------------------------- ------------ -------------

1 1 g(1-48),ch(1-8) other Required

2 2 permanent Required

3 3 g1 permanent Required

4 4 permanent Required

5 5 g1 permanent Required


ポートにVLANを割り当てます。

console(config-if)# switchport access vlan 2

console(config-if)# interface ethernet g10

console(config-if)# switchport access vlan 2

console(config-if)# interface ethernet g11

console(config)# interface range ethernet g12-20

console(config-if)# switchport access vlan 4

現在の状況を確認。

console(config-vlan)# end

console# show vlan

Vlan Name Ports Type Authorization

---- ----------------- --------------------------- ------------ -------------

1 1 g(1-9,21-48),ch(1-8) other Required

2 2 g(10-11) permanent Required

3 3 g1 permanent Required

4 4 g(12-20) permanent Required

5 5 g1 permanent Required

まだこのシリーズは続きます、show running-config での内容をもう少し詰めれたらと。。

トラックバック - http://d.hatena.ne.jp/QURULI/20110608

2011-06-07 スイッチ show vlan、 show running-config このエントリーを含むブックマーク

Dell スイッチを少し触ったのでメモしようと思いました。

まずはシリアル接続 ※MacBook Air 11in

> screen /dev/tty.usbserial-* 9600

特権モードに移行

> enable ※enと省略してもOK

console# enable

VLAN設定の確認

console# show vlan (※下記は例)

-------- --------------- ------ ----- --------------

1 default 1/g1-1/g2 Other Required

2/g1-1/g4

10 VLAN0010 1/g3-1/g4 dynamic Required

11 VLAN0011 1/g1-1/g2 static Required

20 VLAN0020 1/g3-1/g4 static Required

21 VLAN0021 static Required

30 VLAN0030 static Required

31 VLAN0031 static Required

91 VLAN0011 1/g1-1/g2 static Not Required

3964 Guest VLAN 1/g17 Guest - g47 permanent Required

現在使用中のコンフィグレーション情報を表示 ここ参照

console# show running-config

... 省略(幾つか抜粋します。) 

no spanning-tree

flowcontrol on

no mdix

interface ethernet g(ポート番号)</em

switchport mode trunk

ログアウト

console# ex

> Ctl + a - Ctl + k

kill this window ? (y / n) y


次回は実際に VLAN の設定を編集追加等を行います。また上記は本当に一部です。

トラックバック - http://d.hatena.ne.jp/QURULI/20110607

2011-02-20

iPhone アプリ UITableViewの かゆい所 その1

11:45 | iPhone アプリ UITableViewの かゆい所 その1を含むブックマーク

iPhone アプリでよく使われる cocoa の UI のひとつに UITableView が含まれていると思います。

といいますか、私自体、動的な UI、GPS、加速度センサーだったりを使用したことがないので悪しからず。。。

ということで、私が知ってる限りの知識の中で UITableView のマニュアルから調べるとちょっと時間が

かかりそうな 簡単そうなんだけど記述方が分からない機能を記述していこうと思います。

セルをタップした時の動作制御

ー(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {

   NSUInteger row = [indexPath row];

   if (row == 0 || row == 1)

   return nil;

   return indexPath;

}

上記の場合、一番最初のセルとその次のセルは、タップしても反応しませんよ。

という感じです。よく一行目とかには、画像とか、広告とかを独自で表示することがあると思いますのでよく使うかと思います。

※コピペしても動きません。 なぜなら ー(NSIndexPath *) の ー が全角だからです。 小文字で入力したらはてな記法?に引っかかって別の文字になっちゃいました。 ほんとすみません。

では第二回を乞うご期待!

トラックバック - http://d.hatena.ne.jp/QURULI/20110220