Check last modify time of growing log files
Check last modify time of growing log files
Hello KS-support team,
I have a problem to identify several log files.
I want to check the age (last modify time) of the newest file with "Folder/File Availability"-test.
In the following I want to show you the structure of log files which are
located !!!only in one!!! directory.
---------------------------------------------------------------
"Control_3_PROD20150313.0" (50MB - old log file)
"Control_3_PROD20150313.1" (newest log file)
"Control_5_PROD20150313.0" (50MB - old log file)
"Control_5_PROD20150313.1" (newest log file)
"Control_13_PROD20150313.0" (50MB - old log file)
"Control_13_PROD20150313.1" (newest log file)
---------------------------------------------------------------
Unfortunately, the system, which generate log files, will create new log-file by reaching size of 50 MegaBytes and increase ending number of filename.
So, if I use the path-string "\\[SERVER-IP]\[DIRECTORY-NAME]\Control_3_PROD%yyyy%%mm%%dd%.*" with enabled macro translation,
HostMonitor can not identify the newest log-file.
Can you help me to find the way to identify always the growing log-files?
Regards,
Stefan
I have a problem to identify several log files.
I want to check the age (last modify time) of the newest file with "Folder/File Availability"-test.
In the following I want to show you the structure of log files which are
located !!!only in one!!! directory.
---------------------------------------------------------------
"Control_3_PROD20150313.0" (50MB - old log file)
"Control_3_PROD20150313.1" (newest log file)
"Control_5_PROD20150313.0" (50MB - old log file)
"Control_5_PROD20150313.1" (newest log file)
"Control_13_PROD20150313.0" (50MB - old log file)
"Control_13_PROD20150313.1" (newest log file)
---------------------------------------------------------------
Unfortunately, the system, which generate log files, will create new log-file by reaching size of 50 MegaBytes and increase ending number of filename.
So, if I use the path-string "\\[SERVER-IP]\[DIRECTORY-NAME]\Control_3_PROD%yyyy%%mm%%dd%.*" with enabled macro translation,
HostMonitor can not identify the newest log-file.
Can you help me to find the way to identify always the growing log-files?
Regards,
Stefan
Hi Alex,
sorry for my bad description.
I want to check newest file of each log-file.
But unfortunately, there are all three log-files into same directory! (see following example)
---------------------------------------------------------------
"Control_3_PROD20150313.0" (50MB - old log file)
"Control_3_PROD20150313.1" (newest log file)
"Control_5_PROD20150313.0" (50MB - old log file)
"Control_5_PROD20150313.1" (newest log file)
"Control_13_PROD20150313.0" (50MB - old log file)
"Control_13_PROD20150313.1" (newest log file)
---------------------------------------------------------------
Which file will HostMonitor check by using %NewestFile% Variable? (Always the newest one ???)
Regards,
Stefan
sorry for my bad description.
I want to check newest file of each log-file.
But unfortunately, there are all three log-files into same directory! (see following example)
---------------------------------------------------------------
"Control_3_PROD20150313.0" (50MB - old log file)
"Control_3_PROD20150313.1" (newest log file)
"Control_5_PROD20150313.0" (50MB - old log file)
"Control_5_PROD20150313.1" (newest log file)
"Control_13_PROD20150313.0" (50MB - old log file)
"Control_13_PROD20150313.1" (newest log file)
---------------------------------------------------------------
Which file will HostMonitor check by using %NewestFile% Variable? (Always the newest one ???)
Regards,
Stefan
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
JScript for Shell Script test method may look like the following:
Start cmd: cmd /c cscript /B /E:JScript %Script% %Params%
Script requires 3 parameters: <folder path> <partial file name e.g.: Control_6_PROD> <age in minutes>
E.g.:
"\\SERVER-IP\DIRECTORY-NAME\" Control_13_ 15
Code: Select all
statusUnknown = "ScriptRes:Unknown:"
statusOk = "ScriptRes:Ok:"
statusBad = "ScriptRes:Bad:"
objArgs = WScript.Arguments;
if (objArgs.length<3) {
WScript.StdOut.Write(statusUnknown + 'Required 3 parameters: <folder path> <partial file name e.g.: TEST03> <age in minutes>');
WScript.Quit();
}
var oFS = new ActiveXObject('Scripting.FileSystemObject');
var ff1 = oFS.GetFolder(objArgs(0));
var fc = new Enumerator(ff1.files);
var newestFile = false;
var newestTime = false;
for (; !fc.atEnd(); fc.moveNext())
{
if (newestFile === false&&fc.item().name.indexOf(objArgs(1))>-1) {
newestTime = fc.item().DateLastModified;
newestFile = fc.item();
}
if (fc.item().DateLastModified > newestTime&&fc.item().name.indexOf(objArgs(1))>-1) {
newestTime = fc.item().DateLastModified;
newestFile = fc.item();
}
}
if (newestFile === false) {
WScript.StdOut.Write(statusUnknown + 'No files found with name like ('+objArgs(1)+')');
WScript.Quit();
}
var dat = new Date;
var fileAge = parseInt((dat - newestTime)/1000/60);
if (fileAge > parseInt(objArgs(2))) {
WScript.StdOut.Write(statusBad+fileAge+' ('+newestFile.name+')');
WScript.Quit();
}
WScript.StdOut.Write(statusOk+fileAge);
Script requires 3 parameters: <folder path> <partial file name e.g.: Control_6_PROD> <age in minutes>
E.g.:
"\\SERVER-IP\DIRECTORY-NAME\" Control_13_ 15
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact: