SQL Server memory usage alert script
As JamesZ mentioned, the memory is intended for the SQL Server to use, particularly for the data cache.  Therefore SQL Server will attempt to use everything that has been made available to the SQL Server process.  (Plus some operating overhead.)

If you are concerned about reserving memory for Windows Operating System and any other processes that you run on the server you can adjust your maxservermemory to a lower number.

I have had good success with Jonathan Kehayias's "formula" that he posted here: 

How Much Memory Does My SQL Server Actually Need?

The first paragraph has a good outline of how Kehayias would by default  configure the Maximum Memory.  Of course, this is not absolute and you will need to observe your SQL Server and determine whether more or less memory needs to be reserved.

Brent Ozar has a sanity check post at:
Memory Dangerously Low or Max Memory Too High

So, you should not have a script to tell you that there is too little memory available.  You should configure appropriately for what your system needs.  

Brent Ozar's post for a 512 GB Server suggests:

EXEC sys.sp_configure ‘max server memory (MB)’, ‘471859’; 
RECONFIGURE;