- The added line is THIS COLOR.
- The deleted line is THIS COLOR.
#author("2023-06-02T16:53:35+09:00","default:kaw","kaw")
#author("2023-06-03T00:40:14+09:00","default:kaw","kaw")
*System Activity Grapher - インストール手順 [#q17f4773]
///**表記
///説明中の引用で、
/// $ foo
///は一般ユーザ権限でコマンドfooを実行することを表します。また、
/// |This is
/// |the file
/// |contents
///はファイルの容(あるいはそれをエディタで編集している状態)を表します。
**インストール手順 [#ia414e37]
(編集中)
///-インストールのシステムが前項の要件を満たしていることを確認します。必要なソフトで未インストールのものがあればインストールしておきます。
///-http://fuguita.org/kawhc/dl/pub/sag/よりSAGのソースコードを取得します。
/// $ cd
/// $ ftp http://fuguita.org/kawhc/dl/pub/sag/sag-1.0.tar.gz
/// $ tar xvzf sag-1.0.tar.gz
/// $ mv sag .sag
/// (インストールするシステムがCobaltRaQあるいはOpenBSDの場合は、
/// ~/.sag/arch/ARCH_NAME以下のファイルでオリジナルのファイルを置き換えます)
///実行ディレクトリ($HOME/.sag/bin)にgnuplotおよびppmtogifへのリンクを
///張ります(もしくは、実行バイナリをコピーしておきます)。
/// $ cd ~/.sag/bin
/// $ ln -s `which gnuplot` .
/// $ ln -s `which ppmtogif` .
///.sag/confディレクトリのサンプルファイルをコピーし、実際の設定ファイルを
///編集します。
/// $ cd ~/.sag/conf
/// $ cp crontab.sample crontab
/// $ cp dfplot.gp.sample dfplot.gp
/// $ cp netdev.pl.sample netdev.pl
/// $ cp shconf.sh.sample shconf.sh
///crontabの編集を行います。
///(実行スケジュールを変更したい特別の理由がない限り、編集は不要です。)
/// $ emacs -nw crontab.gp
/// |# ### for System Activity Grapher logging system ###
/// |#
/// |* * * * * exec $HOME/.sag/bin/tick ←毎分の処理(t0001)
/// |*/5 * * * * chmod u+x $HOME/.sag/bin/t0005 ←5分毎のデータ収集処理
/// |55 * * * * chmod u+x $HOME/.sag/bin/t0100 ←1時間毎のデータ収集処理
/// |30 0 * * * chmod u+x $HOME/.sag/bin/t2400 ←毎日のデータ更新処理
///ディスク容量グラフ描画スクリプト中のディスクパーティション設定を編集します。
/// $ emacs -nw dfplot.gp
/// |plot "sumtmp-0100df" using 1:3 title "/" \
/// | ,"sumtmp-0100df" using 1:4 title "/usr" \
/// | ,"sumtmp-0100df" using 1:5 title "/home" \
/// | ,"sumtmp-0100df" using 1:6 title "/opt/1"
///dfplot.gpはgnuplotのコマンドファイル(の一部)です。
///行末の\は行の継続を表し、実際には描画を行うplotコマンド一命令を表します。
///取得データの第3フィールド以降が各パーティションの使用率になりますので、
///plotコマンドのusing 1:'''n'''の'''n'''に相当するフィールド番号を当し、
///title "'''labelstring'''"の'''labelstring'''にはディスクパーティション
///、マウントするディレクトリ名、あるいは用途などを記します。
///
///ネットワークトラフィック集計スクリプト中のネットワークインタフェース名を設定します。
/// (Linux系OSの場合)
/// $ emacs -nw netdev.pl
/// |$IFACE='eth0'; ←ネットワークインタフェース名を指定
/// |
/// |1;
///
/// (OpenBSDの場合)
/// $ emacs $HOME/.sag/bin/t0001
/// |(echo =dt $DAYTIME
/// | echo =la `cat /kern/loadavg`
/// | echo =net
/// | set `netstat -I tun0 -b -n -i`; echo $7 ${10} ${11} ←-Iオプションで指定
/// | echo =end) >> var/rl0001
///データの保存期間、および集計結果グラフの描画期間を設定します。
/// $ emacs -nw shconf.sh
/// |# category to process data
/// |#
/// |targets='0001la 0001ps 0001net 0005mem 0100df' ←測定を行う目を記入
/// | (注:アーキテクチャによりサポートしてない目あり)
/// |# days to restore data
/// |#
/// |rotate_max=60 ←ログを保存する期間
/// |
/// |# days to display graph
/// |#
/// | span_la=7 ←ロードアベレージをグラフ上で表示する日数
/// | span_ps=7 ←プロセス起動数
/// |span_net=7 ←ネットワークトラフィック
/// |span_mem=7 ←メモリ
/// | span_df=60 ←ディスク使用率
///crontabを設定し、実際にスクリプトが実行されるようにします。
/// (新たにcronを設定する場合)
/// $ crontab ./crontab
///
/// (既にcronを設定している場合)
/// $ crontab -e
///以上でインストールは終了です。
///
**rootでの作業 [#ec23c073]
***gitのインストール [#m4f51c2e]
# pkg_add git
quirks-6.121 signed 2023-06-01 07:54:26
quirks-6.121: ok
:
:
git-2.40.0: ok
The following new rcscripts were installed: /etc/rc.d/gitdaemon
See rcctl(8) for details.
New and changed readme(s):
/usr/local/share/doc/pkg-readmes/git
#
***gnuplotのインストール [#e3d77dd1]
# pkg_add git
quirks-6.121 signed 2023-06-01 07:54:26
Ambiguous: choose package for gnuplot
a 0: <None>
1: gnuplot-5.2.7p1
2: gnuplot-5.2.7p1-no_x11
Your choice: 1
gnuplot-5.2.7p1:readline-7.0p0: ok
:
:
gnuplot-5.2.7p1: ok
Running tags: ok
New and changed readme(s):
/usr/local/share/doc/pkg-readmes/glib2
***sagユーザの作成 [#jb9b1131]
# adduser
:
:
Enter username []: sag
Enter full name []: System Activity Grapher
Enter shell csh git-shell ksh nologin sh [ksh]:
Uid [1000]:
Login group sag [sag]:
Login group is ``sag''. Invite sag into other groups: guest no
[no]:
Login class authpf bgpd daemon default pbuild staff unbound vmd xenodm
[default]:
Enter password []:
Enter password again []:
Name: sag
Password: ****
Fullname: System Activity Grapher
Uid: 1000
Gid: 1000 (sag)
Groups: sag
Login Class: default
HOME: /home/sag
Shell: /bin/ksh
OK? (y/n) [y]: y
Added user ``sag''
Copy files from /etc/skel to /home/sag
Add another user? (y/n) [y]: n
Goodbye!
#
**sagユーザでの作業 [#xe5ac3b1]
***SAGの取得と置
$ git clone https://github.com/ykaw/sag
Cloning into 'sag'...
remote: Enumerating objects: 515, done.
remote: Counting objects: 100% (92/92), done.
remote: Compressing objects: 100% (48/48), done.
remote:nTotale515:(delta(40),5reused 66 (delta 33), pack-reused 423
Receiving objects: 100% (515/515), 368.37 KiB | 784.00 KiB/s, done.
Resolving deltas: 100% (229/229), done.
$ mv sag/.git sag/* $HOME
$ rmdir sag
***各種ファイルの編集 [#vadf7e23]
gnuplotのシンボリックリンクを作成
$ ln -s `which gnuplot` ~/bin
設定ファイルの編集
$ cd ~/conf
$ cp examples/dfplot.gp examples/netcmd.sh examples/postgproc.sh examples/shconf.sh .
dfplot.gpの編集
$ vi dfplot.gp
編集容
# definitions of disk partitions
#
# $Id: dfplot.gp,v 1.2 2017/01/07 06:10:54 kaw Exp $
#
# This file will included from $SAGHOME/plot/gen0100df.gp
# Reconfigure following to fit to the disk layout.
plot "sumtmp-0100df" using 1:3 title "RDROOT", \ <--+ この部分を
"sumtmp-0100df" using 1:4 title "LIVEMEDIA", \ | 実際のパーティション
"sumtmp-0100df" using 1:5 title "SYSTEM", \ | 構成に合うように
"sumtmp-0100df" using 1:6 title "WRITABLE" <--+ 編集
netcmd.shの編集
$ vi netcmd.sh
編集容
# a command line to get i/f name, send/receive bytes
# then print them out
#
# this command will eval-ed by $SAGHOME/bin/t0001
#
# $Id: netcmd.sh,v 1.3 2021/10/05 02:29:26 kaw Exp $
netcmd='set $(netstat -I bce0 -b -n -i); echo $7 ${11} ${12}'
~~~~ここを実際のインターフェース名に変更
postgproc.shの編集
$ vi postgproc.sh
編集容
#!/bin/sh
# processes after generating graphs
# This script will be called by $SAGHOME/bin/t0100
#
# $Id: postgproc.sh,v 1.3 2021/10/04 15:26:38 kaw Exp $
# To enable this,
# # Make next line commented.
# exit 0 <--この行をコメント化する
# and follwing lines uncommented
#
# sample of post process
sleep 60 <--この行以降をアンコメントする
cp $SAGHOME/var/*.png /var/www/htdocs/sag/.
shconf.shの編集
$ vi shconf.sh
編集容
# shconf.sh - shell variable configuration for SAG
#
# $Id: shconf.sh,v 1.3 2021/10/04 15:22:35 kaw Exp $
# categories to process data
#
targets='0001la 0001net 0005mem 0100df 0100time 0005timeofs'
# days to store data
#
rotate_max=64 <--ファイルに保存する日数
# days to display graph <--グラフに描画する日数
#
span_la=8
span_net=8
span_mem=8
span_df=32
span_time=32
span_timeofs=8
グラフ描画関連のセットアップ
$ cd ~/plot
$ cp examples/common.gp examples/gen* .
$ vi common.gp
ファイル置場の作成
$ mkdir ~/var
**rootでの作業 [#n20828a3]
# cd ~sag/conf/examples/
# crontab -l > crontab.orig
# cat crontab.orig crontab-root | crontab
/etc/rc.localの編集
# cat rc.local >> /etc/rc.local
# vi /etc/rc.local
編集容
# for System Activity Grapher
# Add this to /etc/rc.local
#
# $Id: rc.local,v 1.2 2017/01/07 06:10:54 kaw Exp $
su -l sag -c 'PATH-TO-CMD/bin/addgap' # Rewrite to the real location.
~~~~~~~~~~~実際のパスに書換え
# setups for ntp monitoring
#
touch /tmp/ntpctl.out
chown sag:sag /tmp/ntpctl.out
chmod 0640 /tmp/ntpctl.out
sagユーザのcrontabを設定
# crontab -u sag ~sag/conf/examples/crontab
----
| ←[[SAG/概要]] | ↑[[SAG TOP>SAG]] | [[SAG/運用]]→ |