2008/09/14(Sun)screenでデタッチできない 解決編
2008/09/14 21:21
デタッチできないというよりも、むしろアタッチできないという方が正しい表現だったようだ。
これはscreenの問題ではなく、回線が切れたときにsshセッションが切れず、sshdプロセスが生きたままで、その応答待ちでscreenがattachedから変化しない模様。
以下、対処法。
$ ps x | grep pts | grep sshd
13819 ? S 0:00 sshd: kero@pts/2
13985 ? S 0:00 sshd: kero@pts/8
14595 pts/2 S+ 0:00 grep sshd
grepが走っているpts/2が現在操作中のポートなので、pts/8を落とす。
$ kill -KILL 13985
$ screen -ls
There is a screen on:
9120.pts-0.spinel (Multi, detached)
1 Socket in /var/run/screen/S-kero.
$ screen -r
これで自動的にdetatchされ(autodetatchがonの場合)再アタッチ可能になる。が、いちいちこんな事やるのが面倒なので、自分以外のsshセッションを片っ端から強制終了するスクリプトを書いてみた。
最近Perlの正規表現にハマってたりなので…。/bin/sh+sedかawk…と思いつつも、慣れてる方が書きやすい。
screenの内側から実行しないように注意。
#!/usr/bin/perl
use strict;
(my $tty = `echo -n \$SSH_TTY`) =~ s/\/dev\///;
my $dead = `ps x | grep pts | grep sshd | grep -v $tty | grep -v grep`;
foreach(split(/\n/, $dead)){
$_ =~ s/^\s*(\d+).+$/$1/;
print qq|Kill pid=$_...\n|;
`kill -KILL $_`;
}
参考元:http://subtech.g.hatena.ne.jp/cho45/20070517/1179373075
2008/09/12(Fri)zshセグメ違反 解決
2008/09/12 19:19
さて、zshに乗り換えようかな…?
▼zsh4.3.4になってました。

2008/09/12(Fri)LoadAverageが50!?
2008/09/12 19:06
あ、こりゃまずいと思った時には、SSHの操作を受け付けるのが非常に困難に。
しばらく待ってたら、だんだん落ち着いて、topコマンドが入るようになったので、見てたけど、なにやら起動したPerlアプリのメモリが70%食ってるとかありえない表示になってたり。おかしいなぁ、そんなに酷い処理は書いてないんだけど…。
とりあえずkillallで該当Perlにkillをかけてから、sftpが収まるのを待ってようやくスムーズに。
後でサーバーの保守ログから作成したグラフを見て驚いたwこれはすげぇ…、Load Average 50いってたんだ。しかもswapの減り方が……。あぁかわいそう。
そんなに忙しいにもかかわらず頑張ってグラフ描いてくれたんだね、偉い偉い。*1


