2013年3月13日水曜日

Installing Munin on gentoo and CentOS

Munin, which is a software to monitor the servers requires less effort to setup than MRTG.
I setup Munin server on gentoo box and munin-node on centos boxes.
Munin server collects status from munin-nodes and generates charts.

Setup Munin server on gentoo

Article in gentoo wiki is helpful.
Before installing munin, it is better to serup httpd like apache, lighttpd.
If you have already installed httpd, simple emerge it, but you cannot use -minimal flag.
# emerge -v munin
# emerge --config net-analyzer/munin
If you also want to monitor this box, it should also be munin-node.
# rc-update add munin-node default
# /etc/init.d/munin-node



Then edit the /etc/munin/munin.conf and add following entry if not exists.
[yourserver.example.com]
        address 127.0.0.1
        use_node_name yes
emerge --config commands installs crontab, so you will find newly generated charts within 5 minutes at /var/www/localhost/htdocs/munin/.

Setup Munin-node on centos

Enable EPEL

Because munin is not hosted in the default repository, you have to enable EPEL (Extra Packages for Enterprise Linux).
On CentOS 5.x x86_64 
# rpm -ivh http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm
 On CentOS 6.x x86_64
# rpn -ivh http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/6/x86_64/epel-release-6-5.noarch.rpm
Then edit/etc/yum.repos.d/epel-testing.repo and set enable of [epel-testing].
enabled=1

Install munin-node

Just yum it.
# yum install munin-node
Edit /etc/munin/munin-node.conf and  add allow entry for Munin server. Note that the IP address must be described as a regular expression.
allow ^192\.168\.0\.\d+$
Then boot munin-node and make it executed automatically.
# /etc/init.d/munin-node start
# chkconfig --add munin-node
# chkconfig munin-node on

Add munin-node to be monitored

Edit /etc/munin/munin.conf on gentoo box and add an entry of centos box.
 [centos.example.com]
        address 192.168.0.2
        use_node_name yes
Now you can check the status at http://gentoobox.example.com/munin/.

2013年3月7日木曜日

802.1X PEAP-md5 authentification with freeradius

A few wireless access point supports WPA2-EAP, each user can have different password to connect wifi with it.
Some model of corega supports WPA2-EAP, you have to check the datasheet before you buy.

RADIUS server, which manages accounts is necessary for EAP auth.
I realized WPA2-EAP wifi access point with freeradius on gentoo linux.
Following is the procedure of it.

Install freeradius

Simply emerge it.
# emerge freeradius -v

Setup the config files

Edit /etc/raddb/clients.conf to allow clients(access point) to query the account.
Add an entry like following.
client 192.168.0.0/24 {
        secret = secretphrase
        shortname = yourservername
}

Make account

Edit /etc/raddb/users to add accounts.
The following 3 lines are required for each account.

account_name Cleartext-Password := "password"
        Service-Type = Framed-User,
        Framed-Protocol = PPP

Setup access point 

Setup the access point to use WPA2-EAP auth.
You have to specify at least 2 information below.
  1. IP address or hostname of radius server
  2. secret key specified in clients.conf




Start daemon with debug mode

# radiusd -X
If you try to connect the access point, access point queries the radius server and radiusd will show the debug messages.
You will have to enter the account name and password as in /etc/radvd/users.

I tested with 4 clients, windows8 pro, android 2.3, android 4.0 and android 4.2. Only android 2.3 failed to connect. I am not sure the reason.

Let radiusd starts at boot time

# rc-update add radiusd default

What is TLMu?

TLMu, which is originaly written by Edgar Iglesias  is a software based on QEMU.

QEMU is a emulator which supports various kinds of architectures like x86, arm, ppc, mips, xtensa and so on.
TLMu lets you connect CPU core in QEMU to SystemC models.
TLMu hooks memory access from CPU core and redirect to TLM-2.0 access.
CPU core in QEMU can access SystemC world and vice versa.

