Script to update ifAlias/ifDescr title via cron

Anything that you think should be in Cacti.

Moderators: Moderators, Developers

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

Script to update ifAlias/ifDescr title via cron

#1 Post by bsdboy » Thu Apr 12, 2007 2:38 pm

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: 1630
Joined: Thu Feb 20, 2003 10:16 am
Location: Canada
Contact:

#2 Post by Linegod » Wed Apr 18, 2007 9:45 am

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
Contact:

#3 Post by bsdboy » Wed Apr 18, 2007 9:55 am

Great, I'll give it a go!

aleu
Cacti User
Posts: 215
Joined: Mon Dec 11, 2006 10:17 am

#4 Post by aleu » Fri May 04, 2007 1:03 pm

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: 22375
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

#5 Post by gandalf » Fri May 04, 2007 2:58 pm

What happens, if you reindex a single host using the script?
Reinhard

pokai
Posts: 2
Joined: Thu Jul 19, 2007 4:43 am

#6 Post by pokai » Thu Jul 19, 2007 5:08 am

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: 14817
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

#7 Post by TheWitness » Thu Jul 19, 2007 7:50 am

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 MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Central Plugin Repository
Central Templates Repository


I'm still out there people. Getting excited for Cacti 1.2. I think it will be a great release.

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

#8 Post by TheWitness » Thu Jul 19, 2007 8:16 am

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 780 times
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Central Plugin Repository
Central Templates Repository


I'm still out there people. Getting excited for Cacti 1.2. I think it will be a great release.

pokai
Posts: 2
Joined: Thu Jul 19, 2007 4:43 am

#9 Post by pokai » Thu Jul 19, 2007 11:00 pm

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!

#10 Post by claymation » Fri Jul 20, 2007 12:01 am

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: 14817
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

#11 Post by TheWitness » Fri Jul 20, 2007 11:42 am

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 MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Central Plugin Repository
Central Templates Repository


I'm still out there people. Getting excited for Cacti 1.2. I think it will be a great release.

claymation
Posts: 2
Joined: Thu Jul 19, 2007 11:41 pm
Location: Atlanta, GA

#12 Post by claymation » Fri Jul 20, 2007 3:49 pm

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

#13 Post by uno » Mon Aug 27, 2007 7:26 am

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: 22375
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

#14 Post by gandalf » Mon Feb 04, 2008 10:44 am

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

#15 Post by thierry.chich » Tue May 27, 2008 3:32 am

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