NutaNice Xperience

主にNutanix製品を検証したり触ったりした結果をつづっています。※このブログの内容は個人の見識や見解をもとに作成しています。参考にされる場合は自己責任でご活用ください。実際に製品を使用される場合は、メーカードキュメントの手順に従い実施してください。

Nutanixでsyslog転送の様子を確認してみる【AOS 7.0 AHV 10.0】

 

※この記事は「AOS 7.0.xx」時点の情報をもとに作成しています。その後の機能アップデートについてはメーカーの公開情報をご確認ください。

前回の記事では、NutanixでCLIからsyslogを設定してみました。今回は、Nutanix側の設定ファイルと接続の状況を確認してみます。

目次

1.今回の環境

3ノードAHVクラスタ
AOS: 7.0.1
AHV: 10.0.1
rsyslogサーバ用VM: Rocky Linux v9.5

環境は以下のイメージで、一般的なNutanixの3ノードクラスタです。

▽syslogサーバとNutanixでのsyslogの設定は以下の記事をご参照ください。

今回は、syslogサーバとしてRocky Linux v9.5を使用し、/etc/rsyslog.d/remote.confファイルを作成して、syslog受信の設定をしています。

Nutanixから転送する対象のモジュールは「syslog_module」のみで設定しました。Nutanixのsyslog設定は以下の通りです。

<ncli> rsyslog-config ls-servers

    Name                      : syslog-test
    Host Address        : 172.22.5.104
    Port                         : 514
    Protocol                : TCP
    Relp Enabled       : false

        Module Name               : SYSLOG_MODULE
        Log Level                           : INFO
        Include Monitor Logs    : true

2. Nutanixのsyslog設定ファイルを確認

nCLIからsyslogを設定して有効化すると、CVMに「/etc/rsyslog.d/rsyslog-nutanix.conf」という設定ファイルが作成されます。▽以下のように、すべてのCVMで作成されていることが確認できます。

nutanix@cvm:~$ allssh sudo cat /etc/rsyslog.d/rsyslog-nutanix.conf

================== 172.22.1.51(CVM-01) =================
# Nutanix remote server rules
$ModLoad imfile
$ActionForwardDefaultTemplate RSYSLOG_ForwardFormat
$InputRunFileMonitor
local0.*
$WorkDirectory /home/log/rsyslog
action(type="omfwd" target="172.22.5.104" port="514" protocol="tcp"
              queue.filename="rsyslog_queue"
              queue.highwatermark= "30000"
              queue.lowwatermark= "10000"
              queue.size="40000"
              queue.type="LinkedList"
              queue.maxdiskspace="200m"
              queue.discardmark="35000"
              queue.maxfilesize="200m"
              queue.discardSeverity="3"
              action.resumeRetryCount="-1"
              queue.saveOnShutdown="on" )
if *.info action(type="omfwd" target="172.22.5.104" port="514" protocol="tcp") #TCP forwarding
# Nutanix remote server rules end

================== 172.22.1.52(CVM-02) =================
# Nutanix remote server rules
$ModLoad imfile
$ActionForwardDefaultTemplate RSYSLOG_ForwardFormat
$InputRunFileMonitor
local0.*
$WorkDirectory /home/log/rsyslog
action(type="omfwd" target="172.22.5.104" port="514" protocol="tcp"
              queue.filename="rsyslog_queue"
              queue.highwatermark= "30000"
              queue.lowwatermark= "10000"
              queue.size="40000"
              queue.type="LinkedList"
              queue.maxdiskspace="200m"
              queue.discardmark="35000"
              queue.maxfilesize="200m"
              queue.discardSeverity="3"
              action.resumeRetryCount="-1"
              queue.saveOnShutdown="on" )
if *.info action(type="omfwd" target="172.22.5.104" port="514" protocol="tcp") #TCP forwarding
# Nutanix remote server rules end

================== 172.22.1.53(CVM-03) =================
# Nutanix remote server rules
$ModLoad imfile
$ActionForwardDefaultTemplate RSYSLOG_ForwardFormat
$InputRunFileMonitor
local0.*
$WorkDirectory /home/log/rsyslog
action(type="omfwd" target="172.22.5.104" port="514" protocol="tcp"
              queue.filename="rsyslog_queue"
              queue.highwatermark= "30000"
              queue.lowwatermark= "10000"
              queue.size="40000"
              queue.type="LinkedList"
              queue.maxdiskspace="200m"
              queue.discardmark="35000"
              queue.maxfilesize="200m"
              queue.discardSeverity="3"
              action.resumeRetryCount="-1"
              queue.saveOnShutdown="on" )
if *.info action(type="omfwd" target="172.22.5.104" port="514" protocol="tcp") #TCP forwarding
# Nutanix remote server rules end

参考までに、転送対象のモジュールに「Prism」を追加すると▽こんな感じの設定ファイルになります。

nutanix@cvm:~$ sudo cat /etc/rsyslog.d/rsyslog-nutanix.conf

