Reader small image

You're reading from  Cacti 0.8 Beginner's Guide

Product typeBook
Published inMar 2011
Reading LevelBeginner
PublisherPackt
ISBN-139781849513920
Edition1st Edition
Languages
Tools
Concepts
Right arrow
Author (1)
Thomas Urban
Thomas Urban
author image
Thomas Urban

Thomas Urban is the owner of Urban-Software.de, a software and consulting services company providing add-ons, plugins, and services for the Cacti Performance Monitoring systems. He has been in the consulting business for more than 5 years and has been creating web applications for over 20 years building reporting interfaces, network management software, asset management sites, and much more. He is a part of the Cacti community and is known as Phalek in the Cacti forums, where he is among the Top 10 contributors. He started writing the first Cacti Beginners Guide for Cacti 0.8 back in 2011. The second edition is his second official effort.
Read more about Thomas Urban

Right arrow

Chapter 8. Plugin Architecture

Now, that you have learned about the basic Cacti features, you are going to learn how to extend the capabilities of your Cacti instance with the available Plugin Architecture.

In this chapter we are going to:

  • Provide a short overview of Plugin Architecture

  • Install and configure Plugin Architecture

  • Learn how to extend Cacti with plugins

  • Allow users to use the extended features of plugins

Let's start!

Introduction to the Plugin Architecture


The Plugin Architecture is an optional set of files that extend the basic functionality of Cacti with the ability to call external functions and applications, also called "plugins".

Why plugins?

Plugins allow other external developers to implement open source as well as commercial features for Cacti without the need to change the core Cacti sources. Security patches for the core can also be safely applied without interfering with the functionality of the plugins.

Plugins allow end users to implement missing features or create specific enhancements needed for internal corporate usage.

Plugin features

As already mentioned, plugins can have different functionalities. The following is a list of features implemented by some of the available plugins:

  • User interface enhancements—such as re-branding the login screen

  • Accessing the Cacti database—interaction with external tools

  • Manipulating RRD files—removing spikes from the graphs

  • Implementing caching/performance enhancements...

Installing the Plugin Architecture


Let's start with installing the Plugin Architecture, also abbreviated as PIA.

Time for action – installing the Plugin Architecture


  1. Go to http://www.cacti.net/downloads/pia/.

  2. Right-click on the latest PIA version compatible with your installation.

  3. Copy the link-target to the clipboard.

  4. Logon to your Cacti installation as root.

  5. Change to the Cacti base directory:

    cd /var/www/html/cacti/
    
  6. Download the PIA:

    wget http://www.cacti.net/downloads/pia/cacti-plugin-0.8.7g-PA-v2.9.tar.gz
    
  7. Unpack the archive:

    tar -xzvf cacti-plugin-0.8.7g-PA-v2.9.tar.gz
    
  8. A new directory will be created named cacti-plugin-arch.

  9. Run the patching process using the following command. Alternatively, you can also use the pre-patched files contained in the PIA archive:

    patch -p1 -N < cacti-plugin-arch/cacti-plugin-0.8.7g-PA-v2.9.diff
    
  10. Check for any error message as shown in the following screenshot:

  11. In case of errors, you can copy the already patched files from the cacti-plugin-arch/files-0.8.7g/ directory:

    cp cacti-plugin-arch/files-0.8.7g/poller.php .
    cp cacti-plugin-arch/files-0.8.7g/data_sources.php...

Upgrading the Plugin Architecture


When upgrading the Plugin Architecture, patching the files using the provided diff may create issues. If you have a standard Cacti installation, without any customized code within the Cacti source files, you can use the provided replacement files.

