EXOS: UPM Script - port number in log message


Userlevel 6
Today i play around with a UPM Script which refresh nodealias table after a port link down.
#
# Module upm configuration.
#
create upm profile clear-nodealias
create log message Starting_Script_clear-nodealias
clear nodealias port $EVENT.LOG_PARAM_0
create log message Finishing_Script_clear-nodealias

.
#[/code]Here is the log output if the script runs successfully:
03/12/2018 18:35:43.95 [i] Finishing_Script_clear-nodealias
03/12/2018 18:35:43.94 [i] Starting_Script_clear-nodealias
03/12/2018 18:35:43.85 Launched profile clear-nodealias for the event log-message
03/12/2018 18:35:43.85 [i] Port 19 link down[/code][/code]I want enhance the log message "Starting_Script_clear-nodealias" by the Port Number which part of nodealias table will be cleared.

So i try this:
create log message Starting_Script_clear-nodealias on port $EVENT.LOG_PARAM_0[/code]But then UPM Scripts runs successful but this line was not written down to log file.

How can i achieve my goal ?

3 replies

Userlevel 6
The spaces in your log message makes the command wrong.
* Slot-1 SWTCORE1.2 # create log message test 123
^
%% Invalid input detected at '^' marker.
* Slot-1 SWTCORE1.3 # create log message "test 123"
* Slot-1 SWTCORE1.4 #

However, using a variable inside "" does not seem to work.

Slot-1 SWTCORE1.5 # set var port "1:1"
* Slot-1 SWTCORE1.6 # show var port
1:1
* Slot-1 SWTCORE1.7 # create log message "test port $port"
* Slot-1 SWTCORE1.8 # sh log
03/13/2018 10:07:40.37 [i] Slot-1: test port $port

Using _ instead of spaces and not use quotes makes it possible to use variables but is a bit ugly.
* Slot-1 SWTCORE1.14 # create log message test_port_$port
* Slot-1 SWTCORE1.15 # sh log
03/13/2018 10:10:35.50 [i] Slot-1: test_port_1:1
Userlevel 6
OscarK wrote:

The spaces in your log message makes the command wrong.
* Slot-1 SWTCORE1.2 # create log message test 123
^
%% Invalid input detected at '^' marker.
* Slot-1 SWTCORE1.3 # create log message "test 123"
* Slot-1 SWTCORE1.4 #

However, using a variable inside "" does not seem to work.

Slot-1 SWTCORE1.5 # set var port "1:1"
* Slot-1 SWTCORE1.6 # show var port
1:1
* Slot-1 SWTCORE1.7 # create log message "test port $port"
* Slot-1 SWTCORE1.8 # sh log
03/13/2018 10:07:40.37 [i] Slot-1: test port $port

Using _ instead of spaces and not use quotes makes it possible to use variables but is a bit ugly.
* Slot-1 SWTCORE1.14 # create log message test_port_$port
* Slot-1 SWTCORE1.15 # sh log
03/13/2018 10:10:35.50 [i] Slot-1: test_port_1:1

Thanks for that advice - not nice but it works!

Regards
Userlevel 7
you have to end your log message with a normal character to have it to work, for example:

EXOS-VM.6 # create log message "the port is $ports !"
EXOS-VM.7 # sh log
03/15/2018 15:16:34.18 [i] the port is 1:1 !

Reply