NetXMS Support Forum

English Support => General Support => Topic started by: mcc on June 26, 2014, 04:07:16 AM

Title: Server Command Object Tool %OBJECT_IP_ADDR%
Post by: mcc on June 26, 2014, 04:07:16 AM
Hi,

I've created a Server Command under Object Tools that calls a bash script stored locally on the NetXMS server and passes the the %OBJECT_IP_ADDR% variable to the script. The script is very basic and looks something like this:

#!/bin/bash --
/usr/bin/do_something $1
echo `date +"%Y-%m-%d %T : "` Something done on device $1 >> script.log


I can run this script manually and the expected output is in the log file and the expected action is completed.

If I run this script using the created Server Command Object Tool, the script is executed but what I see in the log is:

date_and_time: Something done on device BJECT_IP_ADDR

Is there a way to pass the %OBJECT_IP_ADDR% variable to a Server Command Object Tool?

Title: Re: Server Command Object Tool %OBJECT_IP_ADDR%
Post by: Dani@M3T on June 26, 2014, 09:41:55 AM
I also get "OBJECT_NAME" in a server script using %OBJECT_NAME% in the Object Tools.

Update:
I saw this in admin guide:
QuoteAction, file download, local command, and URL tool types allows macro substitution.
Title: Re: Server Command Object Tool %OBJECT_IP_ADDR%
Post by: Victor Kirhenshtein on June 26, 2014, 07:00:17 PM
Actually it's an error in documentation. For server commands macros are expanded on server side, and you should use event processing macros (https://www.netxms.org/documentation/adminguide/event-processing.html#macros-for-event-processing (https://www.netxms.org/documentation/adminguide/event-processing.html#macros-for-event-processing)).
Title: Re: Server Command Object Tool %OBJECT_IP_ADDR%
Post by: Dani@M3T on June 26, 2014, 07:15:32 PM
I can confirm that. When I use "%n" in server command it's expanded to nodes name. Thank's
Title: Re: Server Command Object Tool %OBJECT_IP_ADDR%
Post by: mcc on June 26, 2014, 07:50:03 PM
That fixed it for me. Thanks much.