# Nutanix remote server rules
$ModLoad imfile
$ActionForwardDefaultTemplate RSYSLOG_ForwardFormat

input(Type="imfile"
      File="/home/nutanix/data/logs/prism_monitor.INFO"
      stateFile="prism-prism_monitor.INFO.stat"
      Tag="prism_monitor:"
      Facility="local0"
      Severity="info"
      startmsg.regex="^"
      readTimeout="10"
)

input(Type="imfile"
      File="/home/nutanix/data/logs/prism_monitor.WARNING"
      stateFile="prism-prism_monitor.WARNING.stat"
      Tag="prism_monitor:"
      Facility="local0"
      Severity="info"
      startmsg.regex="^"
      readTimeout="10"
)

input(Type="imfile"
      File="/home/nutanix/data/logs/prism_monitor.ERROR"
      stateFile="prism-prism_monitor.ERROR.stat"
      Tag="prism_monitor:"
      Facility="local0"
      Severity="info"
      startmsg.regex="^"
      readTimeout="10"
)

input(Type="imfile"
      File="/home/nutanix/data/logs/prism_monitor.FATAL"
      stateFile="prism-prism_monitor.FATAL.stat"
      Tag="prism_monitor:"
      Facility="local0"
      Severity="info"
      startmsg.regex="^"
      readTimeout="10"
)

input(Type="imfile"
      File="/home/nutanix/data/logs/prism.out"
      stateFile="prism-prism.out.stat"
      Tag="prism:"
      Facility="local0"
      Severity="info"
      startmsg.regex="^"
      readTimeout="10"
)

input(Type="imfile"
      File="/home/nutanix/data/logs/prism_gateway.log"
      stateFile="prism-prism_gateway.log.stat"
      Tag="prism_gateway:"
      Facility="local0"
      Severity="info"
      startmsg.regex="^"
      readTimeout="10"
)
$InputRunFileMonitor
if $programname == 'prism_gateway' or $programname == 'prism_monitor' or $programname == 'prism' and $msg contains 'DEBUG' then ~
local0.*
$WorkDirectory /home/log/rsyslog
action(type="omfwd" target="172.22.5.104" port="514" protocol="tcp"
              queue.filename="rsyslog_queue"
              queue.highwatermark= "30000"
              queue.lowwatermark= "10000"
              queue.size="40000"
              queue.type="LinkedList"
              queue.maxdiskspace="200m"
              queue.discardmark="35000"
              queue.maxfilesize="200m"
              queue.discardSeverity="3"
              action.resumeRetryCount="-1"
              queue.saveOnShutdown="on" )
if $programname == 'prism_gateway' or $programname == 'prism_monitor' or $programname == 'prism' then ~
*.info action(type="omfwd" target="172.22.5.104" port="514" protocol="tcp") #TCP forwarding
local0.*    ~ # Do not further process Nutanix logs
# Nutanix remote server rules end

Nutanixのsyslogでは、1つのCVMが代表してログを転送しているのではなく、すべてのCVMがローカルノードのログを転送しているようです。実際に、rsyslogサーバ側でのTCPセッションを見てみます。

3. syslogのTCPセッションを確認してみる

転送先のrsyslogサーバでTCPの接続状態を確認してみました。

[root@rsyslog ~]# netstat -tn

Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address                         State
tcp        0             0         172.22.5.104:514        172.22.1.51:49696(cvm01)       ESTABLISHED
tcp        0             0         172.22.5.104:514        172.22.1.63:34552(ahv03)       ESTABLISHED
tcp        0             0         172.22.5.104:514        172.22.1.53:34560(cvm03)       ESTABLISHED
tcp        0             0         172.22.5.104:514        172.22.1.61:52320(ahv01)       ESTABLISHED
tcp        0             0         172.22.5.104:514        172.22.1.53:34544(cvm03)       ESTABLISHED
tcp        0             0         172.22.5.104:514        172.22.1.52:50886(cvm02)       ESTABLISHED
tcp        0             0         172.22.5.104:514        172.22.1.51:49698(cvm01)       ESTABLISHED
tcp        0             0         172.22.5.104:514        172.22.1.52:50880(cvm02)       ESTABLISHED
tcp        0             0         172.22.5.104:514        172.22.1.62:53848(ahv02)       ESTABLISHED
tcp        0             0         172.22.5.104:22         172.20.40.61:57893      ESTABLISHED

各CVMからポート番号「514」で接続されていることが確認できます。やはりログは各CVMが個別に転送しているようです。

おや、AHVからも514ポート宛に接続がありますね!

実は、nCLIからsyslogサーバを指定して有効化した時点で、各AHVにも▽以下のようなリモートロギングの設定ファイルが自動作成され、ログの転送が開始されます。

[root@ahv ~]# cat /etc/rsyslog.d/50-log-forward-Genesis.conf

# ### This file has been generated by AHV Host Agent ###
#
# ### begin forwarding rule ###

$ActionQueueType LinkedList                 # Memory based queue.
$ActionQueueSize 1024                               # Size of memory queue, default 1000 for v5.
$ActionResumeRetryCount -1                  # Infinite retries
$ActionQueueDiscardMark 819               # Number of messages after which
                                                                               # lower priority messages are discarded.
