[mrtg] Script returns 4 values, Plot values via MRTG/routers2?

MMartin at jwpepper.com MMartin at jwpepper.com
Wed Jan 2 21:45:07 CET 2013


Hey Keith,

Are you trying to have those 4 Values on a single graph..?
If yes, then you could try this.

You would change your script to do the same thing as I explained in the 
last email. Which is having the
script accept 4 separate arguments. One Argument for each of the values 
you want graphed. So basically,
the 1st argument would print the 1st value, 2nd ARG would print the 2nd 
value, and so on...

Then in your MRTG cfg file you would have 4 "Regular" sections and 1 
User-Defined Section.


Like this:

################################################################################
#                                                       START MRTG CONFIG  
                                                   #
################################################################################


        ########################################
        # Modem - Count 1
        Target[modem_count1]: `/path/to/script/my_script count1`        # 
"count1" will print the 1st counter variable
        Title[modem_count1]: Modem - Count 1
        YLegend[modem_count1]: #
        Legend1[modem_count1]: Count
        Legend3[modem_count1]: Max Count
        MaxBytes[modem_count1]: 10000000
        Options[modem_count1]: growright, gauge, noo                    # 
'noo' is important, tells MRTG NO 2nd Value
        routers.cgi*Graph[modem_count1]: All-Counters average           # 
'All-Counters' Will be the name of the UserDefined Graph
        :......

        ########################################
        # Modem - Count 2
        Target[modem_count2]: `/path/to/script/my_script count2`        # 
"count2" will print the 2nd counter variable
        Title[modem_count2]: Modem - Count 2
        YLegend[modem_count2]: #
        Legend1[modem_count2]: Count
        Legend3[modem_count2]: Max Count
        MaxBytes[modem_count2]: 10000000
        Options[modem_count2]: growright, gauge, noo                    # 
'noo' is important, tells MRTG NO 2nd Value
        routers.cgi*Graph[modem_count2]: All-Counters average           # 
'All-Counters' Will be the name of the UserDefined Graph
        :......

        ########################################
        # Modem - Count 3
        Target[modem_count3]: `/path/to/script/my_script count3`        # 
"count3" will print the 3rd counter variable
        Title[modem_count3]: Modem - Count 3
        YLegend[modem_count3]: #
        Legend1[modem_count3]: Count
        Legend3[modem_count3]: Max Count
        MaxBytes[modem_count3]: 10000000
        Options[modem_count3]: growright, gauge, noo                    # 
'noo' is important, tells MRTG NO 2nd Value
        routers.cgi*Graph[modem_count3]: All-Counters average           # 
'All-Counters' Will be the name of the UserDefined Graph
        :......

        ########################################
        # Modem - Count 4
        Target[modem_count4]: `/path/to/script/my_script count4`        # 
"count4" will print the 4th counter variable
        Title[modem_count4]: Modem - Count 4
        YLegend[modem_count4]: #
        Legend1[modem_count4]: Count
        Legend3[modem_count4]: Max Count
        MaxBytes[modem_count4]: 10000000
        Options[modem_count4]: growright, gauge, noo                    # 
'noo' is important, tells MRTG NO 2nd Value
        routers.cgi*Graph[modem_count4]: All-Counters average           # 
'All-Counters' Will be the name of the UserDefined Graph
        :......


        ########################################
        # UserDefined Graph - Modem Count 1, 2, 3 and 4
        #       *be sure to include "routers.cgi*" before all of the 
UserDefined Graph's Directives...
        #       **Make sure the Target Name (in square-brackets) matches 
the name given for the
        #         'routers.cgi*Graph[]:..." Directive on ALL the above 
Sections
        routers.cgi*ShortName[All-Counters]: All-Counters
        routers.cgi*Description[All-Counters]: All Modem-Counters 1-4
        routers.cgi*Title[All-Counters]: Modem Counters
        routers.cgi*YLegend[All-Counters]: Count
        routers.cgi*MaxBytes[All-Counters]: 10000000
        routers.cgi*UnScaled[All-Counters]: dwmy
        routers.cgi*WithPeak[All-Counters]: dwmy
        routers.cgi*Options[All-Counters]: default,nototal              # 
