Mar 29, 2012

Bash script : cacti add graph to tree

I had to add much graph to graph trees on cacti over 80 nodes.
So I made the following script. I hope this will help you.

Please edit awk pattern phrases like "/host pattern/" as your situation.

#!/bin/bash
#
#   CopyLeft 2012 Joongjin, Bae
#
#

CACTI_CLI_DIR=/var/www/cacti/cli

cd $CACTI_CLI_DIR

HOST_ID_LIST=`php -q add_tree.php --list-hosts | awk '/host pattern/ { print $1}'`
TREE_ID=`php -q add_tree.php --list-trees | awk '/graph tree name/ { print $1}'`
PARENT_ID_LIST=`php -q add_tree.php --list-nodes --tree-id=$TREE_ID | awk '/^Header/ {print $0}' | awk '/graph tree header node pattern/ {print $2}'`
TARGET_GRAPH_ID_LIST=()

for host_id in $HOST_ID_LIST
do
  TARGET_GRAPH_ID_LIST=("${TARGET_GRAPH_ID_LIST[@]}" "`php -q add_tree.php --list-graphs --host-id=$host_id | awk '/add target graph pattern/ { print $1 "\n"}'`")
done

idx=0

for parent_id in $PARENT_ID_LIST
do
  for graph_id in ${TARGET_GRAPH_ID_LIST[$idx]}
  do
    php -q add_tree.php --type=node --node-type=graph --tree-id=$TREE_ID --parent-node=$parent_id --graph-id=$graph_id
  done
  idx=$((idx+1))
done

echo Mission Completed!

Feb 3, 2012

how to change language in netbeans


First of all, Let me show you my environment.
Windows 7 Professional 64bit
NetBeans7.1 64bit
Java 1.6 64bit

Now, I just changed my job and need to prepare new development environment. So I downloaded and installed NetBeans 7.1 English ver. But you know what I'm in Japan. So smart IDE, NetBeans, shows Japanese menu for me. It's cool But I'm Korean and I prefer to use it in English. As you know Java supports all of languages int the world.(It may be not.) Anyway, I asked Google Sensei.

Fortunately, I got one shot. Read the following URL.

It tells me use locale option like following.

  • "C:\Program Files\NetBeans 7.1\bin\netbeans.exe" --locale en:US



I just add this option to shortcut property. OK. It works. But I want another way. Because I want to write Blog. :) I asked G Sensei again in Japanese. Sensei shows me other ways. Here is my solution.

Add language option to netbeans.conf file. This file is located in ↓ if you installed it in default path

  • C:\Program Files\NetBeans 7.1\etc


