Script to update ifAlias/ifDescr title via cron

Anything that you think should be in Cacti.

Moderators: Developers, Moderators

bsdboy
Cacti User
Posts: 87
Joined: Mon May 22, 2006 5:24 pm

Script to update ifAlias/ifDescr title via cron

Post by bsdboy »

So I've got about 3k worth of switchports that the name changes from time to time. I've asked in the general forum if this feature/script was available without manually going in and "ReApplying Suggested Names" and was directed to the feature request forum.

Would be great to have a utility that we could add to cron and forget :lol:

thanks!
User avatar
Linegod
Developer
Posts: 1626
Joined: Thu Feb 20, 2003 10:16 am
Location: Canada
Contact:

Post by Linegod »

poller_reindex_hosts.php and rebuild_poller_cache.php should do what you need.
--
Live fast, die young
You're sucking up my bandwidth.

J.P. Pasnak,CD
CCNA, LPIC-1
http://www.warpedsystems.sk.ca
bsdboy
Cacti User
Posts: 87
Joined: Mon May 22, 2006 5:24 pm

Post by bsdboy »

Great, I'll give it a go!
aleu
Cacti User
Posts: 216
Joined: Mon Dec 11, 2006 10:17 am

Post by aleu »

bsdboy wrote:Great, I'll give it a go!
This does not work for me. The only way I am able to update graph titles is via Graph Management--Selecting device's traffic graphs and choosing "Reapply Suggested Names". Somebody mentioned that it would work if you click on a small green circle when creating new graphs (to reload the Data Query) but it does not work for me either.

Please advise, I have around 2000 nodes which need to be relabeled.

Thanks
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

What happens, if you reindex a single host using the script?
Reinhard
pokai
Posts: 2
Joined: Thu Jul 19, 2007 4:43 am

Post by pokai »

I have problem too.

I can use poller_reindex_hosts.php and rebuild_poller_cache.php to update ifAlias.
But if I remove Description(ifAlias) on switch and update it. I suppose the title will become such as "lab-sw - Traffic - Fa0/6" , but it become "lab-sw - Traffic - Fa0/6 -|query_ifAlias|".

If I click "Reapply Suggested Names" manually, this problem will be fixed.
But how can I fix this problem not by hand?
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

That's easy, write a script. Let's see how much energy I have this morning.....

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

This might work. I have not debugged. If you find any syntax errors, repost :)

TheWitness
Attachments
poller_graphs_reapply_names.zip
(2.17 KiB) Downloaded 847 times
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
pokai
Posts: 2
Joined: Thu Jul 19, 2007 4:43 am

Post by pokai »

It works with little bug.

The error message as below.

Notice: Undefined variable: filter in /usr/share/cacti/site/poller_graphs_reapply_names.php on line 84
claymation
Posts: 2
Joined: Thu Jul 19, 2007 11:41 pm
Location: Atlanta, GA

DOH!

Post by claymation »

Running the script seems to have *removed* all of the ifAlias names from my graph titles! :(

I had just edited the graph template title to include |query_ifAlias| and was faced with the prospect of manually reapplying suggested names to thousands of interfaces, so I figured I'd give this script a go. But not only has the script removed the ifAlias names from the few interfaces that had them, now manually reapplying suggested names on a handful of interfaces does not add the ifAlias port description.

Could you describe what api_reapply_suggested_graph_title() actually does, and why the graph titles aren't just generated dynamically every time the graph is rendered?

Thanks!

Clay
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

It takes the "most" appropriate suggested name from the data query definition and renames the graphs. It does "EXACTLY" what the user interface does. So, you must have done something else.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
claymation
Posts: 2
Joined: Thu Jul 19, 2007 11:41 pm
Location: Atlanta, GA

Post by claymation »

TheWitness wrote:It takes the "most" appropriate suggested name from the data query definition and renames the graphs. It does "EXACTLY" what the user interface does. So, you must have done something else.
Correction: Whether I use the web interface or your script, the ifAlias values are removed. Editing and saving the graph template causes them to reappear, along with bogus |query_ifAlias| text for switch interfaces without descriptions.

I see that your script and the web interface both call api_reapply_suggested_graph_title(), so I'm curious if that function might not be correct. I'll dig through the source to see what I can find.

In any case, I'm curious why the graph titles aren't always dynamically generated. Why does this function exist? Why are graph titles "suggested" and not "defined"? :)

Thanks,

Clay
uno
Posts: 32
Joined: Mon Aug 27, 2007 7:22 am

Post by uno »

claymation wrote:
TheWitness wrote:It takes the "most" appropriate suggested name from the data query definition and renames the graphs. It does "EXACTLY" what the user interface does. So, you must have done something else.
Correction: Whether I use the web interface or your script, the ifAlias values are removed. Editing and saving the graph template causes them to reappear, along with bogus |query_ifAlias| text for switch interfaces without descriptions.

I see that your script and the web interface both call api_reapply_suggested_graph_title(), so I'm curious if that function might not be correct. I'll dig through the source to see what I can find.

In any case, I'm curious why the graph titles aren't always dynamically generated. Why does this function exist? Why are graph titles "suggested" and not "defined"? :)

Thanks,

Clay
I get exactly the same behaviour as previous user. When running poller_graphs_reapply_names.php, all ifAliases are removed. When I edit and save the graph template, they reappear, unchanged from before I ran the script.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please verify using current 087a release. Sould be fine, now. Else, please file a bug as given by http://www.cacti.net/bugs.php
Reinhard
thierry.chich
Posts: 24
Joined: Tue Jun 14, 2005 7:58 am

Post by thierry.chich »

I have small problems to try the solutions given here:
find / -name poller_graphs_reapply_names.php
or find / -name poller_reindex_hosts.php
is giving nothing to me.

I use Version 0.8.7b of cacti coming form the lenny package.

Is there a new soltion to this problem ?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest