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?
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.
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)
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.
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.