Skip to content

Commit

Permalink
- added getMin() to Net_Ping_Result
Browse files Browse the repository at this point in the history
 - added getAvg() to Net_Ping_Result
 - added getMax() to Net_Ping_Result
 - added getTransmitted() to Net_Ping_Result
 - added getReceived() to Net_Ping_Result

 - fixed E_ALL notices in hpux and aix parser


git-svn-id: http://svn.php.net/repository/pear/packages/Net_Ping/trunk@144182 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Jan Lehnardt committed Nov 12, 2003
1 parent d3e74c5 commit 281f3ed
Showing 1 changed file with 77 additions and 15 deletions.
92 changes: 77 additions & 15 deletions Ping.php
Original file line number Diff line number Diff line change
Expand Up @@ -696,34 +696,36 @@ function _parseResultdarwin()
*/
function _parseResulthpux()
{
$parts = array();
$raw_data_len = count($this->_raw_data);
$icmp_seq_count = $raw_data_len - 5;

/* loop from second elment to the fifths last */
for($idx = 1; $idx <= $icmp_seq_count; $idx++) {
$parts = explode(' ', $this->_raw_data[$idx]);
$this->_icmp_sequence[(int)substr($parts[4], 9, strlen($parts[4]))] = (int)substr($parts[5], 5, strlen($parts[5]));
}
$this->_bytes_per_request = $parts[0];
$this->_bytes_total = (int)$parts[0] * $icmp_seq_count;
$this->_target_ip = substr($parts[3], 0, -1);
$this->_bytes_per_request = (int)$parts[0];
$this->_bytes_total = (int)($parts[0] * $icmp_seq_count);
$this->_target_ip = NULL; /* no target ip */
$this->_ttl = NULL; /* no ttl */

$stats = explode(',', $this->_raw_data[$raw_data_len - 2]);
$transmitted = explode(' ', $stats[0]);
$this->_transmitted = $transmitted[0];
$this->_transmitted = (int)$transmitted[0];

$received = explode(' ', $stats[1]);
$this->_received = $received[1];
$this->_received = (int)$received[1];

$loss = explode(' ', $stats[2]);
$this->_loss = (int)$loss[1];

$round_trip = explode('/', str_replace('=', '/',$this->_raw_data[$raw_data_len - 1]));

$this->_round_trip['min'] = ltrim($round_trip[3]);
$this->_round_trip['avg'] = $round_trip[4];
$this->_round_trip['max'] = $round_trip[5];
$this->_round_trip['stddev'] = $round_trip[6];
$this->_round_trip['min'] = (int)ltrim($round_trip[3]);
$this->_round_trip['avg'] = (int)$round_trip[4];
$this->_round_trip['max'] = (int)$round_trip[5];
$this->_round_trip['stddev'] = NULL; /* no stddev */
} /* function _parseResulthpux() */

/**
Expand All @@ -733,24 +735,26 @@ function _parseResulthpux()
*/
function _parseResultaix()
{
$parts = array();
$raw_data_len = count($this->_raw_data);
$icmp_seq_count = $raw_data_len - 5;

/* loop from second elment to the fifths last */
for($idx = 1; $idx <= $icmp_seq_count; $idx++) {
$parts = explode(' ', $this->_raw_data[$idx]);
$this->_icmp_sequence[(int)substr($parts[4], 9, strlen($parts[4]))] = (int)substr($parts[6], 5, strlen($parts[6]));
}
$this->_bytes_per_request = $parts[0];
$this->_bytes_total = (int)$parts[0] * $icmp_seq_count;
$this->_bytes_per_request = (int)$parts[0];
$this->_bytes_total = (int)($parts[0] * $icmp_seq_count);
$this->_target_ip = substr($parts[3], 0, -1);
$this->_ttl = substr($parts[5], 4, strlen($parts[3]));
$this->_ttl = (int)substr($parts[5], 4, strlen($parts[3]));

$stats = explode(',', $this->_raw_data[$raw_data_len - 2]);
$transmitted = explode(' ', $stats[0]);
$this->_transmitted = $transmitted[0];
$this->_transmitted = (int)$transmitted[0];

$received = explode(' ', $stats[1]);
$this->_received = $received[1];
$this->_received = (int)$received[1];

$loss = explode(' ', $stats[2]);
$this->_loss = (int)$loss[1];
Expand All @@ -760,7 +764,7 @@ function _parseResultaix()
$this->_round_trip['min'] = (int)ltrim($round_trip[3]);
$this->_round_trip['avg'] = (int)$round_trip[4];
$this->_round_trip['max'] = (int)$round_trip[5];
$this->_round_trip['stddev'] = $round_trip[6];
$this->_round_trip['stddev'] = NULL; /* no stddev */
} /* function _parseResultaix() */

/**
Expand Down Expand Up @@ -954,5 +958,63 @@ function getRoundTrip()
return $this->_round_trip;
} /* function getRoundTrip() */

/**
* Accessor for $this->_round_trip['min'];
*
* @return array statistical information
* @access private
* @see Ping_Result::_round_trip
*/
function getMin()
{
return $this->_round_trip['min'];
} /* function getMin() */

/**
* Accessor for $this->_round_trip['max'];
*
* @return array statistical information
* @access private
* @see Ping_Result::_round_trip
*/
function getMax()
{
return $this->_round_trip['max'];
} /* function getMax() */

/**
* Accessor for $this->_round_tripp['avg'];
*
* @return array statistical information
* @access private
* @see Ping_Result::_round_trip
*/
function getAvg()
{
return $this->_round_trip['avg'];
} /* function getAvg() */

/**
* Accessor for $this->_transmitted;
*
* @return array statistical information
* @access private
*/
function getTransmitted()
{
return $this->_transmitted;
} /* function getTransmitted() */

/**
* Accessor for $this->_received;
*
* @return array statistical information
* @access private
*/
function getReceived()
{
return $this->_received;
} /* function getReceived() */

} /* class Net_Ping_Result */
?>

0 comments on commit 281f3ed

Please sign in to comment.