New plugin: creating device, community comes from other DB

Discussions on developing plugins for the Cacti Plugin Architecture

Moderators: Developers, Moderators

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

New plugin: creating device, community comes from other DB

Post by bernplugins »

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
Here is the illustration
Here is the illustration
auto-completion.JPG (109.45 KiB) Viewed 4339 times
bernplugins
Posts: 2
Joined: Wed Jun 15, 2011 6:00 am

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

Post by bernplugins »

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

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

Post by TheWitness »

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 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?
cigamit
Developer
Posts: 3369
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

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

Post by cigamit »

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

Who is online

Users browsing this forum: No registered users and 0 guests