Time for action – upgrading the Plugin Architecture


  1. Logon to your Cacti server as root.

  2. Change to the Cacti installation directory:

    cd /var/www/html/cacti
    
  3. Download the PIA:

    wget http://www.cacti.net/downloads/pia/cacti-plugin-0.8.7g-PA-v2.9.tar.gz
    
  4. Unpack the archive:

    tar -xzvf cacti-plugin-0.8.7g-PA-v2.9.tar.gz
    
  5. A new directory will be created named cacti-plugin-arch.

  6. Create a backup of your config.php file:

    cp include/config.php include/config.php.bak
    
  7. Copy the replacement files to your Cacti installation:

    'cp' –R cacti-plugin-arch/files-0.8.7g/* .
    
  8. Restore your original config file:

    cp include/config.php.bak include/config.php
    
  9. Import the additional SQL statements:

    mysql -u root -p cacti < cacti-plugin-arch/pa.sql
    

What just happened?

You just upgraded the Plugin Architecture on your Cacti instance by replacing the existing Cacti files with the provided patched versions.

Configuring the Plugin Architecture


Once you have installed the Plugin Architecture, you can assign one new realm permission to users who you want to allow the plugin administration.

Time for action – configuring the Plugin Architecture


  1. Logon to your Cacti web interface as an admin user.

  2. Go to Utilities | User Management.

  3. Select the user to whom you want to allow the plugin administration.

  4. Select the Plugin Managment box within the Real Permissions list.

  5. Click on the Save button.

  6. You should notice a new menu called Plugin Management within the Configuration settings:

  7. Click on the Plugin Management menu entry.

  8. You will see a list of installed plugins. At the moment this list should be empty, as shown in the following screenshot:

What just happened?

You just added permissions to install, enable, disable, and uninstall plugins to a user. By default, no user will have this permission, so you need to give it to at least one user in order to be able to use plugins.

Downloading and installing plugins


Now that you have successfully installed the Plugin Architecture, you can go on and install some basic plugins. The plugins available can be divided into two categories: plugins which have been created for the 1.x version of the Plugin Architecture and plugins which are compatible with the 2.x version.

The Plugin Architecture version 2.x supports pre-PIA 2.x plugins.

PIA directory structure

Besides the patching of some source files of Cacti, the Plugin Architecture also adds a new directory to the Cacti installation. The directory is named plugins.

Each plugin needs to be placed into this directory. The following files are needed as a minimum for each plugin to work properly:

  • setup.php

  • index.php

The index.php file only contains a redirection to the main Cacti site in order to disallow end users to browse the plugin directory freely. The setup.php file contains the setup and enablement code, as well as code for the different plugin hooks introduced with...

Time for action – installing the settings plugin


  1. Go to the plugins web page at http://docs.cacti.net/plugins.

  2. Click on the Settings plugin.

  3. Right-click on the download link and copy the link target to the clipboard.

  4. Logon to your Cacti installation as root using PuTTY.

  5. Go to the new plugins directory:

    cd /var/www/html/cacti/plugins
    
  6. Download the settings plugin using the following command:

    wget -O settings-v0.7-1.tgz http://docs.cacti.net/_media/plugin:settings-v0.7-1.tgz?id=plugin%3Asettings&cache=cache
    
  7. Extract the archive:

    tar -xzvf settings-v0.7-1.tgz
    
  8. Logon to your Cacti web interface using a user with Plugin Management permissions.

  9. Go to Configuration | Plugin Management.

  10. You should now be able to see the settings plugin in the list of available plugins:

  11. Click on the blue arrow icon in the Actions column to install the plugin. The list of icons on the Actions column should change as seen in the following screenshot:

  12. Click on the green arrow icon on the Actions column to enable the plugin...

Time for action – removing the settings plugin


  1. Logon to your Cacti web interface using a user with Plugin Management permissions.

  2. Go to Configuration | Plugin Management.

  3. You should now be able to see the settings plugin on the list of available plugins:

  4. Click on the red icon with the circle in it in the Actions column to disable the plugin. The list of icons in the Actions column should change as seen in the following screenshot:

  5. Click on the red arrow icon in the Actions column to uninstall the plugin. You will then see a blue arrow icon appear, as shown in the following screenshot:

  6. Now logon to your Cacti installation as root using PuTTY.

  7. Go to the plugins directory:

    cd /var/www/html/cacti/plugins
    
  8. Remove the settings plugin using the following command:

    rm –rf settings
    

What just happened?

You successfully uninstalled and removed the Settings plugin from your Cacti installation. This will also remove any database tables or columns created. If a plugin had used these tables to store some data...

Updating a plugin


Now that you have learned how to add and remove plugins to and from Cacti, what about updating plugins? The update of a plugin heavily depends on the plugin developer. In most cases, the update process simply involves the extraction of the new plugin and over-writing of the existing files from the old plugin installation.

The Plugin Architecture provides some functionality for the plugin developer to check for the existence of an older version and to update this accordingly.

The Settings plugin is a good example of a plugin where the update process only involves over-writing the existing files.

Before updating a plugin, make sure that you read the readme files or ask within the specific plugin forum topics for help on the update process.

Adding plugin permissions


Some plugins add new realm permissions in the user management page. This allows you to grant access to one user group, but deny access to another. The following screenshot shows the new user realm permission Send Test Mail for the settings plugin, which allows a specific user to send out a test mail in order to check the correct configuration of the settings plugin:

Pop Quiz – a few questions about Chapter 8

  1. What do you need to check if you are unable to see the new Plugin Management link?

    a. The config.php file

    b. The Cacti log file

    c. The realm permissions of the user

  2. How do you disable a plugin?

    a. By using the Plugin Management page

    b. By editing the global.php file

    c. By editing the config.php file

  3. What plugin should you use to find out where a specific computer is located?

    a. The WeatherMap plugin

    b. The MacTrack plugin

    c. The Thold plugin

Summary


You have now successfully installed the Plugin Architecture (PIA) and are now able to add new features and functionality to your Cacti instance using external plugins.

In this chapter, you have covered:

  • What features and functionalities plugins can provide

  • How to install and configure the Plugin Architecture and how to provide plugin management access to a specific user

  • Installation, update, and removal of a plugin

  • How to set up specific plugin permissions for a user

You should now be able to add other plugins and extend your Cacti installation with new features. In the next chapter, you will learn how the plugins are structured and how to write your own plugin.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Cacti 0.8 Beginner's Guide
Published in: Mar 2011Publisher: PacktISBN-13: 9781849513920
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Thomas Urban

Thomas Urban is the owner of Urban-Software.de, a software and consulting services company providing add-ons, plugins, and services for the Cacti Performance Monitoring systems. He has been in the consulting business for more than 5 years and has been creating web applications for over 20 years building reporting interfaces, network management software, asset management sites, and much more. He is a part of the Cacti community and is known as Phalek in the Cacti forums, where he is among the Top 10 contributors. He started writing the first Cacti Beginners Guide for Cacti 0.8 back in 2011. The second edition is his second official effort.
Read more about Thomas Urban