Skip to content

Commit 38bb529

Browse files
committed
Collect logs: aggregate selinux denial patterns
As of now we collect list of all avc denial occurencies, and then count all of them together from all nodes. That is not the actually intended neither useful value, as number just scales to topology or test sets, does not means how many issues to fix there is. Instead we want to know the total number of individual patterns of these denials (e.g. service x cannot read file y, not how many times it happened). Can be achieved by: - strip occurence specific values from denials on each machine (making sort -u list on each machine) - build list of all avc from all machines (this removes cross machine duplicites) - reporting just total number of this list (not simply adding numbers from all machines together) Change-Id: I5e2bad416a696028d8906d56e096bc7e783d347f
1 parent ba6b5f4 commit 38bb529

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

plugins/collect-logs/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
- name: "initialize temp variables"
3636
set_fact:
3737
selinux_problems: 0
38+
# use list to convert selinux avc denials from all nodes into list of unique patterns from all of them together
39+
selinux_problems_list: []
3840
segfault_problems: 0
3941
oom_killer_problems: 0
4042
counted_hosts: "{{ groups['all'] | difference( groups['local'] + (groups['tester'] | default([]) | difference(groups['controller']|default([]))) ) }}"
@@ -44,7 +46,8 @@
4446

4547
- name: "add together all issue counts from all hosts except localhost and tester"
4648
set_fact:
47-
selinux_problems: "{{ selinux_problems | int + ( hostvars[item]['selinux_problems_found'] | default([]) | length ) }}"
49+
selinux_problems_list: "{{ selinux_problems_list + (hostvars[item]['selinux_problems_found'] | default([])) }}"
50+
selinux_problems: "{{ selinux_problems_list | length }}"
4851
segfault_problems: "{{ segfault_problems | int + ( hostvars[item]['segfault_problems_found'] | default([]) | length ) }}"
4952
oom_killer_problems: "{{ oom_killer_problems | int + ( hostvars[item]['oom_killer_problems_found'] | default([]) | length ) }}"
5053
with_items: "{{ counted_hosts }}"

plugins/collect-logs/tasks/collect_host_logs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@
180180

181181
- name: Search for AVC denied
182182
become: yes
183-
shell: "! grep -i denied /var/log/audit/audit*"
183+
# sed used to replace numeric runtime/instance values, to reduce list of occurencies to their patterns
184+
shell: "! (grep -i denied /var/log/audit/* | sed -r 's/audit\\(.*\\): avc/audit(...): avc/; s/(pid|ino)=[0-9]+ /\\1=... /g'|sort -u)"
184185
register: result
185186
ignore_errors: yes
186187

0 commit comments

Comments
 (0)