source: trunk/system/traffic-flow.php@ 176

Last change on this file since 176 was 161, checked in by george, 16 years ago
  • Přesunuto: SQL aktualizační soubory ze složky sql do složky www/sql.
  • Přesunuto: Systémové skripty do složky www/system.
  • Property svn:executable set to *
File size: 1.6 KB
Line 
1<?php
2include_once('/a/www/centrala/global.php');
3
4$Config['Web']['ShowErrors'] = 1;
5
6$Commands = array();
7$Commands[] = '/ip firewall filter {:foreach i in=[find] do={:put (\"src-address=\".[get \$i src-address].\" dst-address=\".[get \$i dst-address].\" bytes=\".[get \$i bytes])}}';
8$Commands = implode(';', $Commands);
9$Command = '/usr/bin/ssh -l admin-ssh -i /root/.ssh/id_dsa rt-hajda-0 "'.$Commands.'"';
10echo($Command."\n");
11//echo('Output: '.shell_exec($Command));
12exec($Command, $Output);
13//array_pop($Output);
14print_r($Output);
15/*
16
17foreach($Output as $Row)
18{
19 $Row = substr($Row, 6);
20 $RowParts = explode(' ', $Row);
21 $Properties = array();
22 foreach($RowParts as $Index => $Item)
23 {
24 if(strpos($Item, '=') !== false)
25 {
26 $ItemParts = explode('=', $Item);
27 $Properties[$ItemParts[0]] = $ItemParts[1];
28 }
29 }
30 if($Properties['status'] == 'up') $Online = 1; else $Online = 0;
31
32 $DbResult = $Database->update('hosts', 'IP="'.$Properties['host'].'"', array('online' => $Online));
33 if($Online == 1)
34 {
35 $DbResult = $Database->select('hosts', 'id', 'IP="'.$Properties['host'].'"');
36 $DbRow = $DbResult->fetch_array();
37 $HostId = $DbRow['id'];
38 $DbResult2 = $Database->select('stat_hosts', '*', '(host_id="'.$HostId.'") AND (time = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
39 if($DbResult2->num_rows == 0) $Database->query('REPLACE INTO stat_hosts (host_id, time) VALUES ("'.$HostId.'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
40 $Database->query('UPDATE stat_hosts SET count = count + 1 WHERE (host_id="'.$HostId.'") AND (time = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
41 }
42}
43*/
44
45?>
Note: See TracBrowser for help on using the repository browser.