Addmi 10.5-basic query-language
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
569
On Slideshare
569
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
14
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • The search is useful to find Hosts where we have not been able to determine the CPU type.
  • Note: “search host” is of course meant to fail.
  • Note: the last query is meant to fail.
  • Note: The second query is meant to fail.

Transcript

  • 1. Basic TF Query Language Power searching
  • 2. Query Language Outline
    • Formulating Queries Basics
    • SEARCH and WHERE
    • Regular Expression Basics
    • Controlling Display
    • Putting it all together
  • 3. Query language
    • A way of asking the datastore to extract a list nodes, and a subset of their attributes
      • Performs the same function as SQL in a relational database
    • It forms the basis of every datastore read
      • Used internally by Atrium Discovery
      • Used when viewing built-in reports
      • Used for user-generated queries
      • Used for ad-hoc user queries
      • Used within TPL (patterns)
    • There are special keywords to describe what to pick: SEARCH, WHERE
    • And keywords to decide how to display it: SHOW, ORDER
  • 4. Formulating Queries in the UI
  • 5. Generic Query Interface
    • Enter query, may split over several lines for clarity
    • Press ‘Run Query’ to see results
    • Results can be exported as CSV or XML
  • 6. Previous Queries
    • Under the search query window a list of previous queries is available
      • Clicking these copies the query into the search box
  • 7. Saving Previous Queries
    • Use “//” to provide a title to your query
    • Title is shown in Previous Queries section
    • Can drag and drop query to bookmark
      • Query will work on any Atrium Discovery instance
  • 8. SEARCH and WHERE
  • 9. SEARCH
    • Looks through all the data and returns a set of nodes based on the specified node kind
    • SEARCH kind
      • Find all nodes of given kind
      • e.g. SEARCH SoftwareInstance
    • These nodes are displayed as a list
  • 10. Adding a WHERE
    • SEARCH Host
      • Collect the set of nodes of kind “Host”
    • Add limiting conditions
    • WHERE os_type = 'Solaris'
      • Restrict the set of nodes to those that contain a specific string in the “os_type” attribute
    • WHERE <attribute> [conditional statement]
  • 11. Some Simple Conditions
    • Equality
      • a = b
    • Not equals
      • a <> b
    • Similarly
      • a > b
      • a < b
      • a >= b
      • a <= b
  • 12. More Advanced Conditions
    • a HAS SUBSTRING b
      • Works if the attribute contains the given string
    • a HAS SUBWORD b
      • Works if the attribute contains the given word
    • a MATCHES b
      • Lets you use pattern matching (Regular Expressions)
    • a IN [b, c, d, e]
      • Lets you search for a number of possible values
  • 13. Multiple Conditions and Arithmetic
    • Multiple conditions if you join them with logical operations
      • AND
      • OR
      • NOT
    • Brackets are useful to aid readability, and ensure precedence
      • ( )
    • Integer arithmetic only
      • + - * /
  • 14. Special Conditions
    • DEFINED
      • This condition is true if the node has the attribute
      • The value is not important
      • Useful given the dynamic nature of the datastore
    • SEARCH Host WHERE processor_type NOT DEFINED
  • 15. A Word on Performance a = b a HAS SUBWORD b a HAS SUBSTRING b a MATCHES b Full use of datastore indexes Full use of datastore indexes Partial use of datastore indexes No use of datastore indexes SPEED
  • 16. Alternatives to MATCHES
    • Case insensitive search
      • WHERE name MATCHES ‘(?i)fred’ (0.20s)
      • WHERE name HAS SUBWORD ‘fred’ (0.03s)
    • Multiple word match
      • WHERE os MATCHES ‘(?i)Microsoft.+Datacenter’ (0.14s)
      • WHERE os HAS SUBWORD 'Microsoft Datacenter‘ (0.09s)
    • A list of possible values
      • WHERE name MATCHES ‘(?i)TSL-D’ (0.24s)
      • WHERE name IN ['tsl-dkirby','tsl-dtweed','tsl-duncan'] (0.08s)
  • 17. Query Exercises
  • 18. Exercise 1
    • SEARCH host
    • SEARCH Host
    • SEARCH SoftwareInstance
    • SEARCH DiscoveredFile
    • Use “//” to title a report
      • Drag and drop to create a bookmark
  • 19. Exercise 2
    • SEARCH Host WHERE os = &quot;SunOS 5.10&quot;
    • SEARCH Host WHERE os <> &quot;SunOS 5.10&quot;
    • SEARCH Host WHERE name has substring &quot; Win &quot;
    • SEARCH Host WHERE name has subword &quot;Win&quot;
  • 20. Exercise 3
    • SEARCH Host WHERE os = &quot;SunOS 5.10&quot; AND vendor = &quot;Sun Microsystems&quot;
    • SEARCH Host WHERE os = &quot;SunOS 5.10&quot; AND vendor NOT matches &quot;Sun Microsystems&quot;
  • 21. Regular Expression Basics
  • 22. Character and Anchoring Matches
    • Characters match themselves, except
      • . ^ $ * + ? { } [ ] | ()
      • To match one of these you need to put a backslash before it
    • Be careful with Foundation pathnames
      • Use . to match a full stop
      • Use to match a (Windows) path separator
    • Anchoring matches
      • ^expr – match only at start of string
      • expr$ – match only at end of string
  • 23. General Matches
    • . A period matches any character
    • [ abcdef] square brackets match any one of the things inside
    • [^123] match anything NOT contained within the brackets
    • a|b matches one thing or the other
    • Brackets group things together: (Fred)|(Fiona) matches either name
  • 24. Repeated Characters
    • Very often want to repeat/extend matches to more than a single character
    • Sometimes called wildcard matching
    • ? matches 0 or 1 occurrences
    • + matches 1 or more occurrences
    • * matches 0 or more occurrences
    • Control case matching
      • (?i) means ignore case of matches
  • 25. Exercise 4
    • SEARCH Host WHERE name matches '01app$'
    • SEARCH Host WHERE name matches '02aPP$'
    • SEARCH Host WHERE name matches '(?i)02aPP$'
  • 26. Exercise 5
    • SEARCH Host WHERE name matches '(?i)0*App$' AND vendor matches '(?i)^sun'
    • SEARCH Host WHERE name matches '(?i)0*App$' AND vendor NOT matches '(?i)^sun'
  • 27. Controlling Display with SHOW
  • 28. SHOW
    • By default results set nodes are displayed by showing the “summary attributes”
      • Defined in the taxonomy
    • SHOW *
      • All attributes defined in the taxonomy
    • SHOW att1, att2
      • Only named attributes of the nodes
    • SHOW summary, attr3
      • Summary attributes defined in the taxonomy, plus attr3
    • SHOW att1 AS ‘col1’ , att2 AS ‘col2’
      • Rename the column headings
  • 29. Exercise 6
    • SEARCH Host WHERE name matches '(?i)0*App$' AND vendor NOT matches '(?i)^sun' SHOW *
    • SEARCH Host WHERE name matches '(?i)0*App$' AND vendor NOT matches '(?i)^sun' SHOW hostname, os_type
    • SEARCH Host WHERE name matches '(?i)0*App$' AND vendor matches '(?i)^sun'
    • SEARCH Host WHERE name matches '(?i)0*App$' AND vendor matches '(?i)^sun' SHOW summary, ram AS &quot;Memory&quot;
  • 30. Putting it all together
  • 31. Query Format
    • Basic format of Query:
      • SEARCH <kinds> [where clause] [show clause]
      • <kinds> – Used to specify the nodes (objects) to search within
      • [where clause] – Optional – filters the current set of nodes
        • A WHERE clause evaluates an attribute
        • WHERE hostname = “itapp”
      • [show clause] – Optional – defines information to return
        • SHOW summary, attribute1, attrbute2
        • SHOW hostname, os
  • 32. Final Exercises
  • 33. Exercise 7
    • For all hosts show following attributes:
      • hostname, host type
      • all os attributes
    • Let’s refine the query:
      • Limit the query to only windows hosts
      • Show attributes a bit more interesting to windows hosts
      • Add the virtual attribute
    • Refine the query again:
      • Limit by windows hosts that have any service pack details
    • Refine the query once again:
      • Limit by windows hosts that DO NOT have service pack details
  • 34. Exercise 8
    • Refine the query from the last labs :
      • To display all hosts except for windows
      • Remove service pack limitation
      • Remove the windows specific attributes
      • Add attributes that are more interesting to non windows hosts
    • Refine again by:
      • Limit by hosts that have power supply status details
      • Show package count totals
  • 35.
    • Online Documentation:
      • http://www.tideway.com/confluence/display/81/Search+and+Reporting+Service
      • http://docs.python.org/dev/howto/regex.html
      • http://www.tideway.com/configipedia/Writing_Efficient_Regex
    Further Resources