Project

General

Profile

« Previous | Next » 

Revision f4f60018

Added by Renato Botelho over 9 years ago

Remove calculated options

View differences:

src/usr/local/www/system_gateways_edit.php
103 103
	$pconfig['weight'] = $a_gateways[$id]['weight'];
104 104
	$pconfig['interval'] = $a_gateways[$id]['interval'];
105 105
	$pconfig['avg_delay_samples'] = $a_gateways[$id]['avg_delay_samples'];
106
	$pconfig['avg_delay_samples_calculated'] = isset($a_gateways[$id]['avg_delay_samples_calculated']);
107 106
	$pconfig['avg_loss_samples'] = $a_gateways[$id]['avg_loss_samples'];
108
	$pconfig['avg_loss_samples_calculated'] = isset($a_gateways[$id]['avg_loss_samples_calculated']);
109 107
	$pconfig['avg_loss_delay_samples'] = $a_gateways[$id]['avg_loss_delay_samples'];
110
	$pconfig['avg_loss_delay_samples_calculated'] = isset($a_gateways[$id]['avg_loss_delay_samples_calculated']);
111 108
	$pconfig['interface'] = $a_gateways[$id]['interface'];
112 109
	$pconfig['friendlyiface'] = $a_gateways[$id]['friendlyiface'];
113 110
	$pconfig['ipprotocol'] = $a_gateways[$id]['ipprotocol'];
......
498 495
		$gateway['interval'] = $_POST['interval'];
499 496

  
500 497
		$gateway['avg_delay_samples'] = $_POST['avg_delay_samples'];
501
		if ($_POST['avg_delay_samples_calculated'] == "yes" || $_POST['avg_delay_samples_calculated'] == "on") {
502
			$gateway['avg_delay_samples_calculated'] = true;
503
		}
504

  
505 498
		$gateway['avg_loss_samples'] = $_POST['avg_loss_samples'];
506
		if ($_POST['avg_loss_samples_calculated'] == "yes" || $_POST['avg_loss_samples_calculated'] == "on") {
507
			$gateway['avg_loss_samples_calculated'] = true;
508
		}
509

  
510 499
		$gateway['avg_loss_delay_samples'] = $_POST['avg_loss_delay_samples'];
511
		if ($_POST['avg_loss_delay_samples_calculated'] == "yes" || $_POST['avg_loss_delay_samples_calculated'] == "on") {
512
			$gateway['avg_loss_delay_samples_calculated'] = true;
513
		}
514 500

  
515 501
		$gateway['descr'] = $_POST['descr'];
516 502
		if ($_POST['monitor_disable'] == "yes") {
......
629 615
if ($input_errors)
630 616
	print_input_errors($input_errors);
631 617

  
632
?>
633
<script type="text/javascript">
634
//<![CDATA[
635
var systemGatewaysEditRecalculate = function(){
636
	var interval = $('#interval')[0].value;
637

  
638
	$('input[name$=_calculated]').each(function (idx, c){
639
		c = $(c);
640
		i = $(c.parents('.form-group').find('input[type=number]')[0]);
641

  
642
		c.prop('disabled', interval==0);
643

  
644
		if (interval==0)
645
			c.prop('checked', false);
646

  
647
		if (!c.prop('checked'))
648
			return i.prop('readonly', false);
649

  
650
		switch (i.attr('name'))
651
		{
652
			case 'avg_delay_samples':
653
				// How many replies should be used to compute average delay
654
				// for controlling "delay" alarms.
655
				// Calculate a reasonable value based on gateway probe interval and RRD 1 minute average graph step size (60).
656
				i.attr('value', Math.round(60 * (1/6) / Math.pow(interval, 0.333)));
657
			break;
658

  
659
			case 'avg_loss_samples':
660
				// How many probes should be used to compute average loss.
661
				// Calculate a reasonable value based on gateway probe interval and RRD 1 minute average graph step size (60).
662
				i.attr('value', Math.round(60 / interval));
663
			break;
664

  
665
			case 'avg_loss_delay_samples':
666
				// The delay (in samples) after which loss is computed
667
				// without this delays larger than interval would be treated as loss.
668
				// Calculate a reasonable value based on gateway probe interval and RRD 1 minute average graph step size (60).
669
				i.attr('value', Math.round(60 * (1/3) / interval));
670
			break;
671
		}
672

  
673
		i.prop('readonly', true);
674
	});
675
};
676

  
677
events.push(function(){
678
	$('#interval').on('change', systemGatewaysEditRecalculate);
679
	$('input[name$=_calculated]').on('change', systemGatewaysEditRecalculate);
680

  
681
	systemGatewaysEditRecalculate();
682
});
683
//]]>
684
</script>
685
<?php
686

  
687 618
$form = new Form;
688 619

  
689 620
/* If this is a system gateway we need this var */
......
910 841
		'max' => 100
911 842
	]
912 843
));
913
$group->add(new Form_Checkbox(
914
	'avg_delay_samples_calculated',
915
	null,
916
	'Use calculated value.',
917
	$pconfig['avg_delay_samples_calculated']
918
));
919 844
$group->setHelp('How many replies should be used to compute average delay for '.
920 845
	'controlling "delay" alarms? Default is %d.',
921 846
	[$dpinger_default['avg_delay_samples']]);
......
932 857
		'max' => 1000
933 858
	]
934 859
));
935
$group->add(new Form_Checkbox(
936
	'avg_loss_samples_calculated',
937
	null,
938
	'Use calculated value.',
939
	$pconfig['avg_loss_samples_calculated']
940
));
941 860
$group->setHelp('How many probes should be useds to compute average packet loss? '.
942 861
	'Default is %d.',
943 862
	[$dpinger_default['avg_loss_samples']]);
......
954 873
		'max' => 200
955 874
	]
956 875
));
957
$group->add(new Form_Checkbox(
958
	'avg_loss_delay_samples_calculated',
959
	null,
960
	'Use calculated value.',
961
	$pconfig['avg_loss_samples_calculated']
962
));
963 876
$group->setHelp('The delay (in qty of probe samples) after which loss is '.
964 877
	'computed. Without this, delays longer than the probe interval would be '.
965 878
	'treated as packet loss.  Default is %d.',

Also available in: Unified diff