Welcome!

Blog Feed Post

Inside the Black Box Part 3 — VBScript

The third topic of the “black box” series brings us to VBScript. For people interested in the first part, generated code, please click here. For the second part, Python, please click here.

The first question which came to my mind when someone wanted to instrument VBScript was “Why would someone want to instrument a script?”. The answer to that question is that VBScript is not only something used to script small actions when a batch file isn’t the best tool for the job. VBScript is also used within other engines, such as Classic ASP.

If you’re only interested in the end users of a classic ASP application, there is no need to do any code changes as instrumenting IIS with UEM will take care of that for you automatically. But if you need to see how long the different parts of your code is taking, you will have to add instrumentation into the code.

To instrument VBScript we need to use the Native ADK seeing as there is no specialized agent for it. VBScript cannot call a non-ActiveX DLL, which is why I ended up creating an ActiveX wrapper for our Native ADK. The full project can be downloaded here and the ActiveX DLL can be downloaded here. It is created in C# and supports the most commonly used functions such as method instrumentation with arguments and tagging and it can be easily expanded if more functionality is needed.

In this post I’ll go through how to take a simple VBScript and instrument it using the wrapper. The code below is the complete script and while it isn’t doing much, it will be able to show how to start the agent, how to create new PurePaths, capture function timings, arguments and more.

The HandleWebRequest function is the entry point of the script and it prints out whatever argument you pass to it. It could be visualized as a web request handler, which is executed once with every web request. The HandleWebRequest function calls the ExecuteQuery function three times with different arguments, simulating a function executing database queries.

If we execute the above script, we get the following result.

To simplify the instrumentation I’ve created a helper class which will take care of the communication to the ActiveX DLL. The first thing to do is importing the helper class, which you can download here. While ASP has the possibility to import files with a single line of code, VBScript has not, so we will have to add a subroutine which will take care of the import. While one could expand the sub routine to do things such as searching in the PATH, this subroutine is sufficient for the current needs. Once we have added the sub routine we can now call Import “dynatrace.vbs” to get access to the helper class.

The next step is to initialize the agent using Dim Dynatrace : Set Dynatrace = (New DynatraceHelper)(“c:\dtagent.dll”, “VBS_INT”, “localhost”). The initialization only needs to be executed once per process, so normally you would call that during the startup of the script. The init function will set up the connection to the AppMon collector and start monitoring the process. It requires a path to the AppMon agent, the name of the agent and the server name. If you want to pass in additional information, such as log levels, it is quite trivial to change it as the helper class doesn’t need to be compiled and is in clear text.

When the process shuts down we need to, if possible, call Dynatrace. Uninitialize to shut down the agent.

Once the agent is injected we will also need to add instrumentation into the code to, for example, start PurePaths and capture timings. The three functions we will use for this is StartPurePath, Enter and Leave.

The StartPurePath and Enter functions require three arguments, the name of the method, the line number and an array with the arguments to capture. The name of the script will be captured automatically.  If you, for example, would like to have a sensor with the name “mySensor”, with the line number 5 and the captured arguments “hello” and “world”, the function would look like this:

This is how the script will look after we added the required lines.

By executing this script we receive the following PurePath in AppMon.

As you can see the instrumentation has captured the function names, arguments, CPU/IO breakdown and name of the file. By looking at the details of the top node we can see that it also recorded the line number and full path to the file.

When registering the ActiveX DLL please keep in mind that it is created using C#, therefore you will need to use RegAsm to register it instead of regsvr32. Please make sure that you register it using the correct architecture as there are two .NET framework folders, one for 32 bit and one for 64 bit. You need to use the correct one depending on the application you are instrumenting or you will get an error about the object not being found. If you, for example, are using a 64-bit IIS this would be the command to use:

The agent ADK, dtadk.dll, can be downloaded from our community downloads and needs to be present in the same folder as the Dynatrace.dll. It needs to be the same architecture as your application.

If you want to test the above example, please make sure you execute the VBScript file using cscript, like this:

Break open the black box and get in control of your applications, even if they are created in VBScript!

The post Inside the Black Box Part 3 — VBScript appeared first on Dynatrace blog – monitoring redefined.

Read the original blog entry...

More Stories By Dynatrace Blog

Building a revolutionary approach to software performance monitoring takes an extraordinary team. With decades of combined experience and an impressive history of disruptive innovation, that’s exactly what we ruxit has.

Get to know ruxit, and get to know the future of data analytics.

