Relevance Logic Across Multiple OS

(imported topic written by SystemAdmin)

We are trying to create a relevance statement that will work across Windows and Linux. We have most of it working but when we add a property from one OS that the other OS doesn’t support, we get a “the property is not defined” error. It seems as if the parenthesis are being ignored.

Here is the relevance:

((name of operating system = “Win2000” OR name of operating system = “Win2003”) AND (exists WMI) AND (exists string value whose (it as lowercase contains “domain.com”) of selects “Domain from Win32_ComputerSystem” of wmi) AND (string value of selects “Manufacturer from Win32_ComputerSystem” of wmi as lowercase contains “dell”) AND (exists key “HKLM\SOFTWARE\Dell Computer Corporation\OpenManage\Applications\SystemsManagement” of registry)) OR (name of operating system as lowercase contains “linux red hat” AND (exists package “Dellmgr” of rpm))

So we are trying to to see if the DELL OpenManage System Administrator software is installed. Any ideas as to why this wouldn’t work? Removing the “AND (exists package “Dellmgr” of rpm)” clause allows it to run on Windows. Shouldn’t that clause simply return NULL or Error and carry on?

(imported comment written by jessewk)

Before evaluating a relevance clause, the relevance engine does a syntax parsing pass over the expression and any unknown inspectors will cause a syntax error. You cannot guard for this with boolean logic.

(imported comment written by BenKus)

Hi jspanitz,

Boolean logic can’t protect against unknown inspectors, but an “if/then/else” statement can… The resulting clause of the then/else part of the expression won’t be parsed until the conditional part of the expression is evaluated… For instance:

q: if true then “woohoo!” else some gibberish invalid inspector
A: woohoo!

q: if false then “woohoo!” else some gibberish invalid inspector
E: The operator “some gibberish invalid inspector” is not defined.

So you can change your expression to:

(if (name of operating system = “Win2000” OR name of operating system = “Win2003”) then ((exists WMI) AND (exists string value whose (it as lowercase contains “domain.com”) of selects “Domain from Win32_ComputerSystem” of wmi) AND (string value of selects “Manufacturer from Win32_ComputerSystem” of wmi as lowercase contains “dell”) AND (exists key “HKLM\SOFTWARE\Dell Computer Corporation\OpenManage\Applications\SystemsManagement” of registry)) else false) OR (if (name of operating system as lowercase contains “linux red hat”) then (exists package “Dellmgr” of rpm) else false)

Ben

(imported comment written by SystemAdmin)

Thanks guys. I knew someone would know how to do it. My scripting skillz are not what they should be :frowning:

(imported comment written by SystemAdmin)

On another note…

we are trying to move the logic into the action script. So we are trying to use:

if value of setting “Location By Half Subnet” of client != “Anytown, USA” then

dos racadm config -g cfgOobSnmp -o cfgOobSnmpAgentCommunity SNMPCommunity1

else

dos racadm config -g cfgOobSnmp -o cfgOobSnmpAgentCommunity SNMPCommunity2

The test server has the value of “Boston, MA” in the “Location By Half Subnet” property, but it always executes the else clause.

(imported comment written by BenKus)

Well… it looks like that is correct according to the logic, right? because it is a “!=” (not equals)…

Also, your syntax is wrong, which I am guessing you know… it should be:

if {relevance }

action1

else

action2

endif

Ben

(imported comment written by SystemAdmin)

I missed pasting the endif. I did add the brackets to the logic though, thanks!

So again assuming the “Location By Half Subnet” = “Boston, MA” and the relevance as below:

if {value of setting “Location By Half Subnet” of client != “Anytown, USA”} then

dos racadm config -g cfgOobSnmp -o cfgOobSnmpAgentCommunity SNMPCommunity1

else

dos racadm config -g cfgOobSnmp -o cfgOobSnmpAgentCommunity SNMPCommunity2

endif

It still runs the else statement. Reversing the logic doesn’t work either. The else always runs. Or perhaps the entire action script is running, ignoring the if then else altoghether. It’s hard to say.

Help…

(imported comment written by jessewk)

I think the ‘then’ key word may need to be on a separate line.

If that doesn’t fix it, my guess would be that the “Location By Half Subnet” setting doesn’t exist.

(imported comment written by BenKus)

Hey guys,

There is no “then” keyword for the “if” statement, the correct syntax is:

if {value of setting “Location By Half Subnet” of client != “Anytown, USA”}

dos racadm config -g cfgOobSnmp -o cfgOobSnmpAgentCommunity SNMPCommunity1

else

dos racadm config -g cfgOobSnmp -o cfgOobSnmpAgentCommunity SNMPCommunity2

endif

In the case that it is “Boston, MA”, I would expect the “else” statement to run… If you want the first statement to run, change “Anytown, USA” to “Boston, MA” and make sure the capitalization is correct to make sure it matches.

Ben