Skip to content

Instantly share code, notes, and snippets.

@zembutsu
Created March 29, 2014 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zembutsu/9851047 to your computer and use it in GitHub Desktop.
Save zembutsu/9851047 to your computer and use it in GitHub Desktop.
To change serf agent's tag that not using serf RPC ( by perl script).
#!/usr/bin/perl
print "\n### DEBUG:: changetag";
my $payload = <STDIN>;
print "DEBUG: payload: $payload\n";
my ($target, $method, $key, $value) = split(/::/, $payload);
print "DEBUG: $ENV{SERF_SELF_NAME}, $target, method = $method\n";
if ($ENV{SERF_SELF_NAME} eq $target) {
print "DEBUG: match target \n";
my $cmd;
if ($method eq 'set') {
$cmd = "/usr/bin/serf tags -set $key=$value";
} elsif ($method eq 'delete') {
$cmd = "/usr/bin/serf tags -delete $key";
}
print "system: cmd = $cmd\n";
my $system = system("$cmd");
print "system: $system\n";
}
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment