-
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.
-
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).
-
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
-
-
This post is deleted! -
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.
-
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
-
@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/pluginsYou’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
-
@Wayne-Workman Thanks much! I’ll take a look at that code today
-
@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
-
@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 through
lib/pages/hostmanagementpage.class.php
and keep your eyes open for those$HookManager->processEvent
calls to find out about all the hooks there are. -
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.
-
What I like to do is take a current working plugin, make a copy, and adjust for the needs.