View | Details | Raw Unified | Return to bug 13425
Collapse All | Expand All

(-)netams-3.4.0rc2.orig/cgi-bin/admin/netams.cgi (-2 / +2 lines)
Lines 55-62 Link Here
55
$result=netams_read();
55
$result=netams_read();
56
@result=split("\n", $result);
56
@result=split("\n", $result);
57
57
58
$netams_version=substr($result[0], 14, 32);
58
$netams_version=$result[0];
59
$netams_version=substr($netams_version, 0, index($netams_version, " root"));
59
$netams_version=~s/^NeTAMS\s(.+)\s\S+\@.*$/$1/;
60
$run_time=substr($result[1], 10);
60
$run_time=substr($result[1], 10);
61
print "";
61
print "";
62
################################################
62
################################################
(-)netams-3.4.0rc2.orig/cgi-bin/admin/policy.cgi (-13 / +6 lines)
Lines 17-29 Link Here
17
		$name=$cgi->param("name_$oid");
17
		$name=$cgi->param("name_$oid");
18
		$tgt=$cgi->param("tgt_$oid");
18
		$tgt=$cgi->param("tgt_$oid");
19
		if ($name ne "" and $tgt ne "") {
19
		if ($name ne "" and $tgt ne "") {
20
			netams_send("service processor");
20
			my @cmds = ("enable","configure terminal","service processor");
21
			$result1=netams_read();
21
			if ($cgi->param("set") ne "") { push(@cmds,"policy oid $oid name $name target $tgt"); }
22
			if ($cgi->param("set") ne "") { netams_send("policy oid $oid name $name target $tgt"); }
22
			elsif ($cgi->param("delete") ne "") { push(@cmds,"no policy name $name"); }
23
			elsif ($cgi->param("delete") ne "") { netams_send("no policy name $name"); }
23
			push(@cmds,("exit","exit","disable"));
24
			$result=netams_read();
24
			netams_cmds(@cmds);
25
			netams_send("exit"); 
26
			$result1=netams_read();
27
		}
25
		}
28
	}
26
	}
29
27
Lines 31-42 Link Here
31
		$pol_name=$cgi->param("name_new");
29
		$pol_name=$cgi->param("name_new");
32
		$pol_tgt=$cgi->param("tgt_new");
30
		$pol_tgt=$cgi->param("tgt_new");
33
		if ($pol_name ne "" and $pol_tgt ne "") {
31
		if ($pol_name ne "" and $pol_tgt ne "") {
34
			netams_send("service processor");
32
			netams_cmds(("enable","configure terminal","service processor","policy name $pol_name target $pol_tgt","exit","exit","disable"));
35
			$result1=netams_read();
36
			netams_send("policy name $pol_name target $pol_tgt");
37
			$result=netams_read();
38
			netams_send("exit"); 
39
			$result1=netams_read();
40
		}
33
		}
41
	}
34
	}
42
	
35
	
(-)netams-3.4.0rc2.orig/cgi-bin/admin/quota.cgi (-63 / +41 lines)
Lines 7-80 Link Here
7
require "netams.cgi";
7
require "netams.cgi";
8
8
9
	$toppane= "<b>Quotas Management</b>"; 
9
	$toppane= "<b>Quotas Management</b>"; 
10
	
10
11
	netams_send("show quota list");
11
	netams_send("show quota list");
12
	$result=netams_read(); @s_units=split("\n", $result);
12
	$result=netams_read(); @s_units=split("\n", $result);
13
	shift @s_units;
13
	shift @s_units;
14
	shift @s_units;
14
	$p1="<b>Here the list of units with quota management ACTIVE:</b><br>";
15
	$p1="<b>Here the list of units with quota management ACTIVE:</b><br>";
15
16
16
	@s=split(/ /, $s_units[0]); %pairs=@s;
17
	foreach $s (@s_units) {
17
	foreach $s (keys %pairs) {
18
		@s=split(/\s/, $s);
18
		$p1.="<a href='$url?action=quotas&oid=".$pairs{$s}."'>".$s."</a> ";
19
		$pairs{$s[0]}=$s[1];
20
		$p1.="<a href='$url?action=quotas&oid=".$s[1]."'>".$s[0]."</a> ";
19
		}
21
		}