Latest Stories
SYS-CON Events announced today that GrapeUp, the leading provider of rapid product development at the speed of business, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Grape Up is a software company, specialized in cloud native application development and professional services related to Cloud Foundry PaaS. With five expert teams that operate in various sectors of the market acr...
"We are a monitoring company. We work with Salesforce, BBC, and quite a few other big logos. We basically provide monitoring for them, structure for their cloud services and we fit into the DevOps world" explained David Gildeh, Co-founder and CEO of Outlyer, in this SYS-CON.tv interview at DevOps Summit at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
SYS-CON Events announced today that Enzu will exhibit at SYS-CON's 21st Int\ernational Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Enzu’s mission is to be the leading provider of enterprise cloud solutions worldwide. Enzu enables online businesses to use its IT infrastructure to their competitive advantage. By offering a suite of proven hosting and management services, Enzu wants companies to focus on the core of their ...
DevOps at Cloud Expo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 21st Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to w...
New competitors, disruptive technologies, and growing expectations are pushing every business to both adopt and deliver new digital services. This ‘Digital Transformation’ demands rapid delivery and continuous iteration of new competitive services via multiple channels, which in turn demands new service delivery techniques – including DevOps. In this power panel at @DevOpsSummit 20th Cloud Expo, moderated by DevOps Conference Co-Chair Andi Mann, panelists examined how DevOps helps to meet the de...
While DevOps most critically and famously fosters collaboration, communication, and integration through cultural change, culture is more of an output than an input. In order to actively drive cultural evolution, organizations must make substantial organizational and process changes, and adopt new technologies, to encourage a DevOps culture. Moderated by Andi Mann, panelists discussed how to balance these three pillars of DevOps, where to focus attention (and resources), where organizations might...
Cloud Expo, Inc. has announced today that Andi Mann and Aruna Ravichandran have been named Co-Chairs of @DevOpsSummit at Cloud Expo Silicon Valley which will take place Oct. 31-Nov. 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. "DevOps is at the intersection of technology and business-optimizing tools, organizations and processes to bring measurable improvements in productivity and profitability," said Aruna Ravichandran, vice president, DevOps product and solutions marketing...
Automation is enabling enterprises to design, deploy, and manage more complex, hybrid cloud environments. Yet the people who manage these environments must be trained in and understanding these environments better than ever before. A new era of analytics and cognitive computing is adding intelligence, but also more complexity, to these cloud environments. How smart is your cloud? How smart should it be? In this power panel at 20th Cloud Expo, moderated by Conference Chair Roger Strukhoff, pane...
SYS-CON Events announced today that Cloud Academy named "Bronze Sponsor" of 21st International Cloud Expo which will take place October 31 - November 2, 2017 at the Santa Clara Convention Center in Santa Clara, CA. Cloud Academy is the industry’s most innovative, vendor-neutral cloud technology training platform. Cloud Academy provides continuous learning solutions for individuals and enterprise teams for Amazon Web Services, Microsoft Azure, Google Cloud Platform, and the most popular cloud com...
We build IoT infrastructure products - when you have to integrate different devices, different systems and cloud you have to build an application to do that but we eliminate the need to build an application. Our products can integrate any device, any system, any cloud regardless of protocol," explained Peter Jung, Chief Product Officer at Pulzze Systems, in this SYS-CON.tv interview at @ThingsExpo, held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA
What's the role of an IT self-service portal when you get to continuous delivery and Infrastructure as Code? This general session showed how to create the continuous delivery culture and eight accelerators for leading the change. Don Demcsak is a DevOps and Cloud Native Modernization Principal for Dell EMC based out of New Jersey. He is a former, long time, Microsoft Most Valuable Professional, specializing in building and architecting Application Delivery Pipelines for hybrid legacy, and cloud ...
SYS-CON Events announced today that IBM has been named “Diamond Sponsor” of SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California.
In the world of DevOps there are ‘known good practices’ – aka ‘patterns’ – and ‘known bad practices’ – aka ‘anti-patterns.' Many of these patterns and anti-patterns have been developed from real world experience, especially by the early adopters of DevOps theory; but many are more feasible in theory than in practice, especially for more recent entrants to the DevOps scene. In this power panel at @DevOpsSummit at 18th Cloud Expo, moderated by DevOps Conference Chair Andi Mann, panelists discussed...
In his session at Cloud Expo, Alan Winters, an entertainment executive/TV producer turned serial entrepreneur, presented a success story of an entrepreneur who has both suffered through and benefited from offshore development across multiple businesses: The smart choice, or how to select the right offshore development partner Warning signs, or how to minimize chances of making the wrong choice Collaboration, or how to establish the most effective work processes Budget control, or how to ma...
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.