Reputation: 1
I am trying to list out all the files in a UNIX folder in Geneos that contains yesterday's date. I tried using the FKM & FTM plugin but it lists out only the 1st file it detects if i give a wildcard character. Ex: /location/*
How to configure Geneos so that it lists out all the file in a folder in UNIX server containing certain fixed character?
Upvotes: 0
Views: 1185
Reputation: 66
You need to use two concepts in the FKM plugin: Date Generation & Dynamic Files.
Included below are exerpts from the really useful help guides and an example xml if you want to copy and paste it into the editor.
FKM file definitions can be configured to generate a filename using the current date and time. The target filename is generated every sample, and if a file exists which matches this name the file will be monitored by FKM (once the current file has been processed to the end). Filenames can be generated using one of three date codes; yesterday, today or tomorrow. These are replaced in the filename using the appropriate date. For example, if the current date is 22-Aug-2008 the following will be produced:
Filename Generated name
app<yesterday>.log app20080821.log
app<today>.log app20080822.log
app<tomorrow>.log app20080823.log
The output format for dates can be controlled by placing format codes in the date tag. Examples of this usage are shown below.
Filename Generated name
app<today %d-%m-%Y>.log app22-08-2008.log
app<today %d%b%y>.log app22Aug08.log
app<tomorrow %d_%m_%Y>.log app23_08_2008.log
The following formatting codes can be used with this feature.
Code Meaning
%a Abbreviated weekday name. (e.g. Wed)
%A Full weekday name (e.g. Wednesday)
%b Abbreviated month name. (e.g. Mar)
%B Full month name (e.g. March)
%c Date and time representation appropriate for the current locale.
%d Day of month as a decimal number (01 – 31).
%H Hour in 24-hour clock format (00 – 23).
%I Hour in 12-hour clock format (01 – 12).
%j Day of year as a decimal number (001 – 336).
%m Month as a decimal number (01 – 12).
%M Minutes as a decimal number (00 – 59).
%p Current locale’s AM / PM indicator for 12-hour clock.
%S Seconds as a decimal number (00 – 61).
%U Week of the year as a decimal number, with Sunday as the first day. (00 – 53).
%w Weekday as a decimal number (0 – 6, with Sunday as 0).
%W Week of the year as a decimal number, with Monday as the first day. (00 – 53).
%x Date representation appropriate for current locale.
%X Time representation appropriate for current locale.
%y Year without century, as a decimal number (00 – 99).
%Y Year with century, as a decimal number (e.g. 2008).
%z,%Z Time-zone name or abbreviation (e.g. GMT or PST); no characters are shown if the time-zone is unknown.
Note It is possible but not recommended to use a seconds (%S) or minutes (%M) time format code in a filename. This is because the generated filename will contain the time at which FKM performed a sample, which is not guaranteed to occur at an exact number of seconds apart.
files > file > source > dynamicFiles
The dynamicFiles type file-source configures FKM to match groups of files based the configured path, pattern and optionally the alias.
When a new group is identified, an additional file row is created which behaves as a normal filename source. Settings for this new row are copied from the settings of the parent dynamicFiles row. The row will be removed when no files remain to create that grouping.
This feature is similar to using a normal filename source with the wildcardMonitorAllMatches setting, but the two features cannot be used in conjunction. FKM will report an error if you attempt to do this.
Groups are specified using the path setting, which should be a file path containing wildcard globbing characters (* and ?). This path will be evaluated, and all files discovered will then be matched against the configured regex pattern.
The name of a row in the view is determined by evaluating the file alias. Any numbered inserts in the alias (identified by a % followed by a number, e.g. %4) will be replaced with the content of that capture group in the regex pattern, as matched against the filename. Capture groups that do not exist or have no content will be replaced with an empty string. A literal percent character can be produced escaping it as %%. When using a case-insensitive regular expression, insertions will be lowercased to ensure consistent row names.
For example, the value of capture group 1 for regex "app_(.)_\d+.log$" matched against file "app_Apache_001.log" would be "Apache" (the contents of the . portion of the regex). The website http://www.internetofficer.com/seo-tool/regex-tester/ can be used to test regexes against various strings, to see the content of each capture group.
Given the following configuration:
Path: /var/logs/app_*.log
Regex pattern: app_(.*)_\d+\.log$
Alias: App-%1
And the files:
/var/logs/app_Apache_001.log
/var/logs/app_Apache_002.log
/var/logs/app_Samba_1_01.log
/var/logs/app_Router.log
FKM would create two rows in the view:
"App-Apache" monitoring "app_Apache_002.log"
"App-Samba_1" monitoring "app_Samba_1_01.log".
The file app_Apache_002.log is selected over app_Apache_001.log because it has a more recent modification-time (it is assumed that Apache is rolling files by creating higher-numbered logs). The time used for this check can be controlled using the wildcardMatchTime setting. File "app_Router.log" is ignored as it does not pass the regex.
<sampler name="Example">
<plugin>
<fkm>
<files>
<file>
<source>
<dynamicFiles>
<path>
<data>/my/path/file*.log</data>
</path>
<pattern>
<data>
<regex>file<yesterday>.log</regex>
</data>
</pattern>
</dynamicFiles>
</source>
</file>
</files>
</fkm>
</plugin>
</sampler>
Upvotes: 0