質問編集履歴
1
表示の整形をしました
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
### 前提・実現したいこと
|
2
2
|
|
3
3
|
CentOS7のrsyslogにてヤマハRTX1200からのログを受信しています。
|
4
4
|
RTX1200からのログは正常に受信できており、/var/log/messagesに記録されていることを確認済みとなります。
|
@@ -6,84 +6,96 @@
|
|
6
6
|
この状態で、RTX1200にVPNログインした際にSlackへ通知を飛ばしたいと考えており、
|
7
7
|
検索しつつ設定を行った所、Slackへ通知が飛ばすことができない状況になります。
|
8
8
|
|
9
|
+
### 発生している問題
|
10
|
+
|
9
11
|
色々確認した所、rsyslogでログがフィルタに引っかからない為、結果的に通知がされないのが原因と考えているのですが、なぜ引っかからないのかがわからず行き詰まってしまいました。
|
10
12
|
|
11
13
|
当方、Linuxに疎く、見落としている場所など、知見をご教授いただきたく、よろしくおねがいいたします。
|
12
14
|
|
13
15
|
今回検知したいログは下記のような形になっています。
|
14
|
-
-----------
|
15
|
-
Sep 23 16:44:56 gateway PP[ANONYMOUS01] Call detected from user 'test'
|
16
|
+
> Sep 23 16:44:56 gateway PP[ANONYMOUS01] Call detected from user 'test'
|
16
|
-
-----------
|
17
17
|
|
18
|
+
|
19
|
+
### 設定および作成したシェルスクリプト
|
20
|
+
|
18
21
|
Slackに飛ばすためのConfは下記の通り
|
19
|
-
|
22
|
+
|
20
23
|
/etc/rsyslog.d/00_slack.conf
|
24
|
+
|
25
|
+
> $template login_msg, "%timegenerated% %fromhost% %msg%\n"
|
26
|
+
>
|
27
|
+
> module(load="omprog")
|
28
|
+
>
|
29
|
+
> if $msg contains 'Call detected from user' \
|
30
|
+
> then {
|
31
|
+
> action(
|
32
|
+
> type="omprog"
|
33
|
+
> binary="/etc/rsyslog.d/WebHook_Slack_stdin.sh"
|
34
|
+
> template="login_msg"
|
35
|
+
> )
|
36
|
+
> }
|
21
37
|
|
22
|
-
$template login_msg, "%timegenerated% %fromhost% %msg%\n"
|
23
38
|
|
24
|
-
|
39
|
+
Slackへ飛ばすためのWebhookシェルスクリプトは単体にて動作確認済み。
|
25
40
|
|
26
|
-
if $msg contains 'Call detected from user' \
|
27
|
-
then {
|
28
|
-
action(
|
29
|
-
type="omprog"
|
30
|
-
binary="/etc/rsyslog.d/WebHook_Slack_stdin.sh"
|
31
|
-
template="login_msg"
|
32
|
-
)
|
33
|
-
}
|
34
|
-
--------------------
|
35
|
-
|
36
|
-
Slackへ飛ばすためのWebhookシェルスクリプトは単体にて動作確認済み。
|
37
|
-
---------------------------
|
38
41
|
/etc/rsyslog.d/WebHook_Slack_stdin.sh
|
39
42
|
|
40
|
-
#!/bin/bash
|
43
|
+
> #!/bin/bash
|
44
|
+
>
|
45
|
+
> WEBHOOK_URL='https://hooks.slack.com/xxxxxxxx'
|
46
|
+
>
|
47
|
+
> while read LINE; do
|
48
|
+
> MESSAGE=`echo $LINE | sed -z 's/\n//g'`
|
49
|
+
> curl -X POST --data-urlencode "payload={\"channel\": \"#nagios\", \"username\": \"Aleat_bot\", \"icon_emoji\": \":computer:\", \"text\": \"${MESSAGE}\"}" $WEBHOOK_URL
|
50
|
+
> done
|
41
51
|
|
42
|
-
WEBHOOK_URL='https://hooks.slack.com/xxxxxxxx'
|
43
52
|
|
44
|
-
while read LINE; do
|
45
|
-
MESSAGE=`echo $LINE | sed -z 's/\n//g'`
|
46
|
-
curl -X POST --data-urlencode "payload={\"channel\": \"#nagios\", \"username\": \"Aleat_bot\", \"icon_emoji\": \":computer:\", \"text\": \"${MESSAGE}\"}" $WEBHOOK_URL
|
47
|
-
done
|
48
|
-
--------------------
|
49
|
-
|
50
53
|
rsyslog.confはほぼデフォルトになります(コメントアウト行割愛)
|
51
|
-
--------------------
|
52
|
-
#### MODULES ####
|
53
54
|
|
55
|
+
>
|
56
|
+
> $ModLoad imuxsock
|
57
|
+
> $ModLoad imjournal
|
58
|
+
>
|
59
|
+
> $ModLoad imudp
|
60
|
+
> $UDPServerRun 514
|
61
|
+
>
|
62
|
+
> $ModLoad imtcp
|
63
|
+
> $InputTCPServerRun 514
|
64
|
+
>
|
65
|
+
> $AllowedSender UDP, 127.0.0.1, 192.168.107.0/24
|
66
|
+
> $AllowedSender TCP, 127.0.0.1, 192.168.107.0/24
|
67
|
+
>
|
68
|
+
> $WorkDirectory /var/lib/rsyslog
|
69
|
+
> $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
|
70
|
+
> $IncludeConfig /etc/rsyslog.d/*.conf
|
71
|
+
> $OmitLocalLogging on
|
72
|
+
>
|
73
|
+
> $IMJournalStateFile imjournal.state
|
74
|
+
>
|
75
|
+
> *.info;mail.none;authpriv.none;cron.none /var/log/messages
|
76
|
+
> authpriv.* /var/log/secure
|
77
|
+
> mail.* -/var/log/maillog
|
54
|
-
|
78
|
+
> cron.* /var/log/cron
|
55
|
-
|
79
|
+
> *.emerg :omusrmsg:*
|
80
|
+
> uucp,news.crit /var/log/spooler
|
81
|
+
> local7.* /var/log/boot.log
|
56
82
|
|
57
|
-
# Provides UDP syslog reception
|
58
|
-
|
83
|
+
### 問題の発生した環境
|
59
|
-
$UDPServerRun 514
|
60
84
|
|
61
|
-
# Provides TCP syslog reception
|
62
|
-
$ModLoad imtcp
|
63
|
-
|
85
|
+
CentOS7
|
64
86
|
|
87
|
+
rsyslogd -v
|
88
|
+
rsyslogd 8.24.0-57.el7_9.1, compiled with:
|
65
|
-
|
89
|
+
PLATFORM: x86_64-redhat-linux-gnu
|
90
|
+
PLATFORM (lsb_release -d):
|
91
|
+
FEATURE_REGEXP: Yes
|
92
|
+
GSSAPI Kerberos 5 support: Yes
|
93
|
+
FEATURE_DEBUG (debug build, slow code): No
|
94
|
+
32bit Atomic operations supported: Yes
|
95
|
+
64bit Atomic operations supported: Yes
|
66
|
-
|
96
|
+
memory allocator: system default
|
97
|
+
Runtime Instrumentation (slow code): No
|
98
|
+
uuid support: Yes
|
99
|
+
Number of Bits in RainerScript integers: 64
|
67
100
|
|
68
|
-
#### GLOBAL DIRECTIVES ####
|
69
|
-
$WorkDirectory /var/lib/rsyslog
|
70
|
-
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
|
71
|
-
$IncludeConfig /etc/rsyslog.d/*.conf
|
72
|
-
$OmitLocalLogging on
|
73
|
-
|
74
|
-
# File to store the position in the journal
|
75
|
-
$IMJournalStateFile imjournal.state
|
76
|
-
|
77
|
-
#### RULES ####
|
78
|
-
*.info;mail.none;authpriv.none;cron.none /var/log/messages
|
79
|
-
authpriv.* /var/log/secure
|
80
|
-
mail.* -/var/log/maillog
|
81
|
-
cron.* /var/log/cron
|
82
|
-
*.emerg :omusrmsg:*
|
83
|
-
uucp,news.crit /var/log/spooler
|
84
|
-
local7.* /var/log/boot.log
|
85
|
-
|
86
|
-
# ### begin forwarding rule ###
|
87
|
-
--------------------
|
88
|
-
|
89
101
|
よろしくおねがいいたします。
|