Get uptime of computer via releance

Hi There,
I’ve automated patching via API. Some of the servers require more than one reboot.
After initiating first reboot, after waiting for 15 minutes I’ve decided to trigger the second reboot.
But to decide whether reboot is triggered on the server or the server came up after first reboot , I need the latest uptime of the server.
I’m new to relevance writing and I’m searching is there a way to get the last uptime of server via BigFix relevance. Any help is appreciated. Thanks in advance.

(now - boot time of operating system) should work for you


Can you give me the full relevance query.
Currently I’m using the below query which returns ‘Singular expression refers to nonexistent object.’

((names of it, ids of it,operating systems of it, value of result from (bes property “uptime”) of it) of bes computer whose ( name of it = “testServer”))

Some machines - notably laptops - have difficulty with this (my laptop is convinced it has an uptime of over 7 days, despite being shutdown and unplugged last night, and started again this morning. Event viewer reveals that it is convinced it was just in a low-power state overnight!
Servers should be OK though.

A quick look at

properties of type "operating system"

shows a few candidates

q: uptime of operating system
A: 7 days, 17:02:50.078
T: 0.546 ms

q: boot time of operating system
A: Thu, 19 Aug 2021 17:07:17 +0100
T: 0.494 ms

Juggling things slightly, we can compare the current time to boot time (and arrive at a value consistent with the uptime property). We can also cast the value to a chosen unit of time

q: now - boot time of operating system
A: 7 days, 17:02:49.578
T: 0.447 ms

q: (now - boot time of operating system) / minute
A: 11102
T: 0.409 ms

and then use that to decide whether our uptime meets our criteria

q: 15 < (now - boot time of operating system) / minute
A: True
T: 0.461 ms

However, use with caution. You need an additional indicator to know that reboot#1 has occurred and reboot#2 is pending. You won’t make many friends by causing a server to endlessly reboot every 15 minutes…

I had this very same problem, this fixes it :smiley:

((names of it, ids of it,operating systems of it, value of result from (bes property “uptime”) of it) of bes computer whose ( name of it = “testServer”))

That is session relevance. You need client relevance.


@trn, Thanks for the useful info, I’d be executing this via API where I’ll be using the relevance as a part of it Like this,

https://bigfixservername:52311/api/query?relevance=(relevance to get the up time)

so can you help me on building that

Thanks John - that does look about the right timeframe for when I did my last reboot.

It helps explain why my new laptop cranks itself up so quickly in the morning!

1 Like

I would advise creating a reboot fixlet that adds a small text file that you can parse for the 2nd reboot

if {(exists file c:\tmp\reboot.log whose (exists line whose (it contains “reboot 1 complete” as string ) of it))}

You will need to add additional work to clean up the log after the 2nd reboot has complete but ultimately that would help you.

RestAPI does use session relevance, but there is no equivalent property exposed for the object ‘bes computer’

You would also have to run this multiple times to be sure of the second reboot running once (and once only) on each server.

I think this needs to be a task sent to all the servers and have them decide when their own 15 minutes has expired.

Here, I’m performing patching in the given downtime, and triggering the reboot via fixlet everytime from the script , so automatic triggers won’t happen. I don’t know how to use session relevance via api and thats what I’m struggling with

I can’t help but feel that this would have been easier if you had posted one question, rather than asking in three different threads - two of them resurrections of old topics.

1 Like

An alterantive approach, rather than a text file, set a client setting that is set before the reboot.

setting "Reboot1Complete"="True" on "{now}" for client
action requires restart "Reboot1"
{insert your preferred restart process here}

2nd Reboot could be fixlet driven (so avoids the issue of lack of uptime data via REST API). I include action requires restart "Reboot1" as that would be cleared by the 1st reboot so is a validation the reboot did actactually complete)

(exists setting "Reboot1Complete" whose (value of it = "True") of client) and (not pending restart "Reboot1") and (uptime of operating system / minute > 15)

The 2nd reboot fixlet could also set a setting and/or restart tag to provide retrievable data of at what stage the server reboots are at. You then have the patching managed by your API approach and the restarts leverage fixlets to detect when to apply. May also way to add a validation that the uptime isn’t so high that the 2nd reboot could occur during business hour if that is pertinent to your environment.


I remember we do have one fixlet under BES Support site named as “Restart Needed” that is based on "Pending Restart", that can also be used & can be configured with re-application if its actually needed.