Community discussions

MikroTik App
 
User avatar
tadpole
newbie
Topic Author
Posts: 47
Joined: Fri May 07, 2010 2:20 pm

System Health to a wordpress site

Mon Feb 03, 2014 12:19 pm

Hi guys,
I have been trying to figure out a way to get the system health, in particular the system voltage off a RB750UP to be a easily viewable as a widget/page on a wordpress site. Is this possible? Alot of what i have seen is a bit confusing, I was imagining intially that it would be some kind of php code i plonked in the page but now that i see http://forum.mikrotik.com/viewtopic.php?f=9&t=29073 and http://wiki.mikrotik.com/wiki/Manual:API i am not sure what is the best way to do this. What would you recommend as the simplest solution to this?

many thanks
Tim
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: System Health to a wordpress site

Mon Feb 03, 2014 1:38 pm

Well, as you point out, you need to get an API client, and maybe write a WordPress plugin that uses it (or if you feel dirty - just write the code for that into a template or whatever).

I'd recommend my own client (but I'm biased, obviously), seen from my signature and the top of the examples under the API page. With it, you can display the voltage like:
use PEAR2\Net\RouterOS;
require_once 'PEAR2_Net_RotuterOS-1.0.0b4.phar';

$util = new RouterOS\Util($client = new RouterOS\Client('192.168.0.1', 'admin', 'password'));

$util->changeMenu('/system health');
echo $util->get(null, 'voltage'); 
Or if you want to get everything at "/system health", then perhaps:
use PEAR2\Net\RouterOS;
require_once 'PEAR2_Net_RotuterOS-1.0.0b4.phar';

$client = new RouterOS\Client('192.168.0.1', 'admin', 'password');

$responses = $client->sendSync(new RouterOS\Request('/system health print'));
foreach ($responses as $response) {
    foreach ($response->getAllArguments() as $name => $value) {
        echo "{$name}: {$value}\n";
    }
} 
Last edited by boen_robot on Mon Feb 03, 2014 2:58 pm, edited 1 time in total.
 
User avatar
tadpole
newbie
Topic Author
Posts: 47
Joined: Fri May 07, 2010 2:20 pm

Re: System Health to a wordpress site

Mon Feb 03, 2014 2:47 pm

thanks for the reply boen_robot, will try it out now and post, i was also thinking about maybe using SNMP even to get the info. I like the idea of this API client stuff, I have never tried to write a plugin for a web page, i will give it a go though always a first time for everything!

many thanks again for your time!