$JpStat: Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Created page with "{{DISPLAYTITLE:$JpStat}} <span class="pageSubtitle">Retrieve <var class="product">Janus</var> port's statistics into string</span> <p class="warning">Most Sirius $functions ...")
 
m (→‎Syntax: add "unsigned")
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:$JpStat}}
{{DISPLAYTITLE:$JpStat}}
<span class="pageSubtitle">Retrieve <var class="product">Janus</var> port's statistics into string</span>
<span class="pageSubtitle">Retrieve Janus port's statistics into string</span>
   
   
<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is no OO equivalent for the <var>$JpStat</var> function.</p>
<p class="warn"><b>Note: </b>Many $functions have been deprecated in favor of Object Oriented methods. There is no OO equivalent for the <var>$JpStat</var> function.</p>
   
   
This function allows retrieval of a specific <var class="product">Janus</var> port into a string.
This function allows retrieval of a specific <var class="product">Janus</var> port into a string.
Line 8: Line 8:
The <var>$JpStat</var> function accepts two arguments and returns a string made up of an error code, the port name,
The <var>$JpStat</var> function accepts two arguments and returns a string made up of an error code, the port name,
and returned statistics.
and returned statistics.
The first argument is a string of blank delimited words indicating the statistics to be returned. The length of each returned statistic is always a multiple of 4 bytes. This facilitates the use of <var>[[$StatD]]</var> with the returned string. For more information about available statistics, see the <var class="product">[http://sirius-software.com/maint/download/monr.pdf SirMon User's Guide]</var>.
The second argument is the <var class="product">Janus</var> port name for which data is to be returned.
   
   
==Syntax==
==Syntax==
<p class="syntax">%string = <var>$JpStat</var>(stat_list, task_num)</p>
<p class="syntax">%string = $JpStat(<span class="term">statList</span>, <span class="term">portName</span>)</p>
<p>%string is made up of a combination of binary and character string
 
data, the first 4 bytes of which is an error code. If the error code is negative %string will only be 4 bytes long.</p>
===Syntax terms===
<table>
The data returned by <var>$JpStat</var> is a combination of binary and character string data:
<tr><th>%string</th>
<ul>
<td>A string that might be a combination of binary and character string
<li>The first 4 bytes containing an error code. If the error code is negative, only 4 bytes are returned.
data. For details, see the "Usage notes," below. </td></tr>
If the error code is positive, it contains a number of milliseconds since the online region was brought up. This provides a convenient number for calculating rates for the statistics.
 
</ul>
<tr><th>statList</th>
When a positive error code is returned:
<td>A string of blank delimited words indicating the statistics to be returned. The length of each returned statistic is always a multiple of four bytes. This facilitates the use of <var>[[$StatD]]</var> with the returned string. For more information about available statistics, see the <var class="product">[[SirMon#SirMon topics|SirMon]]</var> M204wiki pages.</td></tr>
 
<tr><th>portName</th>
<td>The <var class="product">Janus</var> port name for which data is to be returned.</td></tr>
</table>
 
===Return codes===
<p class="code"> -5  Required parameter not specified
-12  Invalid parameter
-14  Result string would be longer than 255 bytes
</p>
 
==Usage notes==
The data returned by <var>$JpStat</var> is a string that might be a combination of binary and character string data:
<ul>
<ul>
<li>The next 32 bytes (that is, starting at byte number 5) contain the port name.
<li>If exactly four bytes are returned, the bytes contain a binary number that is an error code; these are described above.
Otherwise, the first four bytes contain the unsigned binary number of milliseconds since the Online region was brought up. This provides a convenient number for calculating rates for the statistics. </li>
 
<li>The next 30 bytes (that is, starting at byte number 5) contain the port name. </li>
 
<li>The next 2 bytes (that is, starting at byte number 35) contain the binary number 1. </li>
 
<li>The port name is followed by the result statistics, starting at byte number 37.
<li>The port name is followed by the result statistics, starting at byte number 37.
Statistics which have string values are returned as 8 bytes, left justified, blank filled.
Statistics that have string values are returned as eight bytes, left justified, blank filled.
Numeric statistics are returned as 4 byte binary values.
Numeric statistics are returned as four-byte binary values. </li>
</ul>
</ul>
 
<p class="code">
==Example==
  -5 - Required parameter not specified
-12 - Invalid parameter
-14 - Result string would be longer than 255 bytes
</p>
<p class="caption"><var>$JpStat</var> return codes
</p>
The following program displays some totals for the port named <code>DATA.INFO</code>:
The following program displays some totals for the port named <code>DATA.INFO</code>:
   
   
<p class="code"> B
<p class="code">B
   
   
%data is string len 255
%data is string len 255
   
   
%data = $jpStat('ACTIVE STATUS', 'DATA.INFO')
%data = $jpStat('ACTIVE STATUS', 'DATA.INFO')
if $len(%data) = 4 then
  if $len(%data) = 4 then
    print '$jpStat error... rc = ' with $unbin(%data)
    print '$jpStat error... rc = ' with $unbin(%data)
    stop
    stop
end if
  end if
   
   
print 'Name  = ' with $substr(%data, 5, 32)
print 'Name  = ' with $substr(%data, 5, 30)
print 'Active = ' with $unbin( $substr(%data, 5 + 32, 4) )
print 'Active = ' with $unbin( $substr(%data, 5 + 32, 4) )
print 'Status = ' with $substr(%data, 5 + 32 + 4, 8)
print 'Status = ' with $substr(%data, 5 + 32 + 4, 8)
   
   
end
end
</p>
</p>
   
   
==Products authorizing {{PAGENAMEE}}==
==Products authorizing {{PAGENAMEE}}==
<ul class="smallAndTightList">
<ul class="smallAndTightList">
<li>[[Sirius $Functions]]
<li>[[List of $functions|Sirius functions]]</li>
</ul>
</ul>
 
<p>
</p>
   
   
[[Category:$Functions|$JpStat]]
[[Category:$Functions|$JpStat]]

Latest revision as of 14:54, 4 October 2016

Retrieve Janus port's statistics into string

Note: Many $functions have been deprecated in favor of Object Oriented methods. There is no OO equivalent for the $JpStat function.

This function allows retrieval of a specific Janus port into a string.

The $JpStat function accepts two arguments and returns a string made up of an error code, the port name, and returned statistics.

Syntax

%string = $JpStat(statList, portName)

Syntax terms

%string A string that might be a combination of binary and character string data. For details, see the "Usage notes," below.
statList A string of blank delimited words indicating the statistics to be returned. The length of each returned statistic is always a multiple of four bytes. This facilitates the use of $StatD with the returned string. For more information about available statistics, see the SirMon M204wiki pages.
portName The Janus port name for which data is to be returned.

Return codes

-5 Required parameter not specified -12 Invalid parameter -14 Result string would be longer than 255 bytes

Usage notes

The data returned by $JpStat is a string that might be a combination of binary and character string data:

  • If exactly four bytes are returned, the bytes contain a binary number that is an error code; these are described above. Otherwise, the first four bytes contain the unsigned binary number of milliseconds since the Online region was brought up. This provides a convenient number for calculating rates for the statistics.
  • The next 30 bytes (that is, starting at byte number 5) contain the port name.
  • The next 2 bytes (that is, starting at byte number 35) contain the binary number 1.
  • The port name is followed by the result statistics, starting at byte number 37. Statistics that have string values are returned as eight bytes, left justified, blank filled. Numeric statistics are returned as four-byte binary values.

Example

The following program displays some totals for the port named DATA.INFO:

B %data is string len 255 %data = $jpStat('ACTIVE STATUS', 'DATA.INFO') if $len(%data) = 4 then print '$jpStat error... rc = ' with $unbin(%data) stop end if print 'Name = ' with $substr(%data, 5, 30) print 'Active = ' with $unbin( $substr(%data, 5 + 32, 4) ) print 'Status = ' with $substr(%data, 5 + 32 + 4, 8) end

Products authorizing $JpStat