Sunday, February 3, 2013

OpenNMS Architecture Introduction (Discovery & Monitor)

O.S. : Ubuntu12.04 LTS
OpenNMS Version : 1.10.7

OpenNMS base on TMN & FCAPS network management models.
OpenNMS Block Diagram


Discovery & Monitor daemons
* Eventd
Event handling daemon
Configuration files:
eventconf.xml -> Defines the UEI (Universal Event Identifiers).
eventd-configuration.xml -> Defines operating parameters for eventd such as timeouts, listener threads and listener port.
events-archiver-configuation.xml -> Configuration for event archive daemon.
events.archiver.properties -> Fine tune events archive subsystem.
etc/events/*.xml -> Vendor UEI define files.
Listening "eventsConfigChange" event.

* Discovery (discovery-configuration.xml)
Discovery service implement the Singleton pattern.
Listening events: discPause, interfaceDeleted, discResume, nodeGainedInterface, discoveryConfigChange and reloadDaemonConfig.

* Capsd (Capabilities daemon, capsd-configuration.xml)
Notified by the discovery process when a new node is discovered, the polls for all the capabilities for this node and loading the data collected into the database.
Listening events: deleteService, changeService, deleteInterface, newSuspect, froceRescan, addInterface, nodeDeleted, addNode, updateServer, nodeAdded, duplicateNodeDeleted, deleteNode and updateService.

* Collectd (collectd-configuration.xml)  
Responsible for gathering and storing data from various sources, including SNMP, JMX, HTTP and NSClient.
Listening events: nodeGainedService, primarySnmpInterfaceChanged, reinitializePrimarySnmpInterface, interfaceReparented, nodeDeleted, duplicateNodeDeleted, interfaceDeleted, serviceDeleted, schedOutagesChanged, configureSNMP, thresholdConfigChange, reloadDaemonConfig and nodeCategoryMembershipChanged.

* Poller (poller-configuration.xml)
Polling services, including ICMP, DNS, FTP, HTTP, HTTPS, SSH, MySQL....
Listening events: nodeGaineService, serviceDeleted, interfaceReparented, nodeDeleted, nodeLabelChanged, duplicateNodeDeleted, interfaceDeleted, suspendPollingService, resumePollingService, schedOutagesChanged, demandPollService, thresholdConfigChange, assetInfoChanged and nodeCategoryMembershipChanged.

* RTC (Real-Time Collector)
The RTC initializes its data from the database when it comes up then subscribes to the events subsystem to receive events of interest to keep the data up-to-date.
Listening events: nodeGainedService, nodeLostService, interfaceDown, nodeDown, nodeUp, nodeCategoryMembershipChanged, interfaceUp, nodeRegainedService, serviceDeleted, serviceunmanaged, interfaceReparented, subscribe, unsubscribe and assetInfoChanged.

Note:
There are two major ways that OpenNMS gathers data about the network.
The first is through polling. Processes called monitors connect to a network resource and perform a simple test to see if the resource is responding correctly. If not, events are generated.
The second is through data collection using collectors. Currently, the only collector is for SNMP data.
Collectd record SNMP data to RRDTool in /share/rrd/snmp/NodeID/*,  Ex:  tcpOutSegs.jrb, icmpInEchos.jrb, tcpInSegs.jrb, ifInOctets.jrb, ifoutOctets.jrb...
Poller record Service data to RRDTool in /share/rrd/response/IP/*,  Ex: icmp.jrb ssh.jrd...

OpenNMS configuration files:

Discovery & Monitor Flow
Here is the event flow then press "Save and Restart Discovery" button on WebGUI.
Figure 1

Figure 2


References :

Saturday, February 2, 2013

Create S3 on AWS use s3cmd

1. open S3 web console


2. Create Bucket
You can use any names for your objects, but bucket names must be unique across all of Amazon S3. 
Objects stored in Amazon S3 are addressable using the REST API under the domain bucketname.s3.amazonaws.com. 
For example, if the object homepage.html is stored in the Amazon S3 bucket mybucket its address would be http://mybucket.s3.amazonaws.com/homepage.html. 
For more information, see Virtual Hosting of Buckets. 


Install s3cmd
download s3cmd from http://s3tools.org/s3cmd

install on Ubuntu 12.04 
$ sudo python setup.py install

configure s3cmd
$ s3cmd --configure

Enter new values or accept defaults in brackets with Enter.
Refer to user manual for detailed description of all options.

Access key and Secret key are your identifiers for Amazon S3
Access Key: AWS_ACCESS_KEY
Secret Key:
AWS_SECRET_KEY

Encryption password is used to protect your files from reading
by unauthorized persons while in transfer to S3
Encryption password: PWD_WHAT_U_WANT
Path to GPG program [/usr/bin/gpg]:

When using secure HTTPS protocol all communication with Amazon S3
servers is protected from 3rd party eavesdropping. This method is
slower than plain HTTP and can't be used if you're behind a proxy
Use HTTPS protocol [No]: Yes

New settings:
  Access Key:
AWS_ACCESS_KEY
  Secret Key:
AWS_SECRET_KEY
  Encryption password: PWD_WHAT_U_WANT
  Path to GPG program: /usr/bin/gpg
  Use HTTPS protocol: True
  HTTP Proxy server name:
  HTTP Proxy server port: 0

Test access with supplied credentials? [Y/n]
Please wait, attempting to list all buckets...
Success. Encryption and decryption worked fine :-)

Save settings? [y/N] y
Configuration saved to '/home/oopsmonk/.s3cfg'
$
Change .s3cfg permission.
$ chmod 600 /home/oopsmonk/.s3cfg

$ s3cmd mb s3://test.s3cmd.cli
Bucket 's3://test.s3cmd.cli/' created



put file
$ s3cmd put ./README s3://test.s3cmd.cli/
WARNING: Module python-magic is not available. Guessing MIME types based on file extensions.
./README -> s3://test.s3cmd.cli/README  [1 of 1]
13130 of 13130   100% in    1s    11.64 kB/s  done

delete file
$ s3cmd del s3://test.s3cmd.cli/README
File s3://test.s3cmd.cli/README deleted

delete Bucket
$ s3cmd rb s3://test.s3cmd.cli
Bucket 's3://test.s3cmd.cli/' removed



Commands:
  Make bucket
      s3cmd mb s3://BUCKET
  Remove bucket
      s3cmd rb s3://BUCKET
  List objects or buckets
      s3cmd ls [s3://BUCKET[/PREFIX]]
  List all object in all buckets
      s3cmd la
  Put file into bucket
      s3cmd put FILE [FILE...] s3://BUCKET[/PREFIX]
  Get file from bucket
      s3cmd get s3://BUCKET/OBJECT LOCAL_FILE
  Delete file from bucket
      s3cmd del s3://BUCKET/OBJECT
  Synchronize a directory tree to S3
      s3cmd sync LOCAL_DIR s3://BUCKET[/PREFIX] or s3://BUCKET[/PREFIX] LOCAL_DIR
  Disk usage by buckets
      s3cmd du [s3://BUCKET[/PREFIX]]
  Get various information about Buckets or Files
      s3cmd info s3://BUCKET[/OBJECT]
  Copy object
      s3cmd cp s3://BUCKET1/OBJECT1 s3://BUCKET2[/OBJECT2]
  Move object
      s3cmd mv s3://BUCKET1/OBJECT1 s3://BUCKET2[/OBJECT2]
  Modify Access control list for Bucket or Files
      s3cmd setacl s3://BUCKET[/OBJECT]
  Enable/disable bucket access logging
      s3cmd accesslog s3://BUCKET
  Sign arbitrary string using the secret key
      s3cmd sign STRING-TO-SIGN
  Fix invalid file names in a bucket
      s3cmd fixbucket s3://BUCKET[/PREFIX]
  Create Website from bucket
      s3cmd ws-create s3://BUCKET
  Delete Website
      s3cmd ws-delete s3://BUCKET
  Info about Website
      s3cmd ws-info s3://BUCKET
  List CloudFront distribution points
      s3cmd cflist
  Display CloudFront distribution point parameters
      s3cmd cfinfo [cf://DIST_ID]
  Create CloudFront distribution point
      s3cmd cfcreate s3://BUCKET
  Delete CloudFront distribution point
      s3cmd cfdelete cf://DIST_ID
  Change CloudFront distribution point parameters
      s3cmd cfmodify cf://DIST_ID
  Display CloudFront invalidation request(s) status
      s3cmd cfinvalinfo cf://DIST_ID[/INVAL_ID]

Friday, November 30, 2012

About Bread!!

結束上份工作後, 不想閒著, 也就開始找新"玩具",
做麵包好像滿有趣的, 又不用出門可以在家陪小朋友,
於是爬了2~3天的文章,了解需要的東西,
Google什麼是yeast(Active dry, Instant dry, Fresh)?
什麼是麵粉(高筋, 中筋, 低筋, 法國粉)?
什麼是麵糰(擴展, 完成)?
什麼是揉麵?
天真的以為"吐司"很簡單,麵糰整好丟進烤模..done.
結果烤到第五條吐司, 才達成滿模的標準.

失敗品之一:


接著白吐司太無聊了, 所以做了其它嚐試,
全麥鮪魚麵包
高粉 270g
全麥粉 30g
Instant dry 3/4t
奶油 20g
塩 1/2t
糖 20g
水 185g

整形參考: 蒔蘿鮪魚麵包


海蒂的白麵包
配方跟做法參考 【肉桂打噴嚏】海蒂的白麵包


全麥豆漿枸杞葡萄乾
高粉 270g
全麥粉 30g
Instant dry 3/4t
奶油 20g
塩 1/2t
糖 20g
豆漿 185g
枸杞 + 葡萄乾 適量.


做了這些後, 深深感到...
萬能的雙手真的累人又吵, 尤其吐司要揉到完成階段.
再上鄰居來關切說: "你家是不是最近在釘東西?"...XD

於是開始Google解決辦法..
沒想到真的有人研發出No-Knead Bread...OMG

不過缺點是要"長時間發酵"..
後來又改善了長時間發酵的缺點:
Speedy No-Knead Bread
  
於是No-Knead Bread成了目前主要的做法
優點:
1. 免揉 == 不累沒噪音
2. 麵糰不加奶油 and 糖, 感覺較健康.
3. 我愛歐包的脆皮及咬勁
缺點:
麵糰水份高, 不易操作.

 使用陶鍋試了這個方法5次後, 覺得缺點還可以接受,
反正自己吃不用做美美的..XD
麵糰配方:
高粉 200g
Instant dry 1/8t
塩 1/4t
水 170~175g
 
今天特別做了一個大size的:
蜂蜜乾果全麥歐包, 乾果是葡萄乾+核桃
 
整形再發酵60分鐘就入烤箱了,
烤箱中的大陶鍋, 上色時表皮的乾果烤焦了..
 
出爐几分鐘後還量了一下,
沒想到裡面還有90几度的高溫@@..

Wednesday, September 12, 2012

How to split boot.img and get kernel config.

boot_cm9.img  file from mk802_legacy-compatibility_v1.zip
Device: Rikomagic MK802
Script files : Split_bootimg.pl , extract-ikconfig ( in {kernel_source}/script )

1. split boot.img
$ mkdir split_boot
$ cd split_boot
Copy boot_cm9.img, Split_bootimg.pl, extract-ikconfig into 'split_boot'
$ ./split_bootimg.pl boot_cm9.img
Page size: 2048 (0x00000800)
Kernel size: 8094708 (0x007b83f4)
Ramdisk size: 178940 (0x0002bafc)
Second size: 0 (0x00000000)
Board name:
Command line: console=ttyS0,115200 rw init=/init loglevel=8
Writing boot_cm9.img-kernel ... complete.
Writing boot_cm9.img-ramdisk.gz ... complete.

Get kernel image (boot_cm9.img-kernel) and ramdisk (boot_cm9.img-ramdisk.gz)

2. extract kernel config
$ dd if=boot_cm9.img-kernel of=dd_uImage bs=1024 skip=1
7903+1 records in
7903+1 records out
8093684 bytes (8.1 MB) copied, 0.0178518 s, 453 MB/s
$./extract-ikconfig dd_uImage > kernel_config


3. extract ramdisk
$ mkdir ramdisk
$ cd ramdisk
$ gzip -dc ../boot_cm9.img-ramdisk.gz | cpio -i
6677 blocks
$ tree .
.
├── data
├── default.prop
├── dev
├── init
├── init.goldfish.rc
├── initlogo.rle
├── init.rc
├── init.sun4i.rc
├── init.sun4i.usb.rc
├── proc
├── sbin
│   ├── adbd
│   └── ueventd -> ../init
├── sys
├── system
├── ueventd.goldfish.rc
├── ueventd.rc
└── ueventd.sun4i.rc


Ref : HOWTO: Unpack, Edit, and Re-Pack Boot Images

Tuesday, August 21, 2012

How to extract kernel config from uImage

How to extract kernel config from uImage
1. get extract-ikconfig in kernel-source/scripts/
$mkdir extreact-uImage
$cd extreact-uImage
$cp {kernel-source}/scripts/extract-ikconfig .

2. dump uImage skip 1024 bytes
$cp {uImage/what/you/want} uImage
$dd if=uImage of=dd_uImage bs=1024 skip=1
$./extract-ikconfig dd_uImage > config

Sunday, July 29, 2012

XBMC for Android on MK802

XBMC announce XBMC for Android.
不過並不打算放上Google Play, 需要自行compile及打包, 方法可參考:
Build XBMC for Android on lubuntu 12.04

在此記錄一下目前在MK802跑起來的情況.
MK802介紹可參考:

Android 4.0 mini PC 最小的主機MK802

CPU : Allwinner A10 - ARM Cortex A8 SoC

GPU : ARM Mali 400
RAM : 1GB
以公定價$79USD及讓人跌破眼鏡的入手價, 拿來玩真是夠本了.
這次是要用Android 手機來控制 XBMC, 因為MK802沒有IR只能用滑鼠操作上有些不便.
Google Play上有Official XBMC Remote可直接下載來用.
中文設定: 切換到Appearance -> Setting -> International -> Language
為了能透過HTTP連到MK802的XBMC, 需要將"網站伺服"的功能打開, 設定port number
接著查看IP, 設定手機上的XBMC Remote如下:
連線成功就會出現控制選項
用手機上"Remote Control" Navigation, 測試播放USB裡的影片,
影片開播後選手機上的"Now Playing", 可以做seek, FF/FB功能,
音量控制是使用手機上的音量鍵.(當初還因為無法控制音量煩腦, 沒想到直接用就可以...冏)
播放online radio, 用的是SKY.FM, 可以到"附加元件"中下載安裝.
音樂Full screen播放, 可以看到背景的GL動畫還可以跑到31fps, 似乎還OK.
天氣+音樂播放, 後面的GL動畫還是正常顯示, 並不是靜態的.

後記:
1. 透過附加元件下載安裝的YouTube及Time.com無法正常播放video.
2. 很吃記憶體大約要吃掉80MB.
3. 研究XBMC在Android 如何implement, 應該是很有趣的.必竟XBMC是用自己的GUI系統, 還要克服Bionic libc在dlopen的不足之處. 


Update:
XBMC APK 下載
APK修改的部份:
1. 修正中文無法顯示問題.
2. 客制開機畫面及背景圖

Saturday, July 28, 2012

Build XBMC for Android on lubuntu 12.04


1. install required packages
# sudo apt-get install build-essential default-jdk git curl autoconf \
   unzip zip zlib1g-dev gawk gperf

2. Getting the Android SDK and NDK
crystax-5 NDK with enabled support of C++ exceptions, RTTI and Standard C++ Library 

3.Installing Android SDK packages
<android-sdk> : $HOME/XBMC_Project/android-sdk-linux
# cd <android-sdk>/tools
# ./android update sdk -u -t platform,platform-tool

4.Setup the Android toolchain
<android-ndk> :  $HOME/XBMC_Project/android-ndk-r8b
<android-toolchain> :  $HOME/XBMC_Project/android_toolchain/android-9
# cd <android-ndk>
# ls platforms
# cd build/tools
# ./make-standalone-toolchain.sh --ndk-dir=../../ \
  --install-dir=<android-toolchain>/android-9 --platform=android-9

5. Create a (new) debug key to sign debug APKs
All packages must be signed. The following command will generate a
self-signed debug key. If the result is a cryptic error, it
probably just means a debug key already existed, no cause for alarm.

# keytool -genkey -keystore ~/.android/debug.keystore -v -alias \
  androiddebugkey -dname "CN=Android Debug,O=Android,C=US" -keypass \
  android -storepass android -keyalg RSA -keysize 2048 -validity 10000

6. Getting the source code
# cd $HOME/XBMC_Project
# git clone git://github.com/xbmc/android.git xbmc-android-git
# cd xbmc-android-git
# git submodule update --init addons/skin.touched

7.Building dependencies
# cd $HOME/XBMC_Project/xbmc-android-git/tools/android/depends
# ./bootstrap
# ./configure --help
#export XBMC_ANDROID_NDK=~/XBMC_Project/android-ndk-r7-crystax-5.beta2
#export XBMC_ANDROID_SDK=~/XBMC_Project/android-sdk-linux
#export XBMC_ANDROID_TARBALLS=~/XBMC_Project/xbmc-tarballs
#./configure --with-toolchain=~/XBMC_Project/android-toolchain/android-9
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for main in -lz... yes
checking for unzip... yes
checking for zip... yes
checking for curl... /usr/bin/curl
checking for tar... /bin/tar
checking for -gcc... no
configure: WARNING: host was not specified. guessing.
checking for gcc... /home/oopsmonk/XBMC_Project/android-toolchain/android-9/arm-linux-androideabi/bin/gcc
        toolchain:       /home/oopsmonk/XBMC_Project/android-toolchain/android-9
        cpu:             armeabi-v7a
        host:            arm-linux-androideabi
        sdk-platform:    android-10
configure: creating ./config.status
config.status: creating Makefile
config.status: creating Makefile.include
#make -j4
make[1]: Leaving directory `/home/oopsmonk/XBMC_Project/xbmc-android-git/tools/android/depends/libssh'
Dependencies built successfully.

8.Building XBMC
#cd ~/XBMC_Project/xbmc-android-git/tools/android/depends/xbmc
#make -j4
APK location : ~/XBMC_Project/xbmc-android-git/xbmcapp-armeabi-v7a-debug.apk
Enjoy it !!

Ref: