顯示具有 Syslog 標籤的文章。 顯示所有文章
顯示具有 Syslog 標籤的文章。 顯示所有文章

2025年6月27日 星期五

FortiGate firewall configures the Syslog filter

FortiGate firewall configures the Syslog filter

Reference URL :  

https://community.fortinet.com/t5/FortiGate/Technical-Tip-Using-syslog-free-style-filters/ta-p/204606


Test







Log Example:

ssh login

Jun 28 14:06:00 192.168.100.254 date=2025-06-28 time=14:06:00 devname="Test-FW" devid="FGVMEXXXXXXXXXXX" eventtime=1751090760672765479 tz="+0800" logid="0100032001" type="event" subtype="system" level="information" vd="root" logdesc="Admin login successful" sn="1751090760" user="admin" ui="ssh(192.168.100.112)" method="ssh" srcip=192.168.100.112 dstip=192.168.100.254 action="login" status="success" reason="none" profile="super_admin" msg="Administrator admin logged in successfully from ssh(192.168.100.112)"


web login 


Jun 28 14:07:10 192.168.100.254 date=2025-06-28 time=14:07:09 devname="Test-FW" devid="FGVMEXXXXXXXXXXX" eventtime=1751090829377377416 tz="+0800" logid="0100032001" type="event" subtype="system" level="information" vd="root" logdesc="Admin login successful" sn="1751090829" user="admin" ui="http(192.168.100.112)" method="http" srcip=192.168.100.112 dstip=192.168.100.254 action="login" status="success" reason="none" profile="super_admin" msg="Administrator admin logged in successfully from http(192.168.100.112)"


=======================================================

ssh config 

Jun 28 13:48:30 192.168.100.254 date=2025-06-28 time=13:48:30 devname="Test-FW01" devid="FGVMEXXXXXXXXXXX" eventtime=1751089710571156282 tz="+0800" logid="0100032102" type="event" subtype="system" level="alert" vd="root" logdesc="Configuration changed" user="admin" ui="ssh(192.168.100.112)" msg="Configuration is changed in the admin session"

web config 

Jun 28 13:58:07 192.168.100.254 date=2025-06-28 time=13:58:07 devname="Test-FW" devid="FGVMEXXXXXXXXXXX" eventtime=1751090286557611095 tz="+0800" logid="0100032222" type="event" subtype="system" level="notice" vd="root" logdesc="Global setting changed" user="admin" ui="GUI(192.168.100.112)" field="hostname" old_value="Test-FW01" new_value="Test-FW" msg="User admin changed hostname global setting to Test-FW from GUI(192.168.100.112)"


==================================================

FTG Config 

Test-FW # config log syslogd filter

Test-FW (filter) # show
config log syslogd filter
    config free-style
        edit 1
            set category event
            set filter "logid 0100032001 0100032102 0100032222"
        next
        edit 2
            set category traffic
            set filter "srcintf port1"
        next
    end
end

Test-FW (filter) # get
severity            : information
forward-traffic     : enable
local-traffic       : enable
multicast-traffic   : enable
sniffer-traffic     : enable
ztna-traffic        : enable
anomaly             : enable
voip                : enable
gtp                 : enable
free-style:
    == [ 1 ]
    id:     1       category: event
    == [ 2 ]
    id:     2       category: traffic

Test-FW (filter) #

2025年6月13日 星期五

Rsyslog 收到特定訊息的觸發動作

 

以往都習慣用 Rsyslog + logfmon 這樣的組合去做一些簡單網管小功能.

但 logfmon 這個好工具,已長久不再更新,故想改變一個方式,去取代這樣的組合.

https://xrcd2.blogspot.com/2016/11/logfmon.html

僅用 rsyslog 去做-->收到特定訊息的觸發動作

但不確定這樣的組合是否可以通過高壓測試?

以往 Rsyslog 僅負責將接收到的特定 IP  log 寫入指定位置,
並透過 logfmon 去做特定訊息的分析及觸發動作.

等上線實戰後再來後續處理了.待追蹤~

記錄相關設定如下:



啟用 omprog 模組 在 rsyslog.conf  加上 module(load="omprog")

並啟用相關設定如:


if ($msg contains "Login failed" or $msg contains "Configured" or  $msg contains "LINEPROTO-5-UPDOWN" or  $msg contains "Critical") then {
    action(type="omprog" binary="/usr/local/sbin/XXX.sh")
    stop
}

=========================================

XXX.sh

#!/bin/bash
while read line; do
  echo "收到特定訊息:$line" >> /var/log/trigger.log
  # 這裡可以改成你想做的動作,例如:
  # echo "$line" | mail -s "特定訊息通知" you@example.com
done




 




2022年5月22日 星期日

Fortigate Log monitoring with Wazuh-manager

 參考自 https://github.com/wazuh/wazuh-kibana-app/issues/1884

 

架構說明

FTG-VM(.254)(syslog)

                                 --->Wazuh(.160)(Rsyslog)

                                                                      --->Wazuh-Agent(localfile)

                                                                                                             --->Wazuh(WEB UI)


==================================

vi /etc/rsyslog.conf 

# Provides UDP syslog reception

$ModLoad imudp

$UDPServerRun 514


if $fromhost-ip startswith '192.168.100.254' then /tmp/forti/syslog.log

& ~

==================================

vi /var/ossec/etc/ossec.conf 

  <localfile>

    <log_format>syslog</log_format>

    <location>/tmp/forti/syslog.log</location>

  </localfile>

===================================


Demo

















2022年5月21日 星期六

Graylog 4.2 on Rocky Linux

 安裝 SOP 參考自 https://tech.davidfield.co.uk/graylog-4-x-on-rhel-8-for-log-monitoring/

使用軟體如下:


[root@rocky8 ~]# cat /etc/redhat-release 

Rocky Linux release 8.6 (Green Obsidian)

[root@rocky8 ~]# 



[root@rocky8 ~]# rpm -qa | grep elasticsearch 

elasticsearch-oss-7.10.2-1.x86_64


[root@rocky8 ~]# rpm -qa | grep mongodb

mongodb-org-server-4.2.20-1.el8.x86_64

mongodb-org-shell-4.2.20-1.el8.x86_64

mongodb-org-4.2.20-1.el8.x86_64

mongodb-org-tools-4.2.20-1.el8.x86_64

mongodb-org-mongos-4.2.20-1.el8.x86_64


[root@rocky8 ~]# rpm -qa | grep graylog

graylog-integrations-plugins-4.3.0-8.noarch

graylog-server-4.3.0-8.noarch


===============================================

測試架構

FTG-VM(192.168.100.254)--->RockyLinux(.160)---->GrayLog 4.2

syslog UDP 514------------------>Rsyslog UDP 514---->Graylog Syslog 8888


 vi /etc/rsyslog.conf


# Provides UDP syslog reception

# for parameters see http://www.rsyslog.com/doc/imudp.html

module(load="imudp") # needs to be done just once

input(type="imudp" port="514")


*.* @192.168.100.160:8888;RSYSLOG_SyslogProtocol23Format


=====================

# You MUST set a secret to secure/pepper the stored user passwords here. Use at least 64 characters.

# Generate one by using for example: pwgen -N 1 -s 96

# ATTENTION: This value must be the same on all Graylog nodes in the cluster.

# Changing this value after installation will render all user sessions and encrypted values in the database invalid. (e.g. encrypted access tokens)

password_secret = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


# Create one by using for example: echo -n yourpassword | shasum -a 256

# and put the resulting hash value into the following line

root_password_sha2 = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


vi /etc/graylog/server/server.conf

root_timezone = Asia/Taipei

http_bind_address = 0.0.0.0:9000

password_secret =

root_password_sha2 =


DEMO





卡關處-待研究

Marketplace

https://github.com/seanthegeek/graylog-fortigate-cef

以前的 Lab http://xrcd2.blogspot.com/2016/07/graylog2.html


2016年11月20日 星期日

論 logfmon 簡單的網管運用

依據 NetAdmin網管人文章

2016/5/24
用logfmon即時比對 Log 透過 gcalcli 存入線上行事曆
指令列串接 Google 日曆打造超炫全自動系統日誌
吳惠麟
URL http://netadmin.pcuser.com.tw/article_content.aspx?sn=1605130016&jump=1

這個 Idea 真的很好,但我這裡僅只試了 logfmon 這個程式.
主要拿它來做簡單的網管運用,
依據上面的文章 logfmon 這支程式是放在
http://sourceforge.net/projects/logfmon/
供人下載與安裝,但我使用之時,它是在 github 上.
https://github.com/nicm/logfmon
不過沒差,還是OK的.
看一下 logfmon 流程
http://netadmin.pcuser.com.tw/images/news/NP160513001616051315272705.png



應該跟 Swatch 的用法差不多,
https://sourceforge.net/projects/swatch/

拿它來做簡單的網路設備 log 分析應該不錯.
所以參照我之前用 Swatch 的技法,
改為 logfmon 的技法!

Swatch 的技法,請自行參閱

http://xrcd2.blogspot.tw/2012/05/cacti-xsmsapi-soap-cacti-sms.html
or
http://xrcd2.blogspot.tw/2016/01/cisco-ios-configuration-cisco-config.html

本文開始


以 CentOS 6.X Linux 為 LAB

(1) 安裝 logfmon


#git clone https://github.com/nicm/logfmon
#cd logfmon
#./autogen.sh
#./configure
#make
#make install

預設裝在哪??

[root@bbb logfmon]# whereis logfmon
logfmon: /usr/local/bin/logfmon

man 一下好了..

[root@bbb logfmon]# man logfmon
LOGFMON(8)                BSD System Manager’s Manual               LOGFMON(8)

NAME
     logfmon - log file monitoring daemon

SYNOPSIS
     logfmon [-dsv] [-f conffile] [-c cachefile] [-p pidfile]

DESCRIPTION
     The logfmon daemon monitors a set of syslog log files and matches each new entry against the rules defined in its configuration file. Each rule may be
     tested against entries from a single file, a set of files or from all files. Depending on the rule, a command may be executed or the entry may be
     ignored. All unmatched messages are batched together and mailed every 15 minutes, or whatever alternative time is specified in the configuration file.

     Messages may also be collected into contexts and piped to a command after a final message is found or a number of messages is reached. See
     logfmon.conf(5) for more details of this.

     The options are as follows:

     -c cachefile
                 Specify the cache file location. Default is /var/db/logfmon.cache.

                 This overrides any location specified in the configuration file.

     -d          Run in the foreground and log to stderr.

                 This option also causes additional debugging messages to be generated.  This option may be specified multiple times for increasing levels of
                 verbosity.

     -s          Monitor stdin.  This causes logfmon to remain in the foreground and filter log messages passed on stdin.

     -f conffile
                 Specify the configuration file location. Default is /etc/logfmon.conf.

     -p pidfile  Specify the pid file location. Default is /var/run/logfmon.pid.

                 This overrides any location specified in the configuration file.

     -v          Display the logfmon version, and exit.

FILES
     /etc/logfmon.conf     default logfmon configuration file

SEE ALSO
     syslog(3), logfmon.conf(5)

.....


這樣  logfmon 就裝好了.

(2) 設定 rsyslog

[root@bbb net]# vi /etc/rsyslog.conf
      1 # rsyslog v5 configuration file
      2
      3 # For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
      4 # If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html
      5
      6 #### MODULES ####
      7
      8 $ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
      9 $ModLoad imklog   # provides kernel logging support (previously done by rklogd)
     10 #$ModLoad immark  # provides --MARK-- message capability
     11
     12 # Provides UDP syslog reception
     13 $ModLoad imudp
     14 $UDPServerRun 514

設定 rsyslog 可以對外收 syslog message

     12 # Provides UDP syslog reception
    --> $ModLoad imudp
    --> $UDPServerRun 514

並指定收到  主機或某網段 的 syslog message 存入某一個檔案中,
預備成為  logfmon 被監控的檔案

    --> 88 if $fromhost-ip == '192.168.111.61' then  /var/log/net/vyos.log

重啟 rsyslog 服務

#service rsyslog restart


設定 192.168.111.61 (client )這台 vyos 的 config ,
宣告它的 syslog host 為 192.168.111.247 ( Rsyslog + logfmon Server )

所以 topolog 為 192.168.111.61 (client ) ---> 192.168.111.247 (Server)

Client 端只要是支援標準的 syslog 即可使用.
Server 端是透過 Rsyslog 作為 syslog server 的角色.
用其它的也可,只是 logfmon 只能用在 log 檔案的分析.


vyos 的設定如下;(模擬成網路設備,Client 端角色)

vyos@vyos:~$ show configuration commands
set interfaces ethernet eth0 address 'dhcp'
set interfaces ethernet eth0 duplex 'auto'
set interfaces ethernet eth0 smp-affinity 'auto'
set interfaces ethernet eth0 speed 'auto'
set interfaces loopback 'lo'
set service ssh port '22'
set system config-management commit-revisions '20'
set system host-name 'vyos'
set system login user vyos authentication encrypted-password '$6$wycLUv4kpl$WEywQMIvFUqIC9yA3HPb42IG0328X1iNqa1967sFWEce6oC6SrvcV3Nn2hQF1n4bTE/vyQ9e9LyF813VEx9HS.'
set system login user vyos authentication plaintext-password ''
set system login user vyos level 'admin'
set system name-server '168.95.1.1'
set system name-server '168.95.192.1'
set system ntp server 'clock.hinet.net'
set system syslog global facility all level 'notice'
set system syslog global facility protocols level 'debug'
set system syslog host 192.168.111.247 facility all level 'all'
set system time-zone 'Asia/Taipei'
vyos@vyos:~$


到目前為止,已有 Syslog Message Client + Server 也安裝好了  logfmon 了.


設定 logfmon.conf (依據 man 的說明是寫在 /etc/logfmon.conf 中),
內容依實務需求撰寫之.

# cat /etc/logfmon.conf
set logregexp "(.*)"
file "/var/log/net/vyos.log" tag login
match in  login  "(.*)(Accepted password for)(.*)"  exec  "/usr/bin/perl /root/shell/sendmail.pl \"$1\" \"$2\" \"$3\""
match in  login  "(.*)(session closed for user)(.*)"  exec  "/usr/bin/perl /root/shell/sendmail.pl \"$1\" \"$2\" \"$3\""


原始的 log 內文 如下.

Nov 18 14:00:25 vyos sshd[7071]: Accepted password for vyos from 192.168.1.115 port 50960 ssh2
Nov 18 14:01:08 vyos sshd[7071]: pam_unix(sshd:session): session closed for user vyos

參照(正規化表示法比對)

match in  login  "(.*)(Accepted password for)(.*)"
match in  login  "(.*)(session closed for user)(.*)"


exec ... sendmail .... (執行自定指令)


# cat /root/shell/sendmail.pl

#!/usr/bin/perl
use Mail::Sender;
print " \n Start \n ";
$sender = new Mail::Sender
{smtp => '192.168.1.xxx', from => 'Test-Alert@abc.com.tw'}  or die "Error in mailing : $Mail::Sender::Error\n";
$sender->MailMsg({to => 'xrcd2@abc.com.tw',subject => 'Test_Alert',msg => "My Test \n\n $ARGV[0] $ARGV[1] $ARGV[2] \n ",debug => $DEBUG,debug_level => 4});
print " \n END \n\n";
print " \n $DEBUG \n ";

DEMO

執行 logfmon

[root@bbb net]# logfmon -f /etc/logfmon.conf

驗證 logfmon 是否有被正常執行,如它無法正常被執行,
請再檢核該 conf 的設定與配置是否正確?!

[root@bbb net]# ps -ef | grep logfmon
root     19091     1  0 15:56 ?        00:00:00 logfmon -f /etc/logfmon.conf
root     19113 15664  0 15:59 pts/1    00:00:00 grep logfmon
[root@bbb net]#

rsyslog 收到 log 後會存入於此.

[root@bbb net]# pwd
/var/log/net
[root@bbb net]# ll
total 0
-rw------- 1 root root 0 Nov 18 15:58 vyos.log
[root@bbb net]#


ssh 到 vyos 做 登入與登出的以驗證 rsyslog + logfmon + sendmail

[root@bbb net]# cat  /var/log/net/vyos.log
Nov 18 16:04:01 vyos sshd[7653]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Nov 18 16:04:05 vyos sshd[7653]: Accepted password for vyos from 192.168.1.115 port 52045 ssh2
Nov 18 16:04:05 vyos sshd[7653]: pam_unix(sshd:session): session opened for user vyos by (uid=0)
Nov 18 16:04:34 vyos sshd[7655]: error: Received disconnect from 192.168.1.115: 0:
Nov 18 16:04:34 vyos sshd[7653]: pam_unix(sshd:session): session closed for user vyos
[root@bbb net]#


 Accepted password for   ( Mail Alert )















session closed for user  ( Mail Alert )
















Topology

運用的實例可參考如下:

圖中的 syslog2msn 即為 rsyslog + logfmon + shell (組合變化而來)


























http://xrcd2.blogspot.tw/2012/05/cacti-xsmsapi-soap-cacti-sms.html




其它更進階的運如下:

那個 Swatch 可由 logfmon 取代之,也是可由 rsyslog + swatch + shell (組合變化而來)

http://xrcd2.blogspot.tw/2016/01/cisco-ios-configuration-cisco-config.html


2016年10月26日 星期三

LogAnalyzer Delete Records

loganalyzer 真是一套不錯的 OpenSource ,
用它來收集與分析 syslog  message 最簡單實用不過了!

官網
http://loganalyzer.adiscon.com/

Demo
http://loganalyzer-demo.adiscon.com/

但這次想做的是,刪除2015年前的舊資料,參考官網上的說明如下:

http://wiki.rsyslog.com/index.php/LogAnalyzer_Delete_Records

.....


Samples

All samples assume that the data to be deleted is contained in logstream 2.

Delete all data
  php maintenance.php cleardata 2 all

Delete all data older then 1 hour
  php maintenance.php cleardata 2 olderthan 3600

Some typical values are
60 - one minute
3,600 - one hour
86400 - one day
2592000 - 30 days, roughly one month

Delete all data before 2008-11-18
  php maintenance.php cleardata 2 date 11 18 2008
....


簡單的說透過 maintenance.php 這支程式即可完成該項作業。

maintenance.php (程式內文節錄如下:)( 這裡也有 Sample )

那個 ID 可透過 WEB 介面去查詢到..


149 // --- BEGIN Custom Code
150         //Additional Includes
151         include($gl_root_path . 'include/functions_debugoutput.php');
152 
153         // Run into Commandline part now!
154         /* Only run if we are in command line mode 
155         *       
156         *       Possible Operation Types:
157         *       cleandata               =       If you want to clear data from a logstream source, you can use the operation type. 
158         *                                               Be carefull using this option, any deletion process cannot be undone!
159         *                                               Sample 1: Delete all data in the logstream with id 2
160         *                                                       php maintenance.php cleandata 2 all
161         *                                               Sample 2: Delete all data older then 60 seconds in the logstream with id 2
162         *                                                       php maintenance.php cleandata 2 olderthan 60
163         *                                               Sample 3: Delete all data before 2008-11-18 in the logstream with id 2
164         *                                                       php maintenance.php cleandata 2 date 11 18 2008 
165         *
166         */


ID 怎麼來圖解如下,官網中也有說明:





該程式放在 cron 這個目錄中.

[root@cacti cron]# pwd
/var/www/html/loganalyzer/cron