20
	$p1 .= "<br><hr>";
22
	$p1 .= "<br><hr>";
21
23
22
	if (($oid ne "000000") and (%pairs > 0) ) {
24
	if (($oid ne "000000") and (%pairs > 0)) {
23
25
24
		# first process something if submitted
26
		# first process something if submitted
25
		if ($cgi->param("act") ne "") {
27
		if ($cgi->param("act") ne "") {
26
			netams_send("service quota 0");
28
			netams_cmds(("enable","configure terminal","service quota","set oid $oid active","exit","exit","disable"));
27
			$result=netams_read();
28
			netams_send("set oid $oid active");
29
			$result=netams_read();
30
			netams_send("exit"); $result=netams_read();
31
			}
29
			}
32
		
30
		
33
		if ($cgi->param("deact") ne "") {
31
		if ($cgi->param("deact") ne "") {
34
			netams_send("service quota 0");
32
			netams_cmds(("enable","configure terminal","service quota","set oid $oid inactive","exit","exit","disable"));
35
			$result=netams_read();
36
			netams_send("set oid $oid inactive");
37
			$result=netams_read();
38
			netams_send("exit"); $result=netams_read();
39
			}
33
			}
40
		
34
		
41
		if ($cgi->param("soft") ne "") {
35
		if ($cgi->param("soft") ne "") {
42
			netams_send("service quota 0");
43
			$result=netams_read();
44
			$soft_val=$cgi->param("soft_val");
36
			$soft_val=$cgi->param("soft_val");
45
			if ($soft_val > -1 and $soft_val <101) {
37
			if ($soft_val > -1 and $soft_val <101) {
46
				netams_send("set oid $oid soft-treshold $soft_val");
38
				netams_cmds(("enable","configure terminal","service quota","set oid $oid soft-treshold $soft_val","exit","exit","disable"));
47
				$result=netams_read();
48
				}
39
				}
49
			netams_send("exit"); $result=netams_read();
50
			}
40
			}
51
41
52
		if ($cgi->param("notify") ne "") {
42
		if ($cgi->param("notify") ne "") {
53
			netams_send("service quota 0");
43
			my @cmds = ("enable","configure terminal","service quota");
54
			$result=netams_read();
55
44
56
			$s=$cgi->param("notify_soft_owner"); if (defined $s) { $s="{owner}"; }
45
			$s=$cgi->param("notify_soft_owner"); if (defined $s) { $s="{owner}"; }
57
			$sn=$cgi->param("notify_soft_name");
46
			$sn=$cgi->param("notify_soft_name");
58
			netams_send("set oid $oid notify soft {none}");	$result=netams_read();
47
			push(@cmds,("set oid $oid notify soft {none}", "set oid $oid notify soft $s $sn"));
59
			netams_send("set oid $oid notify soft $s $sn");	$result=netams_read();
60
48
61
			$s=$cgi->param("notify_hard_owner"); if (defined $s) { $s="{owner}"; }
49
			$s=$cgi->param("notify_hard_owner"); if (defined $s) { $s="{owner}"; }
62
			$sn=$cgi->param("notify_hard_name");
50
			$sn=$cgi->param("notify_hard_name");
63
			netams_send("set oid $oid notify hard {none}");	$result=netams_read();
51
			push(@cmds,("set oid $oid notify hard {none}", "set oid $oid notify hard $s $sn"));
64
			netams_send("set oid $oid notify hard $s $sn");	$result=netams_read();
65
52
66
			$s=$cgi->param("notify_return_owner"); if (defined $s) { $s="{owner}"; }
53
			$s=$cgi->param("notify_return_owner"); if (defined $s) { $s="{owner}"; }
67
			$sn=$cgi->param("notify_return_name");
54
			$sn=$cgi->param("notify_return_name");
68
			netams_send("set oid $oid notify return {none}"); $result=netams_read();
55
			push(@cmds,("set oid $oid notify return {none}", "set oid $oid notify return $s $sn"));
69
			netams_send("set oid $oid notify return $s $sn"); $result=netams_read();
56
			
70
57
			push(@cmds,("exit","exit","disable"));
71
			netams_send("exit"); $result=netams_read();
58
			netams_cmds(@cmds);
72
			}
59
			}
73
60
74
		if ($cgi->param("quotas") ne "") {
61
		if ($cgi->param("quotas") ne "") {
75
			netams_send("service quota 0");
76
			$result=netams_read();
77
78
			if (($t=$cgi->param("h_in"))!=0) { $x.="hour $t in "; }
62
			if (($t=$cgi->param("h_in"))!=0) { $x.="hour $t in "; }
79
			if (($t=$cgi->param("h_out"))!=0) { $x.="hour $t out "; }
63
			if (($t=$cgi->param("h_out"))!=0) { $x.="hour $t out "; }
80
			if (($t=$cgi->param("h_sum"))!=0) { $x.="hour $t sum "; }
64
			if (($t=$cgi->param("h_sum"))!=0) { $x.="hour $t sum "; }
Lines 94-115 Link Here
94
			$x =~ s/-1/0/g;
78
			$x =~ s/-1/0/g;
95
79
96
			if ($x ne "") {
80
			if ($x ne "") {
97
				netams_send("set oid $oid $x");
81
				netams_cmds(("enable","configure terminal","service quota","set oid $oid $x","exit","exit","disable"));
98
				$result=netams_read();
99
				}
82
				}
100
101
			netams_send("exit"); $result=netams_read();
102
			}
83
			}
103
		#netams_send("service quota 0");
84
		#netams_send("service quota 0");
104
		#$result=netams_read();
85
		#$result=netams_read();
105
		$cmd="show quota oid ".$oid; netams_send($cmd); 
86
		$cmd="show quota oid ".$oid; netams_send($cmd); 
106
		$result=netams_readline(); @s_qu=split("\n", $result);
87
		$result=netams_read(); @s_qu=split("\n", $result);
107
		$p2 = "Current unit quota control status follows: <pre>$result</pre>\n";
88
		$p2 = "Current unit quota control status follows: <pre>$result</pre>\n";
108
		$p2 =~ s/{owner}/[owner]/g;
89
#		$p2 =~ s/{owner}/[owner]/g;
109
90
110
		%pairs2 = reverse %pairs;
91
		%pairs2 = reverse %pairs;
111
92
		if (-1 == index($s_qu[1], "ACTIVE")) {# -1 eq NOT, other=YES
112
		if (-1 == index($s_qu[0], "ACTIVE")) {# -1 eq NOT, other=YES
113
			$p1.="Current state for <b>".$pairs2{$oid}." [$oid]</b> is <b>INACTIVE</b>. <input type=submit name=act value='ACTIVATE IT'><br><hr>\n";
93
			$p1.="Current state for <b>".$pairs2{$oid}." [$oid]</b> is <b>INACTIVE</b>. <input type=submit name=act value='ACTIVATE IT'><br><hr>\n";
114
			}
94
			}
115
		else {
95
		else {
Lines 118-139 Link Here
118
98
119
		if ($s_qu[1] ne "") {  # we have something here
99
		if ($s_qu[1] ne "") {  # we have something here
120
100
121
			$j=index($s_qu[0], "soft-treshold:");
101
			$j=index($s_qu[1], "soft-treshold:");
122
			$j=substr($s_qu[0], $j+14, 5); $j=$j+0;
102
			$j=substr($s_qu[1], $j+14, 5); $j=$j+0;
123
			$p3="Current soft treshold is <b>$j%</b>. It means that after reaching of $j percents of some quota, the notification message could be sent.<br> You can specify another value here: <input type=text name=soft_val value=$j size=4><input type=submit name=soft value=Apply><br><hr>";
103
			$p3="Current soft treshold is <b>$j%</b>. It means that after reaching of $j percents of some quota, the notification message could be sent.<br> You can specify another value here: <input type=text name=soft_val value=$j size=4><input type=submit name=soft value=Apply><br><hr>";
124
		
104
		
125
			$nss_s="checked" if (index($s_qu[1], "soft {owner}")!=-1);  
105
			$nss_s="checked" if (index($s_qu[2], "soft owner")!=-1);  
126
			$nhs_s="checked" if (index($s_qu[1], "hard {owner}")!=-1);  
106
			$nhs_s="checked" if (index($s_qu[2], "hard owner")!=-1);  
127
			$nrs_s="checked" if (index($s_qu[1], "return {owner}")!=-1);  
107
			$nrs_s="checked" if (index($s_qu[2], "return owner")!=-1);  
128
		
108
		
129
			$j=index($s_qu[1], "soft"); if (defined $nss_s) { $j+=13; } else { $j+=5; }
109
			$j=index($s_qu[2], "soft"); if (defined $nss_s) { $j+=11; } else { $j+=3; }
130
			$k=index($s_qu[1], ",", $j); $nso_s=substr($s_qu[1], $j, $k-$j);
110
			$k=index($s_qu[2], ",", $j); $nso_s=substr($s_qu[2], $j, $k-$j);
131
111
132
			$j=index($s_qu[1], "hard"); if (defined $nhs_s) { $j+=13; } else { $j+=5; }
112
			$j=index($s_qu[2], "hard"); if (defined $nhs_s) { $j+=11; } else { $j+=3; }
133
			$k=index($s_qu[1], ",", $j); $nho_s=substr($s_qu[1], $j, $k-$j);
113
			$k=index($s_qu[2], ",", $j); $nho_s=substr($s_qu[2], $j, $k-$j);
134
114
135
			$j=index($s_qu[1], "return"); if (defined $nrs_s) { $j+=15; } else { $j+=7; }
115
			$j=index($s_qu[2], "return"); if (defined $nrs_s) { $j+=12; } else { $j+=5; }
136
			$nro_s=substr($s_qu[1], $j);
116
			$nro_s=substr($s_qu[2], $j);
137
117
138
			$p4="Users and unit owners to be notified on quota actions. Select <b>owner</b> and/or type an existing <b>user</b> name.<br>\n";  
118
			$p4="Users and unit owners to be notified on quota actions. Select <b>owner</b> and/or type an existing <b>user</b> name.<br>\n";  
139
			$p4.="<table border=1 width=80% cellpadding=3 cellspacing=0><tr align=center bgcolor=#cccccc><td><b>Soft reach</b></td><td><b>Hard reach</b></td><td><b>Return</b></td><td rowspan=2 valign=center><input type=submit name=notify value=Apply></td></tr>";
119
			$p4.="<table border=1 width=80% cellpadding=3 cellspacing=0><tr align=center bgcolor=#cccccc><td><b>Soft reach</b></td><td><b>Hard reach</b></td><td><b>Return</b></td><td rowspan=2 valign=center><input type=submit name=notify value=Apply></td></tr>";
Lines 142-151 Link Here
142
			$p4.="<td>owner <input type=checkbox $nrs_s name=notify_return_owner><br>user: <input type=text name=notify_return_name value='".$nro_s."' size=10></td></tr></table>";
122
			$p4.="<td>owner <input type=checkbox $nrs_s name=notify_return_owner><br>user: <input type=text name=notify_return_name value='".$nro_s."' size=10></td></tr></table>";
143
			$p4.="<br><hr>\n";
123
			$p4.="<br><hr>\n";
144
124
145
			$q_h_in=q_getval($result, "HOUR   in:"); $q_h_out=q_getval($result, "HOUR  out:"); $q_h_sum=q_getval($result, "HOUR  sum:");
125
			$q_h_in=q_getval($result, "HOUR","in"); $q_h_out=q_getval($result, "HOUR","out"); $q_h_sum=q_getval($result, "HOUR","sum");
146
			$q_d_in=q_getval($result, "DAY    in:"); $q_d_out=q_getval($result, "DAY   out:"); $q_d_sum=q_getval($result, "DAY   sum:");
126
			$q_d_in=q_getval($result, "DAY","in"); $q_d_out=q_getval($result, "DAY","out"); $q_d_sum=q_getval($result, "DAY","sum");
147
			$q_w_in=q_getval($result, "WEEK   in:"); $q_w_out=q_getval($result, "WEEK  out:"); $q_w_sum=q_getval($result, "WEEK  sum:");
127
			$q_w_in=q_getval($result, "WEEK","in"); $q_w_out=q_getval($result, "WEEK","out"); $q_w_sum=q_getval($result, "WEEK","sum");
148
			$q_m_in=q_getval($result, "MONTH  in:"); $q_m_out=q_getval($result, "MONTH out:"); $q_m_sum=q_getval($result, "MONTH sum:");
128
			$q_m_in=q_getval($result, "MONTH","in"); $q_m_out=q_getval($result, "MONTH","out"); $q_m_sum=q_getval($result, "MONTH","sum");
149
129
150
			$p5="You can change quota values here. Please specify '-1' if you wish to skip this quota.<br>\n";
130
			$p5="You can change quota values here. Please specify '-1' if you wish to skip this quota.<br>\n";
151
			$p5.="<table border=1 width=80% cellpadding=3 cellspacing=0><tr align=center bgcolor=#cccccc><td>&nbsp;</td><td><b>IN</b></td><td><b>OUT</b></td><td><b>SUM</b></td><td rowspan=6 valign=center><input type=submit name=quotas value=Apply></td></tr>";
131
			$p5.="<table border=1 width=80% cellpadding=3 cellspacing=0><tr align=center bgcolor=#cccccc><td>&nbsp;</td><td><b>IN</b></td><td><b>OUT</b></td><td><b>SUM</b></td><td rowspan=6 valign=center><input type=submit name=quotas value=Apply></td></tr>";
Lines 173-183 Link Here
173
sub q_getval(){
153
sub q_getval(){
174
	$s1=shift;
154
	$s1=shift;
175
	$s2=shift;
155
	$s2=shift;
176
	$j=index($s1, $s2);
156
	$s3=shift;
177
	if ($j == -1) { return 0; }
157
	my @s=grep(/^\s+$s2\s+$s3:.+hardquota/,split("\n",$s1));
178
	$j2=index($s1, "hardquota ", $j);
158
	return 0 if $#s<0;
179
	$j=$j2+10;
159
	$s[0] =~ /quota\s(\d+(\.\d+)?[KMG]?)/;
180
	$j2=index($s1, ' ratio', $j);
160
	return $1;
181
	$r=substr($s1, $j, $j2-$j);
182
	return "'$r'"; 
183
}
161
}
(-)netams-3.4.0rc2.orig/cgi-bin/admin/unit.cgi (-24 / +9 lines)
Lines 18-30 Link Here
18
#	$righthead = "Unit OID: $oid"; 
18
#	$righthead = "Unit OID: $oid"; 
19
	if ($action eq "list" or $action eq "remove") { # no units choosen
19
	if ($action eq "list" or $action eq "remove") { # no units choosen
20
		if ($action eq "remove") {
20
		if ($action eq "remove") {
21
                        netams_send("service processor 0");
21
			netams_cmds(("enable","configure terminal","service processor","no unit ".$cgi->param("unittype")." oid $oid","exit","exit","disable"));
22
                        $result=netams_read();
23
                        netams_send("no unit ".$cgi->param("unittype")." oid $oid");
24
                        $result=netams_read();
25
                        $p1="<b><i>Removing:</i></b> unit ".$cgi->param("unittype")." oid $oid<hr>\n";
22
                        $p1="<b><i>Removing:</i></b> unit ".$cgi->param("unittype")." oid $oid<hr>\n";
26
                        netams_send("exit");
27
                        $result=netams_read();
28
		
23
		
29
			if($have_radius eq "yes") {
24
			if($have_radius eq "yes") {
30
				use DBI;
25
				use DBI;
Lines 90-109 Link Here
90
	} # oid zero
85
	} # oid zero
91
	else {
86
	else {
92
		if ($action eq "new") {
87
		if ($action eq "new") {
93
			netams_send("service processor 0");
88
			my @result=netams_cmds(("enable","configure terminal","service processor","unit ".$cgi->param("unittype")." name ".$cgi->param("name"),"exit","exit","disable"));
94
			$result=netams_read();
89
			@tmp=split(/\s+/,$result[4]);
95
			netams_send("unit ".$cgi->param("unittype")." name ".$cgi->param("name"));
90
			$oid=$tmp[2];
96
			$result=netams_read();
97
			@tmp=split(/\s+/,$result);
98
			$oid=$tmp[3];
99
			if ($oid eq "name") {
91
			if ($oid eq "name") {
100
				$oid=$tmp[2];
92
			    $p2.="<b><i>Configure:</i></b> unit $tmp[0] oid $tmp[1] name $tmp[4]<hr>";
101
				$p2.="<b><i>Configure:</i></b> unit $tmp[1] oid $oid name $tmp[5]<hr>";
93
			}
102
			} else {
94
			else {
103
				$p2.="<b><i>Creating:</i></b> unit ".$cgi->param("unittype")." oid $oid name ".$cgi->param("name")."<hr>\n";
95
			    $p2.="<b><i>Creating:</i></b> unit ".$cgi->param("unittype")." oid $oid name ".$cgi->param("name")."<hr>\n";
104
			}
96
			}
105
			netams_send("exit");
106
			$result=netams_read();
107
		}
97
		}
108
98
109
		getUnits();
99
		getUnits();
Lines 175-188 Link Here
175
			}
165
			}
176
166
177
			if($cmd ne "") {
167
			if($cmd ne "") {
178
				netams_send("service processor 0");
179
                        	$result=netams_read();
180
				$cmd="unit ".$cgi->param("unittype")." oid $oid $cmd";
168
				$cmd="unit ".$cgi->param("unittype")." oid $oid $cmd";
181
                        	netams_send($cmd);
169
				netams_cmds(("enable","configure terminal","service processor",$cmd,"exit","exit","disable"));
182
                        	$p2.="<b><i>Applying:</i></b> $cmd <hr>";
170
                        	$p2.="<b><i>Applying:</i></b> $cmd <hr>";
183
				$result=netams_read();
184
                        	netams_send("exit");
185
                        	$result=netams_read();
186
			}
171
			}
187
			
172
			
188
			if($have_radius eq "yes" and $radius_update eq "yes" and $type eq "user") {
173
			if($have_radius eq "yes" and $radius_update eq "yes" and $type eq "user") {
(-)netams-3.4.0rc2.orig/cgi-bin/netams_api.pl (-3 / +6 lines)
Lines 43-53 Link Here
43
sub netams_read {
43
sub netams_read {
44
	my ($visible) = @_;
44
	my ($visible) = @_;
45
	my $byte = "";
45
	my $byte = "";
46
	my $prev_byte = "";
46
	my $prev_byte2 = "";
47
	my $prev_byte1 = "";
47
	my $out_string = "";
48
	my $out_string = "";
48
	my $count = 0;
49
	my $count = 0;
49
	while ( not ( $byte eq " " and ( $prev_byte eq "#" or $prev_byte eq ">" ) ) ) {
50
	while ( not ( $byte eq " " and ( $prev1_byte eq "#" or $prev1_byte eq ">" ) and ($prev2_byte eq "\n" or $prev2_byte eq ")") ) ) {
50
		$out_string .= $prev_byte = $byte;
51
		$prev2_byte = $prev1_byte;
52
		$prev1_byte = $byte;
53
		$out_string .= $byte;
51
		$count = sysread(NETAMS_SOCKET, $byte, 1);
54
		$count = sysread(NETAMS_SOCKET, $byte, 1);
52
		if (!defined $count) { sleep(1); next }
55
		if (!defined $count) { sleep(1); next }
53
		if ($count == 0) { last }
56
		if ($count == 0) { last }

Return to bug 13425