Get OS uptime

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Get OS uptime

Torsten Bergmann
Julien Delplanque wrote:
>I can't find out how to get the uptime of the OS from pharo

  (FileSystem disk root / 'proc' / 'uptime') asFileReference readStreamDo: [:s | s upToEnd asString ]

or if you load the "OSUnix" project in Pharo 4 from the config browser
it is even easier:

    UnixSystem upTime

bye
T.

Reply | Threaded
Open this post in threaded view
|

Re: Get OS uptime

Nicolai Hess
2015-03-19 9:05 GMT+01:00 Torsten Bergmann <[hidden email]>:
Julien Delplanque wrote:
>I can't find out how to get the uptime of the OS from pharo

  (FileSystem disk root / 'proc' / 'uptime') asFileReference readStreamDo: [:s | s upToEnd asString ]

or if you load the "OSUnix" project in Pharo 4 from the config browser
it is even easier:

    UnixSystem upTime

bye
T.



And, if there is a system library that provides this data, there is the NativeBoost way:
For example( not linux but windows):

new method:
NBWin32Shell>>#getUptime
   
    <primitive: #primitiveNativeCall module: #NativeBoostPlugin error: errorCode >
     ^ self nbCall: #( ulonglong GetTickCount64() ) module: #Kernel32

and then you can call it like that:
NBWin32Shell getUptime milliSeconds.




Reply | Threaded
Open this post in threaded view
|

Re: Get OS uptime

Julien Delplanque
In reply to this post by Torsten Bergmann

>   (FileSystem disk root / 'proc' / 'uptime') asFileReference readStreamDo: [:s | s upToEnd asString ]
>
> or if you load the "OSUnix" project in Pharo 4 from the config browser
> it is even easier:
>
>     UnixSystem upTime
>
> bye
> T.
>
Thank you, that's exactly what I was looking for, I'll check it later.

Julien

Reply | Threaded
Open this post in threaded view
|

Re: Get OS uptime

Julien Delplanque
In reply to this post by Nicolai Hess

> And, if there is a system library that provides this data, there is the
> NativeBoost way:
> For example( not linux but windows):
>
> new method:
> NBWin32Shell>>#getUptime
>
>     <primitive: #primitiveNativeCall module: #NativeBoostPlugin error:
> errorCode >
>      ^ self nbCall: #( ulonglong GetTickCount64() ) module: #Kernel32
>
> and then you can call it like that:
> NBWin32Shell getUptime milliSeconds.
>

Ok, nice to see there are different way to do it :)

But I think I'll use Torsten's solution.

Thank for the response anyway :)

Julien

Reply | Threaded
Open this post in threaded view
|

Re: Get OS uptime

Nicolai Hess
2015-03-19 10:27 GMT+01:00 Julien Delplanque <[hidden email]>:

> And, if there is a system library that provides this data, there is the
> NativeBoost way:
> For example( not linux but windows):
>
> new method:
> NBWin32Shell>>#getUptime
>
>     <primitive: #primitiveNativeCall module: #NativeBoostPlugin error:
> errorCode >
>      ^ self nbCall: #( ulonglong GetTickCount64() ) module: #Kernel32
>
> and then you can call it like that:
> NBWin32Shell getUptime milliSeconds.
>

Ok, nice to see there are different way to do it :)

But I think I'll use Torsten's solution.

Thank for the response anyway :)

Ah, I just saw, he already provides the same in OS-Windows.

 

Julien