/build/static/layout/Breadcrumb_cap_w.png

Does anyone have a sql query I can use to create a smart label that lists systems that have been up for more than 7 days? I've found a few other references from 7 or 8 years ago but I can't get them to work.

I have tried the advice here (https://www.itninja.com/question/creating-a-label-for-system-uptime), here (https://www.itninja.com/blog/view/kace-last-reboot-and-last-sync-smart-machine-label), and here (https://www.itninja.com/blog/view/workstation-uptime-24-hours-smart-label) to no avail.  Either I get query error or the results are wrong.  This is what I have thus far.  I created it by making a basic smart label looking for windows 10 OS_Name and then modifying it to also include (LAST_REBOOT > DATE_SUB(now(5), interval 24 hour)) as found here (https://www.itninja.com/blog/view/kace-last-reboot-and-last-sync-smart-machine-label)


SELECT MACHINE.NAME AS SYSTEM_NAME, SYSTEM_DESCRIPTION, MACHINE.IP, MACHINE.MAC, MACHINE.ID as TOPIC_ID FROM MACHINE  WHERE ((OS_NAME like '%windows 10%'))
AND (LAST_REBOOT > DATE_SUB(now(5), interval 24 hour))


Any help is greatly appreciated.


0 Comments   [ + ] Show comments

Answers (1)

Answer Summary:
Posted by: Hobbsy 4 years ago
Red Belt
0

Top Answer

Try this, 

SELECT 

MACHINE.NAME AS SYSTEM_NAME, 

SYSTEM_DESCRIPTION, 

MACHINE.IP, 

MACHINE.MAC, 

MACHINE.ID as TOPIC_ID 

FROM MACHINE  

WHERE (((TIMESTAMP(LAST_REBOOT) <= NOW() AND TIMESTAMP(LAST_REBOOT) > DATE_SUB(NOW(),INTERVAL 7 DAY)))) 

But I have to say that there are a couple of timestamps that you could use rather that LAST_REBOOT, ie LAST_INVENTORY and LAST_SHUTDOWN


Comments:
  • Thanks for the response. I ended up creating a smart label with a rule 'Uptime Since Last Reboot does not match REGEX ^([0-5]|) days' and it works like a champ! - Peaux 4 years ago
    • Nice one, there is always more than one way to work things out ;o) - Hobbsy 4 years ago

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