09-19-2019 11:21 AM
Hi!
Simple question, we have two nodes, and in the Alfresco Admin Console, at the very top, there is a field that displays the hostname and IP. I would like that to display the actual hostname and IP of the node This helps us identify which node we are in for testing etc., Any suggestions? The hostname/IP is set in /etc/hosts on the machines, and issuing a 'hostname' command from the terminal returns the correct hostname.
Pic below:
09-19-2019 02:08 PM
Did you try to set alfresco.host variable in alfresco-global.properties ?
Kind regards.
--C
09-19-2019 03:17 PM
The alfresco.host property is only ever used for generating URLs in emails and other utilities using the SysAdminParams utility. It is meant to provide only the "publicly accessible" name of the system, and may therefor be set to the DNS name of a proxy / load balancer, and not reflect the actual, technical hostname.
Edit: This was meant as a reply to the response of cesarista, but it appears that the new platform does not show any sub-threads / relations between replies in the main thread view (only when actually editing the reply again do I see the relation).
09-20-2019 01:39 AM
@afaust wrote:The alfresco.host property is only ever used for generating URLs in emails and other utilities using the SysAdminParams utility. It is meant to provide only the "publicly accessible" name of the system, and may therefor be set to the DNS name of a proxy / load balancer, and not reflect the actual, technical hostname.
Edit: This was meant as a reply to the response of cesarista, but it appears that the new platform does not show any sub-threads / relations between replies in the main thread view (only when actually editing the reply again do I see the relation).
Correct. I think I was too anxious to test the new platform.
Thanks for the explanation Axel.
Regards.
--C.
09-19-2019 02:59 PM
When admin console page is loaded, it extracts the host and ip using utility script. This 'admin-systemsummary.get.html.ftl' loads the admin screen, it includes a js file 'admin-common.lib.js'. This js calls the util script. This is the class which facilitates the util script: https://github.com/Alfresco/alfresco-remote-api/blob/master/src/main/java/org/alfresco/web/scripts/W...
If you open this java class, you will notice that it is using InetAddress.getLocalHost().getHostAddress(); and InetAddress.getLocalHost().getHostName(); to get the details. Ideally these two methods gets the correct information.
Try running these methods as a standalone program on your instance and see if it returns the correct details. InetAddress is however ambigous on linux machines. Linux systems enumerate the loopback network interface the same way as regular LAN network interfaces, but the JDK InetAddress.getLocalHost method does not specify the algorithm used to select the address returned under such circumstances, and will often return the loopback address, which is not valid for network communication.
Refer here for more details: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4665037 and you can follow the workaround. Or you can try extending the unitilty/admin system summary component and try to use 'java.net.NetworkInterface' API for getting the hostname and ip.
09-22-2019 11:11 AM
We talked about this class in the above response: https://github.com/Alfresco/alfresco-remote-api/blob/master/src/main/java/org/alfresco/web/scripts/W... --- It is the utilty class which is facilitating the valiue of host name and IP address in admin console admin summary page.
I also mentioned about the ambigous InetAddress.getLocalHost.getHostName() and InetAddress.getLocalHost().getHostAddress(). Updating the host file did not work in some complex network setups. It is not working in your case as well as you mentioned.
So to test this case, i updated the utility (which is used by admin summary page to get the host and ip) to use network interface api and scan the NIC to find most appropriate IP address.
Here is what i did to make it work:
1- Extend the class WebScriptUtils:
public class WebScriptUtilsExtension extends WebScriptUtils { private static final Logger LOGGER = LoggerFactory.getLogger(WebScriptUtilsExtension.class); public String getHostAddress() { try { LOGGER.info("getHostAddress invoked.."); return getLocalHost().getHostAddress(); } catch (UnknownHostException unknownHostex) { LOGGER.error("Exception occurred while scanning for LAN Host Address", unknownHostex); return "Unknown"; } } public String getHostName() { try { LOGGER.info("getHostName invoked.."); return getLocalHost().getHostName(); } catch (UnknownHostException unknownHostex) { LOGGER.error("Exception occurred while scanning for HOSTName", unknownHostex); return "Unknown"; } } private InetAddress getLocalHost() throws UnknownHostException { try { InetAddress nonlbAddrsCandidate = null; for (final Enumeration<NetworkInterface> netInterfaceEnum = NetworkInterface.getNetworkInterfaces(); netInterfaceEnum.hasMoreElements();) { final NetworkInterface netInterface = netInterfaceEnum.nextElement(); for (final Enumeration<InetAddress> inetAddrsEnum = netInterface.getInetAddresses(); inetAddrsEnum.hasMoreElements();) { final InetAddress inetAddr = inetAddrsEnum.nextElement(); if (!inetAddr.isLoopbackAddress()) { if (inetAddr.isSiteLocalAddress()) { return inetAddr; } else if (nonlbAddrsCandidate == null) { nonlbAddrsCandidate = inetAddr; } } } } if (nonlbAddrsCandidate != null) { return nonlbAddrsCandidate; } final InetAddress jdkProvidedAddress = InetAddress.getLocalHost(); if (jdkProvidedAddress == null) { throw new UnknownHostException("Unexpected null value from InetAddress.getLocalHost() method!"); } return jdkProvidedAddress; } catch (SocketException socketEx) { LOGGER.error("SocketException occurred while scanning for LAN Address", socketEx); throw prepareUnknownHostException(socketEx); } catch (IOException ioex) { LOGGER.error("IOException occurred while scanning for LAN Address", ioex); throw prepareUnknownHostException(ioex); } catch (Exception excp) { LOGGER.error("Exception occurred while scanning for LAN Address", excp); throw prepareUnknownHostException(excp); } } private UnknownHostException prepareUnknownHostException(final Exception excp) { final UnknownHostException unHostEx = new UnknownHostException("Failed to determine LAN address due to: " + excp.getMessage()); unHostEx.initCause(excp); return unHostEx; } }
2- Add this bean definition for extending the above class:
<bean id="utilsScriptExtension" parent="utilsScript" class="com.github.abhinavmishra14.repo.jscript.WebScriptUtilsExtension"> <property name="extensionName"> <value>utils</value> </property> <property name="serviceRegistry"> <ref bean="ServiceRegistry" /> </property> <property name="nodeService" ref="nodeService"/> <property name="repositoryContainer"> <ref bean="webscripts.container" /> </property> </bean>
I have created a sample project here using sdk4: https://github.com/abhinavmishra14/about-share-and-adminconsole-extension/blob/master/README.md
You can have a look at it. You can take reference from this project to make changes in your environment and see if this works for you.
09-23-2019 11:03 AM
Thanks for the detailed response, I feel though that this seems to be overly complicated. We have exact same version of Alfresco running in another environment and did not have to do anything to see the hostname/IP populated in the admin console.
The only difference would be the other system is running Ubuntu 14 and this one is Ubuntu 18. Of course the hostname and /etc/hosts on the machine are configured properly as far as I can tell. I'm fairly certain that the proper information appeared "out of the box" with the older system. Both of these systems have two nodes which are clustered, if I didn't mention that earlier. I will keep digging....
09-19-2019 11:22 PM
Hi,
You may need to change the hostname of your Linux box. Refer this link https://geekflare.com/how-to-change-hostname-in-linux/ or https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-hostname.html for reference.
Best Regards,
Deepak
09-20-2019 02:10 AM
As far as in know this are the values configured in alfresco-global.properties.
Explore our Alfresco products with the links below. Use labels to filter content by product module.