Highlighted
Respected Contributor.. ashok411 Respected Contributor..
Respected Contributor..
341 views

Query on OMi Log file moniotirng

Jump to solution

Hi Team,

We have a requirement to monitor application logs for which the name is changing dynamically.

for example log files containing log file generated date in the log file name  logfilename_26042017.log....

So i would like to know how i need to configure the log file policy to match the requirement..

Regards,

Ashok

1 Solution

Accepted Solutions
Outstanding Contributor.. Shawn Tripet Outstanding Contributor..
Outstanding Contributor..

Re: Query on OMi Log file moniotirng

Jump to solution

You can create a logfile policy template and in the "Source" field you can run a command which is a script which returns the logfiles you want monitored:

From the Logfile policy doc  online doc:

"Script or command that returns the path and name of the log file you want to access. For example, type <`command`> where command is the name of a script that returns the path and name of the log file you want the policy to read.

The command can also return more than one log file path separated by spaces. The HPE Operations Agent processes each of the files using the same options and conditions as configured for this policy. This is very useful when you want to dynamically determine the log file path or process multiple instances of a log file."

Here is an example of one of our logfile policies Source tab Log file path field:

<`IPG_Get_Logfile_Names.bat`>

And...Here is an example of the contents of the IPG_Get_Logfile_Names.bat script:

@ECHO off
😧
Set OutDir=D:\temp
cd "%OutDir%"
For %%a in (D:\temp) do (
        for /F "tokens=1 usebackq" %%b in (`@dir /B /S %%a\Error_*.* 2^>NUL`) do (
                      @ECHO %%a\%%b
        )
)

I use this method and it works great!

"Read-Aim-Fire, NOT Ready-Fire-Aim"

View solution in original post

4 Replies
Outstanding Contributor.. Shawn Tripet Outstanding Contributor..
Outstanding Contributor..

Re: Query on OMi Log file moniotirng

Jump to solution

You can create a logfile policy template and in the "Source" field you can run a command which is a script which returns the logfiles you want monitored:

From the Logfile policy doc  online doc:

"Script or command that returns the path and name of the log file you want to access. For example, type <`command`> where command is the name of a script that returns the path and name of the log file you want the policy to read.

The command can also return more than one log file path separated by spaces. The HPE Operations Agent processes each of the files using the same options and conditions as configured for this policy. This is very useful when you want to dynamically determine the log file path or process multiple instances of a log file."

Here is an example of one of our logfile policies Source tab Log file path field:

<`IPG_Get_Logfile_Names.bat`>

And...Here is an example of the contents of the IPG_Get_Logfile_Names.bat script:

@ECHO off
😧
Set OutDir=D:\temp
cd "%OutDir%"
For %%a in (D:\temp) do (
        for /F "tokens=1 usebackq" %%b in (`@dir /B /S %%a\Error_*.* 2^>NUL`) do (
                      @ECHO %%a\%%b
        )
)

I use this method and it works great!

"Read-Aim-Fire, NOT Ready-Fire-Aim"

View solution in original post

Micro Focus Expert
Micro Focus Expert

Re: Query on OMi Log file moniotirng

Jump to solution

Just to add on to the existing good answer:

Basically your `cmd` needs to produce to std a whitespace separated list of one or more /path/filename

Another example (Unix) to process all log files in a given directory.
Log File Path / Name:
<`find /tmp/mylogs -maxdepth 1 -type f -print`>

Ie, putting the OS native command into the policy means you don't need to create instrumentation.  This is ok for simple commands, but for a more complicated series of commands, then sure you'd need to create a script, create instrumentation that you upload into the OMi DB via ConfigExchange[.sh|.bat] CLI, call it in the policy as <`scriptname`> and select the instrumentation name in the policy in the Properties tab to ensure it is deployed with the policy, since the policy depends on it.

CP.

Outstanding Contributor.. Mayur_Khardikar Outstanding Contributor..
Outstanding Contributor..

Re: Query on OMi Log file moniotirng

Jump to solution

Very interesting solutions provided by Shawn & Carol!

Thanks for sharing!

 

Regards,

Mayur

Aaron Laing Outstanding Contributor.
Outstanding Contributor.

Re: Query on OMi Log file moniotirng

Jump to solution

Do you know if this mechanism should work on an Operations Connector server, as opposed to a server running the standalone Operations Agent?  I've played around with it, but no success so far.

We're running on Windows - where would the .bat file need to be saved in order for this to work?

Thanks,
Aaron

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.