i run this code 2 times but i want to clean it up run it one time with 2 ip
192.168.87.1
and
192.168.87.2
can someone help me with this maybe on how to do it 2 set 2 values for 1 verable
<?php require_once('api_mt_include2.php'); ?>
<?php
$ipRouteros="192.168.87.1"; // tu RouterOS.
$Username="apilinks";
$Pass="api";
$api_puerto=8728;
$API = new routeros_api();
$API->debug = false;
if ($API->connect($ipRouteros , $Username , $Pass, $api_puerto)) {
$API->write("/system/ident/getall",true);
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
$name = $ARRAY[0]["name"];
if(count($ARRAY)>0){ // si esta conectado
$API->write("/system/licen/getall",true);
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
$nlevel = $ARRAY[0]["nlevel"];
$API->write("/system/reso/getall",true);
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
$cpu = $ARRAY[0]["cpu"];
$cpu_frequency = $ARRAY[0]["cpu-frequency"];
$arquitectura = $ARRAY[0]["board-name"];
$API->write("/system/pack/getall",true);
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
$version = $ARRAY[0]["version"];
echo '<img src="icon_led_green.png" /> ';
echo "<strong>".$name."(" .$arquitectura. ")</strong> ";
echo "v:" . $version. " ";
echo "level:" . $nlevel . " ";
echo $cpu."(".$cpu_frequency." Mhz.)";
}else{ //el servidor API esta of line
echo '<img src="icon_led_grey.png" /> '.$ARRAY['!trap'][0]['message'];
}
}else{
echo "<font color='#ff0000'>La conexion ha fallado. Verifique si el Api esta activo.</font>";
}
$API->disconnect();
echo
$ipRouteros="192.168.87.2";
$Username="apilinks";
$Pass="api";
$api_puerto=8728;
$API = new routeros_api();
$API->debug = false;
if ($API->connect($ipRouteros , $Username , $Pass, $api_puerto)) {
$API->write("/system/ident/getall",true);
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
$name = $ARRAY[0]["name"];
if(count($ARRAY)>0){ // si esta conectado
$API->write("/system/licen/getall",true);
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
$nlevel = $ARRAY[0]["nlevel"];
$API->write("/system/reso/getall",true);
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
$cpu = $ARRAY[0]["cpu"];
$cpu_frequency = $ARRAY[0]["cpu-frequency"];
$arquitectura = $ARRAY[0]["board-name"];
$API->write("/system/pack/getall",true);
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
$version = $ARRAY[0]["version"];
echo '<img src="icon_led_green.png" /> ';
echo "<strong>".$name."(" .$arquitectura. ")</strong> ";
echo "v:" . $version. " ";
echo "level:" . $nlevel . " ";
echo $cpu."(".$cpu_frequency." Mhz.)";
}else{ //el servidor API esta of line
echo '<img src="icon_led_grey.png" /> '.$ARRAY['!trap'][0]['message'];
}
}else{
echo "<font color='#ff0000'>La conexion ha fallado. Verifique si el Api esta activo.</font>";
}
$API->disconnect();
?>