How to get CPU cores from REST API?

I’m trying to get CPU cores properties from REST API. I run the following GET URL to get properties for a single computer but it doesn’t include the CPU cores.
https://SERVER1:52311/api/computer/16768147

When I look at the computer in the BES console, I see the summary properties are divided into categories such as Computer Properties, Client Settings, Windows - CPU info, etc

The category “Windows - CPU info” contains what I need but I don’t see it in the data returned when I call the rest API with the URL above. Can someone give me an example of how to get this info through REST?

Number of Cores 4
Number of Cores per CPU 4
Number of CPUs 1

Through REST you will have to use session relevance which doesn’t include those things. You would have to make properties or analyses to examine so if Windows - CPU info is enabled then you’d look at making session relevance with the following types of relevance https://developer.bigfix.com/relevance/reference/bes-property.html

Hi Alan,

I’m new and having a hard time following. Yes, the “Windows - CPU Info” category is enabled and I see the CPU cores property that I want in the BES console. I looked at the link you sent and lost as to how to construct the URL for the REST call using this relevance thing. I haven’t looked at relevance query for Bigfix for over 10 years so I’m very rusty and new to this API. Examples would help me very much so if you or anyone can provide an example of how I could write the relevance and construct the GET/POST for the API that would be most helpful.

https://SERVER1:52311/api/help/session
I am trying though. I went to the API help and see session but it looks like it needs an ID, but the computerID doesn’t work.

So I’m guessing I need to something like this but I’m lost on how to construct the relevance statement with the link you sent me.
https://<bigfix_server>:52311/api/query?relevance={relevance statement}

This is like learning a new language and I don’t see many examples on how to retrieve the session properties for a single computer given the computerId
https://developer.bigfix.com/rest-api/api/query.html

I don’t have that property in my deployment, so I’ll do one using “Number of Processor Cores - Windows” from the “Hardware Information - Windows” Analysis.

Doing API queries from the command line is tricky in that you need to URLencode the query, because quotes, ampersands, percents, spaces, etc. are interpreted by the Windows command shell or curl.exe differently.

The easiest way to figure out the right query is using Web Reports’ hidden “QNA” page, at https://your-web-reports-server/webreports?page=QNA
That page behaves like the Fixlet Debugger, but for doing Session Relevance.
Once you have the right query, you can URL-encode it into the command line for Curl, submit it in the URL field on a browser, etc. but I think the easiest way to handle it is to put the query into a file, and then post the file with curl.exe (at least for testing).

In my case I create a file “query.txt” with the following content:
relevance=values of results (bes properties whose (name of it = "Number of Processor Cores - Windows"), bes computers whose (name of it as lowercase = "my_host_name"))

Then, I’ll use the curl.exe command line
curl -k -u [myoperatoraccount] -X POST "https://[my_root_server]:52311/api/query" -d @query.txt

And get back a result

<?xml version="1.0" encoding="UTF-8"?>
<BESAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
        <Query Resource="values of results (bes properties whose (name of it = &quot;Number of Processor Cores - Windows&quot;), bes computers whose (name of it as lowercase = &quot;my_host_name&quot;)) ">
                <Result>
                        <Answer type="string">4</Answer>
                </Result>
                <Evaluation>
                        <Time>156.172ms</Time>
                        <Plurality>Plural</Plurality>
                </Evaluation>
        </Query>
</BESAPI>
1 Like

Thanks Jason, this is exactly what I was looking for and it works

Hi @JasonWalker, I am trying to return the Computer Manufacturer – Windows and Computer Model – Windows via the REST API but if I use your relevance above and change the the name to “contains Computer” I only get these back…

How do I get to the Hardware Information - Windows where Manufacturer and Model are? I can see the information in the relevance tester but cant get it via the REST API. Do I need to do something else to access it, locally or on the server? Thanks
image

Edit: the first pic looks tiny, this is what is returned from
((names of it) of properties of it) of results (bes properties whose (name of it contains “Computer”), bes computers whose (name of it as string = “LP-BMURPHY” as uppercase))
image

I think you’re using a sound method to find these…a few things I would check:

I haven’t much used the Session Relevance Tester, but if I’m not mistaken I think it uses the SOAP API via Web Reports, while your REST API queries would be using the BES Root Server. This can give slightly different results, as you may have different user rights assigned in BES Root Server vs rights in Web Reports (for instance, I allow my users to retrieve results in Web Reports for computers they cannot otherwise manage in BigFix itself).

Check that your REST API user has at least Read access to te “BES Inventory and License” site in the console, and that it has operator rights on the LP-BMURPHY computer.

You might try logging in to the Console with this user account and refine your query in the Presentation Debugger. In the console, hit CTRL-ALT-SHIFT-D to bring up the Debug dialog, then check the box at the top for “Show Debug Menu”. Close out the debug dialog, and in the console’s top menu there will be a new “Debug” item added right next to Help. From the Debug menu, you can open the Presentation Debugger to test session relevance queries.

The Presentation Debugger, and the Summary view of the computer in the console, may give some insight as to why your REST API account is not retrieving the property.

Your query is returning correct results for me…but there is something in it you might tune.

((names of it) of properties of it) of results (bes properties whose (name of it contains “Computer”), bes computers whose (name of it as string = “LP-BMURPHY” as uppercase))

If your computer’s name is not already uppercase, it might not get included. But you did get some result. It occurs to me that you might have two instances of your computer in the console - if you are using any proxy agents such as Bare Metal OSD, or VMWare Management Extender, you could have that computer object listed in uppercase (and giving results on this query), but your Native (real) computer object defined in mixed-case and not giving results. Try amending your query to allow case-insensitive computernames via

((names of it) of properties of it) of results (bes properties whose (name of it contains “Computer”), bes computers whose (name of it as string as uppercase = “LP-BMURPHY” as uppercase))