A simple script to Automate adding graphs based on ifAlias

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
rgreening
Posts: 4
Joined: Thu Apr 22, 2010 11:28 am

A simple script to Automate adding graphs based on ifAlias

Post by rgreening »

Here is a simple script which can be used as is or modified to suit your needs.

It simply adds graphs on any interfaces found on all Cisco Devices (template value 5) as tagged in Cacti. Each interface is polled for their ifAlias (the description string you define on an interface) and based on matching some criteria I have defined for the format of the string, will assign an appropriate SNMP Query Type and Graph Template ID.

* For my purposes, I needed a way to automatically have new interfaces for our customers get auto populated and a new graph created.

* We have 3 main types of data service: a) Flat Rate b) Volume (GB In+Out) and c) 95th Percentile (Burst).

* Each interface description starts with a specific prefix, denoting the data service (CCF, CCV, and CCB repspectively).

Armed with this info, I pulled the appropriate ID's from the Cacti install, and wrote this script. I have this placed in my CLI scripts dir and added a cron job to call this periodically.

In the script, most everything is a variable which can be edited in the first 30 lines (e.g. the templates to use). Also, this is based on having well defined descriptions on the interface. If you do, then modifying line 53 and 63 to pattern match your setup should be trivial.

I post this mostly so I do not lose it, but also that it may be useful to someone else out there.

This script is free to use and do with what you will. No warranty, and use at your own risk, etc... If it eats your puppy, I cannot be held accountable.

Cheers,

Rod.
Attachments
automate_graphs_to_add.sh.gz
automate adding graphs script
(890 Bytes) Downloaded 153 times
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests