Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is Mac OS X Activity Monitor implemented? Can I use the same API?

Tags:

macos

I'm looking at implementing a tool that looks at CPU usage on my Mac, similar to Activity Monitor, but I'm using the numbers in a calculation. I need to be able to get the CPU usage at 0.5 second intervals or so. What API does Activity Monitor use? Is it documented somewhere?

I'd rather not parse the output of command line programs if that's avoidable.

like image 913
John DD Avatar asked Sep 08 '11 16:09

John DD


People also ask

How does Mac Activity Monitor work?

The Energy pane of Activity Monitor is your Mac's resource monitor. It shows overall energy use and power used by each app. You'll see the Energy Impact of running apps, along with the Avg Energy Impact of each app over the last 12 hours or since your Mac booted up, whichever is shorter.

What is the system tool used in MacOS to monitor and manage the processes running on the Mac computer?

Every copy of macOS has the Activity Monitor app installed in it. Like the Task Manager in Windows, Activity Monitor lets you see everything that's running on your Mac. This includes apps that you can open and quit as normal, but it also includes background processes, which you don't normally see.

What is root on Mac Activity Monitor?

The user named root, or superuser, is a special user account in UNIX-like operating systems that has unrestricted read and write privileges to all areas of the file system in OS X 10.10 or earlier.

How can you tell if a Mac is a suspicious process?

Look for any suspicious processes that are running on your Mac. On the menu bar, click Go, and then select Utilities. Double-click Activity Monitor. Review the list for any processes that look suspicious to investigate further.


1 Answers

You could probably find out by looking at the source for the Darwin version of the top command.

http://www.opensource.apple.com/source/top/top-73/libtop.c

This looks like it might be useful...

static kern_return_t libtop_pinfo_update_cpu_usage(task_t task, libtop_pinfo_t* pinfo, int *state)

like image 54
torstenvl Avatar answered Nov 11 '22 17:11

torstenvl