skip to main content
Programmers documentation > Styling > Customizing object states > Customizing the SNMP state system
 
Customizing the SNMP state system
Describes the SNMP states and how to customize them.
*SNMP primary and secondary states
*Describes the SNMP states, discusses customization of primary and secondary states and describes how to create an SNMP primary state.
*Customizing SNMP secondary states
*Describes how to customize each graphical representation of SNMP secondary states.
*Creating a new attribute in the System group
*Describes how to create a new attribute in the group used for SNMP System attributes.
SNMP primary and secondary states
The SNMP state dictionary is based on RFC 1213 - Management Information Base for Network Management of TCP/IP-based internets - MIB-II.
JViews TGO provides a visual representation of the SNMP primary state by changing the object base graphic representation. SNMP secondary states are represented using icons, gauges, charts or counters. For information on the SNMP state system and its graphic representation, refer to
SNMP states explains how to customize the object representation according to the SNMP state information. You can also customize the decoration that is displayed when a given SNMP secondary state is set in the object.
In the SNMP state dictionary, most of the secondary states are numeric and by default they are represented by a gauge. There are also two other possible representations for these states. The IltDecorationType class defines the possible graphical representations. The possible values of this class are:
*Gauge
*Chart
*Counter
How to create an SNMP primary state
Each primary state in the SNMP state dictionary is associated with a different base style.
To create a new primary state:
*Create a new SNMP state using the method NewState.
 
IltSNMP.State state = IltSNMP.NewState ("Pending", "Indicates if the object
is waiting for validation");
This method takes two arguments: a name and a description. The name is used to identify the state in the application. The description is used to provide information about the semantics of the state.
The new state can be used in XML in the following way.
 
<state>Pending</state>
*Create a CSS file that configures the representation of the objects according to the new state.
 
object."ilog.tgo.model.IltObject"["objectState.SNMP.State"=Pending] {
  foreground: red;
  background: yellow;
  pattern: '@|pattern("SkewGrid", 8, 2)';
  lineStyle: "1.000001, 7.000001";
}
For more information on CSS, see Introducing cascading style sheets. For more information on how to customize the object representation based on states, see Customizing the object representation based on states.
*Create a selector that resets the values defined by the state selector, so that the normal configuration is still applied to the objects when the state changes.
 
object."ilog.tgo.model.IltObject" {
  foreground: '';
  background: '';
  pattern: '';
  lineStyle: '';
}
Customizing SNMP secondary states
How to customize an SNMP secondary state decoration (using the API)
SNMP secondary states can be displayed as charts, gauges or counters. By default, the gauge decoration is used. If you want to indicate that you are going to use another type of representation, without changing the default configuration for each representation, modify the secondary state information as follows.
 
IltSettings.SetValue("SNMP.Interface.InOctets.Type", IltDecorationType.Chart);
The property to be set is based on the SNMP state name followed by “ .Type ”, for example, SNMP.ICMP.InMsgs.Type or SNMP.TCP.OutSegs.Type.
How to customize an SNMP secondary state decoration (using CSS)
You can customize an SNMP secondary state decoration using global CSS settings.
You must specify the full state name, for example " SNMP.Interface.InOctets ", when matching the " name " attribute. The CSS property to be customized is type.
 
setting."ilog.tgo.model.IltState"[name="SNMP.Interface.InOctets"] {
   type: Counter;
}
For more information on global CSS settings, see
How to modify the gauge graphical representation of an SNMP secondary state (using the API)
When an SNMP secondary state is graphically represented by a gauge decoration, the configuration of this decoration has to be previously defined. All SNMP secondary states have a predefined gauge representation. For information on how each secondary state is graphically represented, refer to
Suppose you have a secondary state that is configured with a gauge decoration as follows.
 
IltSettings.SetValue("SNMP.ICMP.OutErrors.Type", IltDecorationType.Gauge);
You can modify this decoration in the following way.
 
IltColorModifier modifier1 = new IltColorModifier.Shade(0.5f);
IltColorModifier modifier2 = new
    IltColorModifier.MultiColor(IltColorModifier.MultiColor.USE_LAST_VALUE);
IltColorModifier modifier = modifier1.compose(modifier2);
 
IltGaugeMapping mapping = (IltGaugeMapping)
    IltSettings.GetValue("SNMP.ICMP.OutErrors.Gauge");
mapping.setColorModifier(modifier);
You can also create a new gauge mapping, and set the new value in the following way.
 
IltGaugeMapping mapping = new IltGaugeMapping(minImg, maxImg);
IltSettings.SetValue("SNMP.ICMP.OutErrors.Gauge", mapping);
How to modify the gauge graphical representation of an SNMP secondary state (using CSS)
You can customize the gauge graphical representation using global CSS settings. You must specify the full state name, for example " SNMP.Interface.InOctets ", when matching the " name " attribute. The CSS property to be customized is gauge.
When defining a new gauge mapping class, the following CSS properties are used: minImage, maxImage, direction, colorModifier. They match corresponding set methods of the IltGaugeMapping class (and its super class).
 
setting."ilog.tgo.model.IltState"[name="SNMP.ICMP.OutErrors"] {
  gauge: @+gaugeSnmp;
}
Subobject#gaugeSnmp {
  class: 'ilog.tgo.graphic.IltGaugeMapping';
  minImage: '@|image("icon1.png")';
  maxImage:'@|image("icon2.png")';
  direction: Bottom;
  colorModifier: @+myColorModifier;
}
Subobject#myColorModifier {
  class: "MyColorModifier";
}
In this example, the color modifier class named MyColorModifier has been created and included in the search path.
For information on how to customize the gauge decorations, refer to ilog.tgo.graphic.IltGaugeMapping.
How to modify the chart graphical representation of an SNMP secondary state (using the API)
When an SNMP secondary state is graphically represented by a chart decoration, the configuration of this decoration has to be previously defined. All SNMP secondary states have a predefined chart representation. Refer to The SNMP state dictionary in the Business Objects and Data Sources documentation for information on how each secondary state is graphically represented.
Suppose you have a secondary state that is configured with a chart decoration as follows:
 
IltSettings.SetValue("SNMP.ICMP.OutErrors.Type", IltDecorationType.Chart);
You can modify this decoration in the following way:
 
IltColorModifier modifier1 = new IltColorModifier.Shade(0.5f);
IltColorModifier modifier2 =
  new IltColorModifier.MultiColor(IltColorModifier.MultiColor.USE_LAST_VALUE);
IltColorModifier modifier = modifier1.compose(modifier2);
 
IltChartMapping mapping = (IltChartMapping)
  IltSettings.GetValue("SNMP.ICMP.OutErrors.Chart");
mapping.setColorModifier(modifier);
You can also create a new chart mapping, and set the new value in the following way:
 
IltChartMapping mapping = new IltChartMapping(minImg, maxImg);
IltSettings.SetValue("SNMP.ICMP.OutErrors.Chart", mapping);
How to modify the chart graphical representation of an SNMP secondary state (using CSS)
You can also customize the chart graphic representation by using global CSS settings. You must specify the full state name, for example " SNMP.ICMP.OutErrors ", when matching the " name " attribute. The CSS property to be customized is chart.
When defining a new chart mapping class, the following CSS properties are used: minImage, maxImage, xAxisDirection, yAxisDirection, colorModifier. They match corresponding set methods of the IltChartMapping class (and its super class). Refer to ilog.tgo.graphic.IltChartMapping for information on how to customize the chart decorations.
In the example below, the color modifier class named MyColorModifier has been created and included in the search path.
 
