Querying RPM and PKGDB in same relevance

(imported topic written by dmoore21)

I’m attempting to write a combined analysis that queries the rpm database and pkgdb for the version info of a given application. What I have works moderately well, but was wondering if there were room for improvement… The reason I say moderately well (and recognize the room for improvement) is because none of the Solaris boxes are returning information - I get a result of “” and the tool tip says that “The operator RPM is not defined” while on a few (but not all) Red Hat boxes I get a result of “” with a tool tip of “The operator PKGDB is not defined”.

Here’s the relevance I’m using:

if (exists rpm) then ((names of it, versions of it) of packages whose (name of it contains “httpd”) of rpm) else if (exists pkgdb) then (((names of it, versions of it) of pkginfo whose (name it contains “SUNWapch2”) of pkgdb)) else (“fubar”)

Thanks!

(imported comment written by dmoore21)

No suggestions yet? I’m honestly pretty stumped.

(imported comment written by NoahSalzman)

Why not throw a “if operating system is redhat” and “if operating system is solaris” in there as guard relevance? (Conceptually, not literally.)

(imported comment written by dmoore21)

If I try something like this:

if (name of operating system contains “Linux”) then ((names of it, versions of it) of packages whose (name of it contains “httpd”) of rpm) else if (name of operating system contains “SunOS”) then (((names of it, versions of it) of pkginfos whose (name it contains “SUNWapch2”) of pkgdb)) else (“fubar”)

Then the hosts that were returning results start to error out with an “Incompatible Types” error. Also, if you’re wondering why I chose “Linux” and not “Red Hat” as the qualifier in the first half of the relevance, it’s because we also have some Fedora boxes that I’m wanting to keep tabs on as well as the RHEL boxes…

(imported comment written by NoahSalzman)

the values returned in the if statement have to be the same type as the else statement OR you need to use the sneaky “nothings” operator

q:

if
(
true
)
then
((names
of

it,
size
of

it
)
of
files
of
folder
"c:"
)
else

“fubar”

E:
Incompatible types.

q:

if
(
true
)
then
((names
of

it,
size
of

it
)
of
files
of
folder
"c:"
)
else
nothings

A:
autoexec.bat, 24

A:
bootmgr, 333257

A:
BOOTSECT.BAK, 8192

A:
config.sys, 10

A:
cpsweb.log, 1720

A:
IO.SYS, 0

A:
MSDOS.SYS, 0

A:
pagefile.sys, 4607938560

T:
1.270 ms

(imported comment written by dmoore21)

I had no idea there was a “nothings” operator… so that helped! Getting closer!

When I try this relevance:

if (name of operating system contains “Linux”) then ((names of it, versions of it) of packages whose (name of it contains “httpd”) of rpm) else if (name of operating system contains “SunOS”) then (((names of it, versions of it) of pkginfos whose (name it contains “SUNWapch2”) of pkgdb)) else nothings

The Solaris boxes now return a “” result with a message of “The operator “name” is not defined”. Also, on some of the RHEL boxes, I now get a return of “” with a message of “Singular expression refers to nonexistent object”.

(imported comment written by NoahSalzman)

Solaris is a typo: “name of it” rather than “name it”

On Linux, see if that “error” is because those boxes don’t have “rpm”. That is, create a test analysis of “exists rpm” and see if the boxes that return “false” are the same ones that return the error. Basically, you have to figure out what the “nonexistent” item is… your query is asking those boxes for “something” and the agent is telling you that thing isn’t there.

(imported comment written by dmoore21)

Ha! I didn’t even see that I had a typo in the Solaris portion of the relevance! Thanks for that!

And you’re right on why the Linux portion was failing on some of the servers… Those boxes didn’t have “rpm”.