Watch another folder on your devices
Add a folder of your own to file integrity for every device in the realm, through the shared configuration, and see a change in it reported.
API
Your billing service keeps its settings in /opt/billing/config on each server, and a change there that nobody
recorded is something you want to hear about. File integrity watches the system’s own folders out of the box; you
add yours once, in the configuration every sensor in the realm shares, and each device picks it up by itself.
Before you start
Section titled “Before you start”- You are an administrator of the realm, in a group holding
RealmOwner, with your session in$CVYUH_SESSION(Call the API), andjqto edit the configuration. - The realm has enrolled devices, with the folder on them (see Device records). A device starts watching a folder in real time only if the folder is there when the change arrives.
Add the folder
Section titled “Add the folder”-
Read the shared configuration, and keep it as it is, to put back later if you need to:
Terminal window curl https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/group/configuration \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" > held.jsonIt holds the configuration’s text,
xml, and therevisionyou read it at. -
Add a block for the folder after what’s there. The text can hold any number of
<agent_config>blocks, so what was there stays as it was:Terminal window jq --arg dir /opt/billing/config '{revision, xml: (.xml + "\n<agent_config>\n <syscheck>\n <directories realtime=\"yes\" check_all=\"yes\">" + $dir + "</directories>\n </syscheck>\n</agent_config>\n")}' \held.json > written.jsonrealtime="yes"reports a change as it happens, andcheck_all="yes"records every checksum, the owner and the permissions. Every setting you can use is in the Configuration reference. -
Write it back, with the revision you read:
Terminal window curl -X PUT https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/group/configuration \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d @written.jsonThe answer is the configuration’s new
revision. It goes out to every device in the realm over each device’s own connection, and each sensor reloads with it, usually within two minutes. A device that’s offline gets it when it reconnects.
Check it worked
Section titled “Check it worked”Ask one device’s sensor (by its sensor id, from the sensors list), which folders its file monitor watches now:
curl https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/agents/<sensor id>/configuration/files \ -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"files.directories lists /opt/billing/config once the device has reloaded. If it doesn’t after two minutes, restart
the sensor (Sensor actions); if the folder didn’t exist when the sensor started,
create it first. Change a file in the folder on that
device, and the change appears in the device’s file change alerts, as
Security events with preset=fim.
Undo it
Section titled “Undo it”Read the configuration again for its new revision, and write back the text you kept in held.json with it:
curl https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/group/configuration \ -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" > now.jsonjq --slurpfile was held.json '{revision, xml: $was[0].xml}' now.json > undone.jsoncurl -X PUT https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/group/configuration \ -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \ -H "Content-Type: application/json" \ -d @undone.jsonRelated
Section titled “Related”- Group configuration: what the shared configuration is, and its limits.
- File integrity: what the sensor watches out of the box, and how changes show.
- Sensor actions: restart sensors, if one doesn’t pick the change up.