Hi i m creating some script filter script for my Mikrotik. I tested in terminal and now i want to write it in a PHP format.
So how i m suppose to write ?
terminal: ip firewall connection print where src-address=“111.11.11.11:2222”
example of my php coding:
$API->write(‘/ip/firewall/filter/print’, false);
$API->write(‘=where src-address=“111.11.11.11:2222”=’);
You need to use queries.
(And sidenote: I wouldn’t mind hearing about what you like about that other PHP client…)
Haha this is because i m trying to make a web based interface together with Mikrotik API. Would you be so kind to show me an example for the query ?
Right. That’s pretty much a given with PHP… But why the other PHP client I mean? And even more oddly… why work with raw protocol words?
Well, using the client from my signature:
$client = new RouterOS\Client('192.168.88.1', 'admin', 'password');
$firewallFilters = $client->sendSync(
new RouterOS\Request(
'/ip firewall filter print',
RouterOS\Query::where('src-address', '111.11.11.11')
)
)->getAllOfType(RouterOS\Response::TYPE_DATA);
or better yet:
$util = new RouterOS\Util(
$client = new RouterOS\Client('192.168.88.1', 'admin', 'password')
);
$firewallFilters = $util->setMenu('/ip firewall filter')
->getAll(
array(),
RouterOS\Query::where('src-address', '111.11.11.11')
);
If you insist on using raw protocol words… The link above contains examples. Just write each line in the example as a separate call to the “write” method.
(But again… why?)
Hi guys
i need a hand here
i am testing a api php on a RB450G which i can run in terminal the /system health print cmd and it outputs the voltage and CPU temperatura
now i am trying to export it in my api php
i am using the follwogin function
<div class="col-lg-3 col-xs-6">
<!-- small box-->
<div class="small-box bg-yellow">
<div class="inner">
<h3>System Health</h3>
<?php $ARRAY = $API->comm("/system/health/print");
$voltage = $ARRAY['0']['voltage']/1048576;
?>
<p>Voltage</p>
<p><?php echo " ".round($voltage,1)."V"; ?><sup style="font-size: 20px"></sup></p>
</div>
<div class="icon">
<i class="ion ion-stats-bars"></i>
</div>
But the output displays 0V
I am using a similar function which works
$ARRAY = $API->comm("/system/resource/print");
$ramtotal = $ARRAY['0']['total-memory']/1048576;
<?php echo " ".round($ramtotal,1)." MB"; ?><sup style="font-size: 20px"></sup> Total</p>
which displays the Total Memory Available on the system
Any help will be appreciated on how to get the Print of to display from Voltage and CPU temperature
Hi guys
i know, this is old news and old threats, but as i am working on a new project development ISP Management system with freeradius 3xx and full system monitoring via snmp, api.. we are implementing from scratch a new system, and each time we come across some searches on google it ends up here on mikrotik and routerOS php api or Pear2 php api
so here is a working example for monitoring a system health print , using RouterOS 1.6 with new login method for version 6.45, 6.46, 6.47 etc..
$stats = $API->comm('/system/health/print');
print_r($stats);
$meme = $stats['0'];
echo "<td>" . $meme['voltage'] . "</td><br />";
echo "<td>" . $meme['temperature'] . "</td><br />";
and PHP table output below to echo the data later in a column or table
<!-- Count item widget-->
<div class="col-xl-2 col-md-4 col-6">
<div class="wrapper count-title d-flex">
<div class="icon"><i class="fa fa-thermometer-empty" aria-hidden="true"></i></div>
<div class="name"><strong class="text-uppercase">Temperature</strong><span><?php echo "<td>" . $meme['temperature'] . "</td>"; ?></span>
<!--<div class="count-number"></div>-->
</div>
</div>
</div>