help-cfengine
[Top][All Lists]
Advanced

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

Re: Defining a Class based on ShellCommand Output or No Output


From: Brian E. Seppanen
Subject: Re: Defining a Class based on ShellCommand Output or No Output
Date: Fri, 5 Aug 2005 13:45:09 -0400 (EDT)

On Fri, 5 Aug 2005, Brian E. Seppanen wrote:

On Thu, 4 Aug 2005, Ed Brown wrote:

This uses ReturnsZero, but not a secondary script.  Also, it was tested
on linux.  Would something like this work for you:

classes:
 SmcOn = ( ReturnsZero(/bin/sh -c "netstat -ln |grep -q 898") )


Thanks for the additional syntax hints.  On solaris I ended up having to use
smcstop = ( ReturnsZero(/usr/xpg4/bin/sh -c "/usr/bin/netstat -an | /usr/xpg4/bin/grep -q 898")

before it would work...

Somewhat offtopic, but would anyone mind giving a brief synopsis of what the /usr/xpg4 stuff is?

I didn't realize I was going to have to initiate it's own shell to accomplish it, but I got a bunch of errors without initiating /usr/xpg4/bin/sh.

I tried ( ReturnsZero(/usr/bin/netstat -an | /usr/xpg4/bin/grep -q 898) )
and got invalid argument arguments for netstat

I tried it with single quotes and double ( ReturnsZero('/usr/bin/netstat -an | /usr/xpg4/bin/grep -q 898') )
( ReturnsZero("/usr/bin/netstat -an | /usr/xpg4/bin/grep -q 898")  )

cf:cfengine::/var/cfengine/os/solaris/cf.solaris:18: ExecResult(/command) must specify an absolute path


The good news is it works now.  Thanks for the help.

The bad news is that this actually doesn't seem to be working. Almost all of my solaris servers are shutting down smc every time they run, regardless of whether the process was running or not previously.

So ReturnsZero is getting 0 from something other than (/usr/xpg4/bin/sh -c "/usr/bin/netstat -an | /usr/xpg4/bin/qpage -q 898).

If I run that on the command line it doesn't work, but the output I'm getting from cfengine tells me something is being incorrectly interpretted.

To track my logic I have the following
classes:
        any::
smcstop = ( ReturnsZero(/usr/xpg4/bin/sh -c "/usr/bin/netstat -an | /usr/xpg4/bin/grep -q 898") )

then
shellcommands:
      smcstop::
                "/etc/init.d/init.wbem stop"



So grep will return 0 if port 898 is open, which means that smc is running and that it needs to be stopped.

If smc isn't running it will return 1, and the class should not be defined.


Anyone have any ideas.
Thanks,


Brian Seppanen
608.826.1464




reply via email to

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