<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>M/Monit Admin | Hosts</title>
    <meta name="theme-color" content="#3D3E40">
    <meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-title" content="M/Monit" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
    <link rel="apple-touch-icon" href="../../img/apple-touch-icon.png"/>
    <link rel="manifest" href="../../img/manifest.webmanifest">
    <script src="../../lib/js/appearance.js"></script>
    <link rel="stylesheet" href="../../lib/css/styles.css?version=430">
</head>
<body>
    <div id="wrap">
        <div id="fixed-header">
            <div id="fake-status-bar"></div>
            <div id="header">
                <div id="nav">
                    <a id="logo" target="webapp" href="../../"></a>
                    <a id="logout" title="Logout" target="webapp" href="../../login/logout.csp"></a>
                    <ul id="menu">
                        <li>
                            <a target="webapp" href="../../index.csp"><span>Dashboard</span></a>
                        </li>
                        <li>
                            <a target="webapp" href="../../status/hosts/"><span>Status</span></a>
                        </li>
                        <li>
                            <a target="webapp" href="../../reports/analytics/"><span>Reports</span></a>
                            <ul>
                                <li><a target="webapp" href="../../reports/analytics/">Analytics</a></li>
                                <li><a target="webapp" href="../../reports/uptime/">Uptime</a></li>
                                <li><a target="webapp" href="../../reports/events/">Events</a></li>
                            </ul>
                        </li>
                        <li class="active">
                            <?cs if:#Request.Param.IsAdmin ?>
                            <a target="webapp" href="../../admin/general/"><span>Admin</span></a>
                            <ul>
                                <li><a target="webapp" href="../../admin/general/">General</a></li>
                                <li><a target="webapp" href="../../admin/hosts/">Hosts</a></li>
                                <li><a target="webapp" href="../../admin/groups/">Groups</a></li>
                                <li><a target="webapp" href="../../admin/users/">Users</a></li>
                                <li><a target="webapp" href="../../admin/roles/">Roles</a></li>
                                <li><a target="webapp" href="../../admin/alerts/">Alerts</a></li>
                                <li><a target="webapp" href="../../admin/settings/">Settings</a></li>
                            </ul>
                            <?cs else ?>
                            <a target="webapp" href="../../admin/users/edit?id=<?cs var:Request.Param.RemoteUserId ?>"><span>Profile</span></a>
                            <?cs /if ?>
                        </li>
                        <li id="logout-phone"><a target="webapp" href="../../login/logout.csp">Logout</a></li>
                    </ul>
                </div> <!-- nav -->
            </div><!-- header -->
        </div><!-- fixed-header -->
        <div id="main">
<?cs if:#Request.Param.IsAdmin ?>
            <ul class="breadcrumb">
                <li><a href="../general/">Admin</a> <span class="divider">/</span></li>
                <li><a href=".">Hosts</a> <span class="divider">/</span></li>
                <li class="active">Edit</li>
            </ul>
            <div id="title">
                <a href="#" id="help" class="help-button" title="Help" data-help="#helpbox"></a>
                <h1>
                    Edit host
                </h1>
            </div>
            <form data-bind="submit:updateHost" id="theform" autocomplete="off">
                <input type="hidden" id="CSRFToken" name="CSRFToken" value="<?cs var:Request.CSRFToken ?>">
                <input type="hidden" data-bind="value:sslout" name="sslout">
                <div class="row-fluid">
                    <div class="span8">
                        <ul class="tableView">
                            <li data-bind="validationElement:hostname">
                                <span>Host Name</span>
                                <span class="accessory">
                                    <input placeholder="Descriptive name..."
                                    data-bind="value:hostname, valueUpdate: 'afterkeydown'"
                                    name="hostname"
                                    />
                                </span>
                            </li>
                            <li class="switch-button">
                                <input  name="keepname" type="checkbox" data-bind="checked: keepname" />
                                <label data-bind="event: {vclick:toggleKeepName}" for="keepname">Persistent hostname</label>
                            </li>
                        </ul>
                        <h3>Host Description</h3>
                        <ul class="tableView">
                            <li  data-bind="validationElement:description">
                                <textarea
                                class="accessory-color"
                                placeholder="Enter a host description..."
                                data-bind="text:description"
                                name="description" rows="2"
                                maxlength="1024"
                                ></textarea>
                            </li>
                        </ul>
                    </div> <!-- span8 -->
                </div> <!-- row-fluid -->
                <div class="row-fluid">
                    <div class="span8">
                        <ul class="tableView">
                            <li>
                                <span>Host LED</span>
                                <span class="accessory">
                                    <img data-bind="attr: { src: '../../img/led' + led() + '.png', title: 'host state' }">
                                </span>
                            </li>
                            <li>
                                <span>Host Status</span>
                                <span class="accessory">
                                    <div class="select-button">
                                        <select name="status" data-bind="value: status, foreach: availableHostStatuses">
                                            <option data-bind="text: $data, attr: {value: $index()}"></option>
                                        </select>
                                    </div>
                                </span>
                            </li>
                        </ul>
                    </div> <!-- span8 -->
                </div> <!-- row-fluid -->
                <div class="row-fluid">
                    <div class="span8">
                        <ul class="tableView">
                            <li>
                                <span>Created</span>
                                <span class="accessory disabled" data-bind="text:created_at"></span>
                            </li>
                            <li>
                                <span>Last updated</span>
                                <span class="accessory disabled" data-bind="text:lastmodified"></span>
                            </li>
                        </ul>
                    </div> <!-- span8 -->
                </div> <!-- row-fluid -->
                <div class="row-fluid">
                    <div class="span8">
                        <ul class="tableView">
                            <li>
                                <span>Monit Version</span>
                                <span class="accessory disabled" data-bind="text:monitversion"></span>
                            </li>
                            <li>
                                <span>Monit ID</span>
                                <span class="accessory disabled" data-bind="text:monitid"></span>
                            </li>
                        </ul>
                    </div> <!-- span8 -->
                </div> <!-- row-fluid -->
                <div class="row-fluid">
                    <div class="span8">
                        <h3>Monit Network Settings</h3>
                        <ul class="tableView">
                            <li data-bind="validationElement:monituser">
                                <span>Username</span>
                                <span class="accessory">
                                    <input placeholder="Username..."
                                    data-bind="value:monituser, valueUpdate: 'afterkeydown'"
                                    name="monituser" autocomplete="off"
                                    />
                                </span>
                            </li>
                            <li data-bind="validationElement:monitpassword">
                                <span>Password</span>
                                <span class="accessory">
                                    <input placeholder="Password..."
                                    data-bind="value:monitpassword, valueUpdate: 'afterkeydown'"
                                    name="monitpassword"
                                    type="password" autocomplete="new-password"
                                    />
                                </span>
                            </li>
                            <li>
                                <span>Address</span><span class="accessory disabled" data-bind="text:ipaddrin"></span>
                            </li>
                            <li>
                                <span>Port</span>
                                <span class="accessory disabled" data-bind="text: portin() + (sslin() ? ' (SSL)' : '')"></span>
                            </li>
                            <li class="list" data-bind="click:toggleNetworkOverride, css:enableNetworkOverride() ? 'active' : ''">
                                <span>Override network settings</span>
                                <span class="accessory"></span>
                            </li>
                            <!-- NETWORK OVERRIDE -->
                            <li class="insertView">
                                <ul class="tableView dark" data-bind="slideVisible:enableNetworkOverride()">
                                    <li>
                                        <span>Address</span>
                                        <span class="accessory">
                                            <input placeholder="IP or name..."
                                            data-bind="value:ipaddrout"
                                            name="ipaddrout"
                                            />
                                        </span>
                                    </li>
                                    <li data-bind="validationElement:portout">
                                        <span>Port</span>
                                        <span class="accessory">
                                            <input placeholder="Port number..."
                                            data-bind="value:portout, valueUpdate: 'afterkeydown'"
                                            name="portout"
                                            />
                                        </span>
                                    </li>
                                    <li class="switch-button">
                                        <input  name="keepname" type="checkbox" data-bind="checked: ssl" />
                                        <label title="Turn on if Monit is using SSL" data-bind="event: {vclick:toggleSSL}" for="keepname">Enable SSL</label>
                                    </li>
                                </ul>
                            </li> <!-- END NETWORK OVERRIDE -->
                            <li id="test-connection">
                                <span><a href="#" data-bind="click:test">Connection status</a></span>
                                <span class="accessory">
                                    <span class="led-button" id="connection-status" data-bind="popover:{content: connectionInfo, placement:popoverplacement}, css:connectionStatus"></span>
                                </span>
                            </li>
                        </ul>
                    </div> <!-- span8 -->
                </div> <!-- row-fluid -->
                <div class="row-fluid">
                    <div class="span8">
                        <ul class="tableView">
                            <li>
                                <span class="text accessory-color">
                                    A Monit agent has to send status update within a certain timeframe. Acceptable report
                                    skew gives the number of Monit cycles M/Monit will wait before reporting the host as
                                    down. Default value is <span class="text" data-bind="text:defaultskew"></span>. You might want to correlate this with this host's poll cycle length
                                    which is <span class="badge" data-bind="text:poll"></span> seconds.
                                </span>
                            </li>
                            <li>
                                <span>Acceptable report skew</span>
                                <span class="accessory">
                                    <input data-bind="value:skew" name="skew" type="number" min="1" max="999999" style="width:70px;margin-top:-1px;" /> cycles
                                </span>
                            </li>
                        </ul>
                    </div> <!-- span8 -->
                </div> <!-- row-fluid -->
                <!-- Buttons -->
                <div class="row-fluid" id="actions">
                    <div class="span6">
                        <button class="btn btn-primary btn-inverse" data-bind="disable:hasErrors(), visible:modified, click:updateHost" type="submit">Update</button>
                        <button class="btn" data-bind="click:cancel">Cancel</button>
                    </div> <!-- span10 -->
                    <div class="span2">
                        <button class="btn toright" data-target="#confirmDelete" data-toggle="modal" >Delete</button>
                    </div> <!-- span2 -->
                </div> <!-- row-fluid -->
            </form>
<?cs /if ?>
        </div> <!-- main -->
    </div> <!-- wrap -->
    <div id="footer">
        <div class="toleft hidden-phone">Logged in as <?cs var:Request.RemoteUser ?></div>
        <div class="toright hidden-phone">
            <ul class="piped">
                <li>Copyright &copy; 2024 <a href="https://tildeslash.com/">Tildeslash</a>. All Rights Reserved.</li>
                <li><a href="https://mmonit.com/">M/Monit</a></li>
                <li><a href="https://mmonit.com/monit/">Monit</a></li>
                <li><a href="https://mmonit.com/wiki/">Wiki</a></li>
            </ul>
        </div>
        <div id="copy" class="visible-phone">Copyright &copy; 2024 <a href="https://tildeslash.com/">Tildeslash</a>. All Rights Reserved.</div>
    </div> <!-- footer -->
    <!-- Hidden -->
    <!-- Confirm Delete Dialog -->
    <div id="confirmDelete" class="modal hide">
        <div class="modal-body">
            <h2>Delete <span class="text-error" data-bind='text:hostname'></span>?</h2>
            <p>Are you sure you want to remove this host from the system? All statistics and events for the host will be removed as well. There is no undo.</p>
        </div>
        <div class="modal-footer">
            <button class="btn" data-dismiss="modal">Cancel</button>
            <button class="btn btn-danger" data-dismiss="modal" data-bind="click:$root.deleteHost">Delete</button>
        </div>
    </div>

    <div id="helpbox">
        <div class="title"><h2>Host Help</h2></div>
        <div class="content paragraphify">
            <p>
                Use this page to edit a Host running a Monit agent.
            </p>
            <h3>
                Host Name
            </h3>
            <p>
                The Host Name field is a descriptive name which is used in various places in M/Monit to refer to the Host. The first time Monit
                reports in, a new Host entry is created and the Host Name is set to the hostname reported by Monit. This name is usually the DNS
                name of the host or its IP-address. If the hostname later is changed in DNS the host name will automatically be updated in M/Monit
                after Monit is restarted on the given host.
            </p>
            <p>
                If you change the host name yourself, the <strong>persistent</strong> hostname switch is turned on and Monit will no longer overwrite the host name
                automatically. This can be useful if you want to use and <em>keep</em> a descriptive name for the host, such as "database server #1". To reenable automatic host name
                updates, just turn off the Persistent hostname switch.
            </p>
            <h3>
                Monit ID
            </h3>
            <p>
                Each Monit instance is identified by a unique ID, by default stored in the file, <code>$HOME/.monit.id</code> on the host running Monit. This
                file is automatically created at startup by Monit if it does not exist. Care should be taken not to delete or change this file as the ID is used
                to pair messages from Monit with a host entry in M/Monit.
            </p>
            <p>
                A new host is automatically created in M/Monit by a message from Monit if and only if the ID embedded in the message is new and unique, otherwise
                M/Monit will use the ID to find the host in its database and update the host status.
            </p>
            <h3>
                Host LED
            </h3>
            <p>
                The LED icon represents the Host's Error State as reported by Monit. While the Host Status below is associated, it specifically represents
                the Host's reporting state. The Host LED incorporates both the reporting state and any additional error states where:
                <ul class="led">
                    <li class="red">
                        Error - Either the host did not report in or all services are down
                    </li>
                    <li class="orange">
                        Warning - At least one service is down or in unmonitored mode.
                    </li>
                    <li class="green">
                        OK - All services are up and running
                    </li>
                    <li class="grey">
                        Host is in Ignored or in Inactive state.
                    </li>
                </ul>
            </p>
            <h3>
                Host Status
            </h3>
            <p>
                A Host can be in one of three states:
            </p>
            <ul>
                <li>
                    <em>Active</em> - When Monit starts, it automatically activates itself in M/Monit by sending a start event message. M/Monit expects
                    periodic status reports from active hosts. If a host does not send a status report within a certain time frame, it is marked as down
                    and an alert is generated by M/Monit. See also <em>skew</em> below.
                </li>
                <li>
                    <em>Inactive</em> - If Monit is stopped correctly, it automatically deactivates itself by sending a stop event message to M/Monit.
                </li>
                <li>
                    <em>Ignored</em> - The Ignored state can be used to temporarily suppress all events from Monit. For example, if you are going to
                    perform maintenance work on a host and you expect Monit to issue many alerts, set the Host to Ignored state to disregard events sent
                    by Monit for the duration of the work.
                </li>
            </ul>
            <h3>
                Network settings
            </h3>
            <p>
                The fields <strong>Monit Network Settings</strong>, are used to uniquely specify connection to and from Monit.
            </p>
            <p>
                Monit <strong>username</strong> and <strong>password</strong> are the credentials used for Monit authentication.
            </p>
            <p>
                The <strong>address</strong> is either the IP-address or the hostname of the host Monit is running on. M/Monit will use this
                address to connect to Monit and issue actions when you click a button in the host/detail page. The address is read-only and
                managed by Monit. Dynamic changes (such as DHCP lease) will automatically update the host settings in M/Monit. If Monit is
                using SSL and the address is an IP-address and not a DNS name (FQDN) then see [Override network settings] below.
            </p>
            <p>
                Monit <strong>port</strong> number is the HTTP port the Monit agent is setup with on the host (usually 2812). The port number
                is also read-only and automatically updated by Monit. If SSL is used, you'll find this indicated in parenthesis after the port
                number.
            </p>
            <p>
                <strong>Override network settings</strong>: If the Monit Host is using SSL or if the Monit Host is behind a NAT or a Proxy and
                M/Monit must use a different IP-address and port number to reach Monit, click <em>[Override network settings]</em> and specify
                the outbound <em>IP-address</em> or the Host's Fully Qualified Domain Name (<em>FQDN</em>), <em>port</em> number and whether
                <em>SSL</em> should be used by M/Monit to reach Monit. If <strong>SSL</strong> is used, enter the Host's DNS name (FQDN) instead
                of the IP-address, otherwise the SSL certificate Host Name verification might fail.

                Override settings takes precedence and will be used
                instead of Monit's reported values. If Monit's configuration is changed later, you will need to update the override settings
                manually.
            </p>
            <p>
                <b class="accent-color">Connection Status</b> shows the connection status <em>to</em> Monit, using the current network settings. The check
                is performed automatically when this page opens, but you can also run the test by clicking the Connection Status link. This status is
                different from Host LED and Host Status above, which represent the inbound Host status from Monit. Connection Status represents the
                outbound connection status from M/Monit to Monit.
            </p>
            <h3>
                Acceptable report skew
            </h3>
            <p>
                Monit has to send status update within a certain timeframe. Acceptable report skew specify the number of Monit cycles M/Monit
                will wait before reporting the Host as down. The default value is 3 Monit poll cycles. If Monit is setup with a short poll
                cycle, e.g. 5 seconds or if Monit is verifiable up, but for some reason is slow to send reports it can be useful to increase
                the skew value to avoid getting false alerts because Monit did not report in on time. You can change the default skew value in the
                <a href="../../admin/settings/">Settings</a> page and it will apply to <em>new</em> Hosts that register in M/Monit.
            </p>
        </div> <!-- content -->
    </div> <!-- helpbox -->
    <script src="../../lib/f/jquery/jquery.js?version=430"></script>
    <script src="../../lib/f/jquery/jquery.mobile.vmouse.js?version=430"></script>
    <script src="../../lib/js/webapp.js?version=430"></script>
    <script src="../../lib/f/jquery/jquery.getUrlParam.js?version=430"></script>
    <script src="../../lib/f/twbootstrap/js/bootstrap.js?version=430"></script>
    <script src="../../lib/f/knockout/knockout.js?version=430"></script>
    <script src="../../lib/f/knockout/knockout-mapping.js?version=430"></script>
    <script src="../../lib/f/knockout/knockout.validation.js?version=430"></script>
    <script src="../../lib/js/tableview.js?version=430"></script>
    <script src="../../lib/js/error.js?version=430"></script>
    <script src="../../lib/js/help.js?version=430"></script>
    <script src="../../lib/js/csrf.js?version=430"></script>
    <script src="../../assets/admin/admin_hosts_crud.js?version=430"></script>
</body>
</html>
