I have been using the report wizard to run a report on users who have not restarted in over 7 days. When I choose the criteria "Last system reboot > X" is the X in hours, days, minutes, etc? I keep getting no results shown then i try to view it.

i only want to see users who have not rebooted in over 7 days, no one else. Any help would be greatly appreciated!

Answer Summary:
SELECT NAME, USER_LOGGED, LAST_REBOOT FROM MACHINE M WHERE LAST_REBOOT < DATE_SUB(NOW(), INTERVAL 7 DAY) ORDER BY M.NAME
Cancel
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Answers

3

This will work. I'm not sure what all other info you need?

SELECT NAME, USER_LOGGED, LAST_REBOOT

FROM MACHINE M

WHERE LAST_REBOOT < DATE_SUB(NOW(), INTERVAL 7 DAY)

ORDER BY M.NAME
Answered 02/26/2013 by: dugullett
Red Belt

  • I'd love their log in username!
    • You can change USER_LOGGED, to USER_NAME. As long as they are logged in at time of check in that field will be populated. I've gotten used to USER_LOGGED just because it has DOMAIN\user. Since we have multiple domains.
  • fantastic! I will need to try this tomorrow first thing in the morning and i will get back to you.
    • You can also change it to this if you want the date to be a little more friendly.

      SELECT NAME, USER_LOGGED, DATE_FORMAT(LAST_REBOOT, '%r %M %D, %Y' ) as 'Last Reboot'
      FROM MACHINE M
      WHERE LAST_REBOOT < DATE_SUB(NOW(), INTERVAL 7 DAY)
      ORDER BY M.NAME
  • This works great. Is there anywhere you can point me in the direction of the syntax needed to work in K1000 reports? It's been a looong time since i;ve done SQL
    • This question has some good info http://itninja.com/question/looking-for-some-good-mysql-information . Start here. Get the MSQL browser and start testing some things out. Starting out make sure to add LIMIT 5 to the end of your scripts. I've brought down my Kbox a time or two with some crazy queries. This will at least limit the results.

      http://www.mysql.com/downloads/workbench/
      • did you just add your k1000 box under a "new connection" on here?
  • lol...thank goodness for the reboot button. Thanks so much for all this, checking it out now.
  • did you just add your k1000 box under a "new connection" on here?
    • Yes. By default the password is box747. I would suggest changing that since it's pretty well known.
  • I am logged in to it but every time i run a query it says:

    Error Code: 1046. No database selected Select the default DB to be used by double-clicking its name in the SCHEMAS list in the sidebar. 0.000 sec


    What schema do i need to choose? My options are KBSYS ORG1 REPORT_TEMP
    • Usually everything will come from ORG1. KBSYS is usually used for warranty type reports.
  • Book org 1 worked! Thank you so much for you help. I will post back here with any more questions if that is ok.
    • Works for me. If you do get stuck on a query I would post a new question. Usually if people have a starting point it's usually a few minor tweaks. It would probably get answered faster.
  • Great, thanks again.
  • If you dont want to write your tables with org1 or kbsys on the table name just double click the db you are going to query and it will set it as the default then you can code the same way you would in kace. Its the equivalent of starting a sql script with

    USE ORG1
    GO
Please log in to comment
Answer this question or Comment on this question for clarity
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja

Share