Community discussions

MUM Europe 2020
 
User avatar
airstream
Member Candidate
Member Candidate
Topic Author
Posts: 188
Joined: Fri Feb 03, 2006 6:33 am
Location: New Zealand

Show varible value in /tool e-mail

Tue Apr 15, 2008 7:54 am

Hi all, Due to a recent downgrade from v3 back to 2.9.51 some of our scripts need adjusting. Most notable is the script handling of /tool e-mail.

We are trying to do this:
:set foo 900
 /tool e-mail send to=mailbox@domain.com from=mailbox@domain.com server=1.2.3.4 subject="variable is $foo" body="value is $foo"
But the 2.9 ROS wont accept the $foo in the body of the email (invalid argument). How do I wrap this value in the body to display the value in the generated email?
Keep tryin' its bound to work!!
-----
-----
ROOT@COSMOS> Reality.sys corrupted -- Reboot Universe (Y/N)?
>_
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 5970
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Show varible value in /tool e-mail

Tue Apr 15, 2008 10:09 am

subject=("variable is " . $foo) body=("value " . $foo)
 
User avatar
airstream
Member Candidate
Member Candidate
Topic Author
Posts: 188
Joined: Fri Feb 03, 2006 6:33 am
Location: New Zealand

Re: Show varible value in /tool e-mail

Tue Apr 15, 2008 10:25 am

Hi, Thanks for your help there, the Email scripts are working! :wink:

Now having trouble with my logical statements in another script:
{:local warninglevel
:local name
:local surname
:local usage
:local bytesin
:local bytesout
:local bytestotal
:local megstotal
:local cap
:local comment
:local newcomment
:local lastwarning
:local newwarning
:local percentage
:local percentile
:local warn
:local update
:local email
:local server
:local username

:set server 10.19.60.20
/tool user-manager user
:foreach i in=[/tool user-manager user find subscriber=admin] do={

:set name [get $i first-name]
:set surname [get $i last-name]
:set comment [get $i group-name]
:set bytesin [get $i download-used]
:set bytesout [get $i upload-used]
:set bytestotal ($bytesin + $bytesout)
:set email [get $i email]
:set username [get $i name]



:set megstotal ($bytestotal / 1000000)
:set cap [:pick $comment 0 4]
:set lastwarning [:pick $comment 4 6]
:set percentage (($megstotal*100) / $cap)



:if ($percentage < 50) do={ :set warninglevel 10 ; :log info ("---set to--- " . $warninglevel) }

:if ($percentage > 50) do={
:if ($percentage < 75) do={ :set warninglevel 50 ; :log info ("---set to--- " . $warninglevel) }
:if ($percentage > 75) do={ :set warninglevel 75 ;}
}

:if ($percentage > 75) do={
:if ($percentage < 90) do={ :set warninglevel 75 ;}
:if ($percentage > 90) do={ :set warninglevel 90 ;}
}

:if ($percentage > 90) do={
:if ($percentage < 100) do={ :set warninglevel 90 ;}
:if ($percentage > 100) do={ :set warninglevel 99 ;}
}

:log info ($name . " percentage " . $percentage . " warnlevel " . $warninglevel ) } }
- Kudos to Kridge who provided the script source -
At this line (added for debug) the warninglevel value is null
:log info ($name . " percentage " . $percentage . " warnlevel " . $warninglevel ) } }
At this point of the script $percentage has a value but it wont assign the warninglevel variable to the values in marks if the statement is true. could you point me to the correct syntax here?

Cheers
Keep tryin' its bound to work!!
-----
-----
ROOT@COSMOS> Reality.sys corrupted -- Reboot Universe (Y/N)?
>_

Who is online

Users browsing this forum: CZFan, macsrwe and 18 guests