Custom data input value automatically inserted

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
morya
Posts: 21
Joined: Tue Mar 15, 2011 9:40 am
Location: Switzerland

Custom data input value automatically inserted

Post by morya »

Hello,

I'm having a SNMP query retrieving several information:

Network Id CPA Linecard Name
1 4 Test Rx 4 Lk
1 82 Test Rx 5 Lk
1 83 Test Rx 6 Lk

Then i configured a data input method based on a php script using arguments (host ip address and CPA number). In my data template i can tell cacti to use the host ip address automatically but i have to enter the CPA number for each graph. Is there a way to automatically retrieve my CPA number out of that table?

Thanking you

Morya
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: Custom data input value automatically inserted

Post by noname »

Is the following topic similar to yours?
- http://forums.cacti.net/viewtopic.php?f=21&t=44887
morya
Posts: 21
Joined: Tue Mar 15, 2011 9:40 am
Location: Switzerland

Re: Custom data input value automatically inserted

Post by morya »

Hi noname,

It is not for the graph title. I use 2 arguments with my PHP script. The hostname and the so called "CPA" number (retrieve by a SNMP query). For the hostname (IP address) it is not a problem as it is build in cacti. For the CPA number i have to enter it manually each time i create a graph. I'm just wondering if this could be automated by somehow retrieving the CPA number out of my SNMP query (input direction).

Hope it is clear engough.

Thanking you
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: Custom data input value automatically inserted

Post by noname »

Ah, (maybe) I see.
You're using "Data Input Method" and execute your script like this...

Code: Select all

php <path_cacti>/scripts/your_script.php <host> <cpa_number>
...but you will have to specify <cpa_number> as "Custom Data" for each datasources when creating graphs. (correct?)

Hmm,
if one parameter is known, then the other parameter can be known?
In other words -- are you able to retrieve a CPA number from IP address of the host?

If so, I guess you can specify <host> only for the script on Cacti by retrieving CPA number within the script.
morya
Posts: 21
Joined: Tue Mar 15, 2011 9:40 am
Location: Switzerland

Re: Custom data input value automatically inserted

Post by morya »

You're right i'm running a script like this...

mysript.php <host> <cpa_number>

And yes the cpa number is handled as "Custom Data". Per a single host i can have up to 400 or 500 different "CPAs". But yes i'm able to retrieve all CPA from the host with a SNMP query.
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: Custom data input value automatically inserted

Post by noname »

morya wrote:Per a single host i can have up to 400 or 500 different "CPAs". But yes i'm able to retrieve all CPA from the host with a SNMP query.
Hmm.. What about using "Data Queries" instead of "Data Input Method"?
I think it might be able to retrieve data by "Get SNMP Data (Indexed)" or "Get Script Data (Indexed)".

For example -- when you perform snmpwalk to the device,
if its output is like this

% snmpwalk -v1 -c xxxx host .1.3.6.1.4.1.a.b.c
.1.3.6.1.4.1.a.b.c.1 = <CPA1>
.1.3.6.1.4.1.a.b.c.2 = <CPA2>
.1.3.6.1.4.1.a.b.c.3 = <CPA3>
.1.3.6.1.4.1.a.b.c.4 = <CPA4>
.1.3.6.1.4.1.a.b.c.5 = <CPA5>
...

and other values are

% snmpwalk -v1 -c xxxx host .1.3.6.1.4.1.d.e.f
.1.3.6.1.4.1.d.e.f.<CPA1> = <ValueX_1>
.1.3.6.1.4.1.d.e.f.<CPA2> = <ValueX_2>
.1.3.6.1.4.1.d.e.f.<CPA3> = <ValueX_3>
.1.3.6.1.4.1.d.e.f.<CPA4> = <ValueX_4>
.1.3.6.1.4.1.d.e.f.<CPA5> = <ValueX_5>
...

then, probably SNMP data query might be like the following:

Code: Select all

<interface>
        <name>Sample Query</name>
        <description>Sample Query</description>
        <oid_index>.1.3.6.1.4.1.a.b.c</oid_index>
        <index_order>CPAnumber</index_order>
        <index_order_type>numeric</index_order_type>
        <fields>
                <CPAnumber>
                        <name>CPA number</name>
                        <source>index</source>
                        <direction>input</direction>
                </CPAnumber>
                <ValueX>
                        <name>Value X</name>
                        <method>walk</method>
                        <source>value</source>
                        <direction>output</direction>
                        <oid>.1.3.6.1.4.1.d.e.f</oid>
                </ValueX>
        </fields>
</interface>
morya
Posts: 21
Joined: Tue Mar 15, 2011 9:40 am
Location: Switzerland

Re: Custom data input value automatically inserted

Post by morya »

I'm already using "Get SNMP Data (Indexed)". I'm basically graphing throughput statistics for satellite modem. Unfortunately i do not have an OID for TX or RX like in Cisco but i have OID's for site name, remote ip address, CPA number and various other things. Therefor i'm using a php script querying the data (TX and RX traffic) from a MySQL database. Everything is gathered through the same host as it is my NMS.

To make things easier for endusers i'm using "Get SNMP Data (Indexed)" in order to populate the complete list of Satellite modem configured on my NMS with its IP, name and CPA number. I've attached graph templates to that data query based on my data input method using the php script.

So basically whenever we want to create new graph i can click on my corresponding Satellite Modem retrieved from the host with the data query and generate my graph. When i'm doing it i've got 2 custom data:

- Hostname (IP address of my host). It can be done automatically
- CPA number that i have to enter manually.

As i'm retrieving this CPA number through my data query is there any way to tell cacti that my "custom data" field for CPA number should use the one stored in that SNMP table? (CPA number is retrieved in input direction).
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: Custom data input value automatically inserted

Post by noname »

Mmm... then, I think it's better to use "Script Data Query".
- Script Data Query Walkthrough - Cacti Docs

Please look into "Unix - Get Mounted Partitions" data query for example.
(See "resource/script_queries/unix_disk.xml" and "scripts/query_unix_partitions.pl")

It shows partitions as list, but we don't have to specify partition name when creating graph.
morya
Posts: 21
Joined: Tue Mar 15, 2011 9:40 am
Location: Switzerland

Re: Custom data input value automatically inserted

Post by morya »

I will look into it.

Thanks
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest