Hi
I would like the below script to e-mail me a list in one e-mail with all the user’s that have gone over 10Gigs. The script does work but i receive one e-mail per a user that has one over 10gigs.
:global bytesin
:global bytesout
:global bytestotal
:global name
/tool user-manager user
:foreach i in=[/tool user-manager user find subscriber=admin] do={
:set bytesin [get $i download-used]
:set bytesout [get $i upload-used]
:set bytestotal ($bytesin + $bytesout)
:set name [get $i name]
:if ($bytestotal > 10737418240) do= {
/tool e-mail send server=1.1.1.1 to=admin@admin.com subject="User manager notification" body="$name"
}
}
Any Ideas ?
mrz
May 13, 2009, 1:47pm
2
email sending is inside foreach loop.
Use variable to store usernames and then at the end of the script send email
Hi mrz
Thanks for the reply , how would i create a variable to store usernames?
:if ($bytestotal > 10737418240) do= {:global tmpname }
mrz
May 14, 2009, 5:44am
4
at the beginning add
:global tmpNames;
then inside loop instead of sending mail, write it to variable
:set tmpNames “$tmpNames\n$name”;
Thanks mrz
:global bytesin
:global bytesout
:global bytestotal
:global name
:local tmpnames
:local gigstotal
/tool user-manager user
:foreach i in=[/tool user-manager user find subscriber=admin] do={
:set bytesin [get $i download-used]
:set bytesout [get $i upload-used]
:set bytestotal ($bytesin + $bytesout)
:set name [get $i name]
:set gigstotal ($bytestotal / 1073741824)
:if ($bytestotal > 10737418240) do={
:set tmpnames "$tmpnames\nName: $name\nGigs Used: $gigstotal\n"
}
};
/tool e-mail send to=admin@admin.com server=1.1.1.1 subject="User's Over 10 Gigs" body="$tmpnames" from=user-manager@admin.com