moved service bits to HariSekhon::MapR
4c2ccf9e
Hari Sekhon
committed
1 changed file
check_mapr_node_services.pl
/check_mapr_node_services.pl-20+7
/check_mapr_node_services.pl
Add comment 18
Add comment 19 Tested on MapR 3.1.0 and 4.0.1";
Add comment 20
Add comment 21 Minus  $VERSION = "0.2";
Add comment 21 Plus  $VERSION = "0.3";
Add comment 22
Add comment 23 use strict;
Add comment 24 use warnings;
Add comment 46 5 => "standby",
Add comment 47 );
Add comment 48
Add comment 49 Minus  my $service;
Add comment 50 Minus  my $list_services = 0;
Add comment 51 Minus  
Add comment 52 49 %options = (
Add comment 53 50 %mapr_options,
Add comment 54 51 %mapr_option_node,
Add comment 55 Minus   "s|service=s" => [ \$service, "Check the specified service" ],
Add comment 56 Minus   "list-services" => [ \$list_services, "List services, requires --node" ],
Add comment 52 Plus   %mapr_option_service,
Add comment 57 53 );
Add comment 58 54
Add comment 59 55 get_options();
Add comment 60 56
Add comment 61 57 validate_mapr_options();
Add comment 62 Minus  list_nodes();
Add comment 63 Minus  $node = validate_host($node, "node");
Add comment 64 Minus  if(defined($service)){
Add comment 65 Minus   $service =~ /^(\w[\w\s-]+\w)$/ or usage "invalid service name, must be alphanumeric, may contain spaces/dashes";
Add comment 66 Minus   $service = $1;
Add comment 67 Minus  }
Add comment 68 58
Add comment 69 59 vlog2;
Add comment 70 60 set_timeout();
Add comment 71 61
Add comment 62 Plus  list_nodes();
Add comment 63 Plus  $node = validate_host($node, "node");
Add comment 64 Plus  list_services();
Add comment 65 Plus  $service = validate_service($service) if $service;
Add comment 66 Plus  
Add comment 72 67 $status = "OK";
Add comment 73 68
Add comment 74 69 $json = curl_mapr "/service/list?node=$node", $user, $password;
Add comment 89 84 } else {
Add comment 90 85 $node_services{$displayname} = "unknown";
Add comment 91 86 }
Add comment 92 Minus  }
Add comment 93 Minus  
Add comment 94 Minus  if($list_services){
Add comment 95 Minus   print "Services on node '$node':\n\n";
Add comment 96 Minus   foreach(sort keys %node_services){
Add comment 97 Minus   print "$_\n";
Add comment 98 Minus   }
Add comment 99 Minus   exit $ERRORS{"UNKNOWN"};
Add comment 100 87 }
Add comment 101 88
Add comment 102 89 my $found_service;