/build/static/layout/Breadcrumb_cap_w.png

Systems Management Question


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.

09/10/2020 137 views

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.

Answer Summary:
0 Comments   [ + ] Show comments

Comments


Answer Chosen by the Author

0

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

Answered 09/11/2020 by: Hobbsy
Red Belt

  • 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!
    • Nice one, there is always more than one way to work things out ;o)

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