NetXMS Support Forum

English Support => General Support => Topic started by: Sympology on September 27, 2010, 05:36:28 PM

Title: Endit a .bat file so XMS can alert
Post by: Sympology on September 27, 2010, 05:36:28 PM
We currently run a batch file to warn of impending doom (ok when a system is down).
Is there a way to get NetXMS to run this (or an internal version), but put the message in the highlighted section, so it would say 'Server %m is down'

I'm no programmer, so simple is best ;-)

@echo off

c:\Rcmd \\exchange1 osql -S exchange1 -U sa -P ourpassword -Q "insert into VGSMDB..loglog (destination, content) values ('Majors','Server is back up and running.')"

pause


Thanks.

Stu
Title: Re: Endit a .bat file so XMS can alert
Post by: Victor Kirhenshtein on September 28, 2010, 11:19:06 AM
Hi!

You have two options:

1. Create an action of type "execute command on management server", entering your command in "command" field like following:


c:\\Rcmd \\\\exchange1 osql -S exchange1 -U sa -P ourpassword -Q "insert into VGSMDB..loglog (destination, content) values ('Majors','Server %n is down')"


Note that all backslashes are doubled, because backslash is an escape character in action command definition, and you have to use \\ to get single backslash in command.

2. Modify you .bat file to accept server name as argument:


@echo off

c:\Rcmd \\exchange1 osql -S exchange1 -U sa -P ourpassword -Q "insert into VGSMDB..loglog (destination, content) values ('Majors','Server %1 is down')"

pause


and define action to call it, with "command" field set to


my_script.bat %n



In both cases, just add this new action to appropriate rule in event processing policy.

Hope this helps!

Best regards,
Victor