How do I know a mac needs to restart? Is there a way to figure out from a script whether a Mac needs to reboot? A file, the presence or contents of which I could monitor perhaps? 

I'm looking for an equivalent to the file /var/run/reboot-required found on my Ubuntu boxes. My use case would be to centrally monitor my servers (and perhaps laptops) using Puppet, collectd or… well, something.
Like Linux, OS X is designed not to require restarting. There is no system wide means to determine if a restart is required - or even requested by a process.

For situations where a restart is required, the process responsible for needing the restart is also responsible for organising the restart.

Tools that update OS X are most likely to request a restart.

softwareupdate

Take a look at the  softwareupdate manual page for the most likely candidate to request a restart.

softwareupdate prints a message at the end of the updating process stating if a restart is required. The calling script or user is then responsible for restarting.

Delayed Updates

If an update requires a restart to be successfully and safely installed, OS X will delay the updating process. The update will wait until the next restart or shut down.

This approach allows updates to be downloaded as part of a schedule but not interrupt or interfere with running processes or active users.

Pending Updates

To see if an update is pending, check the contents of /Library/Updates/. This folder appears to contain property list files documenting packages and updates queued for installation.

You can use the tool defaults in your scripts to read plist files such as /Library/Updates/index.plist:

defaults read /Library/Updates/index.plist InstallAtLogout