From e1e5a14ab524f4d765141480dc84ee39ce59083f Mon Sep 17 00:00:00 2001 From: Stefan Seidel Date: Mon, 11 Jun 2012 23:26:07 +0200 Subject: [PATCH] make sure host_name is only printed once per plugin call --- plugins/vmware/esx_ | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/plugins/vmware/esx_ b/plugins/vmware/esx_ index 22d41d43..19cdb432 100755 --- a/plugins/vmware/esx_ +++ b/plugins/vmware/esx_ @@ -173,19 +173,20 @@ if ($0 =~ /vcenter_(.+)$/) { my @returns = (); foreach $host_name (@host_names) { + # make sure we only print one host_name statement per plugin + if ((@returns == 0) and (defined $ARGV[0]) and ($ARGV[0] eq "config")) { + if ($ENV{flatview}) { + print "host_name $ENV{flatview}\n"; + print "# for host $host_name\n" if $DEBUG; + } else { + print "host_name $host_name\n"; + } + } local *FH; my $pid = open(FH, "-|"); if ($pid == 0) { # CHILD - if ((defined $ARGV[0]) and ($ARGV[0] eq "config")) { - if ($ENV{flatview}) { - print "host_name $ENV{flatview}\n"; - print "# for host $host_name\n" if $DEBUG; - } else { - print "host_name $host_name\n"; - } - } # env.user and env.password need to be set in plugin-conf.d Opts::set_option ('username', $ENV{user} || 'root');