= 2010-05-11 = * 組務報告 - 軟體技術組 :: 綠能雲端團隊(Green Cloud Team) * [wiki:jazz/Performance_Tuning 系統效能調校參數(Performance Tuning Parameters)] == Linux == * [http://packages.debian.org/acct acct] - The GNU Accounting utilities for process and login accounting * 從 [http://phantom.nchc.org.tw/ Phantom Cluster] 的架構圖中看到 psacct package,原來是可以拿來統計不同使用者登入登出跟執行指令的工具啊!! ([wiki:jazz/09-09-23#ClusterComputing 2009-09-23]) * ac - 統計使用者連線時間 (單位: 小時) (Ref: [http://cha.homeip.net/blog/archives/2006/11/psacct_checkins.html psacct & checkinstall 使用備忘]) * sa - 統計執行過的程序 {{{ #!sh ~$ sudo apt-get install acct ~$ ac -d # 依日期統計 ~$ ac -p # 依使用者帳號統計 ~$ ac -f /var/log/wtmp.1 # 指定來源檔案 (預設 /var/log/wtmp) - 因此只能統計近期的使用情形 ~$ sudo sa -a # 顯示所有程序記錄 ~$ sudo sa -m # 依使用者統計 }}} == Perl + SQLite3 == * [專案] 實作 Perl + SQLite * [wiki:jazz/08-12-29#Perl 其他參考連結] * [參考] [http://mailliststock.wordpress.com/2007/03/01/sqlite-examples-with-bash-perl-and-python/ SQLite examples with Bash, Perl and Python] (2007-03-01) * 環境: Debian 5.0.4 , amd64 核心 {{{ jazz@drbl:~$ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 5.0.4 (lenny) Release: 5.0.4 Codename: lenny jazz@drbl:~$ uname -a Linux drbl 2.6.26-lustre-amd64 #1 SMP Sun Jun 28 18:28:02 CST 2009 x86_64 GNU/Linux }}} * 相關套件: [http://packages.debian.org/sqlite3 sqlite3],[http://packages.debian.org/libsqlite3-0 libsqlite3-0],[http://packages.debian.org/libdbd-sqlite3-perl libdbd-sqlite3-perl] {{{ jazz@drbl:~$ sudo apt-get install sqlite3 libdbd-sqlite3-perl libsqlite3-0 jazz@drbl:~$ dpkg -l | grep sqlite ii libdbd-sqlite3-perl 1.14-3 Perl DBI driver with a self-contained RDBMS ii libsqlite3-0 3.5.9-6 SQLite 3 shared library ii sqlite3 3.5.9-6 A command line interface for SQLite 3 }}} * 使用範例程式建立 test.db {{{ jazz@drbl:~$ vi perlsqlite3.pl jazz@drbl:~$ chmod a+x perlsqlite3.pl jazz@drbl:~$ ./perlsqlite3.pl jazz@drbl:~$ file test.db test.db: SQLite 3.x database jazz@drbl:~$ sqlite3 test.db "select * from n" 1|john|smith }}} {{{ #!perl #!/usr/bin/perl -w use DBI; use strict; my $db = DBI->connect("dbi:SQLite:test.db", "", "", {RaiseError => 1, AutoCommit => 1}); $db->do("CREATE TABLE n (id INTEGER PRIMARY KEY, f TEXT, l TEXT)"); $db->do("INSERT INTO n VALUES (NULL, 'john', 'smith')"); my $all = $db->selectall_arrayref("SELECT * FROM n"); foreach my $row (@$all) { my ($id, $first, $last) = @$row; print "$id|$first|$last"; } }}}