まあ再起動することなく、おさまってくれてよかったです。
ちなみにおかしな挙動をしたPerlモジュールは変更せずにもう一回実行しても、↑のようなハングは起きませんでした。sftpのせい??
# 余談ですが、Linuxのsftpコマンドだけでレジューム転送ってどうやるんだろう?man調べたけどよく分からなかった。
2008/08/30(Sat)SeaTools
2008/08/30 20:15
そのLinux版の扱い方メモ。
ここからダウンロード可能。ページ下部の"Linux コマンドライン版"を選択。
seatools_cli.tarがダウンロードされる。
# tar xvf seatools_cli.tar
# ./st -l
Drive information:
/dev/sg0 ATA ST380021A 3.05 156301487 blocks
# ./st -i /dev/sg0
/dev/sg0
Vendor = ATA
Product = ST380021A
Version = 3.05
Serial Number =
Copyright =
SCSI Firmware = t
Servo RAM Release = 9
Servo ROM Release = !5v
Servo RAM Date = �
Servo ROM Date = E
Blocksize = 512, Highblock = 156301487, Capacity = 78151 MB
-this is a Seagate drive
-this drive does not support DST
-Mode Page Settings [current value (default)]:
-WCE bit = 1 (0)
-RCD bit = 0 (0)
-AWRE bit = 1 (0)
-ARRE bit = 0 (0)
-DExcpt bit = 0 (0)
-Number of cache segments = 0 (0)
システムからは/dev/sdaとして見えているが、SeaToolsに渡す引数は/dev/sg0のようなデバイスなのでそこを注意。ちなみにこのツールは以下のようなオプションがあるらしい。
サーバーとして動作中なのでファーム書き換え等は出来ないが、トラブルが起こった時には試してみようかな。
Usage: SeaTools Enterprise [-option][variable][device]
Allowed options are:
-l list all attached SCSI disks
-i display drive Inquiry information
-I display drive Inquiry information for all SCSI devices
-t ### execute ###% (10% - 100%) short Drive Self Test (DST)
ex: st -t 10 /dev/sga execute 10 % of the short Drive Self Test (DST)
-T ### execute ###% (10% - 100%) long Drive Self Test (DST)
ex: st -T 20 /dev/sga execute 20 % of the long Drive Self Test (DST)
-s stop Drive Self Test (DST)
-g ### execute ###% (1-% - 100%) generic short test for legacy & non-Seagate drives
ex: st -g 10 /dev/sga execute 10 % of the short legacy test
-G generic long test (sequential verify test of entire drive)
-r generate Seagate RMA form
-v show Seatools version and licence agreement
example: ./st -i /dev/sga displays inquiry for /dev/sga
Advanced options (some cause data loss):
-Marg Drive Preferences (mode page) change
Note: Use -i INQUIRY option to display the supported & current settings.
Performance Mode (PM)
-Mpmon/off desktop/server PM bit
Write Cache Enable (WCE)
-Mwceon/off set/clear WCE bit
Read Cache Disable (RCD)
-Mrcdon/off set/clear RCD bit
Just In Time (JIT)
-Mjitdefault set all JIT bits, factory default
-Mjit1on set only JIT bit 1, clears any others
-Mjit2on set only JIT bit 2, clears any others
Automatic Write Rallocation Enable (AWRE)
-Mawreon/off enable/disable AWRE bit
Automatic Read Rallocation Enable (ARRE)
-Marreon/off enable/disable ARRE bit
Disable Exception Control (DExcpt, SMART logging)
-Mdexon/off disable/enable DExcpt bit
Disable Loop Master (DLM, fibre channel only)
-Mdlmon/off disable/enable DLM bit
Disable Target Oriented Loop Initialization (DTOLI, fibre channel only)
-Mdtolion/off disable/enable DTOLI bit
Number of Cache Segments
-Mcache# set # cache segments
ex: -Mcache8 set # of cache segments to 8
-F default low-level scsi format
Usage: [-option] [variable] [device]
-d file firmware download
ex: st -d fwfile /dev/sga download firmware file fwfile into /dev/sga
-C ### capacity change
ex: -C 1234567890 set high blocks to 1234567890 (zero based)
ex: -C max change capacity to factory maximum
-B ### sector size change followed by a format
ex: -B 1024 change to 1024 bytes/sector
ついでにUDMA5(ATA100)で動作中のこいつのベンチマーク。# hdparm -tT /dev/sda /dev/sda: Timing cached reads: 288 MB in 2.02 seconds = 142.85 MB/sec Timing buffered disk reads: 102 MB in 3.02 seconds = 33.76 MB/sec
2008/08/30(Sat)Plagger on Fedora 8
2008/08/30 15:13
まず、repoファイルをwget……してもいいのだが、rpmがあるのでこれを利用
$ wget http://pub.woremacx.com/worepo/deprecated/worepo-release-7.rpm # sudo rpm -ivh worepo-release-7.rpm # ls /etc/yum.repos.d/wo.repo /etc/yum.repos.d/wo.repowo.repo内のアドレスが変わっているようなので、修正。
# vi /etc/yum.repos.d/wo.repo - baseurl=http://pub.woremacx.com/worepo/fedora7/i386 + baseurl=http://pub.woremacx.com/worepo/deprecated/fedora7/i386で、
# yum install perl-Plagger .... Transaction Summary ====================================================== Install 314 Package(s) Update 2 Package(s) Remove 0 Package(s) Total download size: 45 M Is this ok [y/N]: y ... Complete!という感じで物凄いインストール。
仮にcpanで同じインストールをするとして、314パッケージもmakeの面倒見るなんて御免だ。パッケージに頼るに限る。
で、無事動いてます。