[logstash][geoip] 以public-IP取代priveate-IP

No Comments

為了統計上的便利, 並取得全面性的資料樣態
需要把內部IP轉化為數據群體的一部分

在 logstash 設定的方法如下,

if [clientip] and [clientip] !~ "(^127\.0\.0\.1)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^192\.168\.)|(^169\.254\.)" {

            geoip {
                database => "/opt/logstash-2.2.2/GeoLiteCity.dat"
                source => "clientip"
                target => "geoip"
                add_field => [ "[geoip][coordinates]", "%{[geoip][longitude]}" ]
                add_field => [ "[geoip][coordinates]", "%{[geoip][latitude]}"  ]
            }
else {
           mutate {
                add_field => [ "lanip" => "real-public-ip-here" ]
                }
           geoip {
                source => "lanip"
                target => "geoip"
                add_field => [ "[geoip][coordinates]", "%{[geoip][longitude]}" ]
                add_field => [ "[geoip][coordinates]", "%{[geoip][latitude]}"  ]
                }
          mutate {
                remove_field => [ "lanip" ]
                }
        }

以上設定能將內部IP轉為外部IP

關於 \r\n 以及^M 的一些事

No Comments

在 vim 環境下, 顯示出 ^M 符號
https://superuser.com/questions/97692/vim-show-line-feeds-carriage-return

【轉貼】\r\n和\n的差異
http://seacatcry.pixnet.net/blog/post/13732061

利用 rsync 備份資料的相關資訊

No Comments

利用 rsync daemon 方式, 密碼以檔案方式載入
http://tnrc.ncku.edu.tw/course/93/fedora_core2/page15/p15.htm

;rsync -a --password-file=/root/scripts/rsync-sec /opt/alfresco-community/ sopadmin@IP:[port]:Public/alfresco-community/

如果是已經透過 NFS/CIFS 掛載目錄
就直接 rsync -a /source-dir /distination-dir

—- updated —-
http://blog.xuite.net/csiewap/cc/59463116
《使用 rsync 實做重複資料刪除技術 差異備份 版本控制 增量備份》

去除文件裡的 ^M 特殊符號

No Comments

一般 ^M 符號是出現在每行的最後
這時可利用 dos2unix 指令來解決會比較簡單

但偶有情況是出現在行中, 而不是在行尾/行末
這時 dos2unix 就會處理不到

這時要改用以下網頁的方法

http://dragonspring.pixnet.net/blog/post/33146613

sed  "s/\r//" dos_file  > dos_file_linux

或是

tr -d "\r" < dos_file  > dos_file_linux

NextVOD 網樂通安裝 Debian wheezy, 增加 apt source

No Comments

deb [arch=all] http://ftp.tw.debian.org/debian/ wheezy main contrib non-free
deb [arch=all] http://ftp.tw.debian.org/debian/ wheezy-proposed-updates main contrib non-free
deb [arch=all] http://ftp.tw.debian.org/debian/ wheezy-backports main contrib non-free
deb [arch=sh4] http://www.si-linux.co.jp/pub/debian-sh/wheezy-sh4 wheezy main
deb [arch=sh4] http://download.si-linux.co.jp/debian-sh/wheezy-sh4 wheezy main contrib non-free
deb http://ftp.yzu.edu.tw/Linux/debian-sh4-for-nextvod/ wheezy all

REF:
https://ftp.yzu.edu.tw/Linux/debian-sh4-for-nextvod/download.php
http://ftp.yzu.edu.tw/Linux/debian-sh4-for-nextvod/dists/wheezy/all/binary-sh4/

tshark or tcpdump get arp packets

No Comments

tshark

"C:\Program Files\Wireshark\tshark.exe" -n -i 1 -f "arp" -l -t ad
"C:\Program Files\Wireshark\tshark.exe" -n -i rpcap://ip:2002 -f "arp" -l -t ad

tcpdump (尚未找到支援 rpcap 的方法, 一般是 ssh 或 安裝 rpcapd)

tcpdump -n -e -i eth0 arp -U > arp_dump

————– updated ———————-
如何安裝tshark
https://www.question-defense.com/2010/03/07/install-tshark-on-centos-linux-using-the-yum-package-manager

————– updtaed ———————-
Linux 取得rpcap封包的方法, (windows 有內建, 所以不需要)
http://wsunccake.pixnet.net/blog/post/110857051

wireshark:
rhel:~ # wget –no-check-certificate https://1.as.dl.wireshark.org/src/wireshark-1.12.5.tar.bz2
rhel:~ # tar jxf wireshark-1.12.5.tar.bz2
rhel:~/wireshark-1.12.5 # cd wireshark-1.12.5/
rhel:~/wireshark-1.12.5 # ./configure –with-pcap –with-pcap-remote –enable-tshark
rhel:~/wireshark-1.12.5 # make
rhel:~/wireshark-1.12.5 # make install

rhel:~ # tshark -i rpcap://10.10.0.1:2002/eth0 # 使用 textmode wireshark