If you specifically need a procedure to do this;
Create an SQL view, something like this
SELECT dbo.vMachine.Machine_GroupID, ISNULL(DATEDIFF(Day, dbo.lastReboot.rebootTime, { fn NOW() }), - 1) AS lastreboot
FROM dbo.vMachine LEFT OUTER JOIN
dbo.lastReboot ON dbo.vMachine.agentGuid = dbo.lastReboot.agentGuid
Then in your procedure use GetVariable() --> SQL View Data --> dbo.YourViewName/lastreboot
This will return the number of days since reboot.
Then use if statements for the rest
If #lastreboot# greater than 30
Reboot()
* -1 will show as the value of this variable if the machine hasn't rebooted since the agent was installed.
--Chris