$section->addInput(new Form_Checkbox('monitor_disable', 'Gateway Monitoring', 'Disable Gateway Monitoring', $pconfig['monitor_disable']))->toggles('.toggle-monitor-ip')->setHelp('This will consider this gateway as always being up'); $group = new Form_Group('Monitor IP'); $group->addClass('toggle-monitor-ip', 'collapse'); if (!$pconfig['monitor_disable']) { $group->addClass('in'); } $group->add(new Form_Input('monitor', null, 'text', $pconfig['gateway'] == $pconfig['monitor'] ? '' : $pconfig['monitor']))->setHelp('Enter an alternative address here to be ' . 'used to monitor the link. This is used for the quality RRD graphs as well as the ' . 'load balancer entries. Use this if the gateway does not respond to ICMP echo ' . 'requests (pings).'); $section->add($group); $section->addInput(new Form_Checkbox('force_down', 'Force state', 'Mark Gateway as Down', $pconfig['force_down']))->setHelp('This will force this gateway to be considered Down'); $section->addInput(new Form_Input('descr', 'Description', 'text', $pconfig['descr']))->setHelp('You may enter a description here for your reference (not parsed).'); // If any of the advanced options are non-default, we will not show the "Advanced" button // and will display the advanced section if (!(!empty($pconfig['latencylow']) || !empty($pconfig['latencyhigh']) || !empty($pconfig['losslow']) || !empty($pconfig['losshigh']) || !empty($pconfig['data_payload']) || isset($pconfig['weight']) && $pconfig['weight'] > 1 || isset($pconfig['interval']) && !($pconfig['interval'] == $dpinger_default['interval']) || isset($pconfig['loss_interval']) && !($pconfig['loss_interval'] == $dpinger_default['loss_interval']) || isset($pconfig['time_period']) && !($pconfig['time_period'] == $dpinger_default['time_period']) || isset($pconfig['alert_interval']) && !($pconfig['alert_interval'] == $dpinger_default['alert_interval']) || isset($pconfig['nonlocalgateway']) && $pconfig['nonlocalgateway'])) { $btnadvanced = new Form_Button('toggle-advanced', 'Advanced options'); $advdflt = true; $btnadvanced->toggles('.advanced-options')->setAttribute('type', 'button'); $btnadvanced->removeClass('btn-primary')->addClass('btn-default'); $section->addInput(new Form_StaticText(null, $btnadvanced)); } $form->add($section); $section = new Form_Section('Advanced'); if (isset($advdflt)) { $section->addClass('collapse'); } $section->addClass('advanced-options'); $section->addInput(new Form_Select('weight', 'Weight', $pconfig['weight'], array_combine(range(1, 30), range(1, 30))))->setHelp('Weight for this gateway when used in a Gateway Group.'); $section->addInput(new Form_Input('data_payload', 'Data Payload', 'number', $pconfig['data_payload'], ['placeholder' => $dpinger_default['data_payload']]))->setHelp('Define data payload to send on ICMP packets to gateway monitor IP.'); $group = new Form_Group('Latency thresholds'); $group->add(new Form_Input('latencylow', 'From', 'number', $pconfig['latencylow'], ['placeholder' => $dpinger_default['latencylow']])); $group->add(new Form_Input('latencyhigh', 'To', 'number', $pconfig['latencyhigh'], ['placeholder' => $dpinger_default['latencyhigh']])); $group->setHelp('Low and high thresholds for latency in milliseconds.