help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: defining classes based on returning results of (shell) commands?


From: David E. Nelson
Subject: RE: defining classes based on returning results of (shell) commands?
Date: Thu, 24 Aug 2006 08:41:46 -0500 (CDT)


Hi Guolin,

Looks to be missing a pair of parens:

checkCommand = ( ReturnsZero(/usr/bin/test "`sysctl -e -n net.ipv4.tcp_abc 
2>/dev/null` " = '1') )
               ^                                                                
                 ^
               |                                                                
                 |

Regards,
         /\/elson

On Wed, 23 Aug 2006, Guolin Cheng wrote:

David,

Good idea.

I tried the following but it fails.


Error messages are:
...
cf:cfengine::/var/lib/cfengine/inputs/cf.groups:102: syntax error
...

The #102 line is the checkCommand class definition line.

Any ideas?

Thanks.

--Guolin



-----Original Message-----
From: help-cfengine-bounces+guolin=alexa.com@gnu.org
[mailto:help-cfengine-bounces+guolin=alexa.com@gnu.org] On Behalf Of
David E. Nelson
Sent: Wednesday, August 23, 2006 5:40 PM
To: Robinson Tiemuqinke
Cc: help-cfengine@gnu.org
Subject: Re: defining classes based on returning results of (shell)
commands?


Hi Robinson,

How about leveraging 'egrep'?  For example, I use something like the
following
in my 'groups:' section:

WrongOptLocal = ( ReturnsZero(/bin/sh -c
"PATH=/bin:/usr/bin:/sbin:/usr/sbin ;
mount | egrep 'filer:/vol/vol0/opt/local' > /dev/null 2>&1") )

Use regex w/ egrep to get as specific as you want.

And then in 'alerts:' I have:

alerts:

  WrongOptLocal::

    "WARNING: System is mounting /opt/local from the wrong filer"

Regards,
         /\/elson


On Wed, 23 Aug 2006, Robinson Tiemuqinke wrote:

Hi,

If there are any ways to define groups/classes with
the return results of (shell) commands? Currently
there is a function called ReturnZero can be used to
define classes based on exit code, like explained in
the online reference:

ReturnsZero(command)
True if the named shell command returns with exit code
zero (success).

But what I'd like to have is something like the
following:

strCmpReturn(identificationString, command)

        True if the named shell command returns with
(exactly) the identificationString(or number).

If there is already a function like the above? If
not, anyone can suggest another way to workaround it?

Thanks a lot.



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


_______________________________________________
Help-cfengine mailing list
Help-cfengine@gnu.org
http://lists.gnu.org/mailman/listinfo/help-cfengine




--
~~ ** ~~ Research has shown that Mondays account for 1/7th of your time ~~ ** ~~




reply via email to

[Prev in Thread] Current Thread [Next in Thread]