cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 8

SQL Statement for if last boot is within last 10 minutes then insert the word in email "Power Loss"

I have an alert for when a branch goes offline.  I want to track if the issue was power related or not.  My thought is that I can look to the last boot time.  I would like to insert the phrase "Power Loss" into an email alert when the device comes back online if the last boot time is within the last 10 minutes.

Tags (3)
0 Kudos
4 Replies
Product Manager
Product Manager

Try the following as a SQL variable in your alert.

select case 
when lastboot is null
then 'No Last Boot Time Available'
when DATEDIFF(MINUTE,lastboot, getdate()) <= 10
then 'Possible Power Outage' 
when DATEDIFF(MINUTE,lastboot, getdate()) >= 10 
then 'No' 
end as 'MinutesSinceLastBoot'
from nodes
0 Kudos

I altered the time differences to 1 because in simply testing by reloading the device. Still the same result.
0 Kudos

The solution provided doesn't work.  The response I get simply says "No" each time.

0 Kudos

I'm testing this now and will let you know

0 Kudos