By giving the 'default' option, this graph will show 1st
        routers.cgi*InSummary[All-Counters]: yes
        routers.cgi*InCompact[All-Counters]: yes
        routers.cgi*GraphStyle[All-Counters]: range
        :......

################################################################################
#                                                       END MRTG CONFIG    
                            #
################################################################################


So basically the above config will Display 5 Total Graphs. One graph for 
each of the counters (i.e. Count1, Count2, Count3 and Count4)
Then the 5th Graph will be the UserDefined Graph. This will contain ALL 4 
Counters on a single graph. This is specified by using 
this Directive below:
                routers.cgi*Graph[target_name]: All-Counters

Where the "target_name" for the UserDefined Graph will be "All-Counters".
I've found that UserDefined Graphs can be your best friend.... I use AT 
LEAST one for most of my configs...

Also, I think there is a way to display ONLY the Graph containing ALL 4 
Values (i.e. Only the UserDefined Graph).
If you'd like to do that let me know and I'll see if I can find my cfg 
that I did that for.

Hope that helps!


Thanks,
Matt






From:   Keith <kwoody at citytel.net>
To:     <MMartin at jwpepper.com>
Cc:     <mrtg at lists.oetiker.ch>
Date:   01/02/2013 02:26 PM
Subject:        Re: [mrtg] Script returns 4 values, Plot values via 
MRTG/routers2?
Sent by:        <mrtg-bounces+mmartin=jwpepper.com at lists.oetiker.ch>




Hi.

That might work. I'm just having trouble wrapping my head around having a
.cfg file that can parse four values.

The numbers that are returned are actually cable modem counts on four
seperate downstream channels of a cmts.

Using expect and some shell, I extract the four values:

85
102
101
74

Is what gets returned from running the script. I have no problem doing a
mrtg cfg file for 2 values and scripting, but 4 and using rrd/routers2 is
a bit harder.

Thanks, I'll see what I can work out.

Keith


On Wed, 2 Jan 2013 MMartin at jwpepper.com wrote:

|->Hey Keith,
|->
|->Here's just a thought, maybe point you in the right direction...
|->
|->You could have your script take say 4 separate arguments. One argument 
for
|->each of the values you plan to output, I
|->think you said you are outputting 4 Values...?
|->
|->Then You would have 4 "sections" in you .cfg File, one for each of the
|->values the script outputs. Then for each "Target:"
|->line you would use that specific argument to get that specific value...
|->
|->For Instance, let's say your script (call it "get_cpu-usage") is 
printing
|->CPU-Usage and the 4 Values printed are:
|->        Line 1 == 1-Min Avg
|->        Line 2 == 5-Min Avg
|->        Line 3 == 10-Min Avg
|->        Line 4 == 1-Hour Avg

|->Have a device that I cannot poll via SNMP for some values. I wrote
|->a little expect/shell script to get me those values.
|->
|->I use small perl scripts to poll data and feed those into MRTG but
|->those just return two values, which are used to build graphs and
|->work just fine.
|->
|->The expect/shell script actually returns 4 integer values.
|->I have read that it appears I can only use RRD and routers2 to be
|->able to combine and display all 4 values on a graph.
|->
|->I have seen some examples of how others have done this, but the
|->few I have seen are polling multiple devices and combining those into
|->one graph.
|->
|->I am polling one device that returns 4 values.
|->
|->How can I create a .cfg file that can take those 4 values and create
|->one graph?
|->
|->Thanks,
|->Keith
|->
|->
|->
|->_______________________________________________
|->mrtg mailing list
|->mrtg at lists.oetiker.ch
|->https://lists.oetiker.ch/cgi-bin/listinfo/mrtg
|->
|->
|->

_______________________________________________
mrtg mailing list
mrtg at lists.oetiker.ch
https://lists.oetiker.ch/cgi-bin/listinfo/mrtg


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/mrtg/attachments/20130102/be6edd75/attachment-0001.htm 


More information about the mrtg mailing list