help-cfengine
[Top][All Lists]
Advanced

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

Re: Exec a script to determine further action based on return code.


From: Brandon Evans
Subject: Re: Exec a script to determine further action based on return code.
Date: Thu, 23 Jun 2005 16:56:01 -0700
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050317)

Brian E. Seppanen wrote:

I have an action that I need to perform on a regular basis, and the means of determining if the update should be done requires an SQL query. I can write a script that will return 1 or 0 to define a variable, but how do I provide the feedback to cfengine based on the return code as to whether the action should be performed or not...

Any ideas appreciated?

Here is an example that may help


control:
#  This returns 1 if there is a /home partation, 0 if not
ret_home = ( ExecResult(/bin/sh -c "df -l | grep -E '^/dev' | awk '{print $NF}' | grep -c '^/home'"))



classes:
# Here I use strcmp to check if ret_home is a 1 or 0
#  if it is a 1, HomePart is defined
HomePart = ( Strcmp("1","${ret_home}") )


disks:
# Check /home for free space. if less the 25%, define FullHome
HomePart::
  /home/    freespace=25% inform=false define=FullHome force=true

shellcommands:
# If FullHome is defined, echo a little warning message that
# is then emailed to me
FullHome::
   "/bin/echo 'WARNING: /home is very low on disk space!'"


You can skip the whole disk part and run a shell command based
on what Strcmp returns.

HomePart = ( Strcmp("1","${ret_home}") )


--
Thanks,
    Brandon Evans




reply via email to

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