http://www.ibm.com/support/knowledgecenter/SSSHYH_7.1.0.4/com.ibm.netcoolimpact.doc/solution/uidataprovider_status_and_precentages_widget_t.html
Displaying status and percentage in a widget
Displaying status and percentage in a widget
You can show status and percentage in topology, tree, table,
and list widgets by using policies or data types. To show status and
percentages in a widget, you must create a script in JavaScript format
in the data type if the policy uses the GetByFilter function.
About this task
For data types, SQL, SNMP, and internal data types are
supported. For policies the GetByFilter, DirectSQL and Impact Object,
and Array Of Impact Objects are supported.
- Create the data type.
- In the data type configuration window, add the script to the Define
Custom Types and Values (JavaScript) area.Restriction: Not all functions that are provided by JavaScript are supported. If you get a syntax error for a known JavaScript function, check that the function is supported in an Impact policy.
- Click the Check Syntax and Preview Sample Result button to preview the results and to check the syntax of the script.
For DirectSQL and Impact Object, Array Of Impact Objects,
the Status, and Percentage can be specified when you create the schema
definition. For policies, you can use IPL or JavaScript for the DirectSQL
or GetByFilter functions.
The script uses the following syntax
for data types and for policies that use the GetByFilter function.
ImpactUICustomValues.put("FieldName,Type",VariableName);
Where Type is
either Percentage or Status. VariableName,
can be a variable or hardcoded value. Always cast the variable name
to String to avoid any error even if the value is numeric. See the
following examples:
ImpactUICustomValues.put("MyField,Percentage",""+VariableName);
ImpactUICustomValues.put("MyField,Percentage","120");
ImpactUICustomValues.put("FieldName,Percentage",""+(field1/40));
The
status field expects the value to be similar to the Topology widget
configuration:
Status | Number |
---|---|
Critical | 5 |
Major | 4 |
Minor | 3 |
Warning | 2 |
Intermediate or Indeterminate.
|
1 |
There is no limit to how many fields you can put in the
variable ImpactUICustomValues. The variable must
be at the very end of the script. Anything before the variable must
be in JavaScript and can be anything if the variable ImpactUICustomValues is
populated correctly.
Example 1:
Assigns the field
name from the table to be the status or the percentage and assigns
the field value. This example assigns SHAREDOWN and PROFIT as
the percentages, and STANDING as the status.
ImpactUICustomValues.put("SHAREUP,Percentage",SHAREUP);
ImpactUICustomValues.put("SHAREDOWN,Percentage",SHAREDOWN);
ImpactUICustomValues.put("PROFIT,Percentage",PROFIT);
ImpactUICustomValues.put("STANDING,Status",STANDING);
Example
2:
This example has an extra calculation to determine the
value of percentage or status fields. The percentage assumes the
maximum value to use is 100. Then, a factor is used to scale the values
that are based on the maximum value that is expected by the user.
The status and percentage is scaled based on a factor.
var status = "Normal";
var down = 0;
var up = 0;
var factor = ( TOTAL / 100);
down = (DOWN / factor);
up = (UP / factor);
var statusFactor = (DOWN / TOTAL) * 100;
if ( statusFactor >= 50) {
status = "Critical";
} else if ( statusFactor >= 30 ) {
status = "Major";
} else if (statusFactor >= 20) {
status = "Minor";
} else if (statusFactor >= 10 ) {
status = "Warning";
} else {
status = "Normal";
}
ImpactUICustomValues.put("DownPercentage,Percentage",""+down);
ImpactUICustomValues.put("UpPercentage,Percentage",""+up);
ImpactUICustomValues.put("NetworkStatus,Status",""+status);
Example 3:
This example uses extra
fields that do not exist in the table and used to be the Status and
Percentage. The values are the exact values that come from fields
that exist in the table. Calculation can be used to assign different
values:
ImpactUICustomValues.put("CPUPercentUsage,Percentage",CPUUsage);
ImpactUICustomValues.put("RAMPercentUsage,Percentage",RAMUsage);
ImpactUICustomValues.put("DiskPercentUsage,Percentage",DiskUsage);
ImpactUICustomValues.put("NetworkAvailability,Status",NetworkStatus);
Tip: The Table or List widget shows duplicate entries or have
missing data when you compare the data to the data type data items.
Check the data source to ensure that all keys are unique.
Tip: In an instance where you use a policy function to create
a dynamic filter, and you get a message in the policy log. The messages
states that the filter variable is not defined in policy. No eventing
occurs between widgets. Check that you are not using any special characters
in the custom value in the data type for example, ImpactUICustomValues.put("CPU%,Percentage",""+value).
The widgets do not support special characters in field names.
Tip: If a data type field type is incorrectly defined, for example
the field is defined as an integer, but contains float values the
widget fails to load. The widget shows a message similar to this example:
Failed to load
To
resolve the issue, edit the data type field and select the correct
data type float.
No comments:
Post a Comment