* @author Michael Luggen */ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); class syntax_plugin_snmplive extends DokuWiki_Syntax_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'Michael Luggen', 'email' => 'michael.luggen@unifr.ch', 'date' => '2007-03-08', 'name' => 'SNMPlive Plugin', 'desc' => 'Updates various SNMP data live.', 'url' => 'http://wiki.splitbrain.org/plugin:gallery', ); } /** * 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) { $this->Lexer->addSpecialPattern('',$mode,'plugin_snmplive'); } /** * 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(); preg_match_all('/(\w*)="(.*?)"/us',$match,$param,PREG_SET_ORDER); 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 .= ""; $renderer->doc .= $this->_getSNMPdata($data['ip'], $data['oid']); $renderer->doc .= ""; $renderer->doc .= $this->_script($data['ip'],$data['oid']); return true; } return false; } function _script($ip,$oid){ $str = ''; return $str; } /** * Returns the value of the "snmp variable" * * @author Michael Luggen */ function _getSNMPdata($ip,$oid){ return preg_replace('/(\w+)\: "?([^".]+)"?/','${2}',snmpget($ip, 'public', $oid)); } } //Setup VIM: ex: et ts=4 enc=utf-8 :