Edgar seemed to focus on cris and I found several problems on arm and mips.
I had fixed them and Edgar accepted my patches.
After the modifications, I managed to boot the latest Linux kernel (3.4) on TLMu + SystemC peripheral environment. Whole environment is available at here.

Edgar's original TLMu is based on relatively older QEMU (maybe around 1.0).
I wanted to catch up with the mainline QEMU release, so I forked and rebased onto the QEMU-1.2.0.
The internal of QEMU has greatly changed between 1.0 and 1.2, so I had to rewrite the most part of memory access hooks. As a byproduct of the rewrite, I add turbo mode, in which Linux boot time is 7x accelerated.

My TLMu branch keeps up with the mainline QEMU  and has original features like OpenRISC support, turbo mode now.

I will explain the memory access hooks and turbo mode in the next post.

2013年2月25日月曜日

SCV for x86_64 linux patch





I made a patch for scv to be compiled on x86_64 linux platform.

I posted it to SystemC Japan BBS.

You can apply the patch with the following procedure.

  1. Save the text below (from BEGIN to END, exlucde these 2 lines) to scv_x86_64.patch.base64
  2.  tar scv-1.0p2-sysc2.2.12jun06.tgz
  3. cd scv-1.0p2-sysc2.2/
  4. cat scv_x86_64.patch.base64 | base64 -d --ignore | gunzip | patch -p0
  5. aclocal --force 
  6. autoheader --force
  7. automake --force-missing --add-missing --copy
  8. autoconf --force
  9. ./configure --with-systemc=$SYSTEMC_HOME --prefix=$SYSTEMC_HOME
  10. make
  11. make install
I have not tested all functionality of patched SCV.
If you find any problems, please let me know.

--BEGIN
 H4sIAAtwok0AA70Za1ubTPaz/opTal9DgQjkYoxNn6qJNruauIn2tev6UIRJwlsCLJCa1vW/75nh
EiCJl7a7edqQOXPutzmDkiRBeScwfMsLg50z/SsZWTYp69Oy61vjDVWWK5LcwH8gy81KoymrZTn5
gCDvyfKmIAirWSC1okhylVIrlaZabarKEvWHDyBVVVHFdfT48GETNkG3bWjSb0mfguETPSSa4XoW
8QPcFl7HMEDY97bll4NJAdiZ61PPJsHyzrG1AAckBI/4UysILNdB1nlR0NyUNlbJgg1iTFzgXr/a
ubWcnWAC0oSD9ysw3G/Ev/OtkLS27tPfGvVQ8IAUeRJDD2HrPvAN0/IfdhZbZcvJoxa0yhoLG9YI
QhKE8Aokv7i9D+GEOPAvRAMwvIK0DCKU9xnWyCoKS/33iBOWcJ7jhgzRsiOSzYUrUnSq31IgN4zJ
1DVBF+aZuBX0x3DbRHekO9f/SnwabFYNhuuMrPHMJygrLYO6JCuSWgUZs3ivKTfWlEGWNpf/SFZr
qvXV+V+tiXXMf3zssvw3HXsTrECbeJ7e4hyXYyvbcmbzaCkky3p1sR94um/ES0MPCHBboe6PSagZ
3owDy9kEhsJHQmsVJrRWFRtM6EYq8DsJuP195Hl9XanW6jc3jfpbPkKIdYgxhHmjrtWruClsZDVK
GDCqgyPtbHiidQaD/qB0wRSCo/NLCL97BBw3hGDmea4fErOZ15inLEigG0zfhtKg+jZURawpkcJA
P0dXV9qnzqD1ZQt/gWTOph7mF80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6B71QgT4QXyXQvj0VPNo/Rz6umNMkKXn3pVKpju7tQmviqUjLAFtQMYzW/eRJS+9tzBE
c5Agt+NQjos9hefhLYRxh3lMADrjV2XQBsTuKonZrdRs/lk2OrPpoWl+wjb+O616MdeFHfdRq8tL
CGExYTBDSTG+JB/fxHTKMuXyeHzJi3xP8IoW++IxGcsh/gkxhSCTlUHOafFLQSYrDfvVIJNVQc5J
IEmQl/sQmXs+YX+1yvWhmqTIklqhf29SdpvKusviek7FPlRrKvLKPlTBS+MuCNEjudMHhnb7Tbul
f2vAU7lEyvTNz60VaneWGU5KPJ/c6tkGosxICb8TMH29WYoHJpzR4B3lUg6sH6SE0wDOF3RGiIfv
dEgKp158X8F55o1tvgnw0kXpqAic282SxYuQYvGwmIce41CipwH/OB/G5SF6+CSc0Wkx2Y8j91+X
dgpUKh8AAA==

