Add addtional column to Host page

I want to add additional column to below image, is that possible ?

Foreman and Proxy versions:
foreman 2.5
Distribution and version:
Ubuntu 18.04 LTS

Thanks in advance

Regards
Neeloj

There is GitHub - theforeman/foreman_column_view: A simple Foreman plugin showcasing Deface for altering the Hosts view but the installation should mention that you can use the installer (foreman-installer --enable-foreman-plugin-column-view from the top of my head). Perhaps that helps you?

1 Like

thank you so much @ekohl , I had below error with that:

#: foreman-installer --enable-foreman-plugin-column-view
2021-07-13 10:57:26 [NOTICE] [root] Loading installer configuration. This will take some time.
2021-07-13 10:57:34 [NOTICE] [root] Running installer with log based terminal output at level NOTICE.
2021-07-13 10:57:34 [NOTICE] [root] Use -l to set the terminal output log level to ERROR, WARN, NOTICE, INFO, or DEBUG. See --full-help for definitions.
2021-07-13 10:57:36 [ERROR ] [root] Parameter foreman-plugin-column-view-columns invalid: Hash value elements are invalid: nil is not a valid hash
Error during configuration, exiting

I install the plugin via apt-get, and its listed in plugins on GUI:

but the file /etc/foreman/plugins/foreman_column_view.yaml is not available, is there any trick or any .example files ?

thanks in advance

check this file /etc/foreman/plugins/foreman_column_view.yaml.example, adapt it, rename it and restart foreman.

This file is available with rpm, not sure with apt flavour. If not, here the sample:

cat /etc/foreman/plugins/foreman_column_view.yaml.example
# Copy this file to foreman_column_view.yaml to enable, then restart Foreman
#
# See tfm-rubygem-foreman_column_view-doc and /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_column_view-0.4.0/README.md for more information
:column_view:
  :architecture:
    :title: Architecture
    :after: last_report
    :content: facts_hash['architecture']
  :uptime:
    :title: Uptime
    :after: architecture
    :content: facts_hash['uptime']
1 Like

thanks for your answer @kobena.

Its available on apt too, but you have to create the file foreman_column_view.yaml its not created by default with .example

What I dont find is how to create linke for the content parameter. I want to link that also to the host.

What do you mean by content parameter ? Content View ? Smart Proxy ?

1 Like

Here I want to have something like :

:content: link_to( facts_hash['architecture']) so the user can click on the architecture and go to next page.

if you need a link_to, not sure you can use facts_hash.

Maybe something like this may works:

:column_view:
  :architecture:
    :title: Architecture
    :after: last_report
	:content: link_to(#{host.architecture}, "https://katello.fqdn/hosts?search=architecture+%3D+#{host.architecture}")

Just check the link to access to your architectures, it seems look like this form:

https://<katello.fqdn>/hosts?search=architecture+%3D+<archirecture>

Sorry I can’t help you more, my ruby ​​knowledge ends here.

1 Like

thank you so much, I edit 2 foreman files! and it works for me and did what I want.
But I have to be carefull when I update the foreman :smiley: ! I have to edit them again!

I’ll check your solution too, its better if that works!

thank you again @kobena

excellent!

In addition, when I have this type of need from a client, I avoid as much as possible adding plugins nor customizing Katello as much as possible. Updates are getting more and more complicated, and I’m never sure I’m going backwards.

Now, I manage this type of need by developing a prometheus exporter and by using Katello APIs, and by making beautiful grafana dashboards. Usually, it does the job if you don’t have 10,000 hosts and thousand of metrics. If this is the case, massively multiprocessing and pagination must be used.

1 Like

You are right, but in this case its for me, it makes a little bit easier, now I dont have to search in another system for the host. Now I can click that in foreman and I go directly to the next system when I click on it.

its on my To-Do-List but I dont have time for it :frowning:

delighted to have been able to exchange with you :wink:

Do not hesitate to close this topic if you consider your problem solved

1 Like

me too @kobena thank you again

of course Ill do that :slight_smile:

Hey.

Can you confirm if this plugin works with foreman 3.8 ?
I installed it successfully - I can see it in Administer/About/Plugins.

Configuration file didn’t exist in my case.
So I did what kobena suggested. I created a file in:
/etc/foreman/plugins/foreman_column_view.yaml

but it seeems this doesn’t work as I can’t see new columns.

@cps86 in foreman 3.7 I still see the new column. try only one column and check the logs too.

1 Like

Hey

Actually I managed to get it work.
However, I have a problem with links. I want to display simple link in my column, e.g.:

:column_view:
  :name2:
    :title: test
    :after: last_report
    :content: link_to("something", "https://www.google.com")

I don’t have any other column in my configuration.
When I try to open the page I get:

**Oops, we're sorry but something went wrong** undefined method link_to(‘something’, “https://www.google.com”)’ for #Host::Managed:0x000055ee65cb44c8`

Does it work for you?

1 Like

Hey @cps86 sorry I forget to say that the links doesn’t work for me too… I leave it because it take to much time… you have to check the parameter options, if you can set _blank to open it in new window or so

@Neeloj I figured it out.

Edit hosts_helper.rb file which was installed with foreman_column_view plugin.
In my case it was in:
/usr/share/foreman/vendor/ruby/2.7.0/gems/foreman_column_view-0.4.0/app/helpers/foreman_column_view/hosts_helper.rb

In the fcv_content method, edit if condition as it follows:

      if content =~ /(.*)\[(.*)\]/
        return host.send($1)[$2.gsub(/['"]/,'')]
      elsif content =~ /^link_to/
        return eval(content)
      else
        return host.send(content)
      end

Final result :grinning: :star_struck:

1 Like

wow that looks good :slight_smile:
can you maybe also post the content of the plugins file :slight_smile: @cps86