Open it just add user.language=en to netbeans_default_options item. I show you my configuration.
(I don't change locale, cause I live in Japan ^^)

netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true -J-Duser.language=en"

It is for English. kr for Korean ja for Japanese and cn for Chinese, Sorry since don't know other languages I can't show you other options. Anyway now you got another option to change language in NetBeans. If you are smart(I BELIEVE YOU ARE), you can change language in other IDE like Eclipse, IntelliJ and etc.

YOU WANT Japanese page? Just click the following URL.

Jan 5, 2012

The New Year Resolutions

Yes, I know that New Year already started 5 days ago.
I already decided my resolutions last year.
But I want to make it public and detail.
I hope publishing to force me achieve my resolutions.

OK, here are my resolutions.


  1. Promotion to Manager.
  2. Study of Computer Science and Statics in College.
  3. Buying my home.


1. I will be a manager. That's it.

2. I want to study computer science, statics and business. Big Data Analyst(he/she understands business) will be in high demand in 5 years. And analysis is fun.

3. My Home is My Dream.


------
Written on Jan. 4th 2022.

1. I was promoted to an engineering manager in 2016. But I was promoted to a team lead in 2012.
2. I started to study Stastics from 2012. But I finished my course in 2018.
3. I bought a house in 2013.

Dec 13, 2011

Eclipse: java.lang.UnsupportedClassVersionError: Bad version number in .class file

Thrown when the Java Virtual Machine attempts to read a class file and determines that the major and minor version numbers in the file are not supported. from Java 6 API

When I checked out project source, the project didn't have .project and .classpath files.
(I'm using Eclipse 3.7.)
So I added Project Facets Java as 1.6 and used JRE1.4 for JRE System Library.
My project is supposed to work on Java 1.4.
But I compiled it with Java 1.6 because Project Facets is Java 1.6.

I fixed Project Facets and Java Compiler version and have no problem.

Sep 27, 2011

How to reboot Solaris

Just type the following commands. bash-3.00$shutdown -y -i6 -g0 or bash-3.00$reboot

Aug 29, 2011

org.apache.xerces.dom.DeferredDocumentImpl.getXmlStandalone()Z reason

org.apache.xerces.dom.DeferredDocumentImpl.getXmlStandalone()Z

Reason : It occurs when xercesImpl-X.X.X.jar doesn't exist in the class path.
Solution : Just replace xerces-X.X-X.jar to xercesImpl-X.X.X.jar.

You can download xercesImpl-X.X.X.jar the following URL.
http://mirrors.ibiblio.org/pub/mirrors/maven/mule/dependencies/maven2/xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar

Jul 8, 2011

IE9 frameset tag issue

I've got a problem with IE9.
My web page doesn't show on IE9 document mode.
Because I used frameset tag, I thought my web page failed to satisfy HTML5 standard.
But my another page doesn't have any problem, even using same frameset tag.

I started to find why it happened. There is not answer on the net.
Master Google couldn't help me.(Also Bing and Yahoo)
So I quit searching it on the net and started finding the reason my self with developer tool of IE.

1. miss of javascript code -> deleted every javascript code, but it was same.
2. a bug of Tomcat 5.5 -> changed to 6.0, but it was same.
3. jsp -> quit using jsp, but...
4. 5. 6. ... 100. 101. ...
Finally, I found the reason after 4 days.

The reason was CSS. After I deleted the following line, My web page started working well.
<link href="/css/style.css" rel="stylesheet" type="text/css"/link>

May 12, 2011

How to get ORACLE_HOME by SQL

I had to get Oracle alert log file path by SQL on 9i, 10g.
Because I didn't want to force a user input it.

First I tried the following SQL sentence.
SQL> select * from sysman.mgmt$software_homes;

win2k3svrvminst OraHome92 ORACLE_HOME D:\oracle\ora92

win2k3svrvminst OraDb10g_home1 ORACLE_HOME F:\oracle\product\10.2.0\db_1
win2k3svrvminst Independent Products INDEPENDENT N/A
(copied on SQL Developer)

I didn't know which ORACLE_HOME is proper one.

I should keep searching and tried this.


SQL>select substr(file_spec,   1,   instr(file_spec,   '\',   -1,   2) -1) ORACLE_HOME
from dba_libraries
where library_name = 'DBMS_SUMADV_LIB';
(On Unix, substitute with '/'  )

This SQL showed me ORACLE_HOME, C:\oracle\product\10.2.0\db_1, but it required me as sysdba on 10g.

Because my application can't get sysdba's id and password, I had to keep searching.


SQL> set autopri on
SQL> var oracle_home varchar2(255)
SQL> exec dbms_system.get_env('ORACLE_HOME',:ORACLE_HOME)

It works too, but I don't want to use PL/SQL procedure.

Finally, I quited searching.
But this article can help some people who want to know  "How to get ORACLE_HOME by using SQL".

May 10, 2011

How to know Oracle DB log files' path

ALERT LOG

Oracle writes the alert.log file to the directory as specified by BACKGROUND_DUMP_DEST parameter.
If it is not set, the alert.log will be created in the ORACLE_HOME/rdbms/trace directory.

SQL> show parameter BACKGROUND_DUMP_DEST


NAME                                 TYPE
------------------------------------ ---------------------------------
VALUE
------------------------------
background_dump_dest                 string
/u01/app/oracle/diag/rdbms/trace


LISTNER LOG

Oracle writes listener.log file to ORACLE_HOME/NETWORK/log directory in usual.
You can confirm the path of listner.log file using "lsnrctl status" command.


[oracle@helium ~]$ lsnrctl

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 10-5月 -2011 14:55:15

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

LSNRCTLへようこそ。詳細は"help"と入力してください。

LSNRCTL> status
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))に接続中
リスナーのステータス
------------------------
別名                      LISTENER
バージョン                TNSLSNR for Linux: Version 11.2.0.1.0 - Production
開始日                    13-4月 -2011 15:47:37
稼働時間                  26 日 23 時間 7 分 41 秒
トレース・レベル          off
セキュリティ              ON: Local OS Authentication
SNMP                      OFF
パラメータ・ファイル      /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
ログ・ファイル            /u01/app/oracle/diag/tnslsnr/helium/listener/alert/log.xml
リスニング・エンドポイントのサマリー...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=helium.workslan)(PORT=1521)))
サービスのサマリー...
サービス"kiban.workslan"には、1件のインスタンスがあります。
  インスタンス"kiban"、状態READYには、このサービスに対する1件のハンドラがあります...
サービス"kibanXDB.workslan"には、1件のインスタンスがあります。
  インスタンス"kiban"、状態READYには、このサービスに対する1件のハンドラがあります...
コマンドは正常に終了しました。

May 2, 2011

How to log(write) facility and priority to syslog on Linux(RedHat)

On RHEL 5 or higher version.(CentOS 5 or higher ver.), logging the syslog facility and priority is possible.


Add -S or -SS to SYSLOGD_OPTIONS in /etc/sysconfig/syslog and restart the syslog service for the change to take effect.


