710 likes | 1.25k Views
Extending Oracle 10g Grid Control New Metrics, Targets and Plug - ins. Session number 325. Alex Gorbachev The Pythian Group COLLABORATE 07, Las Vegas 16 April 2007. http://www.pythian.com/documents/IOUG06-Extending10gGC.ppt http://www.pythian.com/documents/IOUG06-Extending10gGC.zip.
E N D
Extending Oracle 10g Grid ControlNew Metrics, Targets and Plug-ins Session number 325 Alex Gorbachev The Pythian Group COLLABORATE 07, Las Vegas 16 April 2007 http://www.pythian.com/documents/IOUG06-Extending10gGC.ppt http://www.pythian.com/documents/IOUG06-Extending10gGC.zip
Who am I? • Senior Oracle DBA at The Pythian Group • Working with Oracle since ‘97 • Pythian is a leading DBA outsourcing provider – remote DBA 24x7 • Offices worldwide – Canada, US, UK, India, Australia • www.pythian.com/blogs
Why Extending Grid Control? • Keep your own proven monitoring • Monitor non-Oracle components • In-house or COTS applications • Software and hardware vendors • Cut costs – avoid expensive packs • Write once – use many times
Pythian Real Life Example • Pythian has monitoring tool “Avail” • Built by DBA’s for DBA’s • Years of development and contributions of many DBA’s • More than just Oracle monitoring • Many customers use Avail • They don’t want to loose proven monitoring • Some have invested a lot into OEM but want to leverageyears of experience with other tool
Agenda • User Defined Metrics (UDM) • New target types • Example – MySQL • Management Plug-ins • Advanced Topics • Reports Presentation should be viewed in slide mode to show animation properly
User Defined Metrics • To extend existing targets • Oracle Instance targets • SQL querybased • Host targets • OS scripts based • UDMs - bottom of the target’s home page in the Related Links section
SQL based UDM – 10gR1 • Single column, single row • Numeric value • Thresholds operators – = < <= != etc. • Text value • Threshold operators • CONTAINS, MATCH, = • Avoid NULL values • Use “Test” button • SELECT ROUND (c.open_cursors / p.value * 100) open_cursors • FROM (SELECT sid, COUNT (*) open_cursors • FROM v$open_cursor • GROUP BY sid • ORDER BY 2 DESC) c, • v$parameter p • WHERE p.name = 'open_cursors' AND ROWNUM = 1; • Credentials (username + password) • Thresholds (70,90) • Alert message • Collection interval
Demo open cursors metric • DEMO
SQL based UDM – 10gR2 • Two columns, multiple rows • The key • The value (numeric or text) • Each key-value pair is treated separately SELECT q.owner || '.' || q.NAME queue_name, s.ready FROM v$aq s, dba_queues q WHERE s.qid = q.qid AND q.owner IN ('PYTHIAN') • Key based thresholds “<key1>:<th1>;…” • “QUEUE1:10;QUEUE2:100” • Custom alert message • Queue %Key% contains %value% messages
Demo AQ messages • DEMO
OS script based UDM • Script/binary returning single value • em_result=<value> + return zero • em_error=<message> + return none-zero • Permissions (!) • %scriptsDir% • $AGENT_HOME/sysman/admin/scripts • %perlBin% • Environment variables
OS script based UDM • Script/binary returning single value status=`/usr/bin/mysqladmin ping 2>&1` if [ "$status" = "mysqld is alive" ] ; then echo "em_result=Up" else mysqld=`ps -e | grep mysqld | grep -v grep | wc -l` if [ "$mysqld" = "0" ] ; then echo "em_result=Down“ else echo "em_error=$status“ ;exit 1 fi fi
Demo MySQL Status • DEMO
UMDs Pros and Cons • Very simple • but… • No new targets • Limited collection mechanisms • No collection on cumulative counters (V$SYSSTAT) • Has to be defined and managed for each instance • Separate credentials • No real-time collection • Requires Database Diagnostic Pack
New Targets – Real Extensibity • Develop new target types • Write once and reuse • Variety of collection mechanisms • Separation of development and operations
OEM Repository Management Servers Grid Control Architecture Agent Agent Agent Agent DBA’s Data collection
MySQL monitoring from EM • Monitor • Status, availability • Performance • Alerts • Critical and warning notifications • Reports • Easy to deploy
Demo MySQL sneak preview • DEMO
New Target Type – Main Steps • Create target type metadata • Validate new target type and metric collection • Define metrics default collection parameters • Distribute metadata and required support files to all hosts (Management Plug-ins) • Add instances of new target type
XML DTD’s – Best Reference • $AGENT_HOME/sysman/admin/dtds • Target type metadata • TargetMetadata.dtd • Metrics default collection • TargetCollection.dtd, Schedule.dtd • Target instances (in targets.xml) • TargetInstance.dtd
Target type metadata $AGENT_HOME/sysman/admin/metadata/pythian_mysql.xml <?xml version="1.0" ?> <!DOCTYPE TargetMetadata SYSTEM "../dtds/TargetMetadata.dtd"> <TargetMetadata META_VER="1.0" TYPE="pythian_mysql"> <Display>…</Display> <Metric>…</Metric> <Metric>…</Metric> <InstanceProperties>…</InstanceProperties> </TargetMetadata>
<Display> <Display> <Label NLSID=“pythian_mysql_name">MySQL</Label> </Display>
Target type metadata <?xml version="1.0" ?> <!DOCTYPE TargetMetadata SYSTEM "../dtds/TargetMetadata.dtd"> <TargetMetadata META_VER="1.0" TYPE="pythian_mysql"> <Display>…</Display> <Metric>…</Metric> <Metric>…</Metric> <InstanceProperties>…</InstanceProperties> </TargetMetadata> After (!) Metrics
<InstanceProperties> <InstanceProperties> <InstanceProperty>…</InstanceProperty> <InstanceProperty>…</InstanceProperty> <InstanceProperty>…</InstanceProperty> <DynamicProperties>…</DynamicProperties> <DynamicProperties>…</DynamicProperties> </InstanceProperties>
<InstanceProperties> <InstanceProperties> <InstanceProperty NAME="host"> <Display> <Label NLSID=“pythian_mysql_host">Hostname </Label> </Display> </InstanceProperty> </InstanceProperties>
<InstanceProperties> <InstanceProperties> <InstanceProperty NAME="password“ CREDENTIAL="TRUE“ HIDE_ENTRY="TRUE“ NEED_REENTER="TRUE“ OPTIONAL="TRUE“> <Display>…</Display> </InstanceProperty> </InstanceProperties>
<InstanceProperties> <InstanceProperties> <InstanceProperty NAME="host“/> <InstanceProperty NAME="port“/> <InstanceProperty NAME="user“/> <InstanceProperty NAME=“password“/> </InstanceProperties>
Target type metadata <?xml version="1.0" ?> <!DOCTYPE TargetMetadata SYSTEM "../dtds/TargetMetadata.dtd"> <TargetMetadata META_VER="1.0" TYPE=“pythian_mysql"> <Display>…</Display> <Metric>…</Metric> <Metric>…</Metric> <InstanceProperties>…</InstanceProperties> </TargetMetadata>
<Metric> <Metric NAME="Response" TYPE="TABLE"> <Display>…</Display> <TableDescriptor>…</TableDescriptor> <QueryDescriptor>…</QueryDescriptor> </Metric> • TABLE • STRING • NUMBER Fetchlets • OS Command • SQL • SNMP • URL Timing • HTTP Data • URLXML • JDBC
<Metric> <Metric NAME="Response" TYPE="TABLE"> <TableDescriptor> <ColumnDescriptor NAME="Status" TYPE="STRING“/> <ColumnDescriptor NAME="response_time“ TYPE="NUMBER"> <Display FOR_SUMMARY_UI="TRUE"> <Label NLSID="resp_time">Response time (ms) </Label> <ShortName NLSID="resp_s">Response</ShortName> </Display> </ColumnDescriptor> </TableDescriptor> </Metric>
<Metric> <Metric NAME="Response" TYPE="TABLE"> <Display>…</Display> <TableDescriptor>…</TableDescriptor> <QueryDescriptor>…</QueryDescriptor> </Metric>
<QueryDescriptor> <Metric NAME="Response" TYPE="TABLE"> <QueryDescriptor FETCHLET_ID="OSLineToken"> <Property NAME="myhost“ SCOPE="INSTANCE">host</Property> <Property NAME="myport“ SCOPE="INSTANCE“ OPTIONAL="TRUE">port</Property> <Property NAME="myuser" SCOPE="INSTANCE“ OPTIONAL="TRUE">user</Property> <Property NAME="mypwd" SCOPE="INSTANCE“ OPTIONAL="TRUE">password</Property> …… </QueryDescriptor> </Metric>
<QueryDescriptor> <Metric NAME="Response" TYPE="TABLE"> <QueryDescriptor FETCHLET_ID="OSLineToken"> …… <Property NAME="startsWith“ SCOPE="GLOBAL">em_result=</Property> <Property NAME="errStartsWith“ SCOPE="GLOBAL">em_error=</Property> <Property NAME="delimiter“ SCOPE="GLOBAL">|</Property> <Property NAME="command“ SCOPE="GLOBAL"> %scriptsDir%/emx/pythian_mysql/ pythian_mysql_load.sh %myhost% %myport% %myuser% %mypwd% </Property> </QueryDescriptor> </Metric>
Output– pythian_mysql_load.sh • MySQL server up……………exit 0 em_result=Up|10 • MySQL server down………...exit 0 em_result=Down • Metric collection error………exit 1 em_error=<error message>
Demo MySQL status script • DEMO
Response Metric • Availability monitoring • Must be of type TABLE • Must contain column Status • Must have critical threshold defined in default collection properties
Property Scope • GLOBAL • Target type metadata • SYSTEMGLOBAL • emd.properties • INSTANCE • Instance properties – targets.xml • ENV • Environment variables
Cumulative data collection <TableDescriptor> <ColumnDescriptor NAME="threads_connected“ TYPE="NUMBER“ /> <ColumnDescriptor NAME="threads_running” TYPE="NUMBER“ /> <ColumnDescriptor NAME="connections" TYPE="NUMBER“ TRANSIENT="TRUE" /> <ColumnDescriptor NAME="connections_ps“ TYPE="NUMBER“ COMPUTE_EXPR= “(connections - _connections) / __interval“/> </TableDescriptor>
Cumulative data collection • Two collection points • em_result=9|3|10498 • em_result=6|4|11265 • Interval – 5 minutes • (11265 - 10498) / 300 = 2.6 /sec
Key columns <TableDescriptor> <ColumnDescriptorNAME="action“TYPE="STRING“ IS_KEY="TRUE“ /> <ColumnDescriptorNAME="proccount“TYPE="NUMBER“ /> </TableDescriptor> +=============+===============================+ |action |proccount | |(Action )|(Number of processes in action)| |type = STRING|type = NUMBER | +=============+===============================+ | Query | 1 | +-------------+-------------------------------+ | Sleep | 2 | +-------------+-------------------------------+
Metadata Validation • ILint • Static validation • Data collection • Metric Browser • Verify data collection in Oracle Agent environment
ILint validation • XML syntax • Conformance to DTD • XML file must contain DOCTYPE line • Additional validation based on heuristical rules
ILint syntax • Help – emctl ilint $ emctl ilint \ -m $AGENT_HOME/sysman/admin/metadata/pythian_mysql.xml $ emctl ilint \ –m $AGENT_HOME/sysman/admin/metadata/pythian_mysql.xml \ -i /opt/oracle/pythian_targets.xml \ -t Pythian-MySQL \ –r Response
ILint collection validation • Sample targets.xml with target instance /opt/oracle/pythian_targets.xml <Targets> <Target TYPE=“pythian_mysql“ NAME=“Pythian-MySQL"> <Property NAME="host" VALUE=“gc.pythian.com"/> <Property NAME="user" VALUE="root"/> </Target> </Targets>
ILint collection validation Validating Target = "Pythian-MySQL" of Type = "pythian_mysql" =============================================================================== Target = "Pythian-MySQL" has the following 2 Properties =============================================================================== Property: host --> Value: gc.pythian.com (INSTANCE) Property: user --> Value: root (INSTANCE) =============================================================================== Executing Metric = "Response" =============================================================================== Number of Rows = 1 +=============+====================+ |Status |response_time | | |(Response time (ms))| |type = STRING|type = NUMBER | +=============+====================+ | Up | 60 | +-------------+--------------------+ METRIC=Response, TARGET=(pythian_mysql,Pythian-MySQL)
Demo Ilint validation • DEMO
Metric Browser $AGENT_HOME/sysman/config/emd.properties enableMetricBrowser=true $ emctl stop agent $ emctl start agent Find - EMD_URL=http://<host>:<port>/emd/main/ Use - http://<host>:<port>/emd/browser/main Register: $ emctl config agent addtargets \ /opt/oracle/pythian_targets.xml
Demo Metric Browser • DEMO
Default Collection • Default collection intervals • Default warning and critical thresholds • $AGENT_HOME/sysman/admin/default_collection <?xml version="1.0" ?> <!DOCTYPE TargetCollection SYSTEM "../dtds/TargetCollection.dtd"> <TargetCollection TYPE=“pythian_mysql"> <CollectionItem> … </CollectionItem> <CollectionItem> … </CollectionItem> <CollectionItem> … </CollectionItem> </TargetCollection>
Default Collection <CollectionItem NAME="Response“ UPLOAD="YES“ UPLOAD_ON_FETCH="TRUE"> <Schedule> <IntervalSchedule INTERVAL="5" TIME_UNIT="Min“/> </Schedule> <Condition COLUMN_NAME="Status" CRITICAL="Down“ OPERATOR="CONTAINS“ /> <Condition COLUMN_NAME="response_time“ WARNING="100" CRITICAL="300“ OPERATOR="GT" OCCURRENCES="2“ /> </CollectionItem> $ emctl ilint \ –m $AGENT_HOME/sysman/admin/metadata/pythian_mysql.xml \ -c …/admin/default_collection/pythian_mysql.xml