Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System uptime implementation #39

Closed
giampaolo opened this issue May 23, 2014 · 11 comments
Closed

System uptime implementation #39

giampaolo opened this issue May 23, 2014 · 11 comments
Labels

Comments

@giampaolo
Copy link
Owner

From billiej...@gmail.com on March 17, 2009 01:55:23

In issue 33 we decided that PID 0's create_time must be equal to system uptime.
I'm opening this report to keep track of our progresses about system uptime
implementation on all platforms.

system uptime has been currently implemented on Windows and Linux platforms
as r257 .
OS X and FreeBSD implementations are still missing as well as any potential
test case.

Original issue: http://code.google.com/p/psutil/issues/detail?id=39

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 16, 2009 17:55:49

Summary: System uptime implementation

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 16, 2009 17:56:07

Blockedon: 33

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 16, 2009 18:18:33

Implemented on FreeBSD as r266 .

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 16, 2009 19:02:45

Added test case for FreeBSD as r267 .

@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on March 17, 2009 06:28:54

OS X support added in r268

Status: Started

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 17, 2009 07:00:27

Could you please verify if this test works also on OS X?


        # test PID 0 special case where create_time is supposed to be
        # equal to system uptime
        # XXX - does this work also on OS X?
        if sys.platform.lower().startswith("freebsd"):
            sp = subprocess.Popen(["sysctl", "-x", "kern.boottime"],
                                  stdout=subprocess.PIPE)
            output = sp.communicate()[0]
            uptime = output[output.find('= ') + 2:].split(',')[0]
            self.assertEqual(int(p.create_time), int(uptime))

@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on March 17, 2009 08:29:37

I can't test that on OS X until create_time is implemented for OS X. That being said,
the sysctl command line on OS X doesn't have a -x option. You probably want: 

    [user@host ]$ sysctl -bn kern.boottime
    1236101236

Which provides the boot time in epoch time.

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 17, 2009 09:18:48

Labels: Progress-3in4

@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on March 20, 2009 13:47:00

Turns out there's no need to check the system uptime against PID 0's start time on OS
X, since the start time is provided for all PIDs from syctl()

@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on March 20, 2009 14:15:37

Implemented everywhere and not needed for PID 0 on FreeBSD either

Status: Fixed
Labels: -Progress-3in4

@giampaolo
Copy link
Owner Author

From g.rodola on March 02, 2013 03:47:32

Updated csets after the SVN -> Mercurial migration: r257 == revision 
442aee762cf4 r266 == revision f910f2f333cc r267 == revision 632fae566b94 r268 == revision 9f3b05351fd7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant