Relevance for displaying linux services

(imported topic written by zephryx91)

Hi,

Currently i having a problem on displaying linux service on bigfix console, the relevance below is showing all the runlevel 5 services on linux, may i know how to make it displaying only one specific service, for example “sendmail”

if exists folder “/etc/rc3.d” then (parenthesized parts of matches (regex "S

0-9

+(.*)") of names of files of folder “/etc/rc3.d”) else if exists folder “/etc/rc.d/rc3.d” then (parenthesized parts of matches (regex "S

0-9

+(.*)") of names of files of folder “/etc/rc.d/rc3.d”) else if exists file “/etc/inittab” then (unique values of parenthesized parts 2 of matches (regex "^/(

^/

+/)*(

/ %22

)(\ .|.{0})$") of parenthesized parts whose (it != “” AND it does not contain “/sh -c”) of matches (regex ":0-9

:

:

:frowning:

^#

*)") of lines whose (it contains (regex ":

0-9

[3]0-9

:")) of file “/etc/inittab”) else “”

(imported comment written by Doug_Coburn)

Hello Zephryx,

The easiest way to filter the results is to just put the whole relevance clause in parenthesis. This allows you to be able to do a whose clause for the results of the nested if/then/else.

(if (exists folder “/etc/rc3.d”) then (parenthesized parts of matches (regex “S0-9+(.)") of names of files of folder “/etc/rc3.d”) else (if (exists folder “/etc/rc.d/rc3.d”) then (parenthesized parts of matches (regex "S0-9+(.)”) of names of files of folder “/etc/rc.d/rc3.d”) else (if (exists file “/etc/inittab”) then (unique values of parenthesized parts 2 of matches (regex “^/(^/+/)(/ %22)(\ .|.{0})$") of parenthesized parts whose (it != “” AND it does not contain “/sh -c”) of matches (regex ":0-9:::(^#)”) of lines whose (it contains (regex “:0-9[3]0-9:”)) of file “/etc/inittab”) else ("")))) whose (it as string contains “sendmail”)

(imported comment written by zephryx91)

Hi Doug,

Thanks for your information. The relevance works well and i have another question which is display the status of the service. I have gone through the linux inspector guide and there is a key phrase, "state of " and it stated that it will return the status of the service but it is not working for me, can i have an example of using this relevance? or is it possible to combine this with the previous relevance that i ask for.

Thank you.

(imported comment written by Doug_Coburn)

On the Linux/Unix systems if you’re interested in whether or not something is running I’d do:

exists process whose (name of it as string as lowercase = “sendmail”)

So to tie it into the previous relevance you can do:

((if (exists folder “/etc/rc3.d”) then (parenthesized parts of matches (regex “S0-9+(.)") of names of files of folder “/etc/rc3.d”) else (if (exists folder “/etc/rc.d/rc3.d”) then (parenthesized parts of matches (regex "S0-9+(.)”) of names of files of folder “/etc/rc.d/rc3.d”) else (if (exists file “/etc/inittab”) then (unique values of parenthesized parts 2 of matches (regex “^/(^/+/)(/ %22)(\ .|.{0})$") of parenthesized parts whose (it != “” AND it does not contain “/sh -c”) of matches (regex ":0-9:::(^#)”) of lines whose (it contains (regex “:0-9[3]0-9:”)) of file “/etc/inittab”) else ("")))) whose (it as string contains “sendmail”)) and (exists process whose (name of it as string as lowercase = “sendmail”))

Doug