Script or Extension Attr for Kernal Panic

DBrowning
Valued Contributor II

Is there a way or does anyone out there have something that regularly looks to see if a computer has any Kernal Panic and reports out on it?

5 REPLIES 5

sgoetz
Contributor

You could write something to check /cores. but thats only if you have core dumping turned on. The only way to catch kernal panics is to set the computer to upload it to your own server, vs apples. Its easier to do on stationary macs vs laptops.

jacob_salmela
Contributor II

I have been using this one for a while

# List only the .panic files and count how many lines 
numOfPanics=$(ls -l /Library/Logs/DiagnosticReports/*.panic | wc -l | sed 's/ //g') 

echo "<result>$numOfPanics</result>"

Chris_Hafner
Valued Contributor II

Just started testing this. Works well, especially combined with a few other things I look for in "problem" units. Combine that with automatically generated email and it's a brilliant way to convince users that they should come into the helpdesk when things start going bad.

mm2270
Legendary Contributor III

Just wanted to post a slight alternative to the above. I think its a great idea to capture this for trending purposes. My only concern would be that its possible to count up panic logs that are weeks old, which doesn't necessarily give you a good view on how recent the issues may be. It might be good for long term trending however; so if a Mac starts showing up with a high number of these, it could point to a serious issue with the system.

That said, here's a modification that only pulls a count of panic logs created within the last 7 days, and ignores anything older. The number of days can be easily adjusted to whatever works for you. Just change the "-7" to however many days you want to go back.

#!/bin/sh

echo "<result>$(find /Library/Logs/DiagnosticReports/ -Btime -7 -name *.panic | wc -l | sed 's/^ *//')</result>"

Chris_Hafner
Valued Contributor II

I like the mod... Nice! I'm actually going to rotate that into another grouping actually!