Collect Current Time

FastGM3
Contributor

Is there an easy way in the JSS that I can collect the current system time on our computers and display it in the Inventory or some other type of output?

Thanks,
Chuck

6 REPLIES 6

mm2270
Legendary Contributor III

While you could it would almost always be stale data. Anything in inventory is only a snapshot in time at the moment of a recon. Even stuff like the top info and running processes, etc that Casper captures is typically of no use since that is constantly changing.

What it is that you're trying to use this for? Perhaps there's another solution.

FastGM3
Contributor

We're experiencing time drift and it's naturally causing a problem with our AD bound computers. We have internal and external time servers set in the system prefs, but the drift still occurs. We wanted to see how often and how long it takes for the drift to occur on a specific set of computers.

All 10.8.x computers

mm2270
Legendary Contributor III

Well, you could build an EA that simply grabs the time using the date command. Like this?

#!/bin/sh

echo "<result>$( date "+%H:%M:%S" )</result>"

The thing is, since this would be part of regular inventory, you may not see it update for 24 hours or however frequently your Macs submit inventory. the only way i can see around that in the short term would be a policy kicking in every 15 that ran recon, but that seems like a sledgehammer approach.

FastGM3
Contributor

Thanks for the info, I think I'll choose the smaller hammer on this one. Created a policy to just run ntppdate -u. We'll see how that goes.

gregp
Contributor

Do you have them set to sync to something with ntpd? If so, you can check its sync status with ntpq -c peer

Had a problem here with some drifting Macs. Machine showed it was sync'd to one of the DCs and discovered that the time on a couple of DCs time was off. Since we're not in control of the DCs (we reported the problem, but took a loooong time to fix it), switched the Macs to syncing to a good time source instead of the pool of DCs.

FastGM3
Contributor

Yea, we actually have them setup to sync to two servers using ntpd. Since our district blocks access to outside time servers we have the first lookup to the DC, then so when users take their laptops home the fall over server is set to time.apple.com since the DC time isn't accessible from outside the district.

I'm checking the ntpq now, thanks! looks like it can provide some good information