• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Add Menu item/Limit hosts returned in Host Management

    Scheduled Pinned Locked Moved
    General
    menu sql
    5
    10
    3.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • TCS_TaylorT
      TCS_Taylor
      last edited by TCS_Taylor

      Good afternoon!

      I am working on creating an inventory webpage for my company, for tracking all of our IT assets.

      I chose to do this using the fog database because 90% of the devices we need to track are laptops and PCs which already exist in fog.

      I have already added a couple of fields to the inventory table in fog, and created a page to view the inventory, add a new record (for items which fog doesn’t manage, like switches and servers) and edit existing records. It’s all working very nicely.

      There are two things I’m having an issue with.

      1. when I go to host management, ALL hosts are being showed (including the hosts not being managed by fog.) I would like to add a WHERE iSystype = Desktop or iSystype = Laptop or iSystype = VM clause in the SQL that the host node uses to only show laptops and desktops and VMs. Items that we enter manually have different iSystype’s set (like switch, phone, router, etc).

      2. I would like to add an icon to the menu which will either display the inventory page in space below the menu bar (like how the built in node icons work in FOG) or just redirect to the inventory page.

      I know that if/when we update our FOG, we’ll likely need to update the schema and any changes we make to the FOG proper files. I am creating very thorough documentation to make an upgrade easier.

      My FOG version is 1.3.4 running on Debian 8

      Any help you can provide would be greatly appreciated!

      Taylor

      TCS_TaylorT 1 Reply Last reply Reply Quote 0
      • TCS_TaylorT
        TCS_Taylor @TCS_Taylor
        last edited by

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • george1421G
          george1421 Moderator
          last edited by

          While I’m not a developer, I would think what you want to do should be done as part of a plugin. The FOG Installer manages the database and it will clobber any edits you make to the database schema. What I would recommend is that you create a new table with your custom fields and then link that to the hosts table via a key field. You can manage that process with a custom plugin.

          I can’t give examples of how to do this, or even point you to a wiki page that explains this. I can say if you ask a developer the best route they will say via a plugin.

          Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

          1 Reply Last reply Reply Quote 0
          • TCS_TaylorT
            TCS_Taylor
            last edited by

            Thanks @george1421 ! I had the same thought initially, but couldn’t find any information on making a plugin.

            The only page I came up with is this

            https://wiki.fogproject.org/wiki/index.php?title=Plugins

            Hopefully one of FOG’s super awesome developers will chime in and point me in the right direction 🙂

            Taylor

            Wayne WorkmanW 1 Reply Last reply Reply Quote 1
            • Wayne WorkmanW
              Wayne Workman @TCS_Taylor
              last edited by Wayne Workman

              @TCS_Taylor Moved this to Developers / general.

              You’ll find the source code for all existing plugins here:
              https://github.com/FOGProject/fogproject/tree/master/packages/web/lib/plugins

              You’ll find an example plugin in there too, which is an effort at demonstrating how they are built.

              I’ll admit openly that I have tried to make plugins in the past and failed, I just couldn’t grasp how all of it tied together.

              But, these guys know this stuff pretty good: @Fernando-Gietz @Tom-Elliott @Lee-Rowlett

              Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
              Daily Clean Installation Results:
              https://fogtesting.fogproject.us/
              FOG Reporting:
              https://fog-external-reporting-results.fogproject.us/

              TCS_TaylorT 1 Reply Last reply Reply Quote 0
              • TCS_TaylorT
                TCS_Taylor @Wayne Workman
                last edited by

                @Wayne-Workman Thanks much! I’ll take a look at that code today 🙂

                1 Reply Last reply Reply Quote 0
                • TCS_TaylorT
                  TCS_Taylor
                  last edited by TCS_Taylor

                  @Wayne-Workman - I’m in the same boat as you, I have played with the plugin code, and can’t figure it out. I’m pretty green when it comes to PHP though. At this point, I have made a new table (inventoryexpanded) to store ALL inventory information (both the inventory information that FOG already manages, as well as the bits that I want to track that FOG doesn’t track). I have a python script that runs every 5 minutes and does a one way sync from the FOG tables to the inventoryexpanded table. Then the php pages that edit or create new records update the FOG tables upon execution.

                  I will update this thread with more information on schemas and code once I have completed the project, in case someone wants to use my code, or expand on my ideas…

                  At this point, the only thing I’m missing is an icon to link from the FOG menu to the inventory_expanded.php page.

                  I can’t figure out for the life of me how to accomplish this. I was hoping it would be as easy as making a dummy plugin that just creates the icon and link, but I failed completely at attempting that.

                  Any help/assistance/suggestions you all can provide would be greatly appreciated!

                  Thanks much,

                  Taylor

                  1 Reply Last reply Reply Quote 0
                  • S
                    Sebastian Roth Moderator
                    last edited by Sebastian Roth

                    @TCS_Taylor Sorry for not replying earlier. I’ve had this open in my browser for days after my holiday as I wanted to look into it and give you some hints. But too many other issues kept popping up.

                    Linking to your inventory page can be done in about 2 minutes by using hooks. Edit /var/www/fog/lib/hooks/submenudata.hook.php, set $active = true; and adjust the links a little further down in the code. I know this is not adding an icon (find the links in the left menu bar in the Hosts page) but it was a real quick win.

                    Now to add an icon to the main menu you can use hooks just as well. Took me a bit longer, but here you are. Just download this, put in the hooks directory and activate as described above. Will be added to the official FOG code soon.

                    So now it’s your turn again. There are a lot more hooks and I am sure you can filter the host listing by using a hook as well. Start by looking throughlib/pages/hostmanagementpage.class.php and keep your eyes open for those $HookManager->processEvent calls to find out about all the hooks there are.

                    Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                    Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                    1 Reply Last reply Reply Quote 0
                    • Tom ElliottT
                      Tom Elliott
                      last edited by

                      Yeah, me too, sorry about not responding sooner.

                      I’m usually very helpful but been working on getting a new version of FOG up and tested. My main focus has been on tweaking performance and getting the display working properly.

                      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                      Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                      Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                      1 Reply Last reply Reply Quote 1
                      • Tom ElliottT
                        Tom Elliott
                        last edited by

                        What I like to do is take a current working plugin, make a copy, and adjust for the needs.

                        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post

                        153

                        Online

                        12.0k

                        Users

                        17.3k

                        Topics

                        155.2k

                        Posts
                        Copyright © 2012-2024 FOG Project