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


_______________________________________________
Help-cfengine mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-cfengine

Reply via email to