Getting Linux OS information in analysis to show in computer summary in console

We have a default Analysis called Operating System Information (UNIX). The problem is that the properties are written this way:

if exists file "/etc/redhat-release" then if exists match (regex "(AS|ES|WS) release ([0-9]+) (\([^)]*\))") of line of file "/etc/redhat-release" then ("Red Hat Enterprise Linux " & parenthesized part 2 of it & ".0 " & parenthesized part 1 of it & " " & parenthesized part 3 of it) of match (regex "(AS|ES|WS) release ([0-9]+) (\([^)]*\))") of line of file "/etc/redhat-release" else name of operating system else name of operating system

With a machine running Red Hat Enterprise Workstation release 604 (Santiago), it comes back with a reasonable value: Linux Red Hat Enterprise Workstation 6.4
The problem is that if the operating system is running anything other than Red Hat Enterprise Linux, it comes back with the wrong data from /etc/redhat-release

For example: if we have a machine running Scientific Linux release 6.6 (Carbon), it comes back with Linux Red Hat 4.4.7-16 which is way off.

How do I edit the above so it will return the correct version of linux and not be so Red Hat Enterprise specific? I’ve tried replacing Red Hat in the above with Scientific Linux, but to no avail.


All this information is available in the operating system inspectors

name of operating system

should get you most of it with

codename of operating system

getting the “Santiago”

The agent will do all the work looking at the file in question and knowing if it should use it or some other information depending on the actual OS.

I missed this part. Yes this is a distro that we don’t support directly. The value it returns is the kernel information which is actually very accurate just not what you were expecting.

Do you know of a file or something where this info can be found:

If so, then relevance can be written to get it.

You need to locate the file on this disto that has the disto’s information in it.
At a guess it’s going to be in a file called *-release somewhere in /etc

$ sudo cat /etc/*-release

It is in /etc/redhat-release
What seems to happen is that the above code does not parse the file correctly when it says
Scientific Linux release 6.6 (Carbon)
but it does parse it correctly when it says
Red Hat Enterprise Workstation release 6.4 (Santiago) - it returns Linux Red Hat Enterprise Workstation 6.4
Just replacing the parts that say Red Hat with Scientific Linux doesn’t solve the problem.

I would like to know how to write the above code so it returns something like Scientific Linux release 6.6

The kernel, which is a separate property, does come back with the right value.

The file is a text file, /etc/redhat-release

You can just write relevance that will pull out the info from /etc/redhat-release

Can you provide an example of the contents of this file? If you paste it into the forum, don’t worry if the forum messes up some of the formatting, I can fix that afterwards.

The text of the file /etc/redhat-release is just a single line of plain text (no linefeed or carriage return at the end):

Scientific Linux release 6.6 (Carbon)

For our SL7 machines, it is

Scientific Linux release 7.1 (Nitrogen)

Thank you!

This would read that file:

unique values of (it as trimmed string) whose(it != "") of lines of files "/etc/redhat-release"

Yes, this works perfectly! Many thanks!

1 Like

This is really the important part:

You can fairly easily read and parse any text file using Relevance with BigFix.

This part I added to prevent any empty lines or duplication from being reported. Even if this never actually occurs in the file normally, this construct is good to use in general:

unique values of (it as trimmed string) whose(it != "") of ...