Plugin Architecture for Cacti and Monitoring Module
Moderators: Developers, Moderators
Plugin Architecture for Cacti and Monitoring Module
This was originally posted in the Threshold thread, but it was decided it would be best if in its own thread.
-----
Here is the beginnings of a plugin architecture for Cacti. This is basically the same plugin backend we currently use in Squirrelmail (GPL Licensed!). It makes for an excellent way to hook into almost any area of the code, just by adding a simple function call. I threw this together the other night, and it seems to work without any problems. Eventually we would want to add a ton more hooks, but the functionality is the same.
There are a few things that were taken for granted before, but can't be now. We can't be sure that the current displayed page will always be in the root of the Cacti folder, so we have to add an extra variable to the config.php for this, and modify the header images to use it, instead of just blindly saying "images/picture.gif". You basically just specifiy the root url path to cacti, like "/cacti/". We also add a $plugins variable to list the name (IE folder name) of the plugins we want to load. We could have them auto-load, but that would be a security hole waiting to happen.
The current patch is against plain v0.8.6f, without the threshold module instatlled. The patches are only 22K, so its very unintrusive.
-----
Just as a proof of concept, I have completely modified my Monitoring module to use this architecture. You can see that I easily added to the Host editting form, saving forms, permissions, and even a tab up top. Much more can be done, and I am sure will be done in the future. This plugin itself will add a Column to your Host table called "monitor" but other than that, it doesn't change a single thing.
As with anytime you are testing something new, BESURE TO BACKUP FIRST!!!! (Database and files!)
-----
Instructions are simple, apply the patch by unzipping it and then copying the diff file to your cacti directory. While you are in your cacti directory, run this command
patch -p1 -N < cacti-plugin-arch.diff
You can also use the included already patched files, by just overriding your current files (you will have to reset up your database info in config.php)
Next extract the contents of the plugin into a folder called "monitor" in the plugins folder. Edit your patched include/config.php and uncomment the $plugins[] = 'monitor'; and also set the $config['url_path'].
Thats it!
(These patches contain a few fixes that were not in patches in the other thread, please let me know if you have any issues.
You can get the Patch here
Plugin Architecture Patch
Or the Plugins here
Cacti Plugins
---
(Edit: Updated this thread with the current information)
-----
Here is the beginnings of a plugin architecture for Cacti. This is basically the same plugin backend we currently use in Squirrelmail (GPL Licensed!). It makes for an excellent way to hook into almost any area of the code, just by adding a simple function call. I threw this together the other night, and it seems to work without any problems. Eventually we would want to add a ton more hooks, but the functionality is the same.
There are a few things that were taken for granted before, but can't be now. We can't be sure that the current displayed page will always be in the root of the Cacti folder, so we have to add an extra variable to the config.php for this, and modify the header images to use it, instead of just blindly saying "images/picture.gif". You basically just specifiy the root url path to cacti, like "/cacti/". We also add a $plugins variable to list the name (IE folder name) of the plugins we want to load. We could have them auto-load, but that would be a security hole waiting to happen.
The current patch is against plain v0.8.6f, without the threshold module instatlled. The patches are only 22K, so its very unintrusive.
-----
Just as a proof of concept, I have completely modified my Monitoring module to use this architecture. You can see that I easily added to the Host editting form, saving forms, permissions, and even a tab up top. Much more can be done, and I am sure will be done in the future. This plugin itself will add a Column to your Host table called "monitor" but other than that, it doesn't change a single thing.
As with anytime you are testing something new, BESURE TO BACKUP FIRST!!!! (Database and files!)
-----
Instructions are simple, apply the patch by unzipping it and then copying the diff file to your cacti directory. While you are in your cacti directory, run this command
patch -p1 -N < cacti-plugin-arch.diff
You can also use the included already patched files, by just overriding your current files (you will have to reset up your database info in config.php)
Next extract the contents of the plugin into a folder called "monitor" in the plugins folder. Edit your patched include/config.php and uncomment the $plugins[] = 'monitor'; and also set the $config['url_path'].
Thats it!
(These patches contain a few fixes that were not in patches in the other thread, please let me know if you have any issues.
You can get the Patch here
Plugin Architecture Patch
Or the Plugins here
Cacti Plugins
---
(Edit: Updated this thread with the current information)
- Attachments
-
- Picture of the Monitoring Plugin in action
- monitoring.jpg (145.26 KiB) Viewed 69838 times
Last edited by cigamit on Mon Aug 01, 2005 10:42 pm, edited 2 times in total.
Threshold Plugin
(Edit - Updated this with current data)
I have now converted the Threshold (Thold) Module to the plugin format. You can get it here
Threshold Plugin
I have now converted the Threshold (Thold) Module to the plugin format. You can get it here
Threshold Plugin
Last edited by cigamit on Mon Aug 01, 2005 10:32 pm, edited 2 times in total.
Monitoring Plugin for Cacti
For those wondering what the Monitor Plugin actually does, this is from my post in the other thread.
The "Monitor" tab was developed to replace What's Up Gold, which displays all the Hosts you want to monitor (Simple checkbox on the device to disable monitoring). Up devices are green, Down are red, and Recovering are Blue. It throws an Audiable alert when a host is down, you are able to silence the alert, and it uses a little AI to tell when to re-enable the alert automatically. This allows our 24 hour staff to be alerted when a host goes down, and a quick glance at the screen shows which hosts are down.
Not included in this plugin is a faster version of poller.php that just checks for host up/down status and updates the database. I took the poller, and cmd.php and ripped out alot of stuff to where you can run every minute (if you normally only poll every 5). The fast poller only checks to see if the host is up, and updates the database with the info. The fast poller don't interfer with the normal poller as it runs side by side (its not a replacement) with this, you can set the Monitor window to refresh itself every 30 seconds (instead of the current 5 minutes, so to not miss something). If anyone wants this, just let me know and I will zip it up.
The "Monitor" tab was developed to replace What's Up Gold, which displays all the Hosts you want to monitor (Simple checkbox on the device to disable monitoring). Up devices are green, Down are red, and Recovering are Blue. It throws an Audiable alert when a host is down, you are able to silence the alert, and it uses a little AI to tell when to re-enable the alert automatically. This allows our 24 hour staff to be alerted when a host goes down, and a quick glance at the screen shows which hosts are down.
Not included in this plugin is a faster version of poller.php that just checks for host up/down status and updates the database. I took the poller, and cmd.php and ripped out alot of stuff to where you can run every minute (if you normally only poll every 5). The fast poller only checks to see if the host is up, and updates the database with the info. The fast poller don't interfer with the normal poller as it runs side by side (its not a replacement) with this, you can set the Monitor window to refresh itself every 30 seconds (instead of the current 5 minutes, so to not miss something). If anyone wants this, just let me know and I will zip it up.
-
- Cacti User
- Posts: 52
- Joined: Fri May 06, 2005 7:39 am
- Location: france
- Contact:
Did you edit your include/config.php and set the $config['url_path'] to point to the proper URL for your cacti install?john le lardon wrote:when i'm in monitor page i don't see tabs pics , it's a bug?
Do you have thresholds installed? And if so did you use the thresholds patch instead of the other?
-
- Cacti User
- Posts: 52
- Joined: Fri May 06, 2005 7:39 am
- Location: france
- Contact:
I edit my config.php and change URL by "http://<myipserver>/cacti/" it's the url i use for seeing my cacti server .
i use therhold apply before plugin patch and monitor apply after plungin patch.
when i try to go to graph ot thold tab i have error .
cacti search on /cacti/plugins/mointor graph_view.php and graph_thold.php
any idea ?
i use therhold apply before plugin patch and monitor apply after plungin patch.
when i try to go to graph ot thold tab i have error .
cacti search on /cacti/plugins/mointor graph_view.php and graph_thold.php
any idea ?
- Attachments
-
- my problem with monitor
- probmonitor.png (12.53 KiB) Viewed 69521 times
Last edited by john le lardon on Fri May 27, 2005 7:04 am, edited 2 times in total.
@cigamit
This is the repsons from my patching
patch -p1 -N < cacti-plugin-arch.diff
patching file include/config_arrays.php
Hunk #1 FAILED at 433.
1 out of 1 hunk FAILED -- saving rejects to file include/config_arrays.php.rej
patching file include/config_form.php
patching file include/config.php
Hunk #1 succeeded at 31 with fuzz 2.
patching file include/config_settings.php
Hunk #1 succeeded at 801 (offset 17 lines).
patching file include/plugins.php
patching file include/top_graph_header.php
Hunk #1 succeeded at 92 with fuzz 1 (offset 2 lines).
Hunk #3 succeeded at 125 (offset 2 lines).
Hunk #5 succeeded at 145 (offset 2 lines).
patching file include/top_header.php
patching file lib/api_device.php
patching file lib/functions.php
patching file plugins/index.php
in config_arrays.php.rej the following text could be found
***************
*** 433,436 ****
GDC_SLASH => "/"
);
- ?>
--- 433,438 ----
GDC_SLASH => "/"
);
+ do_hook("config_arrays");
+
+ ?>
When I add the line by hand to that file cacti is not working. I did not see any file. When I leave config_arrays as is (without the patch applied by hand) I get a fourth button (monitor) but when i click on that button i receive the message:
Access Denied
You are not permitted to access this section of Cacti. If you feel that you need access to this particular section, please contact the Cacti administrator.
When i remove the authentication part of that page i get the following reply:
No Database Selected
any thoughts?
I work with thold2.1a
Michael
This is the repsons from my patching
patch -p1 -N < cacti-plugin-arch.diff
patching file include/config_arrays.php
Hunk #1 FAILED at 433.
1 out of 1 hunk FAILED -- saving rejects to file include/config_arrays.php.rej
patching file include/config_form.php
patching file include/config.php
Hunk #1 succeeded at 31 with fuzz 2.
patching file include/config_settings.php
Hunk #1 succeeded at 801 (offset 17 lines).
patching file include/plugins.php
patching file include/top_graph_header.php
Hunk #1 succeeded at 92 with fuzz 1 (offset 2 lines).
Hunk #3 succeeded at 125 (offset 2 lines).
Hunk #5 succeeded at 145 (offset 2 lines).
patching file include/top_header.php
patching file lib/api_device.php
patching file lib/functions.php
patching file plugins/index.php
in config_arrays.php.rej the following text could be found
***************
*** 433,436 ****
GDC_SLASH => "/"
);
- ?>
--- 433,438 ----
GDC_SLASH => "/"
);
+ do_hook("config_arrays");
+
+ ?>
When I add the line by hand to that file cacti is not working. I did not see any file. When I leave config_arrays as is (without the patch applied by hand) I get a fourth button (monitor) but when i click on that button i receive the message:
Access Denied
You are not permitted to access this section of Cacti. If you feel that you need access to this particular section, please contact the Cacti administrator.
When i remove the authentication part of that page i get the following reply:
No Database Selected
any thoughts?
I work with thold2.1a
Michael
-
- Cacti User
- Posts: 52
- Joined: Fri May 06, 2005 7:39 am
- Location: france
- Contact:
for :
for the patch do you have thold ? because if thold install use patch cacti-plugin-arch-thold.zip
try console / User Management / <user_who_can_monitor> / see Realm Permissions (bottom of page ) check "View Monitoring "Access Denied
You are not permitted to access this section of Cacti. If you feel that you need access to this particular section, please contact the Cacti administrator.
for the patch do you have thold ? because if thold install use patch cacti-plugin-arch-thold.zip
- Attachments
-
- add monitoring right
- monitor.png (70.37 KiB) Viewed 69525 times
Last edited by john le lardon on Fri May 27, 2005 6:55 am, edited 1 time in total.
-
- Cacti User
- Posts: 52
- Joined: Fri May 06, 2005 7:39 am
- Location: france
- Contact:
You applied the non-thold patch to a thold installation. Restore the files patched from backup, and then apply the patch I provided for people that use thold. That should do the trick.mgb wrote:@cigamit
This is the repsons from my patching
patch -p1 -N < cacti-plugin-arch.diff
<snip>
I work with thold2.1a
When you were patching, did it happen to fail while applying the patches to top_header.php and top_graph_header.php?john le lardon wrote:I edit my config.php and change URL by "http://<myipserver>/cacti/" it's the url i use for seeing my cacti server .
i use therhold apply before plugin patch and monitor apply after plungin patch.
when i try to go to graph ot thold tab i have error .
cacti search on /cacti/plugins/mointor graph_view.php and graph_thold.php
any idea ?
Try these attached versions. They have both the thold patches, and the plugin patches applied.
Maybe I should include full versions of all the files for people who are having issues trying to patch.
- Attachments
-
- top_headers.zip
- Drop in replacement for includes/top_headers.php and includes/top_graph_headers.php if you have thold installed.
- (4.65 KiB) Downloaded 1362 times
Who is online
Users browsing this forum: No registered users and 2 guests