Skip to content

Latest commit

 

History

History
57 lines (37 loc) · 2.27 KB

multiple_files.rst

File metadata and controls

57 lines (37 loc) · 2.27 KB

How to add multiple log files to be monitored?

By Daniel B. Cid

For Unix Agents

If you have multiple log files to be monitored by OSPatrol and don't want to add each one of them manually, you can configure them using posix regular expressions.

For example, if you have a directory structure like this:

/var/log/host1/xx.log, yy.log, zz.log
/var/log/host2/xx.log, aa.log
/var/log/host3/zz.log, abc.log
/var/log/hostn/bb.log, xyz.log

You can just add one entry in the localfile to monitor all these logs: .. code-block:: console

<localfile>
<log_format>syslog</log_format> <location>/var/log/host*/*.log</location>

</localfile>

This tip can make large configurations much simpler.

For Windows Agents

For the Windows agent, the built-in globing doesn't work. At time of writing (OSPatrol version 1.5) you have to use a script to auto-generate ospatrol.conf if you want to monitor many log files without having to manually enter them. Here's an example batch file to get you started:

Adjust the "for..in" globbing line as needed. In this example, I'm monitoring logs for multiple IIS sites which are all in D:Logs. Save it into a file with a .bat extension and put it somewhere on your hard drive. Create a file named ospatrol_template.conf in the `same directory as the batch file. You can probably just copy your current ospatrol.conf for this file, as this script will only append to it. You can then set up a scheduled task to run the batch file to automatically keep your ospatrol.conf up to date.