[root@cacti cron]# ls -la
total 36
drwxr-xr-x  2 root root 4096 Oct 27 11:39 .
drwxr-xr-x 14 root root 4096 Oct 27 10:35 ..
-rw-r--r--  1 root root 7551 May 17  2013 cmdreportgen.php
-rw-r--r--  1 root root   31 May 17  2013 .htaccess
-rw-r--r--  1 root root   68 May 17  2013 maintenance.bat
-rw-r--r--  1 root root 7251 May 17  2013 maintenance.php
-rw-r--r--  1 root root   89 May 17  2013 maintenance.sh
[root@cacti cron]#

實作吧~

[root@cacti cron]# php maintenance.php cleandata 1 date 1 1 2015 
Num. Facility . Debug Message
1. Information. CleanData. Cleaning data for logstream source 'My Syslog Source'.
2. Information. CleanData. Successfully connected and found '3203148' rows in the logstream source.
3. Information. CleanData. Performing deletion of data entries older then '2015-01-01'.
4. Information. CleanData. Successfully Deleted '446346' rows in the logstream source.'
[root@cacti cron]# 


再透過 mysqlcheck 指令,檢查及優化 MySQL 資料庫 ,並釋放出刪除資料後磁碟空間

[root@cacti cron]# mysqlcheck -a -c  -o -r Syslog 
Syslog.SystemEvents                                OK
Syslog.SystemEventsProperties                      OK
Syslog.logcon_charts                               OK
Syslog.logcon_config                               OK
Syslog.logcon_dbmappings                           OK
Syslog.logcon_fields                               OK
Syslog.logcon_groupmembers                         OK
Syslog.logcon_groups                               OK
Syslog.logcon_savedreports                         OK
Syslog.logcon_searches                             OK
Syslog.logcon_sources                              OK
Syslog.logcon_users                                OK
Syslog.logcon_views                                OK
[root@cacti cron]#

前後對照如下:
(前)
[root@cacti cron]# du /var/lib/mysql/* -hs 
51M /var/lib/mysql/cacti
10M /var/lib/mysql/ibdata1
5.0M /var/lib/mysql/ib_logfile0
5.0M /var/lib/mysql/ib_logfile1
1000K /var/lib/mysql/mysql
0 /var/lib/mysql/mysql.sock
656M /var/lib/mysql/Syslog
4.0K /var/lib/mysql/test

(後)
[root@cacti cron]# du /var/lib/mysql/* -hs 
51M /var/lib/mysql/cacti
10M /var/lib/mysql/ibdata1
5.0M /var/lib/mysql/ib_logfile0
5.0M /var/lib/mysql/ib_logfile1
1000K /var/lib/mysql/mysql
0 /var/lib/mysql/mysql.sock
446M /var/lib/mysql/Syslog
4.0K /var/lib/mysql/test
[root@cacti cron]#

完工

2016年7月17日 星期日

再論 Graylog2

在 Log 的 Search 的運用套件最常看到的組合有
Elasticsearch Logstash Kibana (ELK)
但另一個組合也不錯,那就是 Elasticsearch + Graylog2
可使用 yum 一路裝到底.
目前 Elasticsearch + Graylog2 亦有二種組合.
一為  Elasticsearch (1.7.x)  +   Graylog (1.2.x)

elasticsearch-1.7.5-1.noarch + graylog-web-1.2.2-1.noarch +  graylog-server-1.2.2-1.noarch

另一組則為

 Elasticsearch (2.x)  +   Graylog (2.x)

elasticsearch-2.3.4-1.noarch+graylog-server-2.1.0-2.alpha.2.noarch
DB 同樣是使用 mongodb 3.x

Graylog
https://www.graylog.org/

Elasticsearch
https://www.elastic.co/


Graylog 可以啟動 syslogd 的服務.配合 Elasticsearch,就是一個類 Splunk 的功能.

安裝的參考 URL

http://www.itzgeek.com/how-tos/linux/centos-how-tos/how-to-install-graylog2-on-centos-7-rhel-7.html#axzz3hLHT1k83

graylog 1.x + Elasticsearch 1.7.x

http://www.systeen.com/2016/05/12/install-graylog-2-0-centos-7-collect-windows-logs/

graylog 2.x + Elasticsearch 2.x

如以 CentOS 7 改以 root 身份去啟動  graylog  可

vi /usr/lib/systemd/system/graylog-server.service

(將user & group 由 graylog 改為 root)





































































2014年9月8日 星期一

Logstash Shipper and Indexer


http://logstash.net/docs/1.2.2/tutorials/getting-started-centralized-overview-diagram.png




















logstash shipper configuration  

[root@CentOS6 init.d]# pwd
/etc/init.d
[root@CentOS6 init.d]# cat logstash-agent
#!/bin/bash
# From The Logstash Book
# The original of this file can be found at: http://logstashbook.com/code/index.html
#
#
# Logstash Start/Stop logstash
#
# chkconfig: 345 99 99
# description: Logstash
# processname: logstash

name="logstash-agent"
logstash_bin="/opt/logstash/bin/logstash"
logstash_conf="/etc/logstash/shipper.conf"
logstash_log="/var/log/logstash/shipper.log"

find_logstash_process () {
    PIDTEMP=`ps ux | grep logstash | grep java | awk '{ print $2 }'`
    # Pid not found
    if [ "x$PIDTEMP" = "x" ]; then
        PID=-1
    else
        PID=$PIDTEMP
    fi
}

start () {
    LOG_DIR=`dirname ${logstash_log}`
    if [ ! -d $LOG_DIR ]; then
      echo "Log dir ${LOG_DIR} doesn't exist. Creating"
      mkdir $LOG_DIR
    fi
    nohup ${logstash_bin} agent --verbose -f ${logstash_conf} --log ${logstash_log} > /dev/null 2>&1 &
}

stop () {
    find_logstash_process
    if [ $PID -ne -1 ]; then
        kill $PID
    fi
}

case $1 in
start)
        start
        ;;
stop)
        stop
        exit 0
        ;;
reload)
        stop
        sleep 2
        start
        ;;
restart)
        stop
        sleep 2
        start
        ;;
status)
        find_logstash_process
        if [ $PID -gt 0 ]; then
          echo "logstash running: $PID"
          exit 0
        else
          echo "logstash not running"
          exit 1
        fi
        ;;
*)
        echo $"Usage: $0 {start|stop|restart|reload|status}"
        RETVAL=1
esac
exit 0
[root@CentOS6 init.d]# cat /etc/logstash/shipper.conf 
input {
file {
        type => "syslog"
path => ["/syslog/apache/mod_jk*.log","/syslog/tomcat/*.log"]
        tags => "tomcat"
}
}


