Skip to content

Commit 53e2e11

Browse files
committed
Refactor user parameter handling in CommandCollector and update DB2 user references in configuration checks; enhance network checks for clarity and accuracy.
1 parent de7b627 commit 53e2e11

File tree

4 files changed

+145
-18
lines changed

4 files changed

+145
-18
lines changed

src/module_utils/collector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def collect(self, check, context) -> str:
130130
return f"ERROR: Invalid user parameter: {user}"
131131

132132
if user == "db2sid":
133-
user = f"db2{context.get('database_sid', '')}"
133+
user = f"db2{context.get('database_sid', '').lower()}"
134134

135135
command = f"sudo -u {shlex.quote(user)} {command}"
136136

src/roles/configuration_checks/tasks/files/db2.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,3 +536,106 @@ checks:
536536
report: *check
537537
references:
538538
sap: "2751102"
539+
540+
- id: "DB-Db2-0020"
541+
name: "Filesystem Mount Points"
542+
description: "Displays all filesystem mount points on the Db2 system"
543+
category: *sap_check
544+
severity: *info
545+
workload: *sap
546+
applicability:
547+
os_type: [*suse, *redhat]
548+
os_version: *all_versions
549+
hardware_type: *vm
550+
storage_type: *all_storage
551+
role: [*db_role]
552+
database_type: [*db2]
553+
collector_type: *azure
554+
collector_args:
555+
resource_type: "filesystem"
556+
report: *table
557+
references:
558+
microsoft: "https://learn.microsoft.com/azure/virtual-machines/workloads/sap/dbms-guide-ibm"
559+
560+
- id: "DB-Db2-0021"
561+
name: "Azure Disks"
562+
description: "Displays Azure disk configuration for the Db2 system"
563+
category: *sap_check
564+
severity: *info
565+
workload: *sap
566+
applicability:
567+
os_type: [*suse, *redhat]
568+
os_version: *all_versions
569+
hardware_type: *vm
570+
storage_type: *all_storage
571+
role: [*db_role]
572+
database_type: [*db2]
573+
collector_type: *azure
574+
collector_args:
575+
resource_type: "disk"
576+
report: *table
577+
references:
578+
microsoft: "https://learn.microsoft.com/azure/virtual-machines/workloads/sap/dbms-guide-ibm"
579+
580+
- id: "DB-Db2-0022"
581+
name: "LVM Groups"
582+
description: "Lists all LVM groups to ensure SAP HANA directories are configured with supported LVM configurations."
583+
category: *sap_check
584+
severity: *info
585+
workload: *sap
586+
applicability:
587+
os_type: [*suse, *redhat]
588+
os_version: *all_versions
589+
hardware_type: *vm
590+
storage_type: *all_storage
591+
role: [*db_role]
592+
database_type: [*hana]
593+
collector_type: *azure
594+
collector_args:
595+
resource_type: "lvm_groups"
596+
report: *table
597+
references:
598+
sap: "2972496"
599+
microsoft: "https://docs.microsoft.com/en-us/azure/virtual-machines/workloads/sap/hana-vm-operations-storage"
600+
601+
- id: "DB-Db2-0023"
602+
name: "LVM Volumes"
603+
description: "Lists all LVM volumes to ensure SAP HANA directories are configured with supported LVM configurations."
604+
category: *sap_check
605+
severity: *info
606+
workload: *sap
607+
applicability:
608+
os_type: [*suse, *redhat]
609+
os_version: *all_versions
610+
hardware_type: *vm
611+
storage_type: *all_storage
612+
role: [*db_role]
613+
database_type: [*hana]
614+
collector_type: *azure
615+
collector_args:
616+
resource_type: "lvm_volumes"
617+
report: *table
618+
references:
619+
sap: "2972496"
620+
microsoft: "https://docs.microsoft.com/en-us/azure/virtual-machines/workloads/sap/hana-vm-operations-storage"
621+
622+
- id: "DB-Db2-0024"
623+
name: "ANF Volumes"
624+
description: "Lists all ANF volumes to ensure SAP HANA directories are configured with supported ANF configurations."
625+
category: *sap_check
626+
severity: *info
627+
workload: *sap
628+
applicability:
629+
os_type: [*suse, *redhat]
630+
os_version: *all_versions
631+
hardware_type: *vm
632+
storage_type: *all_storage
633+
role: [*db_role]
634+
database_type: [*hana]
635+
collector_type: *azure
636+
collector_args:
637+
resource_type: "anf_volumes"
638+
report: *table
639+
references:
640+
sap: "2972496"
641+
microsoft: "https://docs.microsoft.com/en-us/azure/virtual-machines/workloads/sap/hana-vm-operations-storage"

src/roles/configuration_checks/tasks/files/network.yml

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ enums:
9090

9191
checks:
9292
- id: "NET-0001"
93-
name: "No of network interface"
94-
description: "Checks the number of network interfaces on the VM"
93+
name: "Virtual Network"
94+
description: "Retrieves the virtual network(s) associated with the VM's network interface(s)"
9595
category: *network_check
9696
severity: *info
9797
workload: *workload
@@ -103,12 +103,16 @@ checks:
103103
az vm nic list --resource-group {{ CONTEXT.resource_group_name }} \
104104
--vm-name {{ CONTEXT.vm_name }} \
105105
--subscription {{ CONTEXT.subscription_id }} \
106-
--query "[].{Name:id}" -o tsv | wc -l
106+
--query "[].id" -o tsv | while read nic_id; do \
107+
nic=$(basename "$nic_id"); \
108+
az network nic show --resource-group {{ CONTEXT.resource_group_name }} --name "$nic" \
109+
--query "ipConfigurations[].subnet.id" -o tsv | awk -F'/' '{print $(NF-2)}'; \
110+
done
107111
report: *check
108112

109113
- id: "NET-0002"
110-
name: "Network Interface Name"
111-
description: "Retrieves the name of the network interface(s) attached to the VM"
114+
name: "Subnet"
115+
description: "Retrieves the subnet(s) associated with the VM's network interface(s)"
112116
category: *network_check
113117
severity: *info
114118
workload: *workload
@@ -120,12 +124,16 @@ checks:
120124
az vm nic list --resource-group {{ CONTEXT.resource_group_name }} \
121125
--vm-name {{ CONTEXT.vm_name }} \
122126
--subscription {{ CONTEXT.subscription_id }} \
123-
--query "[].id" -o tsv | xargs -I {} basename {}
127+
--query "[].id" -o tsv | while read nic_id; do \
128+
nic=$(basename "$nic_id"); \
129+
az network nic show --resource-group {{ CONTEXT.resource_group_name }} --name "$nic" \
130+
--query "ipConfigurations[].subnet.id" -o tsv | xargs -I {} basename {}; \
131+
done
124132
report: *check
125133

126134
- id: "NET-0003"
127-
name: "Subnet"
128-
description: "Retrieves the subnet(s) associated with the VM's network interface(s)"
135+
name: "No of network interface"
136+
description: "Checks the number of network interfaces on the VM"
129137
category: *network_check
130138
severity: *info
131139
workload: *workload
@@ -137,14 +145,29 @@ checks:
137145
az vm nic list --resource-group {{ CONTEXT.resource_group_name }} \
138146
--vm-name {{ CONTEXT.vm_name }} \
139147
--subscription {{ CONTEXT.subscription_id }} \
140-
--query "[].id" -o tsv | while read nic_id; do \
141-
nic=$(basename "$nic_id"); \
142-
az network nic show --resource-group {{ CONTEXT.resource_group_name }} --name "$nic" \
143-
--query "ipConfigurations[].subnet.id" -o tsv | xargs -I {} basename {}; \
144-
done
148+
--query "[].{Name:id}" -o tsv | wc -l
145149
report: *check
146150

147151
- id: "NET-0004"
152+
name: "Network Interface Name"
153+
description: "Retrieves the name of the network interface(s) attached to the VM"
154+
category: *network_check
155+
severity: *info
156+
workload: *workload
157+
applicability:
158+
hardware_type: *vm
159+
collector_type: *azure
160+
collector_args:
161+
command: |-
162+
az vm nic list --resource-group {{ CONTEXT.resource_group_name }} \
163+
--vm-name {{ CONTEXT.vm_name }} \
164+
--subscription {{ CONTEXT.subscription_id }} \
165+
--query "[].id" -o tsv | xargs -I {} basename {}
166+
report: *check
167+
168+
169+
170+
- id: "NET-0005"
148171
name: "Accelerated Networking"
149172
description: "Checks if Accelerated Networking is enabled on the VM's network interface(s)"
150173
category: *network_check
@@ -169,7 +192,7 @@ checks:
169192
expected_output: "true"
170193
report: *check
171194

172-
- id: "NET-0005"
195+
- id: "NET-0006"
173196
name: "No of IP configurations"
174197
description: "Checks the number of IP configurations on each network interface"
175198
category: *network_check
@@ -191,7 +214,7 @@ checks:
191214
done
192215
report: *check
193216

194-
- id: "NET-0006"
217+
- id: "NET-0007"
195218
name: "IP Details"
196219
description: "Retrieves all IP addresses configured on the VM's network interface(s)"
197220
category: *network_check

src/roles/configuration_checks/tasks/files/virtual_machine.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ enums:
7272
user:
7373
- root: &root "root"
7474
- sidadm: &sidadm "sidadm"
75-
- all_users: &user [*root, *sidadm]
75+
- db2sid: &db2sid "db2sid"
76+
- all_users: &user [*root, *sidadm, *db2sid]
7677

7778
validator_type:
7879
- string: &string "string"
@@ -564,7 +565,7 @@ checks:
564565
collector_type: *command
565566
collector_args:
566567
command: "db2pd -alldbs -hadr"
567-
user: *sidadm
568+
user: *db2sid
568569
report: *section
569570

570571
- id: "IC-0029"

0 commit comments

Comments
 (0)