Опишу вкратце проблему:
Есть устройство которое отправляет данные (в моем случае роутер mikrotik но суть не в нем)
Код отправки:
Код: Выделить всё
/tool fetch mode=http url=$url keep-result=no http-method="post" http-data="wifi=$str";
Полный код:
Код: Выделить всё
:local url "http://192.168.88.100/mikrot.php";
:set $str "";
:foreach i in=[/caps-man registration-table find] do={
:local mac [/caps-man registration-table get $i mac-address];
:local ip [/ip dhcp-server lease get [/ip dhcp-server lease find where mac-address="$mac"] address];
:local getcomment [/ip dhcp-server lease get [/ip dhcp-server lease find where address="$ip"] comment];
:local hostname [/ip dhcp-server lease get [/ip dhcp-server lease find where mac-address="$mac"] host-name];
:local capnumber [/caps-man registration-table get [/caps-man registration-table find where mac-address="$mac"] interface];
:local rxsignal [/caps-man registration-table get [/caps-man registration-table find where mac-address="$mac"] rx-signal];
:local uptime [/caps-man registration-table get [/caps-man registration-table find where mac-address="$mac"] uptime];
:set $str "$str|$getcomment;$hostname;$capnumber;$rxsignal;$ip;$mac;$uptime";
}
:do {
/tool fetch mode=http url=$url keep-result=yes dst-path="result.txt" http-method="post" http-data="wifi=$str";
} on-error={ log warning "Mojerdomo: Send to server Failed!" }
А вот как распихать эти данные в классы объекта mdm совершенно не понимаю. Подскажите пожалуйста

Код php:
Код: Выделить всё
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$array=$_POST['wifi'];
print_r($array);
$tmp1 = explode('|', $array);
foreach ($tmp1 as $i) {
list($getcomment, $hostname ,$wlannumber, $signalstr , $ip, $mac, $uptime) = explode(";", $i);
if ($mac != '')
{
$wificlienttmp['getcomment'] = $getcomment;
$wificlienttmp['hostname'] = $hostname;
$wificlienttmp['wlannumber'] = $wlannumber;
$wificlienttmp['signalstr '] = $signalstr ;
$wificlienttmp['ip'] = $ip;
$wificlienttmp['mac'] = $mac;
$wificlienttmp['uptime'] = $uptime;
$wificlient[] = $wificlienttmp;
print_r($wificlienttmp);
}
}
|Xiaomi Gateway;lumi-gateway-v3_miio;Cap1_2.4Ghz;-64;192.168.88.25;7C:49:EB:B0:A9:8D;1d21:59:15.590
Array
(
[getcomment] => Xiaomi Gateway
[hostname] => lumi-gateway-v3_miio
[capnumber] => Cap1_2.4Ghz
[rxsignal] => -64
[ip] => 192.168.88.25
[mac] => 7C:49:EB:B0:A9:8D
[uptime] => 1d21:59:15.590
)