New plugin: creating device, community comes from other DB

Discussions on developing plugins for the Cacti Plugin Architecture

Moderators: Moderators, Developers

Post Reply
Author
Message
bernplugins
Posts: 2
Joined: Wed Jun 15, 2011 6:00 am

New plugin: creating device, community comes from other DB

#1 Post by bernplugins » Wed Jun 15, 2011 6:09 am

Hello all,

First I want to tell you how much i am happy with this tool cacti.
I wrote few little pluggins:
1 - to manage automatically the deployment of the templates...
When installing this pluggins, all templates validated by me are propagated into cacti instances.
2 - a personal rrd cleanup where the cleanup parameters are stored also on cacti settings tab.
3 - a plugin which informs me when the amount of devices or graphs reatch the maximum limit setup also into the setting table.
4 - I am trying to complete a plugin which simplify the device creation.
In cacti previous version 0.8.6 i had it working. today i want to have that into the plugin architecture.
I am trying to write a pluggin which fills automatically the community string...

The goal is to show only the host template, the name, Description, Community string fields and disabled button into the edit host page.
When the user is typping a device name, This pluggin lookup the matched devices list into a remote database.
When the user select one device, the description and community string is automatically populated...

The external DB parameter are stored into the cacti settings table... using config_settings table.
The lookup is developped on Cajax framework....this javascript is called and associated to the cacti fields into the top_header hook ...
I try to use the config_form hook to hide all others fields, the goal is to get them from the read_config function based on the cacti settings table.

I have difficulties to get this part working properly.

How can I not show all device edit page field ....?
I try to use the config_form hook but without good success ...


using
on pluggin hook config_form
$fields_host_edit = array( "method" => "hidden",
"value" => read_config_option("snmp_port")
);
I get error:
document.GetElementById("snmp_port") is null on the host.php file

Can someone help me ?

which hook plugin can i use....? to be able to hide some fields ? and to populate them from the default cacti config ?
Which ones are really mandatory ?


Best regards
A.DB
Attachments
auto-completion.JPG
Here is the illustration
auto-completion.JPG (109.45 KiB) Viewed 3534 times

bernplugins
Posts: 2
Joined: Wed Jun 15, 2011 6:00 am

Re: New plugin: creating device, community comes from other

#2 Post by bernplugins » Tue Jun 21, 2011 2:14 am

AnyOne ?

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

Re: New plugin: creating device, community comes from other

#3 Post by TheWitness » Sat Oct 01, 2011 12:41 pm

Makes no sense.
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.

cigamit
Developer
Posts: 2782
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Re: New plugin: creating device, community comes from other

#4 Post by cigamit » Thu Dec 15, 2011 12:56 am

The problem with the approach you were using (utilizing config_form to modify the array that contains the host fields) is that there is a good bit of hardcoded javascript at the end of the host page that tries to make everything all ajax-ish. Ideally, we would have that code change based upon the actual fields, but for what you want to do, I would suggest this. Detect when host.php page is shown (use the top_header hook) and then do your own top_header and spit out your own code for the edit page.

Post Reply