>
      891             </td>
      892             <script type='text/javascript'>
      893                $(document).ready(function() {
      894 
      895                   let am_csrf = "]] .. ntop.getRandomCSRFValue() .. [[";
      896                   $('#btn-add-am-host').click(function(e) {
      897 
      898                      e.preventDefault();
      899                      const data_to_send = {
      900                         action: 'add',
      901                         am_host: ']] .. host["ip"] .. [[',
      902                         threshold: 100,
      903                         granularity: "min",
      904                         measurement: ']] .. icmp .. [[',
      905                         csrf: am_csrf,
      906                      };
      907 
      908                      $.post(`${http_prefix}/lua/edit_active_monitoring_host.lua`, data_to_send)
      909                      .then((data, result, xhr) => {
      910 
      911                         const $alert_message = $('<div class="alert"></div>');
      912                         if (data.success) {
      913                            $alert_message.addClass('alert-success').text(data.message);
      914                            $('#n-container').prepend($alert_message);
      915 
      916                            setTimeout(() => {
      917                               location.reload();
      918                            }, 1000);
      919 
      920                            return;
      921                         }
      922 
      923                         $alert_message.addClass('alert-danger').text(data.error);
      924                         $('#n-container').prepend($alert_message);
      925                         setTimeout(() => {
      926                            $alert_message.remove();
      927                         }, 5000);
      928 
      929                      })
      930                      .fail(() => {
      931                         const $alert_message = $('<div class="alert"></div>');
      932                         $alert_message.addClass('alert-danger').text("]] .. i18n('expired_csrf') .. [[");
      933 
      934                      });
      935 
      936                   });
      937                });
      938             </script>
      939          ]])
      940 
      941             else
      942                 local last_update = am_utils.getLastAmUpdate(host['ip'], icmp)
      943                 local last_rtt = ""
      944 
      945                 if (last_update ~= nil) then
      946                     last_rtt = last_update.value .. " " .. i18n("active_monitoring_stats.msec")
      947                 else
      948                     last_rtt = i18n("active_monitoring_stats.no_updates_yet")
      949                 end
      950 
      951                 print([[
      952             <td colspan="2">
      953                <a href=']] .. ntop.getHttpPrefix() .. [[/lua/monitor/active_monitoring_monitor.lua?am_host=]] ..
      954                           host['ip'] .. [[&measurement=]] .. icmp .. [['>]] .. last_rtt .. [[</a>
      955             </td>
      956             ]])
      957 
      958             end
      959 
      960             print("</tr>")
      961         end
      962 
      963         if (host["active_alerted_flows"] > 0) then
      964             print("<tr><th>" .. i18n("host_details.active_alerted_flows") .. "</th><td colspan=2></li>" ..
      965                       hostinfo2detailshref(host, {
      966                     page = "flows",
      967                     flow_status = "alerted"
      968                 }, "<span id=num_flow_alerts>" .. formatValue(host["active_alerted_flows"]) .. "</span>") ..
      969                       " <span id=flow_alerts_trend></span></td></tr>\n")
      970         end
      971 
      972         if (host.score_behaviour.tot_num_anomalies > 0) the