Warning |
---|
With the Gwynn R1 release, and subsequent releases, the way that the history tables operate has changed. The queries on this page work with releases up to Fu R3These queries work with iQSonar releases up to and including Fu R3. Changes were made to some underlying tables in Gwynn R1 and Gwynn R2 to reduce the amount of history saved as the diagnostic information can grow. In the Gwynn R3 release the option to preserve or delete this diagnostic can be selected in the user interface. Instructions on how to keep the history data can be found on this page. |
When iQSonar is inventorying a database application (DB2, Oracle, SQL Server, Informix, and so on) it not only looks for files on the server's file systems, it needs to log in to the database and execute certain commands. If it fails to log in to the database it cannot fully report all the required information for licencing reports.
...
Warning |
---|
These queries work with iQSonar releases up to and including Fu R3.They do NOT work with iQSonar Gwynn R1 or later due to changes to the history.t_ConnectionHistory table Changes were made to some underlying tables in Gwynn R1 and Gwynn R2 to reduce the amount of history saved as the diagnostic information can grow. In the Gwynn R3 release the option to preserve or delete this diagnostic can be selected in the user interface. Instructions on how to keep the history data can be found on this page. |
Note that the "Type" column is the Application Type, which is not the same as the Connection type in most of the other queries on this page. You can get a list of valid types in your environment with the following query:
...
Code Block | ||||
---|---|---|---|---|
| ||||
(CONVERT(DATE,AttemptDate) >= '2018-04-18' AND CONVERT(DATE,AttemptDate) <= '2018-04-20')) |
Display credential failures/credential success as a pivot table.
We will need to use the combination of IP Address and Instance name as the left hand column, and the credentials attempted as the other columns,
we want to display success/fail as the data points in the matrix.
For this query, we use a number of CTEs to help with readability.
This example is for Oracle Database Instance connection/login failures, and assumes there are three database credentials defined, with labels Credential1, Credential2 and Credential3. (Don't forget that the Label is what is displayed in the iQSonar UI as opposed to the login name, to allow for multiple passwords for the same user (e.g. the user SYS may have different passwords on different machines)
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
with ScanAttempts AS (
-- Find the success/failures
SELECT CONCAT( ch.Instance, ' on ', ch.[IPAddress] ) as DBInstance
, p.Name as [Project Name]
, c.Label as CredentialName
, c.Username
, o.Name as Outcome
, convert(DATE,AttemptDate) as DateAttempted
, AttemptDate as RawDate
FROM [history].[t_ConnectionHistory] ch
INNER JOIN config.t_Credential c ON ch.CredentialID = c.CredentialID
INNER JOIN config.t_Outcome o ON ch.OutcomeID = o.OutcomeID
INNER JOIN jobs.t_JobLocationProjectIPRange AS jobProj ON jobProj.JobID = ch.JobID
join config.t_Project p on jobProj.ProjectID =p.ProjectID
WHERE Connection = 'Oracle Database'
),
NewestScanAttempts as (
SELECT DISTINCT DBInstance, max(DateAttempted) as RecentAttempt
FROM ScanAttempts
GROUP BY DBInstance
),
PivotThis as
(
SELECT sa.DBInstance, sa.CredentialName, sa.Outcome
FROM ScanAttempts sa INNER JOIN NewestScanAttempts nsa ON (sa.DBInstance = nsa.DBInstance and sa.DateAttempted = nsa.RecentAttempt)
)
select * From PivotThis
PIVOT (
MAX(Outcome) FOR CredentialName IN (
[Credential1], [Credential2], [Credential3]
) ) AS MyTable |