2011-04-27 17:41:35 +00:00
< ? php
$sql = " SELECT * FROM `ports_stack` WHERE `device_id` = ' " . $device [ 'device_id' ] . " ' " ;
2014-01-13 17:43:58 +00:00
2018-07-13 17:08:00 -05:00
$stack_db_array = [];
2015-07-13 20:10:26 +02:00
foreach ( dbFetchRows ( $sql ) as $entry ) {
$stack_db_array [ $entry [ 'port_id_high' ]][ $entry [ 'port_id_low' ]][ 'ifStackStatus' ] = $entry [ 'ifStackStatus' ];
2011-04-27 17:41:35 +00:00
}
2017-02-08 04:54:30 +00:00
unset (
$sql ,
$entry
);
2011-04-27 17:41:35 +00:00
2018-04-24 12:07:32 -05:00
$stack_poll_array = snmpwalk_cache_twopart_oid ( $device , 'ifStackStatus' , array (), 'IF-MIB' );
2015-07-13 20:10:26 +02:00
foreach ( $stack_poll_array as $port_id_high => $entry_high ) {
foreach ( $entry_high as $port_id_low => $entry_low ) {
$ifStackStatus = $entry_low [ 'ifStackStatus' ];
if ( isset ( $stack_db_array [ $port_id_high ][ $port_id_low ])) {
if ( $stack_db_array [ $port_id_high ][ $port_id_low ][ 'ifStackStatus' ] == $ifStackStatus ) {
echo '.' ;
2016-08-28 12:32:58 -05:00
} else {
2015-07-13 20:10:26 +02:00
dbUpdate ( array ( 'ifStackStatus' => $ifStackStatus ), 'ports_stack' , 'device_id=? AND port_id_high=? AND `port_id_low`=?' , array ( $device [ 'device_id' ], $port_id_high , $port_id_low ));
echo 'U' ;
}
unset ( $stack_db_array [ $port_id_high ][ $port_id_low ]);
2016-08-28 12:32:58 -05:00
} else {
2015-07-13 20:10:26 +02:00
dbInsert ( array ( 'device_id' => $device [ 'device_id' ], 'port_id_high' => $port_id_high , 'port_id_low' => $port_id_low , 'ifStackStatus' => $ifStackStatus ), 'ports_stack' );
echo '+' ;
}
} //end foreach
2017-02-08 04:54:30 +00:00
unset (
$port_id_low ,
$entry_low
);
2015-07-13 20:10:26 +02:00
} //end foreach
2017-02-08 04:54:30 +00:00
unset ( $stack_poll_array );
2015-07-13 20:10:26 +02:00
foreach ( $stack_db_array as $port_id_high => $array ) {
foreach ( $array as $port_id_low => $blah ) {
echo $device [ 'device_id' ] . ' ' . $port_id_low . ' ' . $port_id_high . " \n " ;
dbDelete ( 'ports_stack' , '`device_id` = ? AND port_id_high = ? AND port_id_low = ?' , array ( $device [ 'device_id' ], $port_id_high , $port_id_low ));
echo '-' ;
2011-04-27 17:41:35 +00:00
}
}
2015-07-13 20:10:26 +02:00
echo " \n " ;
2017-02-08 04:54:30 +00:00
unset (
$stack_db_array ,
$array ,
$port_id_high ,
$entry_high
);