Created
March 29, 2014 09:01
-
-
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).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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