output {
       redis {
       host => "192.168.1.145"
       data_type => "list"
       key => "logstash"
       }
}
[root@CentOS6 init.d]#






















Logstash Indexer configuration 


[root@Test-Logstash conf.d]# pwd
/etc/logstash/conf.d
[root@Test--Logstash conf.d]# cat syslog.conf 
input {
  tcp {
    type => "syslog"
    port => 514
  }
  udp {
    type => "syslog"
    port => 514
  }
  redis {
host => "127.0.0.1"
type => "redis-input"
data_type => "list"
key => "logstash"
# codec => "json"
 }
}


filter {
  if [type] == "syslog" {
    grok {
      match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
      add_field => [ "received_at", "%{@timestamp}" ]
      add_field => [ "received_from", "%{host}" ]
    }
    syslog_pri { }
    date {
      match => [ "syslog_timestamp", "MMM  d HH:mm:ss", "MMM dd HH:mm:ss" ]
    }
  }
  if [type] == "apache" {
    grok {
      # See the following URL for a complete list of named patterns
      # logstash/grok ships with by default:
      # https://github.com/logstash/logstash/tree/master/patterns
      #
      # The grok filter will use the below pattern and on successful match use
      # any captured values as new fields in the event.
      match => { "message" => "%{COMBINEDAPACHELOG}" }
    }
    date {
      # Try to pull the timestamp from the 'timestamp' field (parsed above with
      # grok). The apache time format looks like: "18/Aug/2011:05:44:34 -0700"
      match => [ "timestamp", "dd/MMM/yyyy:HH:mm:ss Z" ]
    }
  }
}


output {
  elasticsearch {
    embedded => true
  }
}

[root@Test-Logstash conf.d]#






2014年8月28日 星期四

Logstash + Elasticsearch + Kibana

Logstash  + Elasticsearch + Kibana
類似 Splunk 的功能 OpenSource

Logstash 的使用結合  Elasticsearch  與  Kibana

Logstash + Elasticsearch + Kibana

角色說明:

(0) rsyslog [Remote linux server ]
(1) syslog collector [ Logstash ]
(2) search server [Elasticsearch ]
(3) web ui [ Kibana ]

官方實用說明
http://www.logstash.net/docs/1.4.2/tutorials/10-minute-walkthrough/
http://logstash.net/docs/1.4.2/tutorials/getting-started-with-logstash


分別使用 rpm & yum 安裝必要的軟體

(Logstash)

