Skip to content

Commit

Permalink
support new AgentConfig
Browse files Browse the repository at this point in the history
code cleanup
  • Loading branch information
okitsu committed Mar 12, 2012
1 parent 54a7efe commit 7d1d340
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/Net/Zabbix/Sender.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Sender {

function __construct($servername = null,$serverport = null)
{
if( isset($servername)){
if( isset($servername) ){
$this->_servername = $servername;
}
if( isset($serverport) and is_numeric($serverport) ){
Expand All @@ -51,7 +51,8 @@ function __construct($servername = null,$serverport = null)
$this->initData();
}

function initData(){
function initData()
{
$this->_data = $this->_createDataTemplate();
}

Expand All @@ -63,18 +64,15 @@ function _createDataTemplate()
);
}

function importAgentConfig(Agent\Config $agentConfig){
$config = $agentConfig->getAgentConfig();
if( is_array($config) )
{
if( array_key_exists('Server',$config) )
{
$this->_servername = $config{'Server'};
}
if( array_key_exists('ServerPort',$config) )
{
$this->_serverport = intval($config{'ServerPort'});
}
function importAgentConfig(Agent\Config $agentConfig)
{
$server = $agentConfig->getServer();
$port = $agentConfig->getServerPort();
if( isset($server) ){
$this->_servername = $server;
}
if( isset($port) ){
$this->_serverport = $port;
}
}

Expand All @@ -90,10 +88,8 @@ function getTimeout(){

function addData($hostname=null,$key=null,$value=null,$clock=null)
{

$input = array("host"=>$hostname,"value"=>$value,"key"=>$key);
if( isset($clock) )
{
if( isset($clock) ){
$input{"clock"} = $clock;
}
array_push($this->_data{"data"},$input);
Expand Down

0 comments on commit 7d1d340

Please sign in to comment.