$ActionQueueDiscardSeverity 4               # Drop messages below and including Warning level
                                                                               # when the queue gets almost full.
$MainMsgQueueType LinkedList            # Memory based main queue.
$MainMsgQueueSize 10000                       # Size of main in-memory queue.
$MainMsgQueueDiscardMark 9800         # Same as action queue - we drop lower priority
                                                                              # messages when the queue becomes full.
$ActionQueueDiscardSeverity 4             # same as action queue.

$ActionQueueTimeoutEnqueue 0          # Timeout for enqueing message to tcp/udp/relp
                                                                              # queue. If queue is full, dont block process.
$MainMsgQueueTimeoutEnqueue 0       #Timeout for enqueing message to main queue.
                                                                               # If queue is full, dont block process.

# The following line forwards the logs
*.* @@172.22.5.104:514

# ### end of the forwarding rule ###

[root@ahv-01 ~]#

AHVは、自身のsyslogを自分でrsyslogサーバへ転送しているようですね。CVM経由だと思っていたので、新しい発見でした。

▽念のため、tcpdumpでAHVのネットワークをキャプチャしてみます。

[root@ahv01 ~]# tcpdump -i any port 514

dropped privs to tcpdump
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked v1), capture size 262144 bytes

06:01:14.685986 IP ahv01.ntnx.test.40824 > 172.22.5.104.shell: Flags [P.], seq 132930:133030, ack 1, win 502, options [nop,nop,TS val 669141107 ecr 918596077], length 100

06:01:14.685991 IP ahv01.ntnx.test.40824 > 172.22.5.104.shell: Flags [P.], seq 132930:133030, ack 1, win 502, options [nop,nop,TS val 669141107 ecr 918596077], length 100

06:01:14.686114 IP 172.22.5.104.shell > ahv01.ntnx.test.40824: Flags [.], ack 133030, win 249, options [nop,nop,TS val 918596118 ecr 669141107], length 0

06:01:14.686117 IP 172.22.5.104.shell > ahv01.ntnx.test.40824: Flags [.], ack 133030, win 249, options [nop,nop,TS val 918596118 ecr 669141107], length 0

06:01:15.950316 IP ahv01.ntnx.test.40824 > 172.22.5.104.shell: Flags [P.], seq 133030:133140, ack 1, win 502, options [nop,nop,TS val 669142371 ecr 918596118], length 110

06:01:15.950321 IP ahv01.ntnx.test.40824 > 172.22.5.104.shell: Flags [P.], seq 133030:133140, ack 1, win 502, options [nop,nop,TS val 669142371 ecr 918596118], length 110

06:01:15.950507 IP 172.22.5.104.shell > ahv01.ntnx.test.40824: Flags [.], ack 133140, win 249, options [nop,nop,TS val 918597382 ecr 669142371], length 0

06:01:15.950511 IP 172.22.5.104.shell > ahv01.ntnx.test.40824: Flags [.], ack 133140, win 249, options [nop,nop,TS val 918597382 ecr 669142371], length 0

06:01:15.976177 IP ahv01.ntnx.test.40824 > 172.22.5.104.shell: Flags [P.], seq 133140:133240, ack 1, win 502, options [nop,nop,TS val 669142397 ecr 918597382], length 100

06:01:15.976181 IP ahv01.ntnx.test.40824 > 172.22.5.104.shell: Flags [P.], seq 133140:133240, ack 1, win 502, options [nop,nop,TS val 669142397 ecr 918597382], length 100

06:01:15.976300 IP 172.22.5.104.shell > ahv01.ntnx.test.40824: Flags [.], ack 133240, win 249, options [nop,nop,TS val 918597408 ecr 669142397], length 0

06:01:15.976305 IP 172.22.5.104.shell > ahv01.ntnx.test.40824: Flags [.], ack 133240, win 249, options [nop,nop,TS val 918597408 ecr 669142397], length 0

06:01:16.001081 IP ahv01.ntnx.test.40824 > 172.22.5.104.shell: Flags [P.], seq 133240:133350, ack 1, win 502, options [nop,nop,TS val 669142422 ecr 918597408], length 110

06:01:16.001084 IP ahv01.ntnx.test.40824 > 172.22.5.104.shell: Flags [P.], seq 133240:133350, ack 1, win 502, options [nop,nop,TS val 669142422 ecr 918597408], length 110

06:01:16.001251 IP 172.22.5.104.shell > ahv01.ntnx.test.40824: Flags [.], ack 133350, win 249, options [nop,nop,TS val 918597433 ecr 669142422], length 0

06:01:16.001252 IP 172.22.5.104.shell > ahv01.ntnx.test.40824: Flags [.], ack 133350, win 249, options [nop,nop,TS val 918597433 ecr 669142422], length 0

AHVがrsyslogサーバのshell(514/tcp)ポート宛に通信しているのが確認できました。

以上です。