--END

2013年2月19日火曜日

TLMu-1.4.0 is released

I have rebased the tlmu-1.4.0_work branch and renamed it tlmu-1.4.0. I will not rebase it.
It is available at github.

You can try it with the following procedure.

1) Get the package
% git clone https://github.com/yTakatsukasa/tlmu

2) Build
run in the directory tlmu.
% mkdir build
% cd build
% ../configure --extra-cflags=-fPIC --disable-pie --disable-curses --disable-sdl --disable-vnc --disable-xen --disable-kvm --target-list=or32-softmmu,arm-softmmu,mipsel-softmmu,cris-softmmu
% make
% make tlmu
% make -C tests/tlmu install-tlmu
% cd tests/tlmu/
% make
% env LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH ./c_example

Then you will see the Hello world message from arm, cris, mips and openrisc.

2013年2月17日日曜日

TLMu based on QEMU-1.4.0

I have released experimental TLMu based on latest QEMU, version 1.4.0.
It is now available at github .
Please note that this is just experimental release.
I am planning to reorganize and rebase it again!

The most troubling change for me is that the CPU name of OpenRISC has been changed from or1200 to or1200-or32-cpu. I am afraid that the source code in mainline QEMU is still using "or1200" for cpu_openrisc_init() in openrisc_sim.c.

During rebasing TLMu onto the latest QEMU, I wished QEMU had been written in C++.
C++ is better than C in many points. Following points are especially applicable for current QEMU implementation. 

  • templates in C++ is much type safer than complicated C macro tricks
  • class member variables are safer and multi-instance-friendly. global variables are not.
  • native class system in C++ is safer and easy to understand than gtk-like type system. opaque pointers are dangerous.

Now even the basic software like GCC is partially written in C++, why not QEMU.

2011年12月18日日曜日

Clang-3.0のインストール

Clang-3.0がリリースされたので、SystemCとの相性をみるため、まずはClangそのものをインストールしてみる。
Clangをインストールして使うためにはgcc-4.5以降のヘッダファイルが必要になる。それ以前のバージョンのgccでもインストールはできるのだが、いざC++のプログラムをコンパイルする際にweakref関連のエラーが出てしまうためだ。ここではgcc-4.6.0を使用した。


tar zxvf /path/to/llvm-3.0.tgz
cd llvm-3.0
tar zxvf  /path/to/clang-3.0.tgz
mv clang-3.0 tools/clang
 ../configure --prefix=/path/to/clang-3.0  --enable-jit --enable-optimized --enable-targets=all --with-c-include-dirs=/path/to/tools-gcc-4.6.0/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/include:/path/to/tools-gcc-4.6.0/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/include-fixed:/usr/include --with-cxx-include-root=/path/to//tools-gcc-4.6.0/include/c++/4.6.0 --with-cxx_include-arch=x86_64-unknown-linux-gnu | & tee log.configure
make -j4
make install
使う際は、gcc-4.6.0をインストールしたディレクトリのlib以下もLD_LIBRARY_PATHに追加しないと、ランタイムエラーが発生する。

set path=(/path/to/clang-3.0 $path)
setenv LD_LIBRARY_PATH /path/to/tools-gcc-4.6.0/lib:/path/to/clang-3.0/lib:$LD_LIBRARY_PATH