App-ElasticSearch-Utilities
view release on metacpan or search on metacpan
scripts/es-status.pl view on Meta::CPAN
}
verbose({kv=>1,indent=>1}, "index_size", sprintf("%.2f %s", $size_short, $unit) );
verbose({kv=>1,indent=>1,level=>2}, "index_size_bytes", $index_size );
}
}
sub handle_node {
my $stats = es_node_stats();
output({clear=>1,color=>"cyan"}, "Node Status Check", "-="x20);
my $node_id = (keys %{ $stats->{nodes} })[0];
my $node = $stats->{nodes}{$node_id};
output({kv=>1,color=>"cyan"}, "name", $node->{name});
output({kv=>1}, "index_size", $node->{indices}{store}{size} );
verbose({kv=>1}, "index_size_bytes", $node->{indices}{store}{size_in_bytes} );
verbose({kv=>1}, "docs", $node->{indices}{docs}{count} );
output({kv=>1}, "open_fd", $node->{process}{open_file_descriptors} );
# JVM Stats
output({kv=>1}, "jvm", '');
# Threads
output({indent=>1,kv=>1}, "threads_current", $node->{jvm}{threads}{count});
output({indent=>1,kv=>1}, "threads_peak", $node->{jvm}{threads}{peak_count});
# Memory
output({indent=>1,kv=>1}, "mem", '');
output({indent=>2,kv=>1,color=>"yellow"}, "heap_used", $node->{jvm}{mem}{heap_used});
verbose({indent=>2,kv=>1,color=>"yellow"}, "heap_used_bytes", $node->{jvm}{mem}{heap_used_in_bytes});
output({indent=>2,kv=>1}, "heap_committed", $node->{jvm}{mem}{heap_committed});
verbose({indent=>2,kv=>1}, "heap_committed_bytes", $node->{jvm}{mem}{heap_committed_in_bytes});
# GC
output({indent=>1,kv=>1}, "gc", '');
# GC Details
foreach my $collector ( keys %{ $node->{jvm}{gc}{collectors} } ) {
output({indent=>2,kv=>1}, $collector, '');
output({indent=>3,kv=>1}, "collections", $node->{jvm}{gc}{collectors}{$collector}{collection_count} );
output({indent=>3,kv=>1}, "time", $node->{jvm}{gc}{collectors}{$collector}{collection_time} );
output({indent=>3,kv=>1}, "time_ms", $node->{jvm}{gc}{collectors}{$collector}{collection_time_in_millis} );
}
output({kv=>1}, "requests", $node->{transport}{rx_count});
output({indent=>1,kv=>1}, "rx", $node->{transport}{rx_size});
verbose({indent=>1,kv=>1}, "rx_bytes", $node->{transport}{rx_size_in_bytes});
output({kv=>1}, "responses", $node->{transport}{tx_count});
output({indent=>1,kv=>1}, "tx", $node->{transport}{tx_size});
verbose({indent=>1,kv=>1}, "tx_bytes", $node->{transport}{tx_size_in_bytes});
}
sub handle_settings {
my $stats = es_settings();
output({clear=>1,color=>"cyan"}, "Index Settings Check", "-="x20);
my $colorize = sub {
my ($v) = shift;
return "green" if $v eq 'false';
return "yellow" if $v eq 'not set';
return "red";
};
foreach my $index (sort keys %{ $stats } ) {
my %settings = %{ $stats->{$index}{settings} };
output({color=>'cyan'}, "$index:");
my $value = exists $settings{'index.auto_expand_replicas'} && defined $settings{'index.auto_expand_replicas'} ? $settings{'index.auto_expand_replicas'} : 'not set';
my $color = $colorize->($value);
output({indent=>1,kv=>1,color=>$color}, "auto_expand_replicas", $value);
verbose({indent=>1,kv=>1}, "replicas", $settings{'index.number_of_replicas'});
verbose({indent=>1,kv=>1}, "shards", $settings{'index.number_of_shards'});
}
}
__END__
=pod
=head1 NAME
es-status.pl - Simple ElaticSearch Status Checks
=head1 VERSION
version 8.9
=head1 SYNOPSIS
es-status.pl --health --verbose --color
Options:
--help print help
--manual print full manual
Query Modes:
--health Display overall cluster health (--verbose shows more detail)
--node Display node details (--verbose shows more detail)
--segments Display segmentation details (--verbose shows more detail)
--settings Display index settings (--verbose shows more detail)
--all Run all handlers!
From CLI::Helpers:
--data-file Path to a file to write lines tagged with 'data => 1'
--tags A comma separated list of tags to display
--color Boolean, enable/disable color, default use git settings
--verbose Incremental, increase verbosity (Alias is -v)
--debug Show developer output
--debug-class Show debug messages originating from a specific package, default: main
--quiet Show no output (for cron)
--syslog Generate messages to syslog as well
--syslog-facility Default "local0"
--syslog-tag The program name, default is the script name
--syslog-debug Enable debug messages to syslog if in use, default false
--nopaste Use App::Nopaste to paste output to configured paste service
--nopaste-public Defaults to false, specify to use public paste services
--nopaste-service Comma-separated App::Nopaste service, defaults to Shadowcat
=head1 DESCRIPTION
This script is designed to help you get information about the state of the
ElasticSearh cluster in a hurry.
=head1 OPTIONS
=over 8
=item B<help>
( run in 0.322 second using v1.01-cache-2.11-cpan-5623c5533a1 )