addons:hotlink-connect

Hotlink Connect

Author Jeremy Laidman
Compatibility Xymon 4.x
Requirements none
Download None
Last Update 2015-09-29

This is an enhancement to the footer template file, to auto-hotlink hostnames to support click-to-connect for ssh://, telnet//: and similar URLs.

An alternative is to create create “notes” files for servers (by creating a file in $XYMONVAR/www/notes/ called hostname.html) containing the links you require.

If ssh:// or rdp:// links don't work for you, please check out this link describing how to set them up and use them.

  1. Copy the file into xymonbodyfooter.cfg alongside xymonserver.cfg.
  2. In xymonserver.cfg, set: XYMONBODYFOOTER=“file:$XYMONHOME/etc/xymonbodyfooter.cfg”
  3. Create COMMENT or DESCR strings in the form “…(connect: ssh, rdp, telnet)…”

By default, the “(connect …)” text will be removed, but this can be disabled by changing the replaceConnect value from 1 to 0 near the start of the file.

Show Code ⇲

Hide Code ⇱

xymonbodyfooter.cfg
<!--
  -- Adds hotlinks to connect to the server.  To use:
  -- Copy this into the file xymonbodyfooter.cfg alongside xymonserver.cfg.
  -- In xymonserver.cfg, set: XYMONBODYFOOTER="file:$XYMONHOME/etc/xymonbodyfooter.cfg"
  -- Create COMMENT or DESCR strings in the form "...(connect: ssh, rdp, telnet)..."
  -->
 
<!-- we pull in jquery and use it to manipulate the hostname to add links -->
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
        var replaceConnect=1;   // replace (connect:...) string, zero to disable
        jQuery('.line span').replaceWith(function() {
                var title=jQuery(this).attr("title");
                if (title == null) { return; }; // no title? nothing to do
 
                var url = jQuery.trim(jQuery(this).text());
                var servertext = jQuery.trim(jQuery(this).text());
 
                var svclist=[];
                var titlematch=title.match(/^(.*)\s*\(connect:\s*(.*)\)\s*(.*)/);
                if (titlematch != null) {
                        svclist=titlematch[2].split(/\s*,\s*/);
                        if (replaceConnect == 1) { title=titlematch[1]+titlematch[3]; };
                };
 
                var returnstr = "";
                for (var i=0; i < svclist.length; i++) {
                        svc=svclist[i];
                        // webby URLs open in new window
                        returnstr += '<span title="connect with '+svc+'">';
                        returnstr += ' <a href="' + svc + '://' + url + '"';
                        if (svc == 'http' || svc == 'https') { returnstr += '" target="_blank"'; };
                        returnstr += '>' + svc + '</a>';
                        returnstr += '</span>';
                };
                return '<span title="'+title+'">' + servertext + '</span>' + '<font size="-2">' + returnstr + '</font>';
        });
</script>
  • 2015-09-29
    • Initial release
  • addons/hotlink-connect.txt
  • Last modified: 2015/09/29 04:14
  • by jez