Sunday, February 14, 2016

Netezza: view to monitor user run and logon statistics



Create user activity monitoring views. Views are useful to monitor user logons and Netezza  appliance usage:

Create view DDL.

SELECT 'DEV'                                                   as ENV
    ,username                                              AS USERNAME
    ,u.CREATEDATE                                           AS CREATEDATE
    ,timezone(MAX(LAST_LOGON), 'UTC','EST' )                as LAST_LOGON
    , CURRENT_DATE-timezone(MAX(LAST_LOGON), 'UTC','EST' as LAST_LOGON_DAYS
    ,SUM(ACCESS_COUNT)                                   as TOTAL_LOGIN_COUNT
--- List concatenation here: put all database on one line comma delimited.
--- Read: http://nz2nz.blogspot.com/2016/02/netezza-concatenate-rows-into-string.html
    ,trim (trailing ', ' from
            SQL_EXTENSIONS.. replace
               (SQL_EXTENSIONS.. replace
                   (SQL_EXTENSIONS..XMLserialize
                       (SQL_EXTENSIONS..XMLagg
                           (SQL_EXTENSIONS..XMLElement( 'X',dbname))),
               '<X>','' )
          , '</X>' ,',' )) AS DB_ACCESSED
FROM
(
     select username
              ,dbname
              , max( time) AS LAST_LOGON
              , count(* AS ACCESS_COUNT
     from QUERY_HISTORY.."$v_hist_log_events"
     where username not like 'ADMIN%'   --- not interested in ADMIN** users
       and username not like 'ZZ_%'     --- not interested in ZZ_** functional users
     group by username
          , dbname
) as LAST_LOGON_DAYS
left outer join _v_user u using (username)
GROUP BY 1 ,2 ,3
order by TOTAL_LOGIN_COUNT desc

;







SELECT  'DEV'                                   AS ENV
        , QP.USERNAME                            AS USERNAME
        , DATE_TRUNC('day' , QP.SUBMITTIME)     AS THEDAY
        , MIN(QP.SUBMITTIME)                     AS RUN_FROM
        , MAX(QE.FINISHTIME)                     AS RUN_TO
        , COUNT(*)                              AS QUERY_COUNT
        , SUM((QE.FINISHTIME - QP.SUBMITTIME))   AS TOTAL_ELAPSED
        , SUM(QE.RESULTROWS)                     AS TOTAL_ROWS
        , SUM(P.RESULTBYTES)                     AS TOTAL_BYTES
FROM  (       QUERY_HISTORY.QHIST_USER."$hist_query_prolog_3" QP
         JOIN QUERY_HISTORY.QHIST_USER."$hist_query_epilog_3" QE   
               USING (NPSID, NPSINSTANCEID, OPID) )
   JOIN (     QUERY_HISTORY.QHIST_USER."$hist_session_prolog_3" SP
         JOIN QUERY_HISTORY.QHIST_USER."$hist_session_epilog_3" SE 
               USING (NPSID, NPSINSTANCEID, SESSIONID))
  USING (NPSID, NPSINSTANCEID)
LEFT JOIN (
        SELECT PP.NPSID
       , PP.NPSINSTANCEID
       , PP.OPID
       , PP.SESSIONID
       , SUM(PE.RESULTBYTES) AS RESULTBYTES
       , SUM((PP.PREPTIME - PP.SUBMITTIME)) AS QUEUETIME
       , SUM((PP.GRATIME - PP.PREPTIME)) AS PREPTIME
       , SUM((PP.STARTTIME - PP.GRATIME)) AS GRATIME
       , COUNT(PP.PLANID) AS NUMPLANS
       , SUM(PP.QCRESTART) AS NUMRESTARTS
        FROM (QUERY_HISTORY.QHIST_USER."$hist_plan_prolog_3" PP
        JOIN QUERY_HISTORY.QHIST_USER."$hist_plan_epilog_3" PE 
        USING (NPSID, NPSINSTANCEID, OPID, SESSIONID, PLANID))
        GROUP BY PP.NPSID, PP.NPSINSTANCEID, PP.OPID, PP.SESSIONID
) P
 USING (NPSID, NPSINSTANCEID, OPID)
WHERE QP.SESSIONID = SP.SESSIONID
  AND QE.STATUS = 0
  AND QP.SUBMITTIME > current_timestamp - interval '60 days'
  AND UPPER(QP.QUERYTEXT) NOT IN ( 'COMMIT','BEGIN' , 'SELECT * FROM DUMMY WHERE 1=2')
  AND UPPER(QP.QUERYTEXT) not like 'SHOW %'
  AND UPPER(QP.QUERYTEXT) not like 'SET %'
  AND UPPER(QP.QUERYTEXT) not like 'SELECT VERSION%'
  AND UPPER(QP.QUERYTEXT) not like 'SELECT DB_ENCODING%'
  AND UPPER(QP.QUERYTEXT) not like 'SELECT NCHAR_ENCODING%'
  AND UPPER(QP.QUERYTEXT) not like 'SELECT CURRENT_SID%'
  AND UPPER(QP.QUERYTEXT) not like 'SELECT ''JDBC CLIENT VERSION''%'
  /* to be continued based on your system. This xclusion list is to be revised ...*/
GROUP BY ENV, QP.USERNAME, DATE_TRUNC( 'day', QP.SUBMITTIME)
order by THEDAY desc, TOTAL_ELAPSED desc
;



35 comments:

  1. Great post! A well-written resource to anyone looking to boost their NETEZZA through blog commenting. The tools mentioned will also go a long way in making the entire process much more efficient and effective.

    ReplyDelete
  2. I found your blog very interesting and very informative. I think your blog is great information source & I like your way of writing and explaining the topics. A database administrator (DBA) is an IT professional responsible for the configuration, monitoring, administration, installation, upgrading, and security of databases in an organization. More Details About SQL Click here.

    ReplyDelete
  3. Needed to compose one simple word yet thanks for the suggestions that you are contributed here, please do keep updating us...
    Oracle ADF Online Training

    Oracle APPS Functional Online Training

    Oracle DBA Online Training

    ReplyDelete
  4. Astonishing web diary I visit this blog it's incredibly magnificent. Strangely, in this blog content made doubtlessly and sensible. The substance of information is instructive.
    Oracle Fusion Financials Online Training
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training

    ReplyDelete
  5. Within the next step, you can find information through the last service provider. Keeping these records in your records will likely be quite advantageous to keep your account along side QuickBooks Payroll Support Phone Number

    ReplyDelete
  6. QuickBooks Enterprise Tech Support Number get required suggestion after all time. The group sitting aside understands its responsibility as genuine & offers reasonable assistance with your demand.

    ReplyDelete
  7. to us at QuickBooks Support Phone Number The majority of us works 24*7 and serve its customers with excellent service each time they e mail us. It doesn't matter what issue is and however complex it truly is, we assure you that individuals offers you optimal solution as quickly as possible.

    ReplyDelete
  8. The bond lost issue, connection with the free web, sync issue in the software along with other style of setting which not easily can be located & may block the entire workflow .
    For the rectification associated with issue call QuickBooks Technical Support Number is might help the Quickbooks users are right individuals to pin point and fix the issue completely. They assure resolution within the minimum wait time that saves your valuable time.

    ReplyDelete
  9. QuickBooks Payroll Service Phone Number is available and beneficial to many business owners, accountants, CA, CPA to calculate taxes and pay employees. Types of issues and errors arise the necessity to contact the Intuit Payroll support team using QuickBooks Payroll telephone number.

    ReplyDelete
  10. The experts at our QuickBooks EnterprIse Technical Support Number have the necessary experience and expertise to address all issues linked to the functionality associated with the QuickBooks Enterprise.

    ReplyDelete
  11. When you should really be realizing that QuickBooks has made bookkeeping an easy task, you'll find times when you may possibly face a few errors that may bog over the performance when it comes to business. QuickBooks Support Phone Number is the better location to look for instant help for virtually any QuickBooks related trouble.

    ReplyDelete
  12. Consist of a beautiful bunch of accounting versions, viz., QuickBooks Support Phone Number Pro, QuickBooks Premier, QuickBooks Enterprise, QuickBooks POS, QuickBooks Mac, QuickBooks Windows, and QuickBooks Payroll, QuickBooks has grown to become a dependable accounting software that one may tailor depending on your industry prerequisite.

    ReplyDelete
  13. QuickBooks Enterprise Support Number has almost eliminated the traditional accounting process. Along with a number of tools and automations, it offers a wide range of industry verticals with specialized reporting formats and tools.

    ReplyDelete
  14. The group deployed at the final outcome of QuickBooks Support Phone Number takes great proper care of all from the issues for the software. QuickBooks Support telephone number have a team of experts which can be pro in handling all of the issues because of this incredible software.

    ReplyDelete
  15. QuickBooks Tech Support Number is perhaps all concerning User expertise which explains why they need creating dedicated QuickBooks school Support Phone variety; Users will dial the fee number just in case they will have any facilitate in regards to the code.

    ReplyDelete
  16. Get striking solutions for QuickBooks near you straight away! Without having any doubts, QuickBooks has revolutionized the entire process of doing accounting this is the core strength for small as well as large-sized businesses. QuickBooks Support Phone Number is assisted by our customer care representatives who reply to your call instantly and resolve all of your issues at that moment. It really is a backing portal that authenticates the users of QuickBooks to operate its services in a user-friendly manner.

    ReplyDelete
  17. It Will Makes Your Bank Account Job Easy And A Lot Of Important, It's Not Complicated, And Yes It Really Is An Undeniable Fact. QuickBooks Enterprise Is Obviously One The Most Consistent Enterprise Software, Its Recent Version QuickBooks Tech Support Number.

    ReplyDelete
  18. Many companies have now been saving a frequent sum of money out of opting QuickBooks Payroll to transfer the salary with regards to their employees. Also, the payrolls are accurate and shall be cleared timely through QuickBooks Technical Support Number With such satisfactory actions happening around, certain data related issues shall happen every so often. This is how you have to be definite in creating a routine backup and know the ways to restore the info in just about any crucial situations.

    ReplyDelete
  19. you’ll scan in-depth articles concerning most of the errors and also the best way to resolve them. Rectifying errors desires in-depth information regarding the device as well as its intricacies. Our web site can be a go-to supply for everything related to QuickBooks Support.

    ReplyDelete
  20. The best solutions are imperative for the growth of the business enterprise. Therefore, QuickBooks Tech Support Phone Number is available for users across the world once the best tool to supply creative and innovative features for business account management to small and medium-sized business organizations.

    ReplyDelete
  21. You can further see the contact information on how to QuickBooks Support Phone Number. QuickBooks technical support team are active for only 5 days (Mon-Fri) in per week. The QuickBooks support phone number is available these days from 6 AM to 6 PM.

    ReplyDelete
  22. On September 22, 2014, Intuit publicized the release of QuickBooks 2015 with types that users have already been completely demanding through the past versions. Amended income tracker, pinned notes, better registration process and understandings on homepage are the large choice of general alterations for several versions of QuickBooks 2015. It can benefit for QuickBooks Enterprise Phone Support to have technical help & support for QuickBooks.

    ReplyDelete
  23. It is possible to dial the QuickBooks customer Support Number to possess a spoken language because of the QuickBooks Specialists or else you can even talk to them by victimization the chat choice on our internet site.

    ReplyDelete
  24. QuickBooks Payroll Tech Support Phone Number could remotely hook up to your computer to solve most of the issues. The QuickBooks Experts understand that each and every business is unique and has now different needs; that is why, we provide highly customized and agile methods to help you enjoy top-notch customer support and satisfaction.

    ReplyDelete
  25. Everbody knows there are always two sides to a coin and QuickBooks Support Number is not any different. This software also throws some errors in the end. Sometimes it becomes rather difficult to know this will be with this specific error code or message.

    ReplyDelete
  26. Earnings: for starters, a small business can simply survive if it is making adequate profits to smoothly run the operations associated with the work. Our QuickBooks Support team will certainly show you in telling you about the profit projections in QuickBooks Support Phone Number.

    ReplyDelete
  27. Unneeded to mention, QuickBooks has given its utmost support to entrepreneurs in decreasing the price otherwise we’ve seen earlier, however, an accountant wont to hold very different accounting record files. Utilising the assistance of QuickBooks, users will maintain records like examining, recording and reviewing the complicated QuickBooks Support Phone Number procedures.

    ReplyDelete
  28. Error technically means an estimate difference between the calculated value of a quality and its true value. The numeric value, here, 9999 is the value to identity the error. If you would like to learn how to Fix QuickBooks Error 9999, you can continue reading this blog.

    ReplyDelete
  29. This is amazing post for Quickbooks user which is one of the best software for manipulating many accounting task . this software could be any issue . to resolve your issue connect with at icwrapper.dll failed to register quickbooks.

    ReplyDelete
  30. This comment has been removed by the author.

    ReplyDelete
  31. Amazing details, many thanks for providing this kind of information. The best and most fascinating information can be found on your website. Many thanks!
    DevOps Training near me

    ReplyDelete