setting."ilog.tgo.model.IltState"[name="SNMP.ICMP.OutErrors"] {
  chart: @+chartSnmp;
}
Subobject#chartSnmp {
  class: 'ilog.tgo.graphic.IltChartMapping';
  minImage: '@|image("icon1.png")';
  maxImage:'@|image("icon2.png")';
  xAxisDirection: Right;
  yAxisDirection: Bottom;
  colorModifier: @+myColorModifier;
}
Subobject#myColorModifier {
  class: "MyColorModifier";
}
How to modify the counter graphical representation of an SNMP secondary state (using the API)
When an SNMP secondary state is graphically represented by a counter decoration, the configuration of this decoration has to be previously defined. All SNMP secondary states have a predefined counter representation. Refer to The SNMP state dictionary in the Business Objects and Data Sources documentation for information on how each secondary state is graphically represented.
Suppose you have a secondary state that is configured with a counter decoration as follows:
 
IltSettings.SetValue("SNMP.ICMP.OutErrors.Type", IltDecorationType.Counter);
You can modify this decoration in the following way:
 
IltCounterMapping cm = new IltCounterMapping(new DecimalFormat("#Mbs"),
                                             IltrFont.CounterText,
                                             true, Color.black,
                                             Color.white, Color.black,
                                             3, 1, IlvDirection.Right, false);
IltSettings.SetValue("SNMP.ICMP.OutErrors.Counter", cm);
How to modify the counter graphical representation of an SNMP secondary state (using CSS)
You can also customize the counter graphic representation by using global CSS settings. You must specify the full state name, for example " SNMP.ICMP.OutErrors ", when matching the " name " attribute. The CSS property to be customized is counter.
When defining a new counter mapping class, the following CSS properties are used: format, font, antialiasing, foregroundColor, backgroundColor, borderColor, xPadding, yPadding. They match corresponding set methods of the IltCounterMapping class (and its super class). Refer to ilog.tgo.graphic.IltCounterMapping for information on how to customize the counter decorations.
 
setting."ilog.tgo.model.IltState"[name="SNMP.ICMP.OutErrors"] {
  counter: @+counterSnmp;
}
Subobject#counterSnmp {
  class: 'ilog.tgo.graphic.IltCounterMapping';
  format: @+myNumberFormat;
  font: "Helvetica-Bold-12";
  antialiasing: false;
  foregroundColor: red;
  backgroundColor: blue;
  borderColor: red;
  xPadding: 100;
  yPadding: 100;
}
Subobject#myNumberFormat{
  class: 'MyNumberFormat';
}
Creating a new attribute in the System group
JViews TGO defines a specific attribute group to store SNMP System attributes. You can retrieve this attribute group with the method GetSystemAttributeGroup. The attributes present in this group are business object attributes, as defined in IlpAttribute.
JViews TGO provides an attribute class IltAttribute, which you can use directly when customizing the SNMP System group.
To extend the attributes in the SNMP System group:
*Create a new attribute with its type and attribute group.
 
IltAttribyte myAttribute = new IltAttribute("address",
                           String.class,
                           IltSNMP.GetSystemAttributeGroup());
*Register the attribute in the SNMP System Group.
To do so, use the method SetAttributeMapping. This method allows the attribute to be automatically represented in the object System Window.
 
IltSNMP.SetAttributeMapping(myAttribute, defaultValue, "Address");
*Customize the representation of this attribute through cascading style sheets.
When adding a new attribute to the System Window, create a selector for the object and attribute ( object."ilog.tgo.model.IltObject/address" ). This selector contains the following properties:
*visibleInSystemWindow : indicates that the attribute is an entry in the System window
*captionLabelVisible : indicates that a label prefixes the attribute value
*captionLabel : indicates the value of the label
*label : indicates the value of the attribute to be displayed in the System window
The following example illustrates the way to customize an attribute inside the System Window.
 
object."ilog.tgo.model.IltObject/address" {
  visibleInSystemWindow: true;
  captionLabel: Address;
  captionLabelVisible: true;
  label: @address;
}

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.