[mrtg] AW: Accessing Shell Variables in Template

Thomas.Rupp at illwerke.at Thomas.Rupp at illwerke.at
Thu Mar 18 08:56:26 MET 2004


Hi Corey,

partly right ;-)
I would like to pass that variable through cfgmaker to the template.
In the template I would like to do (in pseudocode):

if CPU=1 then
  target target[CPU] ... (1 Line in the Graph for CPU 1)
if CPU=2 then
  target target[CPU] ... (2 Lines in the Graph for CPU 1 and 2)
if CPU=4 then
  target target[CPU] ... (1 Line for all CPUs)

The Docu says that a template is a Perl program - so I need a way to access $CPU from
within this Perl program.

Thanks for your help
Thomas

-----Ursprüngliche Nachricht-----
Von: Fruitman, Corey [mailto:Corey.Fruitman at allstream.com] 
Gesendet: Mittwoch, 17. März 2004 21:48
An: Rupp Thomas; mrtg at list.ee.ethz.ch
Betreff: RE: [mrtg] Accessing Shell Variables in Template


You have a shell script that assigns a value to the variable "CPU" then you want to pass the value of that variable to cfgmaker, right?  Just put a dollar sign ($) before your variable name in the script and the shell will substitute it with the value.

This doesn't have anything to do with Perl (or MRTG).  

Let's assume you want to use bash as your shell.  Try this:

#!/bin/bash
CPU=4
/path/to/cfgmaker --host-template=$CPU.tmpl [...]

Your template will have to be named "4.tmpl" and be located in the same directory as where you're executing cfgmaker.

Should do the trick.  Hope that helps,

Corey.


-----Original Message-----
From: mrtg-bounce at list.ee.ethz.ch [mailto:mrtg-bounce at list.ee.ethz.ch]On
Behalf Of Thomas.Rupp at illwerke.at
Sent: March 17, 2004 2:47 PM
To: mrtg at list.ee.ethz.ch
Subject: [mrtg] Accessing Shell Variables in Template


Hi MRTG-gurus,

I try to create different config files using --host-template 
depending on the number of CPUs a server has.

I have the following shell script

CPU = 4
cfgmaker --host-template=...

What do I have to do to access the Variable CPU in the template?

I know absolutely nothing about Perl so would be very grateful for
any help

Thanks in advance
Thomas Rupp 

--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi

--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the mrtg mailing list