example)

  $ cat /etc/sysconfig/syslog
  # Options to syslogd
  # -m 0 disables 'MARK' messages.
  # -r enables logging from remote machines
  # -x disables DNS lookups on messages recieved with -r
  # See syslogd(8) for more details
  SYSLOGD_OPTIONS="-m 0 -SS -r"
  $ service syslog restart



Now you can confirm the facility and priority in your syslog.
  $ cat /var/log messages

  May  1 04:02:02 helium syslogd 1.4.1: restart.
  May  2 13:09:55 helium kernel: Kernel logging (proc) stopped.
  May  2 13:09:55 helium kernel: Kernel log daemon terminating.
  May  2 13:09:57 helium exiting on signal 15 <-- before 
  May  2 13:09:57 helium syslogd 1.4.1: restart (remote reception). <-- after
  May  2 13:09:57 helium kernel: klogd 1.4.1, log source = /proc/kmsg started.

Apr 11, 2011

bash if grammar or(||) and(&&) (if文の or and条件)

I had to check parameters.
I searched if grammar, but I couldn't get a example of if condition || condition.
So I changed key word for search. It was "condition expressions"
I've got the answer. OR condition is -o and AND condition is -a.
Here is the sample code.

OR condition

if ["$1" == "" -o "$2" == ""] ; then
  exit 1
fi

AND condition

if ["$1" == "" -a "$2" == ""] ; then
  exit 1
fi

Apr 8, 2011

Linux version check

Linuxのバージョンを確認する必要があって調べてみた。


#uname -a
Linux localhost.localdomain 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010 i686 i686 i386 GNU/Linux

#cat /proc/version
Linux version 2.6.18-194.el5 (mockbuild@builder16.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Fri Apr 2 14:58:35 EDT 2010

#cat /etc/redhat-release
CentOS release 5.5 (Final)

linux ssh起動メモ

テストに使うLinux サーバにsshで接続できなかったので
忘れないようにメモ

#service sshd start

Apr 7, 2011

Linux ユーザの全てのプロセスをkillするスクリプト

社内のLinuxサーバに無限にプロセスを生成するスクリプトが実行されたので
該当ユーザの全てのプロセスをkillするスクリプトを作ってみた。

#!bin/bash
uid=$1
pids=`ps ax -o uid,pid | grep $uid 2> /dev/null | awk '{print $2}'`
for pid in $pids
do
  if [ $pid != $$ ]; then
    echo "${user}: ${pid} killed"
    kill -KILL $pid
  fi
done


ちなみにそのユーザはbashのプロセスをずっと生成したので
以下のコマンドでも対応できる。
killall bash

rootユーザなら以下のコマンドで他のユーザの全てのプロセスをkillすることもできる。

killall5

Solarisの vmstat見方メモ

以前AIXのvmstatの見方を説明したが、
今回はSolaris。

$ vmstat 1 3
 kthr      memory            page            disk          faults      cpu
 r b w   swap  free  re  mf pi po fr de sr f0 s6 s1 s1   in   sy   cs us sy id
 0 0 0 1013264 74720  4   5 29  3  3  0  0 -0 -0  0  0  434   85   70  2  3 95
 0 3 0 1011328 96624 11  22  0  0  0  0  0  0  0  0  0  449  137   78  1  3 96
 0 0 0 1011328 96624  7   7  0  0  0  0  0  0  0  0  0  407   88   66  0  3 97

主に仕事で必要な情報はメモリ。

AIXと違うのはまず単位がKBであること、
AIXはページ単位だったため4を掛け算する必要があった。
(ページは4KB)

そしてswap項目は使用可能なvirtual memoryサイズ、
AIXはすでに使われた仮想メモリ領域を意味する。

freeはAIXと同じく物理メモリの使用可能サイズを意味する。

Apr 5, 2011

line numbers in eclipse(行番号を表示する設定)

ソースレビューをしていたら自分のEclipseに行番号が表示されないことに気付き設定した。
忘れないためメモ
Windows(ウィンドウ) -> Preferences(設定) -> General(一般) – > Editors(エディター) -> Text Editors(テキスト・エディター)
“Show Line Numbers(行番号の表示)” チェックボックスにチェックを入れる

Mar 30, 2011

AIX CPU別使用率

AIXでCPU別使用率を取得するコマンドと実行結果
「ALL」の代わりに「0 1」を指定すると全体の使用率は表示されないです。

# sar -P ALL 3 5


AIX jkrs 2 5 000FC63D4C00    03/30/11

System Configuration: lcpu=2

18:27:13 cpu    %usr    %sys    %wio   %idle
18:27:16  0       43       8       0      50
          1       52       3       0      45
          -       47       6       0      47
18:27:19  0       47       4       1      48
          1       47       6       0      48
          -       47       5       0      48
18:27:22  0       48      14       0      37
          1       51      11       0      38
          -       50      13       0      37
18:27:25  0       47       4       0      50
          1       50       5       0      45
          -       48       5       0      47
18:27:29  0       42       6       0      53
          1       53       3       0      44
          -       48       4       0      48