Hello Stefan,
I have followed your steps and was not able to achieve the end results. However, I can provide a workaround that might be helpful in your case, as I think a <wodle> is more suitable than a <localfile> for commands.
Let me guide you through the steps I have followed:
1. Enable remote commands on the Wazuh manager
nano /var/ossec/etc/local_internal_options.conf
# Add the following:
wazuh_command.remote_commands=1
systemctl restart wazuh-manager
2. Add the following wodle into the agent group, in my case 'Windows' (you can also add the configuration in the agent itself):
<agent_config>
<wodle name="command">
<disabled>no</disabled>
<tag>disk_health2</tag>
<command>Powershell -c "$d = Get-PhysicalDisk | Select-Object FriendlyName, HealthStatus; foreach($x in $d){ $x | ConvertTo-Json -Compress }"</command>
<interval>1m</interval>
<ignore_output>no</ignore_output>
<run_on_start>yes</run_on_start>
<timeout>0</timeout>
</wodle>
</agent_config>
3. Add the following custom rule into local_rules.xml:
<group name="WinCounter,">
<rule id="100111" level="3">
<decoded_as>json</decoded_as>
<match>^{"FriendlyName":</match>
<field name="FriendlyName">VBOX HARDDISK</field> <!-- Note that this is my device name, please change it or just replace it with \.+ -->
<description>Windows Counter: Disk Space $(HealthStatus)</description>
<group>CPUUsage,</group>
</rule>
</group>
You should be able to see alerts on the dashboard:
Note that you can create custom rules and use the 'HealthStatus' field for filtering. For instance, the following custom rule:
<rule id="303004" level="7">
<if_sid>303003</if_sid>
<match>^{"FriendlyName":</match>
<field name="HealthStatus">Unhealthy</field>
<description>Windows Counter: Disk Space $(HealthStatus)</description>
<group>CPUUsage,</group>
</rule>
Let me know if this worked for you or if you have any other issues or questions.
Regards,