1 / 65

Extending Perceive (Part 1 The old way)

Extending Perceive (Part 1 The old way). Customizing Perceive. Perceive is built on an open and flexible code base that permits customization for those knowledgeable in XML and SQL.

ramla
Télécharger la présentation

Extending Perceive (Part 1 The old way)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Extending Perceive (Part 1 The old way)

  2. Customizing Perceive • Perceive is built on an open and flexible code base that permits customization for those knowledgeable in XML and SQL. • When trying to handle a specific customer request that is not part of the available features, it is sometimes useful to extend the Perceive capabilities in the field to deliver one-time customer-specific features. • There is currently no UI (or any published guidance) in the product to do this, nor is there any troubleshooting assistance to debug where a custom change went wrong.

  3. The basics – Minimal XML Primer • All configuration files are in XML • Each element is defined by a tag. Ex. <tag> • The first tag is known as the root element. • Each tag must be terminated. Ex. <tag/> or <tag></tag> • Tags can be Hierarchical. Ex. <tag1><tag2/><tag3></tag3></tag1> • Tags can have attributes. Ex. <tag name=“value”/> • Tags can contain data. Ex. <tag>value</tag> • Text in data tags can be escaped. Ex. <![CDATA[…]]> • <!– This is a comment, it can span multiple lines … --> • For more information see:

  4. Example XML Structure • <metric name="Disk Utilization" label="Disk Utilization"> • <metric name="All Disks - Chart" label="All Disks - Chart“/> • <metric name="All Disks - Table" label="All Disks - Table“/> • <metric name="Top 10 Disks -Chart" label="Highest - Chart“/> • </metric>

  5. The Files that you need to know • Location: c:\program files\bmc software\cwa\ • jakarta-tomcat-4.0.3\webapps\qtv\web-inf • Tasks.xml, common.xml, reports.xml, config.xml, • datasources.xml, vis-sql.xml. • Platforms.xml, your-reports.xml, your-common.xml, • your-datasources.xml, your-sql.xml.

  6. The basics – About Tasks.xml • Perceives scheduler. • Possible arguments are in tasks.txt file

  7. The basics – About Reports.xml • Reports.xml Contains the type of reports available to Perceive, the intervals available for selection and the charts that the Administrator has created. • <?xml version="1.0"?> • <defs> • <version id="7.1.21"/> • <reports> • </reports> • <intervals> • </intervals> • <charts> • </charts> • </defs>

  8. The basics – About Config.xml • Config.xml contains the structure of the GUI and the datasources that are activated for Perceive to access. • <?xml version="1.0"?> • <config> • <version id="7.1.21"/> • <reporting> • <defaults interval-id="Yesterday" report-id="" domain="" • system="" legend-position="east" legend-visible="auto"/> • </reporting> • <application name="Perceive" theme-id="pwc" company=" BMC Software" • url="http://www.bmc.com" email="[Administrator]@[Company].com"/> • </config>

  9. The basics – About Datasources.xml • Datasources.xml contains the JDBC driver strings to connect to different ODBC datasources, Agent data and the UDR data repository. • <?xml version="1.0" encoding="UTF-8"?> • <sources> • <version id="7.1.21"/> • <source name="Visualizer - Oracle" java-type="com.bmc.qtv.data.vis.VisJDBCDataSourceFactory"> • <property-def name="host" type="string"/> • <property-def name="user" type="string"/> • <property-def name="password" type="string" masked="true" emptyAllowed="true"/> • <property-def name="database-instance" type="string"/> • <property-def name="port" type="int" defaultValue="1521"/> • <property-def name="max-connections" type="int" defaultValue="10" • minInclusive="1" maxInclusive="20"/> • <property-def name="driver" type="string" hidden="true" • defaultValue="oracle.jdbc.driver.OracleDriver"/> • <property-def name="connection-order" type="int" hidden="true" • defaultValue="1" minInclusive="1"/> • <property-def name="sql-file" type="string" hidden="true" • defaultValue="vis-sql.xml"/> • <property-def name="url-template" type="string" hidden="true" • defaultValue="jdbc:oracle:thin:${user}/${password}@${host}:${port}:${database-instance}"/> • </source>

  10. The basics – About Common.xml • Common.xml contains the list of available reports that can be selected from the “Create View” GUI by the Administrator. • <?xml version="1.0" encoding="UTF-8" ?> • <common> • <version id="7.1.21" /> • <metric name="System Info" label="CPU" • description="System Information" • data-type="com.bmc.qtv.data.PMTextProperties" • cached="false" /> • <metric name="CPU" label="CPU"> • <metric name="CPU Utilization" label="CPU Utilization" data- type="com.bmc.qtv.data.PMSeries" units="%" floor="0" ceiling="100"/> • <metric name="CPU User" label="CPU User" data-type="com.bmc.qtv.data.PMSeries" units="%" floor="0" ceiling="100"/> • <metric name="CPU Privileged" label="CPU Privileged" data-type="com.bmc.qtv.data.PMSeries" units="%" floor="0" ceiling="100"/> • <metric name="Processor CPU Utilization" label="Processor CPU Utilization"> • <metric name="All Processors - Chart" label="All Processors - Chart" description="CPU Utilization - All Processors" data-type="com.bmc.qtv.data.PMMultiSeries" units="%" floor="0" ceiling="100"/> • <metric name="All Processors - Table" label="All Processors - Table" description="CPU Utilization - All Processors" data-type="com.bmc.qtv.data.PMDataObject"/> • <metric name="Top 10 Processors - Chart" label="Highest Processors - Chart" description="CPU Utilization - Highest Processors" data-type="com.bmc.qtv.data.PMMultiSeries" units="%" floor="0" ceiling="100" • cached="false" /> • </metric>

  11. The basics – About Common.xml

  12. The basics – About Vis-SQL.xml • Vis-sql.xml contains the SQL that gets called from when a report is requested by a user. It also contains the discovery query to populate the list of nodes for the drop-down list. • <?xml version="1.0"?> • <vis> • <version id="7.1.21" /> • <nodeDiscoveryQuery> • SELECT NODE_ALIAS AS NAME, MEMORY_SIZE, NUM_OF_PROC AS NUMBER_OF_PROCESSORS, • MODEL, OS_TYPE AS OS, SPEC_RATING, NODE_TYPE AS TYPE • FROM CAXNODE • WHERE NODE_ALIAS NOT LIKE 'zzzROW%' AND NUM_OF_PROC IS NOT NULL • AND OS_TYPE IS NOT NULL AND NODE_ALIAS IS NOT NULL • </nodeDiscoveryQuery>

  13. The basics – How Perceive uses Tomcat • (There are steps skipped in this outline) • -> Perceive Starts ------------------------------------------ • |-> Checks Config.xml to see available datasources | • |-> Uses Datasources.xml to connect to ODBC sources | • |-> Datasources.xml calls vis-sql.xml files | • |-> vis-sql.xml does discovery query ------|

  14. The basics – verbose logging (You will need this!) • The logs are located at C:\program files\bmc software\cwa\jakarta-tomcat-4.0.3\logs • To enable verbose logging: • CWA_HOME/jakarta-tomcat-4.0.3/webapps/qtv/WEB-INF/classes directory, adding the following line to the file; logger4j.properties • Code: • log4j.logger.com.bmc.qtv.data=DEBUG • Then restart the perceive process or service

  15. The basics – More about Tasks.xml • A simple edit: • <tasks> • <task id="1" description="Data Source Maintenance" first-time="5:00" interval-mins="1440"> • <action-ref idref="refresh-ds-class"> • <arg name="class" value="com.bmc.qtv.data.AbstractBMCDataSource"/> • <arg name="node-discovery" value="true"/> • </action-ref> • <on-error><action-ref idref="recover" /></on-error> • </task> • </tasks>

  16. The basics – More about Tasks.xml • A simple edit: • <tasks> • <task id="1" description="Data Source Maintenance" first-time=“7:00" interval-mins="1440"> • <action-ref idref="refresh-ds-class"> • <arg name="class" value="com.bmc.qtv.data.AbstractBMCDataSource"/> • <arg name="node-discovery" value="true"/> • </action-ref> • <on-error><action-ref idref="recover" /></on-error> • </task> • </tasks>

  17. The basics – About reports.xml • The arguments can be found in intervals.txt • A simple edit: • <intervals> • <interval id="Last60Mins" name="Last Hour" type="relative"> • <start> • <min type="relative" value="0"/> • <hour type="relative" value="-1"/> • </start> • <end> • <min type="relative" value="0"/> • </end> • </interval>

  18. The basics – About reports.xml • The arguments can be found in intervals.txt • A simple edit: • <interval id="Demo Data" name="Demo Data" type="relative"> • <start> • <hour type="fixed" value="0"/> • <day type="fixed" value="9"/> • <month type="fixed" value="8"/> • <year type="fixed" value="2002"/> • </start> • <end> • <hour type="fixed" value="0"/> • <day type="fixed" value="14"/> • <month type="fixed" value="8"/> • <year type="fixed" value="2002"/> • </end> • </interval>

  19. The basics – More about common.xml • Perceive only knows about 3 data types;

  20. The basics – More about common.xml

  21. The basics – More about common.xml • Defining a metric – Full metric descriptions have the following attributes;

  22. The basics – vis-sql.xml • Describes the metrics derived from the Visualizer DB. • Hierarchical structure starting with the root element <vis>. • Includes specialized entries for <nodeDiscovery>, <intervalDiscovery> and <System Info> which discover and define available data within the database (topic for an advanced class) • For each metric there is the hierarchical structure; • <query …> • <sql> • SELECT … • </sql> • </query>

  23. The basics – vis-sql.xml • The Query tag contains the following attributes;

  24. The basics – More about vis-sql.xml • Some points of interest;

  25. The basics – More about vis-sql.xml • A few more things… • - Some results are affected • Ex. <operation name="DivideOperation" operand="1024"/> • - Network Packets is an anomaly • - Most of the per platform differences are on the Network, the other is memory. • - There are some hard-coded rules to address these!

  26. Vis-sql.xml – SQL Primer • Just enough SQL to get at the data • SQL – Structured Query Language • Schema – Defines the tables, the fields in each table, and the relationships between fields and tables. • Database – A grouping of tables, views, stored procedures, user permissions etc. This nomenclature applies well to SQL Server, Access and any ODBC data. Oracle, however, calls this a Tablespace.

  27. Vis-sql.xml – SQL Primer • The Select Statement – Retrieves rows from the database • Select all fields for all records from a table • select * from tableA • Select specific fields from a table • select field1, field2 from tableB • Select specific fields from more than one table • select table1.field1, table2.field1 • from tableA, tableB* • *Note – This is not a clean query for reasons beyond the current scope.

  28. Vis-sql.xml – SQL Primer • The Where Statement – Specifies a search condition to restrict the rows returned. • Select field1 from tableA and tableB but only for records where field3 of the two tables are equal. • select tableA.field1, tableB.field1 • from tableA, tableB • where tableA.field3 = tableB.field3

  29. Vis-sql.xml – SQL Primer • The Where Statement – Conditions. • = Equals • < Less Than • > Greater Than • !> Not Greater, !< Not Less • != or <> Not Equal • between X and Y or between ‘X’ and ‘Y’ • in (0, 1, 5, 7) or in (‘CA’, ‘MA’) • String Matches • like ‘abc%’ - A string that starts with abc. • like ‘abc_’ - A four character string starting with abc. • NULL Fields • IS [NOT] NULL

  30. Vis-sql.xml – SQL Primer • Order by – Sorting the selected output • Ex. List all last names in the phonebook in descending alphabetical order. • select distinct(lastname) • from phonebook • order by lastname desc • Group by – Aggregate records for computation • When used with a GROUP BY clause, each aggregate function produces a single value for each group, rather than for the whole table. • Having - Specifies a search condition for a group or an aggregate.

  31. Vis-sql.xml – SQL Primer • Some useful functions • Distinct() – Remove duplicate entries from fields. • Ex. List all names within a phonebook • select distinct(lastname) from phonebook • Count() – A count of the selected records • Ex. How many Stupps are in the phonebook • select count(lastname) from phonebook • where lastname like ‘Stupp’ • Ex. How many unique names are in the phonebook • select count(distinct(lastname)) from phonebook

  32. Vis-sql.xml – SQL Primer • Some other functions • avg() • min() • max() • sum() • trim()

  33. The basics – More about vis-sql.xml • A closer look at the SQL tag. • The SQL Tag is a data element with Text in it. It must contain valid SQL as per; • SELECTINT_START_DATE as D, INT_START_TIME AS T, METRIC AS V • FROM CAXINTVL, CAXCPUS, CAXCPUD • WHERE INTVL=CAXINTVL.INDEXX • AND CAXCPUS.INDEXX=CPUS AND NODE_NAME='!NAME!' • AND CAXINTVL.INTTYPE='M' AND CAXCPUD.CPU_UTIL >= 0 • AND CAXINTVL.INT_START_DATE BETWEEN '!START!' AND '!END!' • GROUP BY CAXINTVL.INT_START_DATE, CAXINTVL.INT_START_TIME • ORDER BY CAXINTVL.INT_START_DATE, CAXINTVL.INT_START_TIME

  34. Getting Started – Adding a metric (The old way) • The easiest way to add a metric is to simply copy and paste and existing metric and alter the details. For instance, let’s add CPU Wait Time. • Update common.xml • 1) Copy • <metric name="CPU Utilization" label="CPU Utilization" data-type="com.bmc.qtv.data.PMSeries" units="% " floor="0" ceiling="100"/> • 2) Change “CPU Utilization” to “CPU Wait Time”

  35. Getting Started – Adding a metric (The old way) • Update vis-sql.xml • This usually requires some comfort with the schema. See the 3.7 documentation for details although even that may not be enough. You should be comfortable browsing the database with native tools. • In this case, we need the CAXCPU tables.

  36. Getting Started – Adding a metric (The old way) • 1) Copy • <query name="CPU Utilization“ path="CPU/CPU Utilization“ os="all“ units="%"> • <sql> • SELECT CAXINTVL.INT_START_DATE AS D, CAXINTVL.INT_START_TIME AS T, • AVG(CAXCPUD.CPU_UTIL) AS V • FROM CAXINTVL, CAXCPUS, CAXCPUD • WHERE CAXCPUD.INTVL=CAXINTVL.INDEXX • AND CAXCPUS.INDEXX=CAXCPUD.CPUS AND CAXCPUS.NODE_NAME='!NAME!' • AND CAXINTVL.INTTYPE='M' AND CAXCPUD.CPU_UTIL >= 0 • AND CAXINTVL.INT_START_DATE BETWEEN '!START!' AND '!END!' • GROUP BY CAXINTVL.INT_START_DATE, CAXINTVL.INT_START_TIME • ORDER BY CAXINTVL.INT_START_DATE, CAXINTVL.INT_START_TIME • </sql> • </query> • 2) Change “CPU Utilization” to “CPU Wait Time” • 3) Change each instance of CPU_UTIL to CPU_WAIT (there are 2)

  37. Getting Started – Adding a metric (The old way) • NOTE! You must restart Perceive in order for these changes to take effect! • NOTE! You will re-start Perceive a lot when building extensions! • NOTE! It’s generally a good idea to test whether the file is valid by loading it in a browser before re-starting Perceive.

  38. Getting Started – Adding a metric (The old way) What is wrong with it? • When upgrading, you have to save your extensions and “cut and paste” them into your new xml files.

  39. Extending Perceive (Part 2 The new way)

  40. Adding a metric. The new structure • Install Perceive 7.1.21 • Patch it with patch level patch-1029531.tar

  41. Adding a metric. The new structure • The new files: • Platforms.xml (exists) • My-datasources.xml (create) (multiple) • My-sql.xml (create) (multiple) • My-common.xml (create) (multiple) • My-reports.xml (create) (multiple)

  42. How Perceive 7.1.21 uses Tomcat • (There are steps skipped in this outline) • -> Perceive Starts < -------------------------------------------------- • |-> Checks Config.xml to see available datasources | | • |-> Checks Platforms.xml for packages available packages | | • |-> Uses Datasources.xml to connect to ODBC sources | | • | |-> Datasources.xml calls vis-sql.xml files | | • | |-> vis-sql.xml does discovery query -------| | • |-> Uses My-Datasources.xml to connect to ODBC sources | • |-> My-Datasources.xml calls my-vis-sql.xml files | • |-> My-vis-sql.xml does discovery query ------|

  43. Adding a metric. The new structure • <?xml version="1.0" encoding="UTF-8"?> • <platforms> • <version id="7.1.21"/> • <platform • datasources="as400_datasources.xml" • description="iSeries Visualizer metrics, data sources, and views" • enabled="false" • id="iseries" • metrics="as400_metrics.xml" • name="iSeries" reports="as400_reports.xml"/> • </platforms>

  44. Adding a metric. The new structure

  45. Adding a metric. The new structure • <?xml version="1.0" encoding="UTF-8"?> • <platforms> • <version id="7.1.21"/> • <platform • datasources="as400_datasources.xml" • description="iSeries Visualizer metrics, data sources, and views" • enabled="false" • id="iseries" • metrics="as400_metrics.xml" • name="iSeries" reports="as400_reports.xml"/> • <platform • datasources=“my-datasources.xml" • description="extended metrics for Visualizer datasources, and views" • enabled=“false" • id="extended" • metrics=“my_common.xml" • name="Extended Visualizer Metrics" reports=“my_reports.xml"/> • </platforms> This tag must match the common_name in my-common.xml and the path in my-sql.xml

  46. Adding a metric. The new structure • Create your own files by copying the existing xml files. • My-datasources.xml • My-reports.xml • My-sql.xml • My-common.xml

  47. Adding a metric. The new structuremy-datasources.xml • <?xml version="1.0" encoding="UTF-8"?> • <sources> • <version id="7.1.21"/> • <source name="Extended Visualizer - Access" java-type="com.bmc.qtv.data.vis.VisODBCDataSourceFactory"> • <property-def name="ODBC-DSN" type="string"/> • <property-def name="user" type="string" required="false" emptyAllowed="true"/> • <property-def name="password" type="string" masked="true" required="false" emptyAllowed="true"/> • <property-def name="max-connections" type="int" hidden="true" • defaultValue="1" minInclusive="1" maxInclusive="1"/> • <property-def name="driver" type="string" hidden="true" • defaultValue="sun.jdbc.odbc.JdbcOdbcDriver"/> • <property-def name="connection-order" type="int" hidden="true" • defaultValue="1" minInclusive="1"/> • <property-def name="sql-file" type="string" hidden="true" • defaultValue=“my-sql.xml"/> • </source> • </sources>

  48. Adding a metric. The new structuremy-reports.xml • <?xml version="1.0"?> • <defs> • <version id="7.1.21"/> • <reports> • </reports> • <intervals> • </intervals> • <charts> • </charts> • </defs> The is basically a placeholder. No changes written in here will have any effect.

  49. Adding a metric. The new structuremy-sql.xml Caused by patch to increase performance • <?xml version="1.0"?> • <vis> • <version id="7.1.21" /> • <nodeDiscoveryQuery> • SELECT NODE_ALIAS AS NAME, MEMORY_SIZE, NUM_OF_PROC AS NUMBER_OF_PROCESSORS, • MODEL, OS_TYPE AS OS, SPEC_RATING, NODE_TYPE AS TYPE • FROM CAXNODE • WHERE NODE_ALIAS NOT LIKE 'zzzROW%' AND NUM_OF_PROC IS NOT NULL • AND OS_TYPE IS NOT NULL AND NODE_ALIAS IS NOT NULL • </nodeDiscoveryQuery> • <intervalDiscoveryQuery> • SELECT INT_START_DATE AS D, INT_START_TIME AS T, INT_DURATION AS DUR • FROM CAXINTVL • WHERE INTTYPE='M' • ORDER BY INT_START_DATE, INT_START_TIME • </intervalDiscoveryQuery> • <query name="System Info" path="/extended/System Info" os="all"> • <sql> • SELECT NODE_ALIAS AS NAME, MEMORY_SIZE, NUM_OF_PROC AS NUMBER_OF_PROCESSORS, MODEL, OS_TYPE AS OS, • SPEC_RATING, NODE_TYPE AS TYPE • FROM CAXNODE • WHERE NODE_ALIAS='!NAME!' • </sql> • </query> • </vis> Match tag in platforms.xml

  50. Adding a metric. The new structuremy-common.xml • <?xml version="1.0" encoding="UTF-8" ?> • <common name="extended" label="extended"> • <version id="7.1.21" /> • <metric name="System Info" label="CPU" • description="System Information" • data-type="com.bmc.qtv.data.PMTextProperties" • cached="false" /> • </common> Tag match from platforms.xml

More Related