官網上下載該 rpm 安裝即可
 (  http://www.elasticsearch.org/overview/elkdownloads/  )
[root@Test-Logstash syslog]# rpm -qa | grep logstash
logstash-contrib-1.4.2-1_efd53ef.noarch
logstash-1.4.2-1_2c0f5a1.noarch

(Java)

yum 安裝即可
[root@Test-Logstash syslog]# rpm -qa | grep java
tzdata-java-2014e-1.el6.noarch
java-1.7.0-openjdk-1.7.0.65-2.5.1.2.el6_5.x86_64

(Elasticsearch)

官網上下載該 rpm 安裝即可
 ( http://www.elasticsearch.org/overview/elkdownloads/ )
[root@Test-Logstash src]# rpm -qa | grep elasticsearch
elasticsearch-1.3.2-1.noarch

(Kinaba)

kibana 官網上下載該檔案即可
 ( http://www.elasticsearch.org/overview/elkdownloads/ )
kibana-3.1.0.tar.gz 並解壓縮後放置於 /var/www/html 內即可,目錄名稱可自行命名之

(Remote Syslog Client)

修改 rsyslog.conf 並重啟該服務即可
最簡單的設定方式

在最下方加入
*.* @xxx.xxx.xxx
or
*.* @@xxx.xxx.xxx




設定 logstash 的 conf

[root@Test-Logstash conf.d]# pwd
/etc/logstash/conf.d
[root@Test-Logstash conf.d]# cat syslog.conf 
input {
  tcp {
    type => "syslog"
    port => 514
  }
  udp {
    type => "syslog"
    port => 514
  }
}

filter {
  if [type] == "syslog" {
    grok {
      match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
      add_field => [ "received_at", "%{@timestamp}" ]
      add_field => [ "received_from", "%{host}" ]
    }
    syslog_pri { }
    date {
      match => [ "syslog_timestamp", "MMM  d HH:mm:ss", "MMM dd HH:mm:ss" ]
    }
  }
}


output {
  elasticsearch {
    embedded => true
  }
}

[root@Test-Logstash conf.d]#


將 logstash 服務改由 root 身份啟動

[root@Test-Logstash init.d]# pwd
/etc/init.d
[root@Test-Logstash init.d]# cat logstash
#!/bin/sh
# Init script for logstash
# Maintained by Elasticsearch
# Generated by pleaserun.
# Implemented based on LSB Core 3.1:
#   * Sections: 20.2, 20.3
#
### BEGIN INIT INFO
# Provides:          logstash
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description:
# Description:        Starts Logstash as a daemon.
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH

if [ `id -u` -ne 0 ]; then
   echo "You need root privileges to run this script"
   exit 1
fi

name=root
pidfile="/var/run/$name.pid"

LS_USER=root
LS_GROUP=root


設定 Kibana config  內的 elasticsearch 的 url

[root@Test-Logstash syslog]# pwd
/var/www/html/syslog
[root@Test-Logstash syslog]# cat config.js
/** @scratch /configuration/config.js/1
 *
 * == Configuration
 * config.js is where you will find the core Kibana configuration. This file contains parameter that
 * must be set before kibana is run for the first time.
 */
define(['settings'],
function (Settings) {


  /** @scratch /configuration/config.js/2
   *
   * === Parameters
   */
  return new Settings({

    /** @scratch /configuration/config.js/5
     *
     * ==== elasticsearch
     *
     * The URL to your elasticsearch server. You almost certainly don't
     * want +http://localhost:9200+ here. Even if Kibana and Elasticsearch are on
     * the same host. By default this will attempt to reach ES at the same host you have
     * kibana installed on. You probably want to set it to the FQDN of your
     * elasticsearch host
     *
     * Note: this can also be an object if you want to pass options to the http client. For example:
     *
     *  +elasticsearch: {server: "http://localhost:9200", withCredentials: true}+
     *
     */
    elasticsearch: "http://192.168.111.145:9200",


Demo

elasticsearch test 




Kibana





2014年8月18日 星期一

Rsyslog + Elasticsearch + Kibana

類似 Splunk 的功能 OpenSource

rsyslog 的進階使用結合  Elasticsearch  與  Kibana

Rsyslog + Elasticsearch + Kibana

角色說明:
(0) rsyslog [Remote linux server ]
(1) rsyslog collector [ Rsyslog ]
(2) search server [Elasticsearch ]
(3) web ui [ Kibana ]


(1)升級並安裝 rsyslog 8.x等必要套件

[root@Rsyslog yum.repos.d]# pwd
/etc/yum.repos.d
[root@Rsyslog yum.repos.d]# cat rsyslog.repo
[rsyslog_v8]
name=Adiscon CentOS-$releasever - local packages for $basearch
baseurl=http://rpms.adiscon.com/v8-stable/epel-$releasever/$basearch
enabled=1
gpgcheck=0
gpgkey=http://rpms.adiscon.com/RPM-GPG-KEY-Adiscon
protect=1
[root@Rsyslog yum.repos.d]#

yum update rsyslog
yum install rsyslog-debuginfo rsyslog-libdbi rsyslog-mysql rsyslog-relp rsyslog-snmp rsyslog-elasticsearch rsyslog-mmanon rsyslog-mmfields rsyslog-mmjsonparse rsyslog-mmnormalize rsyslog-mmutf8fix rsyslog-ommail

[root@Rsyslog rsyslog.d]# rpm -qa | grep rsyslog
rsyslog-8.2.2-1.el6.x86_64
rsyslog-mmfields-8.2.2-1.el6.x86_64
rsyslog-relp-8.2.2-1.el6.x86_64
rsyslog-snmp-8.2.2-1.el6.x86_64
rsyslog-ommail-8.2.2-1.el6.x86_64
rsyslog-mmjsonparse-8.2.2-1.el6.x86_64
rsyslog-mysql-8.2.2-1.el6.x86_64
rsyslog-debuginfo-8.2.2-1.el6.x86_64
rsyslog-mmutf8fix-8.2.2-1.el6.x86_64
rsyslog-mmnormalize-8.2.2-1.el6.x86_64
rsyslog-mmanon-8.2.2-1.el6.x86_64
rsyslog-elasticsearch-8.2.2-1.el6.x86_64
rsyslog-libdbi-8.2.2-1.el6.x86_64
[root@Rsyslog rsyslog.d]#

(2)安裝 java & Elasticsearch

http://www.elasticsearch.org/overview/elkdownloads/

wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.2.noarch.rpm

rpm 安裝即可

(3)安裝 Kibana ( search web api )
wget https://download.elasticsearch.org/kibana/kibana/kibana-3.1.0.tar.gz
放在 web -root 即可

其它重要設定

vi /etc/rsyslog.conf

新增 rsyslog  listen port

# Provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514

# Provides TCP syslog reception
$ModLoad imtcp
$InputTCPServerRun 514


新增與 Elasticsearch 介接設定 syslog.conf

[root@Rsyslog rsyslog.d]# pwd
/etc/rsyslog.d
[root@Rsyslog rsyslog.d]# cat syslog.conf
module(load="omelasticsearch") # for outputting to Elasticsearch

# this is for index names to be like: logstash-YYYY.MM.DD
template(name="logstash-index" type="list") {
 constant(value="logstash-")
 property(name="timereported" dateFormat="rfc3339" position.from="1" position.to="4")
 constant(value=".")
 property(name="timereported" dateFormat="rfc3339" position.from="6" position.to="7")
 constant(value=".")
 property(name="timereported" dateFormat="rfc3339" position.from="9" position.to="10")
}

# this is for formatting our syslog in JSON with @timestamp
 template(name="plain-syslog" type="list") {
 constant(value="{")
 constant(value="\"@timestamp\":\"")     property(name="timereported" dateFormat="rfc3339")
 constant(value="\",\"@host\":\"")       property(name="hostname")
 constant(value="\",\"@severity\":\"")   property(name="syslogseverity-text")
 constant(value="\",\"@facility\":\"")   property(name="syslogfacility-text")
 constant(value="\",\"@syslogtag\":\"")  property(name="syslogtag" format="json")
 constant(value="\",\"@message\":\"")    property(name="msg" format="json")
 constant(value="\"}")
 }
# this is where we actually send the logs to Elasticsearch (localhost:9200 by default)
action(type="omelasticsearch" template="plain-syslog" searchIndex="logstash-index" dynSearchIndex="on")


參考 url http://blog.sematext.com/2013/07/01/recipe-rsyslog-elasticsearch-kibana/

demo





2014年8月14日 星期四

rsyslog 的進階使用,將一般文字檔重導到 log server 內. ( InputFileName )

rsyslog 的進階使用,將一般文字檔重導到 log server 內.

使用環境 CentOS 6.5  rsyslog-5.8.10-8.el6.x86_64

[root@CentOS6 rsyslog.d]# pwd
/etc/rsyslog.d
[root@CentOS6 rsyslog.d]# cat messagesystem.conf

$ModLoad imfile
$WorkDirectory /var/spool/rsyslog


#Add a tag for tomcat events
$template LogglyFormatTomcat,"<%pri%>%protocol-version% %timestamp:::date-rfc3339% %HOSTNAME% %app-name% %procid% %msgid% [ MessageSystme tag=\"tomcat\"] %msg%\n"

# MessageSystem Log

$InputFileName /syslog/tomcat/MessageSystem.log
$InputFileTag messagesystem-log
$InputFileStateFile messagesystem-log
$InputFileSeverity info
$InputFilePollInterval 1
$InputFilePersistStateInterval 1
$InputRunFileMonitor
if $programname == 'messagesystem-log' then @192.168.1.1:514;LogglyFormatTomcat
if $programname == 'messagesystem-log' then ~

其它參考設定可自行參閱 https://www.loggly.com/docs/sending-apache-logs/
或使用參數 http://www.rsyslog.com/doc/property_replacer.html

2012年7月22日 星期日

安裝 Graylog2 筆記 ( centos 6.3 + Ruby 1.9.3 )


關於 Graylog2 (log server)請自行參閱
http://graylog2.org/

前置作業安裝好 Ruby 與 Java 的使用環境

#yum erase ruby ruby-libs ruby-mode ruby-rdoc ruby-irb ruby-ri ruby-docs .............
#yum install gcc gcc-c++ openssl-devel zlib-devel autoconf readline-devel curl-devel expat-devel gettext-devel

如安裝使用 Ruby 1.9.x 請先安裝 yaml-0.1.4.tar.gz
http://pyyaml.org/wiki/LibYAML
yuml
./configure
make
make install

Ruby 1.9.x
./configure --enable-shared --enable-pthread --prefix=/xxxx
make
make install


=================================
另一種安裝方式

#curl -L https://get.rvm.io | bash -s stable
#exit  and relogin
or
#source /etc/profile

rvm pkg install openssl
rvm install 1.9.3 --with-openssl-dir=/usr/local/rvm/usr

=================================

# ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
# gem -v
1.8.23


java-1.6.0-openjdk.i686 : OpenJDK Runtime Environment
java-1.7.0-openjdk.i686 : OpenJDK Runtime Environment

#yum install java-xxxxxxx


gem 的使用技法
#gem install
#gem list
#gem install xxxx -v x.x.x
#gem update

graylog2
http://graylog2.org/
http://graylog2.org/download
elasticsearch
http://www.elasticsearch.org/
https://github.com/elasticsearch/elasticsearch/downloads
elasticsearch-servicewrapper
https://github.com/elasticsearch/elasticsearch-servicewrapper/downloads

DB install (mongoDB)

#vi /etc/yum.repos.d/10gen.repo
[root@graylog2 service]# cat /etc/yum.repos.d/10gen.repo
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
gpgcheck=0
enabled=1
[root@graylog2 service]#

#yum update

#yum install mongo-10gen mongo-10gen-server

設定 port 與 DB 使用的驗證方式
# vi /etc/mongod.conf 

Create graylog2 ID & PWD
# mongo
MongoDB shell version: 2.0.6
connecting to: test
> use graylog2
switched to db graylog2
>db.addUser("userid","userpwd")
>db.system.users.find()
>exit
or
>db.addUser("userid","userpwd")
>db.auth("userid","passwd")
>db.system.users.find()
>exit

相關 DB & ID & PWD 將套用於

# cat /etc/graylog2.conf

# On which port (UDP) should we listen for Syslog messages? (Standard: 514)
syslog_listen_port = 514
syslog_protocol = udp
# ElasticSearch URL (default: http://localhost:9200/)
elasticsearch_url = http://localhost:9200/
elasticsearch_index_name = graylog2
# Always try a reverse DNS lookup instead of parsing hostname from syslog message?
force_syslog_rdns = false
# Set time to NOW if parsing date/time from syslog message failed instead of rejecting it?
allow_override_syslog_date = true
# MongoDB Configuration
mongodb_useauth = true
mongodb_user = userid
mongodb_password = userpwd
mongodb_host = localhost
#mongodb_replica_set = localhost:27017,localhost:27018,localhost:27019
mongodb_database = graylog2
mongodb_port = 27017
....
....
===============================

# cat /opt/graylog2-web-interface/config/mongoid.yml

production:
  host: localhost
  port: 27017
  username: userid
  password: userpwd
  database: graylog2

[root@graylog2 src]#
===============================

驗證 ID & PWD + DB 的方式

#mongo localhost/graylog2 -u userid -p userpwd

or

#mongo

MongoDB shell version: 2.0.6
connecting to: test
> show dbs
admin   (empty)
graylog2        0.0625GB
graylog2_development    (empty)
local   (empty)
test    (empty)
> use graylog2
switched to db graylog2
> show collections
blacklists
filtered_terms
hosts
jobs
message_counts
server_values
settings
streamcategories
streams
system.indexes
system.users
users
> db.hosts.find()
{ "_id" : ObjectId("500b4007f226e0d4bf5c5e93"), "host" : "192.168.100.252", "message_count" : 147 }
{ "_id" : ObjectId("500b4089f226e0d4bf5c5e94"), "host" : "192.168.100.251", "message_count" : 184 }
> db.system.users.find()
{ "_id" : ObjectId("500b2504433e438db352e192"), "user" : "userid", "readOnly" : false, "pwd" : "68cdc0f21c4624d1293d2fc54f966b38" }
> exit


程式安裝的目錄結構如下:

# pwd
/opt
[root@graylog2 opt]# ll
total 12
drwxr-xr-x.  7 root root 4096 Jul 22 06:03 elasticsearch  <-- elasticsearch
drwxr-xr-x.  3 root root 4096 Jul 22 05:36 graylog2
drwxr-xr-x. 10 root root 4096 Jul 22 06:06 graylog2-web-interface
[root@graylog2 opt]#

# pwd
/opt/graylog2
# ll
total 9492
drwxr-xr-x. 2 root root    4096 Jul 22 06:04 bin
-rw-r--r--. 1 root root      30 Jul 22 05:36 build_date
-rw-r--r--. 1 root root   35147 Jul 22 05:36 COPYING
-rw-r--r--. 1 root root    3361 Jul 22 05:36 graylog2.conf.example
-rw-r--r--. 1 root root 9663961 Jul 22 05:36 graylog2-server.jar
-rw-r--r--. 1 root root     106 Jul 22 05:36 README

設定 graylog2 server 的運作方式 (cp graylog2.conf.example 來的)
cp elasticsearch.yml.example /etc/graylog2-elasticsearch.yml
cp graylog2.conf.example /etc/graylog2.conf

#vi /etc/etc/graylog2.conf


# pwd
/opt/elasticsearch/bin

# ll
total 20
-rwxr-xr-x. 1 root root 5517 Jul 22 05:36 elasticsearch
-rwxr-xr-x. 1 root root 2058 Jul 22 05:36 elasticsearch.in.sh
-rwxr-xr-x. 1 root root  729 Jul 22 05:36 plugin
drwxr-xr-x. 4 root root 4096 Jul 22 06:03 service  <-- elasticsearch-servicewrapper

#pwd
/opt/graylog2-web-interface/config
# ll
total 60
-rw-r--r--. 1 root root 2188 Jul 22 05:36 application.rb
-rw-r--r--. 1 root root 1938 Jul 22 05:36 authorization_rules.rb
-rw-r--r--. 1 root root  152 Jul 22 05:36 boot.rb
-rw-r--r--. 1 root root  299 Jul 22 05:36 email.yml
-rw-r--r--. 1 root root  189 Jul 22 05:36 environment.rb
drwxr-xr-x. 2 root root 4096 Jul 22 05:36 environments
-rw-r--r--. 1 root root  998 Jul 22 05:36 general.yml
-rw-r--r--. 1 root root   65 Jul 22 05:36 indexer.yml
drwxr-xr-x. 2 root root 4096 Jul 22 05:36 initializers
drwxr-xr-x. 2 root root 4096 Jul 22 05:36 locales
-rw-r--r--. 1 root root  104 Jul 22 06:05 mongoid.yml
-rw-r--r--. 1 root root 9042 Jul 22 05:36 newrelic.yml
-rw-r--r--. 1 root root 2451 Jul 22 05:36 routes.rb

#vi /opt/graylog2-web-interface/config/mongoid.yml

========================

production:
  host: localhost
  port: 27017
  username: userid
  password: userpwd
  database: graylog2

======================

# passenger-install-apache2-module

#vi /etc/httpd/conf/httpd.conf

Listen 8080
LoadModule passenger_module /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.14/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.14
PassengerRuby /usr/bin/ruby

<VirtualHost *:8080>
   ServerName 192.168.100.180
   # !!! Be sure to point DocumentRoot to 'public'!
   DocumentRoot /opt/graylog2-web-interface/public
   <Directory /graylog2>
      # This relaxes Apache security settings.
      AllowOverride all
      # MultiViews must be turned off.
      Options -MultiViews
   </Directory>
</VirtualHost>

# service httpd restart

安裝 elasticsearch service
# /opt/elasticsearch/bin/service/elasticsearch install

設定 elasticsearch service

#vi /usr/local/elasticsearch/config/elasticsearch.yml
cluster.name: graylog2
啟動 elasticsearch-servicewrapper 
# /opt/elasticsearch/bin/service/elasticsearch start

啟動 graylog2 Server
# /opt/elasticsearch/bin/graylog2ctl start


#gem install bundle

#cd /opt/graylog2-web-interface/
#bundle install

安裝所需的 Ruby Modules or Package 請先務必先執行過 gem install bundle

亦可透過 #gem install 先行安裝所需 modules or package 
(RubyGems is a package management framework for Ruby)

# gem list
*** LOCAL GEMS ***
actionmailer (3.2.6, 3.1.3)
actionpack (3.2.6, 3.1.3)
activemodel (3.2.6, 3.1.3)
activerecord (3.2.6, 3.1.3)
activeresource (3.2.6, 3.1.3)
activesupport (3.2.6, 3.1.3, 2.3.4)
arel (3.0.2, 2.2.1)
bigdecimal (1.1.0)
bson (1.6.4, 1.3.1)
bson_ext (1.6.4, 1.3.1)
builder (3.0.0)
bundler (1.1.5, 1.1.3)
chronic (0.6.7)
ci_reporter (1.7.0, 1.6.5)
daemon_controller (1.0.0, 0.2.6)
daemons (1.1.8)
database_cleaner (0.8.0, 0.6.7)
erubis (2.7.0)
eventmachine (0.12.10)
faker (1.0.1, 0.9.5)
fastthread (1.0.7)
git (1.2.5)
graylog2-declarative_authorization (0.5.2)
hashr (0.0.21)
hike (1.2.1)
home_run (1.0.6, 1.0.4)
hoptoad_notifier (2.4.11)
i18n (0.6.0)
io-console (0.3)
journey (1.0.4)
json (1.7.3, 1.5.4)
kaminari (0.13.0, 0.12.4)
machinist (2.0, 1.0.6)
machinist_mongo (1.2.0)
mail (2.4.4, 2.3.0)
metaclass (0.0.1)
mime-types (1.19, 1.17.2)
minitest (3.2.0, 2.5.1)
mocha (0.12.1, 0.9.12)
mongo (1.3.1)
mongoid (3.0.1, 2.4.5)
moped (1.1.3)
multi_json (1.3.6, 1.0.3)
newrelic_rpm (3.4.0.1, 3.3.0)
origin (1.0.4)
passenger (3.0.14, 3.0.13, 3.0.10, 2.2.1)
polyglot (0.3.3)
pony (1.4, 1.3)
rack (1.4.1, 1.3.5)
rack-cache (1.2, 1.1)
rack-mount (0.8.3)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.6, 3.1.3)
rails_autolink (1.0.9, 1.0.4)
railties (3.2.6, 3.1.3)
rake (0.9.2.2)
rdoc (3.12, 3.11, 3.9.4)
rdoc-data (3.12)
rest-client (1.6.7)
rpm_contrib (2.1.11, 2.1.6)
shoulda (3.1.1, 2.11.3)
shoulda-activemodel (0.0.2)
shoulda-context (1.0.0)
shoulda-matchers (1.2.0)
sprockets (2.4.5, 2.1.3, 2.0.3)
thin (1.4.1)
thor (0.15.4, 0.14.6)
tilt (1.3.3)
timecop (0.3.5)
tire (0.4.2, 0.3.12)
treetop (1.4.10)
tzinfo (0.3.33, 0.3.31)


初始化 graylog2 的 web-admin ID & PWD 方式 (啟動 graylog2 web )
[root@graylog2 graylog2-web-interface]#pwd
/opt/graylog2-web-interface
[root@graylog2 graylog2-web-interface]#RAILS_ENV=production script/rails server
透過上面這個方式建立 web ID & PWD 後,用建好的 ID & PWD 試看看是否可以正常登入!

[root@graylog2 graylog2-web-interface]# RAILS_ENV=production script/rails server
=> Booting WEBrick
=> Rails 3.2.12 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

正式使用方式如下:

安裝 passenger
[root@graylog2 graylog2-web-interface]# gem install passenger
Successfully installed passenger-3.0.14
1 gem installed
Installing ri documentation for passenger-3.0.14...
Installing RDoc documentation for passenger-3.0.14...

graylog2 web 的 啟用方式有二種
(1) 透過 Passenger Standalone (Nginx Server)
#/opt/graylog2-web-interface/passenger start

[root@graylog2 graylog2-web-interface]# passenger start            
*** Phusion Passenger: no passenger_native_support.so found for the current Ruby interpreter. Compiling one...
# mkdir -p /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.14/ext/ruby/ruby-1.9.3-x86-linux
# cd /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.14/ext/ruby/ruby-1.9.3-x86-linux
# /usr/bin/ruby '/usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.14/ext/ruby/extconf.rb'
checking for alloca.h... yes
checking for ruby/io.h... yes
creating Makefile
# make
compiling /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.14/ext/ruby/passenger_native_support.c
linking shared-object passenger_native_support.so
=============== Phusion Passenger Standalone web server started ===============
PID file: /opt/graylog2-web-interface/tmp/pids/passenger.3000.pid
Log file: /opt/graylog2-web-interface/log/passenger.3000.log
Environment: development
Accessible via: http://0.0.0.0:3000/
You can stop Phusion Passenger Standalone by pressing Ctrl-C.
===============================================================================
Rails Error: Unable to access log file. Please ensure that /opt/graylog2-web-interface/log/development.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
** [NewRelic][07/22/12 07:26:33 +0800 graylog2 (10379)] INFO : Dispatcher: passenger
** [NewRelic][07/22/12 07:26:33 +0800 graylog2 (10379)] INFO : Application: Graylog2

(2) 透過 passenger-install-apache2-module  (Apache Server)
這是我是透過 apache2-module方式啟動