Sebastian Mogilowskis Blog

Just another blog about administration, linux and other stuff

Racktables Extension v0.2

New version available !! Klick here.

New version of my Racktables Extension

Changes:

* IPv6 Support
* Support Server chassis (Bladesystems)
* Show VM Hypervisor
* Support new Racktables plugin system

Read here the article of version 0.1.

Download

[download#16#size#nohits]

New version available !! Klick here.

Installation

Move folder “extensions” into the racktables “wwwroot” folder.

With Racktables 0.19.X

Create or modify “local.php” in the “inc” folder with the following content:

<?php
# Load server report
require_once "extensions/reports/server-report.php";

# Load virtual machine report
require_once "extensions/reports/vm-report.php";

# Load switch report
require_once "extensions/reports/switch-report.php";

?>

or copy the example file.

With Racktables 0.20.0 or later:

Create or modify “extensions.php” in the “plugins” folder with the following content:

<?php

# Load server report
require_once "../wwwroot/extensions/reports/server-report.php";

# Load virtual machine report
require_once "../wwwroot/extensions/reports/vm-report.php";

# Load switch report
require_once "../wwwroot/extensions/reports/switch-report.php";

?>

or copy the example file.

Screenshots:

Usage

Login into racktables and go to “Reports”.

Now you find “Server” and “Virtual machines” in the report menu.

Note: Sort multiple columns simultaneously by holding down the shift key and clicking a second, third or even fourth column header!

Modifikations

Add custom attribute:

Find the ID of your attribute. In this example it is “10002”. Open the report file “vm-report.php” for example. And add the following componets to the file:

[...]
$aResult[$Result['id']]['myValue'] = '';
if ( isset( $attributes['10002']['a_value'] ) )
    $aResult[$Result['id']]['myValue'] = $attributes['10002']['a_value'];
[...]

[...]
<th>My Value</th>
[...]

[...]
<td>'.$aRow['myValue'].'</td>
[...]

An easy way to find the ID of your custom attribute is to look in the source code (with your browser) of the attribute setting in the configuration.

Note: If it is an standart value and not an attribute (Don’t listed in attributes in the configuration menu) you can directly access the values:

Example with asset Tag:

[...]
$aResult[$Result['id']]['sAssetTag'] = $Result['asset_no'];
[...]

[...]
<th>Asset Tag</th>
[...]

[...]
<td>'.$aRow['sAssetTag'].'</td>
[...]

Custom sorter:

I have a lot of servers like vServer1, vServer2, …, vServer11, etc. but i want to list vServer10 after vServer2 so i created a custom sorter.

First create a new file in the jQuery-Folder called “sorter.js” with the following content:

$.tablesorter.addParser ( {
    id: 'vserver',
    is: function(s) {
        return false;
    },
    format: function(s) {
        s = s.replace(/<a\b[^>]*>/i,'');
        s = s.replace(/[^0-9]+/g,'');
        return s.trim(s);
    },
    type: 'numeric'
});

Now open your report file “vm-report.php” for example and add:

First the include of the new JS-Sorter:

"echo '	<script type="text/javascript" src="extensions/jquery/sorter.js"/>';"

And below the table in the tablesorter JS-Part:

[...]
headers: {
  0: { sorter: "vserver" },
  3: { sorter: "ipAddress" }
}
[...]

This sorter removes the hyperlink (added by the report) and all text parts from the name of the server (only for the sorting) and sorts the column now numeric.

34 thoughts on “Racktables Extension v0.2

  • Jim Julson says:

    You my friend, are a rockstar! This is a great addition to RT for sure!

    Question, is version 0.20 generally available? If not, how did you get it?

  • Macus Leung says:

    I am using Racktables 0.19.3 and observe the following error. How to fix it?

    PHP Warning: require_once(extensions/reports/server-report.php): failed to open stream: Permission denied in /var/www/html/racktables/inc/local.php on line 4

    • sebastian says:

      I hope you mean 0.19.13

      Check the permissions of the file “server-report.php” and allow access to it for your webserver user.

      Greetings

      Sebastian

  • Macus Leung says:

    It was caused by the selinux.
    Finally I work around this issue by execute setsebool -P httpd_read_user_content=1 as root
    I am using Centos 6.3.
    If I don’t want to change the selinux policy and set httpd_read_user_content=1, what others I can do to fix it?

  • Macus Leung says:

    I found the fix finally.
    Change to the racktables dir and execute to reset the SELinux security contexts
    restorecon -Rv extensions/

  • TommyBotten says:

    An excellent plugin, indeed. Thank you very much for your contribution. I have been looking to do the same, when I stumbled over your extension.

    Have you considered to push it upstream to either racktables core or perhaps the contrib?

    https://github.com/RackTables/racktables-contribs

    Thanks again!

    • sebastian says:

      Hi,

      thank you !

      I’m currently working on version 0.3 of the extension with some new features.
      I hope to release it with racktabes 0.20.0 so i can remove a lot of stuff from the sourcode i need to be compatible with some older versions of racktables.

      Add it to contrib is a good idea, the racktables developers should decide if they want to add it to the core.

      Greets

      Sebastian

  • Chuck says:

    Does anyone have this running under version 0.20.0? I have it running fine under 0.19.13 but when trying the new plugin location setup on 0.20.0 it never loads. Any ideas? Thanks for your work on this!!

    • sebastian says:

      Hi,

      it works on racktables 0.20.0 ( i developed it on 0.20.0 )

      Did you follow the instructions for version 0.20.0 ? Only the extension.php should be in the plugin directory. The plugin requests some files (JQuery and CSS) from the webroot. The rest of the plugin must stay on its old position.

      Greetings

      Sebastian

  • Billy says:

    I have the same problem as Chuck. I have followed the instructions exactly but won’t load. Any suggestions?

  • sebastian says:

    Hi,

    extension folder is in the webroot of racktables and extension.php in the plugin directory ?

    Old local.php removed (replaced by extension.php in v 0.20.0)

    Greetings

    Sebastian

  • Chuck says:

    I think there is a problem reading the path.

    My directory structure is c:\www\racktables\extensions\

    The server is publishing as http://servername/racktables

    How does the extension.php plugin path need to be set?

    require_once “../racktables/extensions/reports/server-report.php”;

    Does not appear to be read at all.

  • leonel says:

    Hi
    When i tried to install over 0.20.3, i can’t see the new reports, is there anothe configuration for this version of RT?

  • garagasli says:

    Documentroot: /var/www/html/racktables

    I installed racktables 0.20.9. I downloaded racktables_extensions_v0.3.1-5.tar and then tar xvc racktab****.tar -C /var/www/html/racktables/ ; cd /var/www/html/racktables
    mv racktables_extension* plugins; cd plugins; mv extensions ../. ;
    But not working.

    • sebastian says:

      Hi,

      please ask your server administrator i think it is an permission problem.

      The white pages are probably PHP Errors. ( There is no output defined for PHP Errors, thats default configuration of PHP. )

      The Error you posted:

      PHP Fatal error: require_once(): Failed opening required ‘/var/www/html/plugins/extension.php’

      This may be because your webserver is not allowed to open the plugin file.

      But i’m not sure. This are not directly problems with this plugin or racktables. Please ask your system administrator to check the webserver configuration and the permissions and flags of your files.

      Greetings

      Sebastian

  • K_storage says:

    Hi,

    im using racktable 0.20.9 on CentOS
    root folder is /var/www/html/racktable

    i copied the “extensions” folder in to:
    /var/www/html/racktables
    there is no folder named “plugin” so i created one and add the file
    /var/www/html/racktables/extension.php
    now.. there is no wwwroot folder (not using windows iis)
    so i canged the path to “require_once “/extensions/reports/server-report.php”;”
    still nothing working..
    any ideas?

    • sebastian says:

      wwwroot and plugins directory are IN the racktables folder.
      Your directory structure must be correct so racktables can include plugins.

      • K_storage says:

        Thanks for answering.
        There are no such file in my installation.
        Can you assist by explaining what folders to add?
        my root folder is:
        /var/www/html/racktables
        in it i have:
        css inc index.php js pix
        Do i need to reinstall the application or can it be fixed?

        Thanks.

        • sebastian says:

          Hi,

          you installed racktables wrong.

          css, inc, index.php js and pix are the content of the wwwroot directory if this is your /var/www/html/racktables directory, than put your plugins directory under /var/www/html/plugins.

          • sebastian says:

            Sorry, according to the racktables installation guide you installed it correct.
            https://wiki.racktables.org/index.php/RackTablesInstallHowto

            Thats a little bit confusing.

            But nevermind. Create /var/www/html/plugins and use it as your plugin directory. And put the extension directory inside your racktables folder.

          • K_storage says:

            I tried that but whenever i put the “extension.php” in /var/www/html/plugins
            i am getting blank (white) pages
            i tried to change the content of the extension.php to use:
            require_once “/var/www/html/racktables/extensions/reports/server-report.php”;
            but still not working all im getting is blank pages.
            ideas?

            thanks in advanced

          • sebastian says:

            White pages may be php errors. Turn on your debug output. Or check apache error log.
            Pathes (plugin and folders) seems to be correct now.

          • K_storage says:

            Thanks for the comment, i found this in the error log of the apache:
            PHP Fatal error: require_once(): Failed opening required ‘/var/www/html/plugins/extension.php’ (include_path=’.:/usr/share/pear:/usr/share/php’) in /var/www/html/racktables/inc/init.php on line 146, referer: http://my-site/racktables/index.php?page=report

            and in the /var/www/html/racktables/inc/init.php

            / load additional plugins
            ob_start();
            if (FALSE !== $plugin_files = glob (“${racktables_plugins_dir}/*.php”))
            foreach ($plugin_files as $plugin_file)
            require_once $plugin_file;
            // display plugins output if it contains something but newlines
            $tmp = ob_get_clean();
            if ($tmp != ” and ! preg_match (“/^\n+$/D”, $tmp))
            echo $tmp;
            unset ($tmp);

          • sebastian says:

            Hi,

            please check if /var/www/html/plugins/extension.php exists and is readable for your apache user.

            Greetings

            Sebastian

          • K_storage says:

            That the problem, whenever i put the extension.php in the plugin dir
            the site stop working (show blanks pages) until i delete the file

          • sebastian says:

            Hi,

            please check your server config “Failed opening” i guess you have file/dir permission problems.

            Greets

            Sebastian

          • K_storage says:

            excuse my ignorance but what is “Failed openin” or more important where can i configure it?
            Thanks

  • K_storage says:

    I tried that but whenever i put the “extension.php” in /var/www/html/plugins
    i am getting blank (white) pages
    i tried to change the content of the extension.php to use:
    require_once “/var/www/html/racktables/extensions/reports/server-report.php”;
    but still not working all im getting is blank pages.
    ideas?

    thanks in advanced

  • Andrew Hsieh says:

    Dear Sebastian,

    Thanks a lot!
    It works for me in 0.20.0. I can now see these three new pages in Report tab.

    You save me a lot of time by using this.

    Best regards,

    Andrew Hsieh
    2015/02/13

  • RJ says:

    This worked great!

    I managed to add other attributes in the report, but I am having some trouble including the Location Name in it. Can anyone help me with this please?

    Also, is there a way we can do bulk upload of data?

    Best regards,
    RJ

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.