add_graphs.php with multiples --snmp-field and --snmp-value

Anything that you think should be in Cacti.

Moderators: Developers, Moderators

Post Reply
tsalle
Posts: 7
Joined: Thu Apr 28, 2011 3:37 am

add_graphs.php with multiples --snmp-field and --snmp-value

Post by tsalle »

To automate cacti host and graphs creation, I've written a patch for the cli/add_graphs.php script.

With this patch you can now use the --snmp-field and --snmp-value multiple times for ds graphs creation.
For example, you can create graphs for a host with only interfaces with ifType=ethernetCsmacd and ifOperStatus=Up.

Example :

Code: Select all

php add_graphs.php --graph-type=ds --graph-template-id='22' --host-id=414 --snmp-query-id=1 --snmp-query-type-id='2' --snmp-field=ifType --snmp-value=ethernetCsmacd --snmp-field=ifOperStatus --snmp-value=Up
You can also uise the --snmp-value-regex instead of the --snmp-value option.
This is usefull if you want to create all interfaces like 'Port-channel'
Example :

Code: Select all

php add_graphs.php --graph-type=ds --graph-template-id='22' --host-id=414 --snmp-query-id=1 --snmp-query-type-id='2' --snmp-field=ifDescr --snmp-value-regex='Port-channel\d+'
Hope this will help..

NB. I posted a feature request on the mantis bug tracker : http://bugs.cacti.net/view.php?id=1986

Thierry.
Attachments
add_graphs.php.patch
cacti cli add_graphs.php patch to allow multiples --snmp-field and --snmp-value options.
(9 KiB) Downloaded 409 times
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: add_graphs.php with multiples --snmp-field and --snmp-va

Post by gandalf »

Thanks for issueing the mantis feature.
Personally, I'd like to advertise the AUTOM8 plugin which already supports such a feature
R.
X-dark
Cacti User
Posts: 111
Joined: Wed Jun 18, 2008 10:21 am
Location: France

Re: add_graphs.php with multiples --snmp-field and --snmp-va

Post by X-dark »

gandalf wrote:Personally, I'd like to advertise the AUTOM8 plugin which already supports such a feature
Yes similar feature can be achieved with autom8 but sometimes it is more appropriate to use the cli scripts to perform some tasks. Such enhancement could then be useful anyway.
Cedric Girard
mstbone67a
Posts: 28
Joined: Mon Sep 21, 2009 9:31 am

Re: add_graphs.php with multiples --snmp-field and --snmp-va

Post by mstbone67a »

Pretty slick!! Loving this.

I could not figure out how to do multiple regex maybe it is due to it being 1am. /shrug

I was trying to look for Gi or PO in the ifDescr AND GMPLS in ifAlias
meaning
any Gigabit and POS interface with GMPLS


[cactiuser@ossccacti01 cli]$ ./add_graphs.php --graph-type=ds --graph-template-id=281 --host-id=2117 --snmp-query-id=1 --snmp-query-type-id=13 --snmp-field=ifDescr --snmp-value-regex='^Gi|PO^' --snmp-field=ifAlias --snmp-value-regex='GMPLS'
ERROR: Could not find snmp-field ifDescr,ifAlias (^Gi|PO^GMPLS) for host-id 2117 (10.13.250.33)
Try --host-id=2117 --list-snmp-fields

or even
./add_graphs.php --graph-type=ds --graph-template-id=281 --host-id=2117 --snmp-query-id=1 --snmp-query-type-id=13 --snmp-field=ifDescr --snmp-value-regex='Gi|PO' --snmp-field=ifAlias --snmp-value-regex='GMPLS'

But no go I must have been using it wrong.

I can't load Automat8 yet on this system due to it being so heavily used.


This did work
[cactiuser@ossccacti01 cli]$ ./add_graphs.php --graph-type=ds --graph-template-id=281 --host-id=1307 --snmp-query-id=1 --snmp-query-type-id=13 --snmp-field=ifDescr --snmp-value-regex='Gi' --snmp-field=ifAlias --snmp-value-regex='GMPLS'

But I just went back to using the following so I got any interface with GMPLS in the description
[cactiuser@ossccacti01 cli]$ ./add_graphs.php --graph-type=ds --graph-template-id=281 --host-id=1307 --snmp-query-id=1 --snmp-query-type-id=13 --snmp-field=ifAlias --snmp-value-regex='GMPLS'
tsalle
Posts: 7
Joined: Thu Apr 28, 2011 3:37 am

Re: add_graphs.php with multiples --snmp-field and --snmp-va

Post by tsalle »

mstbone67a wrote:Pretty slick!! Loving this.

But I just went back to using the following so I got any interface with GMPLS in the description
[cactiuser@ossccacti01 cli]$ ./add_graphs.php --graph-type=ds --graph-template-id=281 --host-id=1307 --snmp-query-id=1 --snmp-query-type-id=13 --snmp-field=ifAlias --snmp-value-regex='GMPLS'
Yeah, cou can only pass the --snmp-field and --snmp-value-regex and one time !

I've received a private message about this patch, but can't read it :( "You are not authorised to read private messages."
mstbone67a
Posts: 28
Joined: Mon Sep 21, 2009 9:31 am

Re: add_graphs.php with multiples --snmp-field and --snmp-va

Post by mstbone67a »

that was my pm. just to check this thread.

so anyway to pass multiple strings in the regex? thinking I am just not using it correctly.

Say i wanted to search for "GMPLS" or "sl-pe"
tsalle
Posts: 7
Joined: Thu Apr 28, 2011 3:37 am

Re: add_graphs.php with multiples --snmp-field and --snmp-va

Post by tsalle »

mstbone67a wrote:that was my pm. just to check this thread.

so anyway to pass multiple strings in the regex? thinking I am just not using it correctly.

Say i wanted to search for "GMPLS" or "sl-pe"
You can use the | for multiple regex :

example : "GMPLS|sl-pe"
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests