Here's a stab at adding a -e flag that lets you run a perl regex against the
hostname.  Then you can run:

./ganglia_ipmimonitoring.pl -e 's/^mp-//g' -h mp-cn[1-4] -D -d

I'm sure it could be cleaned up further or restricted to only doing/checking
for search and replace expressions.

-cdm

On Tue, Dec 21, 2010 at 2:20 PM, Al Chu <[email protected]> wrote:

> Hi Chris,
>
> Hmmm.  I'm not really sure how we could/should do that.  Perhaps some
> other option would tell the script to create/remove the prefix before
> passing it up to ganglia?
>
> Al
>
> On Tue, 2010-12-21 at 10:52 -0800, Christopher Maestas wrote:
> > Any thought given to translating the hostlist from the management
> > processor name to a real device name?  For example:
> >       * device name is mp-cn[1-2] and hostname is cn[1-2]
> >
> >
> > ./ganglia_ipmimonitoring.pl -D -d -h mp-cn[1-2] | sed -e 's/mp-//g'
> >
> >
> > but I don't think that will do what I want ...
> --
> Albert Chu
> [email protected]
> Computer Scientist
> High Performance Systems Division
> Lawrence Livermore National Laboratory
>
>
--- ganglia_ipmimonitoring.pl.orig	2010-12-21 15:20:21.202972142 -0700
+++ ganglia_ipmimonitoring.pl	2010-12-21 22:23:53.368659256 -0700
@@ -52,6 +52,7 @@
 # -d - print debug info
 # -D - do not send sensor data to ganglia (useful during debugging)
 # -H - output help
+# -e - use this expression to run against the name given to gmetric
 #
 # Environment Variables:
 #
@@ -125,6 +126,7 @@
 
 my $IPMIMONITORING_OUTPUT;
 my @IPMIMONITORING_OUTPUT_LINES;
+my $GMETRIC_HOST_EXPR = "";
 my $line;
 
 my $cmd;
@@ -134,6 +136,7 @@
     my $prog = $0;
     print "Usage: $prog -h <hostname(s)> -M <path> -m <sensors arguments> -G <path> -g <arguments> -d -H\n";
     print "  -h specify hostname(s) to remotely access\n";
+	print "  -e use this expression to run against the hostname given to gmetric\n";
     print "  -M specify an alternate ipmimonitoring path\n";
     print "  -m specify additional ipmimonitoring arguments\n";
     print "  -G specify an alternate gmetric path\n";
@@ -144,7 +147,7 @@
     exit 0;
 }
 
-if (!getopts("h:M:m:G:g:dDH"))
+if (!getopts("h:M:m:G:g:e:dDH"))
 {
     usage();
 }
@@ -159,6 +162,11 @@
     $IPMI_HOSTS = $main::opt_h;
 }
 
+if (defined($main::opt_e))
+{
+    $GMETRIC_HOST_EXPR = $main::opt_e;
+}
+
 if (defined($main::opt_M))
 {
     $IPMIMONITORING_PATH = $main::opt_M;
@@ -308,6 +316,11 @@
     $id_string =~ s/ /_/g;
     $id_string =~ s/\//_/g;
     
+
+	if ($GMETRIC_HOST_EXPR) {
+		eval('$hostname =~ ' . "$GMETRIC_HOST_EXPR;");
+	}
+
     if ($hostname ne "localhost" && $hostname ne "127.0.0.1")
     {
         my $packet_ip = gethostbyname($hostname);
_______________________________________________
Freeipmi-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/freeipmi-devel

Reply via email to