Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using cfengine to start the foobar process. Apparently the LHS is discarded when I use process_select? Can I simply pass the LHS to a function, rather than having to put the command match pattern in a body argument?

I wanted to only match foobar processes belonging to a particular user, since another user could easily be running foobar for testing.

bundle agent foobar {
processes:
    "foobar" # documented way would be to use .* here
        process_select => command("foobar"),
        restart_class => start_foobar;

commands:
    start_foobar::
        "/usr/bin/foobar";
}

body process_select command(c) {
    command => "$(c)";
    process_result => "command";
}
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

As far as I know, if you just want to look for the "foobar" process, you don't need to use the process_select feature at all.

Can't you just do this?

processes:
    "foobar"
        restart_class => start_foobar;

If you also need to match other criteria at the same time, like the user running it as you suggest, I would recommend either using a variable like:

vars:
   "program" string => "foobar"; 

Or, better still, writing a bundle that takes some parameters, something like this:

bundle agent restart(program, path) {
processes:
    "${program}" # documented way would be to use .* here
        process_select => command("${program}"),
        restart_class => start_foobar;

commands:
    start_foobar::
        "${path}/${program}";
}

body process_select command(c) {
    command => "$(c)";
    process_result => "command";
}

And then just call this bundle as restart("foobar", "/usr/bin").

I haven't tested the code above, you might have to tweak it!

share|improve this answer
    
Updated to mention that I also wanted to match the process owner. –  joeforker Mar 23 '10 at 13:16
    
Updated to provide another solution :) –  Jonathan Clarke Mar 23 '10 at 20:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.