It's better when it's simple

User Tools

Site Tools


snmplive Plugin

Compatible with DokuWiki

No compatibility info given!

plugin Fetches SNMP values on the network and displays them live through ajax.

Last updated on

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to xfortune

Tagged with ajax, ip, management

based on the xfortune-plugin

It gets the actual SNMP values out of any by the server reachable device (e.g. servers, printers, temp. sensors). I wrote this plugin to realize an easy to set-up server-admin dashboard.


You need the IP of the device and the exact oid… NEW: You can now also set the community.

<snmplive ip="" oid=".x.x. (...) x.x">

Collection of interesting OID's


  • 2009-01-13: enhancement of community-flag by Alexandre Morel
  • 2007-03-08: first Version


Create a directory called snmplive in the lib/plugins directory and place the following files in there.


Create this file in lib/plugins/snmplive/syntax.php

 * Display SNMP values
 * @license    GPL 2 (
 * @author     Andreas Gohr <>
 * @author     Michael Luggen <>
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
class syntax_plugin_snmplive extends DokuWiki_Syntax_Plugin {
     * return some info
    function getInfo(){
        return array(
            'author' => 'Michael Luggen',
            'email'  => '',
            'date'   => '2007-03-08',
            'name'   => 'SNMPlive Plugin',
            'desc'   => 'Updates various SNMP data live.',
            'url'    => '',
     * What kind of syntax are we?
    function getType(){
        return 'substition';
     * What about paragraphs?
    function getPType(){
        return 'normal';
     * Where to sort in?
    function getSort(){
        return 334;
     * Connect pattern to lexer
    function connectTo($mode) {
     * Handle the match
    function handle($match, $state, $pos, &$handler){
        $match = substr($match,9,-1); //strip markup from start and end
        //get values
        $param = array();
        $values = array();
        foreach($param as $value) {
            list($m,$k,$v) = $value;
            $values[$k] = $v;
        return $values;
     * Create output
    function render($mode, &$renderer, $data) {
        if($mode == 'xhtml'){
            $renderer->doc .= "<span id=\"".$data['ip'].$data['oid']."\">";
		    $renderer->doc .= $this->_getSNMPdata($data['ip'], $data['oid'], $data['community']);
            $renderer->doc .= "</span>";
            $renderer->doc .= $this->_script($data['ip'],$data['oid'], $data['community']);
            return true;
        return false;
    function _script($ip,$oid,$community){
        $str  = '<script type="text/javascript" language="javascript">';
        $str .= "addEvent(window,'load',plugin_snmplive('".$ip."','".$oid."', '".$community."'));";
        $str .= '</script>';
        return $str;
     * Returns the value of the "snmp variable"
     * @author Michael Luggen <>
    function _getSNMPdata($ip,$oid,$community){
        return preg_replace('/(\w+)\: "?([^".]+)"?/','${2}',snmpget($ip, $community, $oid));
//Setup VIM: ex: et ts=4 enc=utf-8 :


This is the backend to handle the AJAX requests. Put it into lib/plugins/snmplive/ajax.php.

 * AJAX Backend Function for plugin_snmplive
 * @author Andreas Gohr <>
 * @author Michael Luggen <>
//fix for Opera XMLHttpRequests
if(!count($_POST) && $HTTP_RAW_POST_DATA){
  parse_str($HTTP_RAW_POST_DATA, $_POST);
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
//close sesseion
header('Content-Type: text/html; charset=utf-8');
$SNMPip = cleanID($_POST['SNMPip']);
$SNMPoid = cleanID($_POST['SNMPoid']);
$SNMPcommunity = cleanID($_POST['SNMPcommunity']);
print syntax_plugin_snmplive::_getSNMPdata($SNMPip,$SNMPoid,$SNMPcommunity);


The needed JavaScript goes into lib/plugins/snmplive/script.js

 * Script for plugin_snmplive
 * Fetches the new snmpvalues
 * @author Andreas Gohr <>
 * @author Michael Luggen <>
function plugin_snmplive(ip,oid,community){
    var snmpId = ip + oid + community;
    var obj = document.getElementById(snmpId);
    if(obj === null){
    // We use SACK to do the AJAX requests
    var ajax = new sack(DOKU_BASE+'lib/plugins/snmplive/ajax.php');
    ajax_qsearch.sack.AjaxFailedAlert = '';
    ajax_qsearch.sack.encodeURIString = false;
    // define callback
    ajax.onCompletion = function(){
        var data = this.response;
        if(data === ''){ return; }
        var out = document.getElementById(snmpId);
 = 'hidden';
        out.innerHTML = data; = 'visible';
        // restart timer

Install from tarball

There's also tarball for easy installation: (version 2007-03-08) Just Download unpack it and run:

$ make install prefix=/usr/share/dokuwiki

Known Issues

  • it can not resolve hostnames (yet)
  • little problems with the ajax frame work (throws 2 errors at the beginning)
  • data is not cached (should cache like rss feeds are cached)


I have just installed this plugin using the plugin manager.
If I insert any <snmplive…> entry on a page, the page renders as completely blank - no headers, no footers, no content of any sort…

I am using the monobook template (in case that's significant).
Michael McCarn 2008-09-18

weird, hostnames are resolved for me, using php 5.2.3. however i noticed it first lowercases the oid names and secondly issues some warning:

<snmplive ip="localhost" oid="sysDescr.0">

PHP Warning:  snmpget(): Invalid object identifier: sysdescr.0 in /usr/share/dokuwiki/lib/plugins/snmplive/syntax.php on line 105, referer: http://localhost/dokuwiki/playground:snmplive

however it outputs result ok to the page.

Elan Ruusamäe 2007-08-29

A prerequisite for this plugin is the snmp package for php5. On a Debian system you could do

apt-get install php5-snmp

Robert S. 2011-08-30

Can anyone guide me how to sum several snmplive outputs in dokuwiki?

lolo 2015-03-14

I finally figured it out. You will need tablecalc plugin or something similar:

|**PDU1**|<snmplive ip="" oid="." community="public"><html>&nbsp;</html> watts|
|**PDU2**|<snmplive ip="" oid="." community="public"><html>&nbsp;</html> watts|
|**PDU3**|<snmplive ip="" oid="." community="public"><html>&nbsp;</html> watts|
|**PDU4**|<snmplive ip="" oid="." community="public"><html>&nbsp;</html> watts|
|**Total input feed:**| ~~=r0c1+r1c1+r2c1+r3c1~~<html>&nbsp;</html> watts|
|**Annual cost estimate based on the total power consumption of the system at this load (11¢/kW):**|$~~=round(r4c1*24*0.365*0.11,2)~~/year|

lolo 2015-05-1

  1. leeb 2015-06-17

I am struggling to get any output. If I run the command for SNMPGET from command line I get the expected result
But running in Dokuwiki I get
Warning: snmpget(): No response from xxxxx in /var/www/dokuwiki/lib/plugins/snmplive/syntax.php on line 104

  1. leeb 2015-06-17
plugin/snmplive.txt · Last modified: 2015-06-16 13:11 by