date command ミリ秒 ms
$ echo $(date +%c) $(printf '%03d' $(expr `date +%N` / 1000000))
処理に時間を掛けたくない場合は, simpleにする.
date +"%Y%m%d %H:%M:%S.%N"
2014年3月28日金曜日
2014年3月17日月曜日
サイクロマティック複雑度
「C.Jones Applied Software Measurement Second Edition 1991 McGraw-Hill
ソフトウェア開発の定量化法
共立出版」
1. 10 以下であればよい構造
2. 30 を越える場合,構造に疑問
3. 50 を越える場合,テストが不可能
4. 75 を越える場合,いかなる変更も誤修正を生む原因を作る
別な基準。(ちょっと厳しい)
1-10 :良い。
11-20 :少し複雑。危険度は小。
21-50 :複雑。危険度は大。
50以上:悪し。非常に危険!
ソフトウェア開発の定量化法
共立出版」
1. 10 以下であればよい構造
2. 30 を越える場合,構造に疑問
3. 50 を越える場合,テストが不可能
4. 75 を越える場合,いかなる変更も誤修正を生む原因を作る
別な基準。(ちょっと厳しい)
1-10 :良い。
11-20 :少し複雑。危険度は小。
21-50 :複雑。危険度は大。
50以上:悪し。非常に危険!
sysrqd設定
sysrqd設定方法
sysrqdとは、マジックSysRqキーをnetwork超しにできるようにするdaemon
http://ja.wikipedia.org/wiki/%E3%83%9E%E3%82%B8%E3%83%83%E3%82%AFSysRq%E3%82%AD%E3%83%BC
【firewallを停止する(手っ取り早く設定するため)】
$ /sbin/chkconfig --list|grep iptabl
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
# /sbin/chkconfig iptables off
# /sbin/chkconfig --list|grep iptabl
iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
# /etc/rc.d/init.d/iptables stop
ファイアウォールルールを適用中: [ OK ]
チェインポリシーを ACCEPT に設定中filter [ OK ]
iptables モジュールを取り外し中 [ OK ]
【sysrqd用のpassword fileを準備する】
# chmod a+x /etc/init.d/sysrqd_start
/etc/init.d/sysrqd_start
---------------------------------------------
#!/bin/sh
# chkconfig: 345 99 01
# description: sysrq
/home/user/bin/sysrqd &
exit 0
---------------------------------------------
【sysrqdの自動起動を設定する】
chkconfig --add sysrqd_start
# /sbin/chkconfig --list|grep sysrq
sysrqd_start 0:off 1:off 2:off 3:on 4:on 5:on 6:off
# /sbin/chkconfig --list|grep sysrqd
sysrqd 4094/tcp # sysrq daemon
sysrqd 4094/udp # sysrq daemon
【sysrqdを操作する】
$ telnet TARGET_HOST 4094 (teratermだとpasswrd入力で、Go away!になってしまう)
Trying x.y.z.a...
Connected to TARGET_HOST (x.y.z.a).
Escape character is '^]'.
sysrqd password: mypassword
sysrq> s (マウントされているすべてのファイルシステムをsyncする)
sysrq> u (マウントされているすべてのファイルシステムを読み込み専用モードで再マウントする。)
sysrq> b (即座に再起動する。この際ファイルシステムのsyncやアンマウントは行われない。)
【その他の方法】
・alt+SysRq+文字
# echo 1 > /proc/sys/kernel/sysrq
sysrqdとは、マジックSysRqキーをnetwork超しにできるようにするdaemon
http://ja.wikipedia.org/wiki/%E3%83%9E%E3%82%B8%E3%83%83%E3%82%AFSysRq%E3%82%AD%E3%83%BC
【firewallを停止する(手っ取り早く設定するため)】
$ /sbin/chkconfig --list|grep iptabl
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
# /sbin/chkconfig iptables off
# /sbin/chkconfig --list|grep iptabl
iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
# /etc/rc.d/init.d/iptables stop
ファイアウォールルールを適用中: [ OK ]
チェインポリシーを ACCEPT に設定中filter [ OK ]
iptables モジュールを取り外し中 [ OK ]
【sysrqd用のpassword fileを準備する】
# chmod a+x /etc/init.d/sysrqd_start
/etc/init.d/sysrqd_start
---------------------------------------------
#!/bin/sh
# chkconfig: 345 99 01
# description: sysrq
/home/user/bin/sysrqd &
exit 0
---------------------------------------------
【sysrqdの自動起動を設定する】
chkconfig --add sysrqd_start
# /sbin/chkconfig --list|grep sysrq
sysrqd_start 0:off 1:off 2:off 3:on 4:on 5:on 6:off
# /sbin/chkconfig --list|grep sysrqd
sysrqd 4094/tcp # sysrq daemon
sysrqd 4094/udp # sysrq daemon
【sysrqdを操作する】
$ telnet TARGET_HOST 4094 (teratermだとpasswrd入力で、Go away!になってしまう)
Trying x.y.z.a...
Connected to TARGET_HOST (x.y.z.a).
Escape character is '^]'.
sysrqd password: mypassword
sysrq> s (マウントされているすべてのファイルシステムをsyncする)
sysrq> u (マウントされているすべてのファイルシステムを読み込み専用モードで再マウントする。)
sysrq> b (即座に再起動する。この際ファイルシステムのsyncやアンマウントは行われない。)
refer to http://www.ubuntugeek.com/manage-linux-sysrq-over-network-using-sysrqd.html
【その他の方法】
・alt+SysRq+文字
SysRq(PrintScreen)+ALT+s (disk sync)
SysRq(PrintScreen)+ALT+c (crash dumpをfile出力、5分待ってみる)
SysRq(PrintScreen)+ALT+b (reboot、5分待ってみる)
2014年1月31日金曜日
bash file loop
Directory内にある指定fileを検索し、コマンドを実行するひな形。
#!/bin/bash
#set -x
if [ $# -ne 1 ]; then
echo "usage : ${0} [part_of_directory_string]"
exit 1
fi
filter="Log_20140131"
#for target_file in $( ls . | grep ${filter} ); do
for target_file in ./${filter}*
do
clear
echo "------------------- ${target_file}"
diff ${target_file}/* | less -S
# read www
done
set +x
#!/bin/bash
#set -x
if [ $# -ne 1 ]; then
echo "usage : ${0} [part_of_directory_string]"
exit 1
fi
filter="Log_20140131"
#for target_file in $( ls . | grep ${filter} ); do
for target_file in ./${filter}*
do
clear
echo "------------------- ${target_file}"
diff ${target_file}/* | less -S
# read www
done
set +x
2014年1月14日火曜日
2013年11月6日水曜日
linux timer resolution 時間分解能
#include
#include
#include
#include
/*
* gcc -Wall -lrt -o timerResolution timerResolution.c
*
*/
int main()
{
clockid_t clocks[] = {
CLOCK_REALTIME,
CLOCK_MONOTONIC,
CLOCK_PROCESS_CPUTIME_ID,
CLOCK_THREAD_CPUTIME_ID,
(clockid_t)-1
};
int i;
{
long hz;
hz = sysconf(_SC_CLK_TCK);
if(hz==-1) {
perror("sysconf");
} else {
printf("hz = %ld\n", hz);
}
}
for(i=0; clocks[i]!=(clockid_t)-1; i++) {
struct timespec res;
int ret;
ret = clock_getres( clocks[i], &res);
if(ret) {
perror("clock_getres");
} else {
printf("clock=%d sec=%ld nsec=%ld\n", clocks[i], res.tv_sec, res.tv_nsec);
}
}
return 0;
}
#include
#include
#include
/*
* gcc -Wall -lrt -o timerResolution timerResolution.c
*
*/
int main()
{
clockid_t clocks[] = {
CLOCK_REALTIME,
CLOCK_MONOTONIC,
CLOCK_PROCESS_CPUTIME_ID,
CLOCK_THREAD_CPUTIME_ID,
(clockid_t)-1
};
int i;
{
long hz;
hz = sysconf(_SC_CLK_TCK);
if(hz==-1) {
perror("sysconf");
} else {
printf("hz = %ld\n", hz);
}
}
for(i=0; clocks[i]!=(clockid_t)-1; i++) {
struct timespec res;
int ret;
ret = clock_getres( clocks[i], &res);
if(ret) {
perror("clock_getres");
} else {
printf("clock=%d sec=%ld nsec=%ld\n", clocks[i], res.tv_sec, res.tv_nsec);
}
}
return 0;
}
登録:
投稿 (Atom)