Hi there! Apologies if this message has been sent twice, I noticed that I couldn't see a previous response and I wanted to make sure it was sent correctly.
You can monitor your disk usage by using our command monitoring feature! (
https://documentation.wazuh.com/current/user-manual/capabilities/command-monitoring/command-configuration.html#basic-usage)
To do this, first you would need to configure your windows agent. Assuming you will be monitoring disk C, add the following block:
<localfile>
<log_format>command</log_format>
<command>powershell -command "$disk = Get-PSDrive C | Select-Object Used,Free;$total = $disk.used + $disk.free;if ($total -gt 0){ $PercentFree = [Math]::round((($disk.free/$total) * 100))} else {$PercentFree = 0};if ($PercentFree -le 20){Write-Host 'Device C:/ with less than 20% of free space - '$PercentFree '%'}
"</command>
<frequency>43200</frequency>
<alias>free-space-disk-C</alias>
</localfile>Where:
log_format: Specified the log format. In this case, command.
command: This command in cmd will call a PowerShell script. This one will check the free space in C: disk and will inform in case this is lower than 25 per cent of the total space.
frequency: The frequency of the command execution (set to 12 hours).
alias: Alias of the command.
More information about these options here:
https://documentation.wazuh.com/current/user-manual/reference/ossec-conf/localfile.htmlAfter restarting your wazuh-agent you will receive the following event in your wazuh manager, in case your disk space is lower than 20%:
any->free-space-disk-C ossec: output: 'free-space-disk-C': Device C:/ with less than 25% of free space - 20 %
Then, you would need to add a rule in your manager's /var/ossec/etc/rules/local_rules.xml file that responds to the event generated, for example:
<group name="win-custom,">
<rule id="100034" level="7">
<if_sid>530</if_sid>
<match>ossec: output: 'free-space-disk-C':</match>
<regex>with less than 20%</regex>
<description>Device with less than 20% of free space </description>
</rule>
</group>- Restart your wazuh manager.
- Ensure your alert is working using /var/ossec/bin/wazuh-logtest tool:
# /var/ossec/bin/wazuh-logtest
Starting wazuh-logtest v4.3.0
Type one log per line
ossec: output: 'free-space-disk-C': Device C:/ with less than 20% of free space - 13 %
**Phase 1: Completed pre-decoding.
full event: 'ossec: output: 'free-space-disk-C': Device C:/ with less than 20% of free space - 13 %'
**Phase 2: Completed decoding.
name: 'ossec'
**Phase 3: Completed filtering (rules).
id: '100034'
level: '7'
description: 'Device with less than 20% of free space '
groups: '['win-custom']'
firedtimes: '1'
mail: 'False'
**Alert to be generated.I hope this reaches you well and can help you with your issue!