diff --git a/plugins/other/hadoop-dfs-plugin b/plugins/other/hadoop-dfs-plugin new file mode 100755 index 00000000..9e543467 --- /dev/null +++ b/plugins/other/hadoop-dfs-plugin @@ -0,0 +1,109 @@ +#!/usr/bin/perl + +# +# Description: +# This plugin shows basic filesystem information and statistics about the HDFS +# filesystem. +# +# Installation notes: +# Symlink this file to hadoop_hdfs_block or hadoop_hdfs_capacity to get block +# or capacity informations about the DFS. +# +# Author: KARASZI Istvan +# + +use strict; +use File::Basename qw(basename); + +my $type = &getType($0); + +# +# main +# +if ($ARGV[0]) { + if ($ARGV[0] eq "autoconf") { + print "yes\n"; + } elsif ($ARGV[0] eq "config") { + &printConfig(); + } else { + exit(1); + } +} else { + &getStatistics(); +} + +# +# methods +# +sub getType { + my($command) = @_; + + my $scriptname = &File::Basename::basename($command); + if ($scriptname =~ /_([^_]+)$/) { + if (grep($1, ('block', 'capacity'))) { + return $1; + } + } + + die("Invalid command type '$scriptname'"); +} + +sub printConfig { + if ($type eq "block") { + print <)) { + chomp($line); + + if ($type eq "block") { + &getBlock($line); + } elsif ($type eq "capacity") { + &getCapacity($line); + } + } + close(DFSADMIN) +}