Skip to content

Commit 4542cf0

Browse files
committed
add tests + log in/out adjustement
1 parent 33a4d93 commit 4542cf0

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

files/pixiu

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ PIXIU_USER_INODE_ALARM %{PIXIU_ALARM_PREFIX} %{PIXIU_ALARM_COMMON} reaches (?:or
2121
PIXIU_USER_SPACE_ALARM %{PIXIU_ALARM_PREFIX} %{PIXIU_ALARM_COMMON} reaches (?:or approaches )?to the (:?(?<quota_limit_type>%{WORD}) space(?: quantity)? quota of|space(?: quantity)? (?<quota_limit_type>%{WORD}) quota of) \((?<quota_space_limit>%{PIXIU_BYTES})\)\..*
2222

2323
PIXIU_LOGIN_STATUS failed|succeeded
24+
PIXIU_LOGIN_ACTION in|out
2425

25-
PIXIU_LOGIN_ALARM %{PIXIU_ALARM_PREFIX} User \(user name %{USERNAME:username}\) %{PIXIU_LOGIN_STATUS:state} (?:to log in|in logging in) from source \(%{IPORHOST:source_ip}\)\..*
26+
27+
PIXIU_LOGIN_ALARM %{PIXIU_ALARM_PREFIX} User \(user name %{USERNAME:username}\) %{PIXIU_LOGIN_STATUS:state} (?:to log %{PIXIU_LOGIN_ACTION:action}|in logging %{PIXIU_LOGIN_ACTION:action})(?: upon timeout)? from source \(%{IPORHOST:source_ip}\)\..*
2628

2729
PIXIU_ALARM %{PIXIU_USER_INODE_ALARM}|%{PIXIU_USER_SPACE_ALARM}|%{PIXIU_LOGIN_ALARM}

tests/data/pixiu

+28
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ data = [
208208
"username": "bsdfsdf",
209209
"source_ip": "172.18.124.113",
210210
"state": "failed",
211+
"action": "in",
211212
},
212213
},
213214
{
@@ -218,4 +219,31 @@ data = [
218219
"path": "/108",
219220
},
220221
},
222+
{
223+
"raw": "<187>Jun 5 10:19:28 HKSTO03-Node1 alarm[2003199]: <186>2024-06-05 10:19:26 DST 172.19.96.130 OceanStor-Distributed-Storage 908704 0xFEA6A000E Major(1): The used space (18MB) of quota (type directory quota) of dtree (name --, ID 0) at / in namespace (name zzzzbucket, ID 242) reaches to the space soft quota of (15MB).",
224+
"expected": {
225+
"program": "alarm",
226+
"quota_used_type": "directory",
227+
"namespace": "zzzzbucket",
228+
"namespace_id": 242,
229+
"dtree": "--",
230+
"dtree_id": 0,
231+
"used_space": 18000000,
232+
"quota_used_type": "space",
233+
"quota_type": "directory",
234+
"quota_limit_type": "soft",
235+
"quota_space_limit": 15000000,
236+
"path": "/",
237+
},
238+
},
239+
{
240+
"raw": "<190>Jun 5 11:19:57 C4STO01-Node1 alarm[4162768]: <189>2024-06-05 11:19:57 DST 172.19.104.10 OceanStor-Distributed-Storage 1140981 0x100F00C90022 Informational(9): User (user name adm_CV000080) succeeded in logging out upon timeout from source (172.18.252.67).",
241+
"expected": {
242+
"program": "alarm",
243+
"username": "adm_CV000080",
244+
"source_ip": "172.18.252.67",
245+
"state": "succeeded",
246+
"action": "out",
247+
},
248+
},
221249
]

tests/logstash_7.6.2.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ filter {
2525
}
2626

2727
date {
28-
match => [ "syslog_timestamp", "yyyy-MM-dd'T'HH:mm:ss.SSSSSSZZ", "yyyy-MM-dd'T'HH:mm:ssZZ", "yyyy-MM-dd HH:mm:ss.SSSSSS", "MMM dd HH:mm:ss" ]
28+
match => [ "syslog_timestamp", "yyyy-MM-dd'T'HH:mm:ss.SSSSSSZZ", "yyyy-MM-dd'T'HH:mm:ssZZ", "yyyy-MM-dd HH:mm:ss.SSSSSS", "MMM d HH:mm:ss", "MMM d HH:mm:ss" ]
2929
}
3030

3131
if ("exclude_tags" not in [tags]) {

0 commit comments

Comments
 (0)