Hi.
I have a schedule task in HM at 3:00am executing hms-script:
StartProgram cmd /c del "C:\Logs.Old\*%yyyymmdd[-8d]*.txt"
StartProgram "C:\Program Files\HostMonitor5\Utils\WinZIP\Wzzip.exe" -a -ep -whs -p -r -ybc "C:\BackUp\HostMonitor_Logs_%yyyymmdd[-1d]%__(created_at__%yyyy%_%mm%_%dd%__%hh%_%nn%).zip" "C:\Logs.Old\*%yyyymmdd[-1d]%*.*"
StartProgram "C:\Program Files\HostMonitor5\Utils\WinZIP\Wzzip.exe" -a -ep -whs -p -r -ybc "C:\BackUp\HostMonitor_%yyyymmdd%__(created_at__%yyyy%_%mm%_%dd%__%hh%_%nn%).zip" "C:\Program Files\HostMonitor5"
This task must delete logs more then one week, archive HostMonitor and HM's logs. But in "C:\BackUp\" i have only file with name HostMonitor_%yyyymmdd%__(created_at__2007_02_16__03_00).zip with "%yyyymmdd%" in the filename. No files with logs. In "C:\Logs.Old\" i have files with name like:
Main--20070215--log.txt
Main--20070214--log.txt
Main--20070213--log.txt
Main--20070212--log.txt
20070215--log.txt
20070214--log.txt
20070213--log.txt
20070212--log.txt
...
etc.
Records from syslog:
[2007-02-16 03:00:01] Sys Command "cmd /c del "C:\Logs.Old\*%yyyymmdd[-8d]*.txt"" executed
[2007-02-16 03:00:01] Sys Command ""C:\Program Files\HostMonitor5\Utils\WinZIP\Wzzip.exe" -a -ep -whs -p -r -ybc C:\BackUp\HostMonitor_Logs_%yyyymmdd[-1d]%__(created_at__2007_02_16__03_00).zip "C:\Logs.Old\*%yyyymmdd[-1d]%*.*"" executed
[2007-02-16 03:00:01] Sys Command ""C:\Program Files\HostMonitor5\Utils\WinZIP\Wzzip.exe" -a -ep -whs -p -r -ybc C:\BackUp\HostMonitor_%yyyymmdd%__(created_at__2007_02_16__03_00).zip "C:\Program Files\HostMonitor5"" executed.
Problem with macro?
1) if you check the manual, you will not find any mention that you can use date expressions like %yyyymmdd[-1d]% as parameter of the actions
http://www.ks-soft.net/hostmon.eng/mfra ... #timemacro
2) Use Log processing options to manage log files (Options dialog)
http://www.ks-soft.net/hostmon.eng/mfra ... processing
Regards
Alex
http://www.ks-soft.net/hostmon.eng/mfra ... #timemacro
2) Use Log processing options to manage log files (Options dialog)
http://www.ks-soft.net/hostmon.eng/mfra ... processing
Regards
Alex
From manual:
HMScript
HostMonitor Script file (file extension .HMS) is a text file that contains commands for HostMonitor. You can create and edit script file using any text editor (e.g. notepad). Some common rules:
You can put only one command in each line
Comments: The program ignores all strings with a semicolon (;) as the 1st character
Commands: commands are case insensitive (e.g. "LoadTestList" and "LOADTESTLIST" means the same)
Parameters: parameters are case sensitive
HostMonitor version 3.0 or higher supports macro variables (%HostName%, %Comment%, %Folder%, etc.).
Execute external program
Name of this action tells for it self, it launches specified external application. In addition to the common action parameters it has 2 more parameters:
Command line
Specify command line to launch external application. Macro variables may be used in the command line.
If i'm use "Execute Program" action with "C:\Program Files\HostMonitor5\Utils\WinZIP\Wzzip.exe" -a -ep -whs -p -r -ybc C:\BackUp\HostMonitor_Logs_%yyyymmdd[-1d]%__(created_at__%yyyy%_%mm%_%dd%__%hh%_%nn%).zip "C:\Logs.Old\*%yyyymmdd[-1d]%*.*" string it's work fine.
So i don't see why macro %yyyymmdd[-1d]% doesn't work in HMS-script.
I'm use Log Processing options for moving log-files from active "C:\Logs\" directory to work "C:\Logs.Old\" directory every day.
Can you add in to do list use in HMS-scripts all macro variables, send e-mail action (with parameters like SMTP-server, "From:", "To:", attach files, body text, subject text)? Is it possible to modify "ExecuteProgram" command with don't stop monitoring like as StartProgram but with waiting for complete execution of previous ExecuteProgram?
Thank you.
HMScript
HostMonitor Script file (file extension .HMS) is a text file that contains commands for HostMonitor. You can create and edit script file using any text editor (e.g. notepad). Some common rules:
You can put only one command in each line
Comments: The program ignores all strings with a semicolon (;) as the 1st character
Commands: commands are case insensitive (e.g. "LoadTestList" and "LOADTESTLIST" means the same)
Parameters: parameters are case sensitive
HostMonitor version 3.0 or higher supports macro variables (%HostName%, %Comment%, %Folder%, etc.).
Execute external program
Name of this action tells for it self, it launches specified external application. In addition to the common action parameters it has 2 more parameters:
Command line
Specify command line to launch external application. Macro variables may be used in the command line.
If i'm use "Execute Program" action with "C:\Program Files\HostMonitor5\Utils\WinZIP\Wzzip.exe" -a -ep -whs -p -r -ybc C:\BackUp\HostMonitor_Logs_%yyyymmdd[-1d]%__(created_at__%yyyy%_%mm%_%dd%__%hh%_%nn%).zip "C:\Logs.Old\*%yyyymmdd[-1d]%*.*" string it's work fine.
So i don't see why macro %yyyymmdd[-1d]% doesn't work in HMS-script.
I'm use Log Processing options for moving log-files from active "C:\Logs\" directory to work "C:\Logs.Old\" directory every day.
Can you add in to do list use in HMS-scripts all macro variables, send e-mail action (with parameters like SMTP-server, "From:", "To:", attach files, body text, subject text)? Is it possible to modify "ExecuteProgram" command with don't stop monitoring like as StartProgram but with waiting for complete execution of previous ExecuteProgram?
Thank you.
CorrectHostMonitor version 3.0 or higher supports macro variables (%HostName%, %Comment%, %Folder%, etc.)
CorrectMacro variables may be used in the command line
You may use macro variables. You cannot use date EXPRESSIONS because actions do not support such expressions and never supported.So i don't see why macro %yyyymmdd[-1d]% doesn't work in HMS-script.
Please use link I have provided in my 1st post, you will see list of macro variables that can be used for actions.
It supports all macro variables.Can you add in to do list use in HMS-scripts all macro variables
You may use our SendMail utility that comes with IP-Toolssend e-mail action (with parameters like SMTP-server, "From:", "To:", attach files, body text, subject text)
http://www.ks-soft.net/ip-tools.eng/mfr ... ndmail.htm
Lets talk about this in "Wish list" forumIs it possible to modify "ExecuteProgram" command with don't stop monitoring like as StartProgram but with waiting for complete execution of previous ExecuteProgram?
Regards
Alex
Yes, it's works. So all commands executes step by step with true filenames and with log.Dubolomov wrote:Can i use Execute Program action with bat-files and expressions as parameters? For example "arch.bat %yyyymmdd[-8d]%".
arch.bat:
del /Q C:\Logs.Old\*%1*.txt
Example of command for ExecuteProgram action (every night):
"C:\Program Files\HostMonitor5\Scripts\Archive.bat" %yyyymmdd[-8d]% %yyyymmdd[-1d]% %yyyymmdd% %hhnn%
Example of bat-file:
@echo %1 - Date of files for deleting (yyyymmdd[-8d]).
@echo %2 - Yesterday (yyyymmdd[-1d]).
@echo %3 - Today (yyyymmdd).
@echo %4 - Real Time (hhnn).
@if '%1'=='' goto quit
@if '%2'=='' goto quit
@if '%3'=='' goto quit
@if '%4'=='' goto quit
del /Q "C:\Logs.Old\*%1--log.txt" > "C:\Program Files\HostMonitor5\Scripts\Logs\Archive--%3_%4.log"
"C:\Program Files\HostMonitor5\Utils\WinZIP\Wzzip.exe" -a -ep -whs -p -r -ybc "C:\BackUp\HostMonitor_Logs_for_%2_date__(created_at__%3_%4).zip" "C:\Logs.Old\*%2--log.txt" >> "C:\Program Files\HostMonitor5\Scripts\Logs\Archive--%3_%4.log"
"C:\Program Files\HostMonitor5\Utils\WinZIP\Wzzip.exe" -a -ep -whs -p -r -ybc "C:\BackUp\HostMonitor_for_%3_date__(created_at__%3_%4).zip" "C:\Program Files\HostMonitor5" >> "C:\Program Files\HostMonitor5\Scripts\Logs\Archive--%3_%4.log"
:quit
exit
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
So, you figured it out using .bat files. Good solution. Could you post the script into "Library" branch, please? http://www.ks-soft.net/cgi-bin/phpBB/viewforum.php?f=7Dubolomov wrote:Yes, it's works.Dubolomov wrote:Can i use Execute Program action with bat-files and expressions as parameters? For example "arch.bat %yyyymmdd[-8d]%".
Perhaps, it helps someone.
Regards,
Max
Ok. I wrote mini-how-to in Library section:
http://www.ks-soft.net/cgi-bin/phpBB/vi ... php?t=3844.
Sorry for my bad english.
http://www.ks-soft.net/cgi-bin/phpBB/vi ... php?t=3844.
Sorry for my bad english.

-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact: