Problem with macro?

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
Dubolomov
Posts: 214
Joined: Thu Jun 01, 2006 10:27 am
Location: Russia

Problem with macro?

Post by Dubolomov »

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
.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

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
Dubolomov
Posts: 214
Joined: Thu Jun 01, 2006 10:27 am
Location: Russia

Post by Dubolomov »

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.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

HostMonitor version 3.0 or higher supports macro variables (%HostName%, %Comment%, %Folder%, etc.)
Correct
Macro variables may be used in the command line
Correct
So i don't see why macro %yyyymmdd[-1d]% doesn't work in HMS-script.
You may use macro variables. You cannot use date EXPRESSIONS because actions do not support such expressions and never supported.
Please use link I have provided in my 1st post, you will see list of macro variables that can be used for actions.
Can you add in to do list use in HMS-scripts all macro variables
It supports all macro variables.
send e-mail action (with parameters like SMTP-server, "From:", "To:", attach files, body text, subject text)
You may use our SendMail utility that comes with IP-Tools
http://www.ks-soft.net/ip-tools.eng/mfr ... ndmail.htm
Is it possible to modify "ExecuteProgram" command with don't stop monitoring like as StartProgram but with waiting for complete execution of previous ExecuteProgram?
Lets talk about this in "Wish list" forum

Regards
Alex
Dubolomov
Posts: 214
Joined: Thu Jun 01, 2006 10:27 am
Location: Russia

Post by Dubolomov »

Thanks for detailed answer.
Really i meant expressions.
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

Thank you.
Dubolomov
Posts: 214
Joined: Thu Jun 01, 2006 10:27 am
Location: Russia

Post by Dubolomov »

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
Yes, it's works. So all commands executes step by step with true filenames and with log.
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
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Dubolomov wrote:
Dubolomov wrote:Can i use Execute Program action with bat-files and expressions as parameters? For example "arch.bat %yyyymmdd[-8d]%".
Yes, it's works.
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=7
Perhaps, it helps someone.

Regards,
Max
Dubolomov
Posts: 214
Joined: Thu Jun 01, 2006 10:27 am
Location: Russia

Post by Dubolomov »

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. :oops:
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Good job. Thank you!

Regards,
Max
Post Reply