Skip to content

Commit c7a74b0

Browse files
committed
AI contributions
1 parent e42c0bf commit c7a74b0

File tree

804 files changed

+22828
-707
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

804 files changed

+22828
-707
lines changed

CONTRIBUTING.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- [How to file a bug report](#how-to-file-a-bug-report)
66
- [How to contribute code](#how-to-contribute-code)
7+
- [Plugin Priority System](#plugin-priority-system)
78
- [How to write tests](#how-to-write-tests)
89
- [How to debug your test](#how-to-debug-your-test)
910

@@ -70,6 +71,44 @@ to request changes; when this happens:
7071

7172
4) Once the new plugin has been submitted you'll see some GitHub actions feedback (similars to the ones that you run with `tox`)
7273
74+
## Plugin Priority System
75+
76+
Plugin priorities are assigned based on system stability and operational continuity impact. **999 is the maximum criticality** (system can break at any moment) and **1 is the lowest priority** (informational only).
77+
78+
### Priority Categories
79+
80+
| Priority Range | Category | Impact Level | Description | Examples |
81+
| -------------- | ---------------------- | ------------------------------ | ----------------------------------------------------------- | ----------------------------------------------------------------------- |
82+
| **900-999** | Maximum Criticality | System can break at any moment | Critical system components that can cause immediate failure | Filesystem corruption (950), etcd health (980), API server health (970) |
83+
| **800-899** | High Criticality | System services at risk | Core system services and infrastructure | Network issues (870), systemd problems (890), node health (880) |
84+
| **600-799** | Medium Criticality | Applications & Services | Platform services and applications | OpenStack (750), OpenShift (740), databases (700) |
85+
| **400-599** | Medium-Low Criticality | Middleware & Support | Supporting services and middleware | Web servers (580), load balancers, caching |
86+
| **200-399** | Low Criticality | Monitoring & Logging | Observability and monitoring systems | Monitoring (350), logging (330), performance (280) |
87+
| **100-199** | Very Low Criticality | Informational | Informational and compliance checks | Informative plugins (150), compliance (130) |
88+
| **1-99** | Lowest Priority | Metadata & Development | Metadata collection and development tools | Metadata (70), development tools (50) |
89+
90+
### Priority Assignment Guidelines
91+
92+
When creating or updating plugins, assign priorities based on:
93+
94+
1. **System Stability Impact**: How quickly could this issue cause system failure?
95+
2. **Operational Continuity**: How much would this affect ongoing operations?
96+
3. **Recovery Difficulty**: How hard would it be to recover from this issue?
97+
4. **Blast Radius**: How many systems/users would be affected?
98+
99+
### Examples by Priority
100+
101+
- **980**: etcd cluster health - etcd failure breaks the entire cluster
102+
- **950**: Filesystem corruption - can cause immediate data loss
103+
- **940**: Disk space full - system can become unresponsive
104+
- **880**: Node health issues - affects workload scheduling
105+
- **870**: Network connectivity problems - affects all communications
106+
- **750**: OpenStack service issues - affects cloud operations
107+
- **400**: General system configuration issues
108+
- **350**: Monitoring system problems - affects observability
109+
- **150**: Informational system inventory
110+
- **70**: Metadata collection - purely informational
111+
73112
## How to write tests
74113
75114
Please refer to the
@@ -82,7 +121,7 @@ Specially remember about the headers:
82121
# long_name: plug long name for webui
83122
# description: plug description
84123
# bugzilla: bz url
85-
# priority: 0<>1000 for likelihood to break your environment if this test reports fail
124+
# priority: 1-999 (999=max criticality, 1=lowest priority)
86125
# kb: url-to-kbase
87126
```
88127

risuclient/common.d/00-core.sh

Lines changed: 91 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ first_file_available() {
2929
if [[ $flag -eq 0 ]]; then
3030
if [[ -f ${file} ]]; then
3131
flag=1
32-
echo ${file}
32+
echo "${file}"
3333
fi
3434
fi
3535
done
@@ -46,9 +46,9 @@ if [ "x$RISU_LIVE" = "x0" ]; then
4646
systemctl_list_units_service_running=("${RISU_ROOT}/sos_commands/systemd/systemctl_list-units" "${RISU_ROOT}/sos_commands/systemd/systemctl_list-units_--all")
4747

4848
# find available one and use it, the ones at back with highest priority
49-
systemctl_list_units_active_file=$(first_file_available ${systemctl_list_units_active[@]})
50-
systemctl_list_units_enabled_file=$(first_file_available ${systemctl_list_units_enabled[@]})
51-
systemctl_list_units_service_running_file=$(first_file_available ${systemctl_list_units_service_running[@]})
49+
systemctl_list_units_active_file=$(first_file_available "${systemctl_list_units_active[@]}")
50+
systemctl_list_units_enabled_file=$(first_file_available "${systemctl_list_units_enabled[@]}")
51+
systemctl_list_units_service_running_file=$(first_file_available "${systemctl_list_units_service_running[@]}")
5252

5353
# List of logs/journalctl files
5454
journalctl_file=$(first_file_available "${RISU_ROOT}/sos_commands/logs/journalctl_--no-pager_--boot" "${RISU_ROOT}/sos_commands/logs/journalctl_--all_--this-boot_--no-pager")
@@ -323,3 +323,90 @@ is_higher() {
323323
fi
324324
return 0
325325
}
326+
327+
# Function to get sysctl parameter value from configuration
328+
# Works for both LIVE and sosreport/mustgather mode transparently
329+
get_sysctl_value() {
330+
local param="$1"
331+
local value=""
332+
333+
# Check main sysctl.conf first
334+
if [[ -f "${RISU_ROOT}/etc/sysctl.conf" ]]; then
335+
value=$(grep "^${param}[[:space:]]*=" "${RISU_ROOT}/etc/sysctl.conf" | tail -1 | cut -d'=' -f2 | tr -d ' ')
336+
fi
337+
338+
# Check sysctl.d directory (later files override earlier ones)
339+
if [[ -d "${RISU_ROOT}/etc/sysctl.d" ]]; then
340+
local override_value
341+
override_value=$(find "${RISU_ROOT}/etc/sysctl.d" -name "*.conf" -type f -exec grep "^${param}[[:space:]]*=" {} \; | tail -1 | cut -d'=' -f2 | tr -d ' ')
342+
if [[ -n ${override_value} ]]; then
343+
value="${override_value}"
344+
fi
345+
fi
346+
347+
echo "${value}"
348+
}
349+
350+
# Note: is_active() function already exists above and provides service status checking
351+
352+
# Function to find configuration files
353+
# Usage: find_config_files FILENAME [SEARCH_PATHS...]
354+
# Returns: List of found files
355+
find_config_files() {
356+
local filename="$1"
357+
shift
358+
local search_paths=("$@")
359+
360+
# Default search paths if none provided
361+
if [[ ${#search_paths[@]} -eq 0 ]]; then
362+
search_paths=("/etc" "/opt" "/usr/local/etc")
363+
fi
364+
365+
# Add RISU_ROOT prefix for sosreport/mustgather mode
366+
if [[ "x$RISU_LIVE" == "x0" ]]; then
367+
local prefixed_paths=()
368+
for path in "${search_paths[@]}"; do
369+
prefixed_paths+=("${RISU_ROOT}${path}")
370+
done
371+
search_paths=("${prefixed_paths[@]}")
372+
fi
373+
374+
# Execute find command
375+
find "${search_paths[@]}" -name "$filename" -type f 2>/dev/null
376+
}
377+
378+
# Function to count recent errors in log files
379+
# Usage: count_recent_log_errors LOGFILE [LINES] [PATTERNS...]
380+
# Returns: Number of matching error lines
381+
count_recent_log_errors() {
382+
local logfile="$1"
383+
local lines="${2:-100}"
384+
shift 2
385+
local patterns=("$@")
386+
387+
# Default error patterns if none provided
388+
if [[ ${#patterns[@]} -eq 0 ]]; then
389+
patterns=("error" "ERROR" "critical" "CRITICAL" "alert" "ALERT" "emergency" "EMERGENCY" "FATAL" "FAILED")
390+
fi
391+
392+
# Join patterns with |
393+
local pattern_string=""
394+
for i in "${!patterns[@]}"; do
395+
if [[ $i -gt 0 ]]; then
396+
pattern_string="${pattern_string}|"
397+
fi
398+
pattern_string="${pattern_string}${patterns[$i]}"
399+
done
400+
401+
# Add RISU_ROOT prefix for sosreport/mustgather mode
402+
if [[ "x$RISU_LIVE" == "x0" ]]; then
403+
logfile="${RISU_ROOT}${logfile}"
404+
fi
405+
406+
# Check if log file exists and count errors
407+
if [[ -f $logfile ]]; then
408+
tail -"$lines" "$logfile" | grep -c "$pattern_string" || echo "0"
409+
else
410+
echo "0"
411+
fi
412+
}

risuclient/extensions/node-problem-detector.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ def listplugins(options=None):
6161
options=options,
6262
):
6363
filename = plugin["plugin"]
64-
data = json.load(open(filename, "r"))
64+
with open(filename, "r") as f:
65+
data = json.load(f)
6566
if "logPath" in data and "rules" in data:
6667
path = data["logPath"]
6768

risuclient/plugins/core/CCN-STIC/610A22/cryptopolicieslevel.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# long_name: Check crypto policies applied
1818
# description: Cheks applied crypto policies level
19-
# priority: 900
19+
# priority: 130
2020
# bugzilla: https://www.ccn-cert.cni.es/pdf/guias/series-ccn-stic/guias-de-acceso-publico-ccn-stic/6768-ccn-stic-610a22-perfilado-de-seguridad-red-hat-enterprise-linux-9-0/file.html
2121

2222
# Load common functions

0 commit comments

Comments
 (0)