7 Replies Latest reply on Oct 31, 2018 7:34 AM by phoffmann

    How to Find which queries are running on a device

    Marco_F Apprentice

      Hello everyone,

       

      I would like to know how can I get a list of queries that are running on a specific device.

       

      Thank you in advance.

       

      Best Regards.

      Marco

        • 1. Re: How to Find which queries are running on a device
          carlos Expert

          "queries" that are running on a specific device?

          Could you elaborate a little bit more?

          • 2. Re: How to Find which queries are running on a device
            Marco_F Apprentice

            Hi Carlos,

             

            ok, I will be more clear.

             

            I have created plenty of queries and I wonder how to get, for a device, a list of queries in which this device is part of.

             

            There is a scheduled task that daily runs; it is associated to 15 queries.

             

            In the query that should contain this client, it is excluded but the scheduled task still runs on it again.

             

            So, I want to know if, for any reason, the client is also part of one of the other 14 queries.

             

            Thanks

            • 3. Re: How to Find which queries are running on a device
              carlos Expert

              hmmm, I don't see how it can be done...

              Queries are server side and they use some characteristic on the target to identify it...hmmm.

              For this you'll have to go to SQL management studio and get a list of queries:

              sql list of queries run - Bing

              then maybe a list of "something" affected by each query

              sql devices affected by query - Bing

              hmmm, sorry, not much help here, I dont think its very common to get this type of info.

              Maybe an SQL wizard out there can give you a better idea.

              • 4. Re: How to Find which queries are running on a device
                Marco_F Apprentice

                Ok, I will check those url; hopefully to find out a way to get this kind of information.

                Thanks

                • 5. Re: How to Find which queries are running on a device
                  phoffmann SupportEmployee

                  I'm still a bit confused what you're after here.

                   

                  OK - so to help with this, let's assume the following:

                  • The device you're after is called MYDEVICE
                  • You have a total of 100 queries.
                  • 15 queries of those 100 queries target MYDEVICE by NAME in the conditions (i.e. "NAME LIKE MYDEVICE" )
                  • 5 queries do NOT target "MYDEVICE" by name, but have it as part of the result set (i.e. the query happens to be stuff like "OS LIKE WINDOWS 10")

                  Now....

                  1. Are you looking for (a) "queries that specifically check for MYDEVICE" in the conditions?
                  2. Or do you care about (b) queries that have "MYDEVICE" in their result set?
                  3. Or (c) are you looking for something else entirely (in which case, please clarify).

                   

                  If you're looking for option A -- that's "not too difficult" (and would involve some SQL). I can probably point you in the right place & give you a few things to get started with.

                   

                  If you're looking for option B ... I'd be "really careful" with that, since that'd require you to "run all queries" and then check the result set. It's something that CAN be done ... but could give your Core potentially a LOT of load. Not a technical problem, but something you'd want to do at a quiet time.

                   

                  ... if it's option C, would need more clarification.

                   

                  A bit of context as to WHY you're trying to get this might also help, in case there's a smarter / easier way to solve your actual problem?

                  • 6. Re: How to Find which queries are running on a device
                    Marco_F Apprentice

                    Hi Phoffmann,

                     

                    Thank you for your answer too.

                     

                    Firstly, let me say that I have resolved this "issue" after stopping and restarting the Landesk Management Agent service on the targeted device.

                     

                    In this specific case it was a server which, at the beginning and for a not correct paremeter, was not excluded from this query:

                     

                    ("Computer"."Network"."TCPIP"."Default Gateway Address" LIKE "%111.222.333.444%" OR "Computer"."Device Name" LIKE "%XXXYYY%") AND "Computer"."Type" NOT LIKE "%Server%" AND "Computer"."Type" NOT LIKE "%Virtual Server%"

                     

                    So, for a certain period, it was right that this server was in this query.

                     

                    Yesterday morning, I modified the query and, correctly, the server was no more inside of it.

                     

                    Although, the scheduled task associated to this query (and more others) was still running on this server.

                     

                    So, I was trying to understand if this server was also listed in some of these queries.

                     

                    Finally, to answer to your questions, point B) is what I would like but not if it means manually running query by query.

                     

                    Thanks

                    • 7. Re: How to Find which queries are running on a device
                      phoffmann SupportEmployee

                      OK - so *if* this comes up ... you CAN do this. I didn't mean "running it by hand" -- in effect, we store the SQL for each query in a place ... it'd involve reading said SQL, then running it (which - depending on the complexity of those queries & the data-set CAN be stressful for the SQL Server) and then checking each result-set for whether or not it include "that device you're looking for".

                       

                      So could be scripted & done out of hours, sort of thing.

                       

                      But yeah - good to see that it was sorted, as I suspected that the real driver for this wasn't really related to the question as such.

                       

                      But yes "it's doable" ... (if needed).