How to pass parameters to a function

Hi,

does anyone know how to pass parameters to a function?

I’d like to write a single custom function (e.g.: disk_free_space) and pass to it a parameter, in order to use it into different probes using different values:

a) Probe: server_disk_warning
disk_free_space(2000)

b) Probe: server_disk_alert
disk_free_space(500)

In probe a) I would set the limit threshold to 2000 MB, in probe b) to 500.

Does anybody know if that’s possible and eventually some sample to share the syntax to use into the function?

TKS.

Currently there is no way to pass params to function.

Thanks for your answer. :frowning:

I wonder how can I avoid writing hundreds of functions and probes, all identical except for silly parameters like disk label (C, D, /var…), threshold (100, 1000…) and so on.

Does anybody have ideas?

Many thanks in advance.

How about writing a simple ‘daemon’ script running on the device that creates variables accessible via ros_command?

Any news about this feature ?

I’m also keen to be able to pass parameters into a function that I have written. It seems that this should be possible as many of the built-in functions can accept input parameters. Just that this capability is not exposed (or not documented) for user functions.

Starting from 6.2 ROS supports passing arguments to custom functions:
https://wiki.mikrotik.com/wiki/Manual:Scripting#Functions

Also global variables can be used to pass parameters.

Post by BlackVS » 25 Oct 2017 17:40

Starting from 6.2 ROS supports passing arguments to custom functions:
https://wiki.mikrotik.com/wiki/Manual:S > … #Functions

Also global variables can be used to pass parameters.

I think what you are referring to here is ROS functions - Not Dude functions. If I’m wrong, can you please advise how to pass a parameter into a user created Dude function?

Bump

This topic is already 10 years old and nothing done. Very bad :frowning:

And +3 years additional :frowning: