summaryrefslogtreecommitdiffstats
path: root/usr/local/www/widgets/widgets/interface_statistics.widget.php
blob: a8b99503c3f6677d37663029aef14e5b3925263f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

              <?php $i = 0; $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN');
		for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
			$ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
		}
		
		$array_in_packets = array();
		$array_out_packets = array();
		$array_in_bytes = array();
		$array_out_bytes = array();
		$array_in_errors = array();
		$array_out_errors = array();
		$array_collisions = array();
		$array_interrupt = array();
		
		//build data arrays
		foreach ($ifdescrs as $ifdescr => $ifname){
			$ifinfo = get_interface_info($ifdescr);
			
			$array_in_packets[] = $ifinfo['inpkts'];
			$array_out_packets[] = $ifinfo['outpkts'];
			$array_in_bytes[] = format_bytes($ifinfo['inbytes']);
			$array_out_bytes[] = format_bytes($ifinfo['outbytes']);
			if (isset($ifinfo['inerrs'])){
				$array_in_errors[] = $ifinfo['inerrs'];
				$array_out_errors[] = $ifinfo['outerrs'];
			}
			else{
				$array_in_errors[] = "n/a";
				$array_out_errors[] = "n/a";
			}
			if (isset($ifinfo['collisions']))
				$array_collisions[] = htmlspecialchars($ifinfo['collisions']);
			else
				$array_collisions[] = "n/a";
		
					
			
		}//end for
		
	
		
		
		?>
		<div style="padding: 5px">			
              <div id="int_labels" style="float:left;width:32%">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr><td class="widgetsubheader" style="height:25px">&nbsp;&nbsp;&nbsp;</td></tr>	
					<tr>
	                	<td class="vncellt" style="height:25px">Packets In</td>
					</tr>	              
		            <tr>
		                <td class="vncellt" style="height:25px">Packets Out</td>
		           </tr>	              
	               <tr>
	                <td class="vncellt" style="height:25px">Bytes In</td>
				    </tr>	              
	              <tr>
	                <td class="vncellt" style="height:25px">Bytes Out</td>
				  </tr>	              
	              <tr>
	                <td class="vncellt" style="height:25px">Errors In</td>
				 </tr>	              
	              <tr>
	                <td class="vncellt" style="height:25px">Errors Out</td>
				</tr>              
	              <tr>
	                <td class="vncellt" style="height:25px">Collisions</td>
				 </tr>	              
	              </table>
	          </div>
	          <div id="interfacestats" style="float:right;overflow: auto; width:68%">
	          <table width="100%" border="0" cellspacing="0" cellpadding="0">
	              <tr>
		                <tr>
		                <?php 
		                	foreach ($ifdescrs as $ifdescr => $ifname): ?>
			                	<td class="widgetsubheader" nowrap  style="height:25px">
			                  		<?=htmlspecialchars($ifname);?>
								</td>
							<?php endforeach; ?>
		              </tr>
		              
		              <tr>
			                <?php foreach ($array_in_packets as $data): ?>
							<td class="listr" nowrap style="height:25px">
								<?=htmlspecialchars($data);?>
			                </td>
			                <?php endforeach; ?>
	              		</tr>
	              		
	              		<tr>
			                <?php foreach ($array_out_packets as $data): ?>
							<td class="listr" nowrap style="height:25px">
								<?=htmlspecialchars($data);?>
			                </td>
			                <?php endforeach; ?>
	              		</tr>
			               
			            <tr>
			                <?php foreach ($array_in_bytes as $data): ?>
							<td class="listr" nowrap style="height:25px">
								<?=htmlspecialchars($data);?>
			                </td>
			                <?php endforeach; ?>
	          			</tr>
	          			
	          			<tr>
			                <?php foreach ($array_out_bytes as $data): ?>
							<td class="listr" nowrap style="height:25px">
								<?=htmlspecialchars($data);?>
			                </td>
			                <?php endforeach; ?>
	            		</tr>
	            		
	            		<tr>
			                <?php
				               foreach ($array_in_errors as $data): ?>
									<td class="listr" nowrap style="height:25px">
										<?=htmlspecialchars($data);?>
					                </td>
				                <?php endforeach; ?>
	              		</tr>
		                	
		                <tr>
		                	<?php 
			               foreach ($array_out_errors as $data): ?>
								<td class="listr" nowrap style="height:25px">
									<?=htmlspecialchars($data);?>
				                </td>
			                <?php endforeach; ?>
	             		</tr>
		                	
		                <tr>	
		                	<?php  
				                foreach ($array_collisions as $data): ?>
								<td class="listr" nowrap style="height:25px">
									<?=htmlspecialchars($data);?>
				                </td>
			                <?php endforeach; ?>
						</tr>
	             </table>
			</div>
	</div>
OpenPOWER on IntegriCloud