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
Most technology leaders, contemporary and from the hardware era, are reshaping their businesses to do software. They hope to capture value from emerging technologies such as IoT, SDN, and AI. Ultimately, irrespective of the vertical, it is about deriving value from independent software applications participating in an ecosystem as one comprehensive solution. In his session at @ThingsExpo, Kausik Sridhar, founder and CTO of Pulzze Systems, discussed how given the magnitude of today's application ...
Modern software design has fundamentally changed how we manage applications, causing many to turn to containers as the new virtual machine for resource management. As container adoption grows beyond stateless applications to stateful workloads, the need for persistent storage is foundational - something customers routinely cite as a top pain point. In his session at @DevOpsSummit at 21st Cloud Expo, Bill Borsari, Head of Systems Engineering at Datera, explored how organizations can reap the bene...
With tough new regulations coming to Europe on data privacy in May 2018, Calligo will explain why in reality the effect is global and transforms how you consider critical data. EU GDPR fundamentally rewrites the rules for cloud, Big Data and IoT. In his session at 21st Cloud Expo, Adam Ryan, Vice President and General Manager EMEA at Calligo, examined the regulations and provided insight on how it affects technology, challenges the established rules and will usher in new levels of diligence arou...
You know you need the cloud, but you're hesitant to simply dump everything at Amazon since you know that not all workloads are suitable for cloud. You know that you want the kind of ease of use and scalability that you get with public cloud, but your applications are architected in a way that makes the public cloud a non-starter. You're looking at private cloud solutions based on hyperconverged infrastructure, but you're concerned with the limits inherent in those technologies. What do you do?
Sanjeev Sharma Joins June 5-7, 2018 @DevOpsSummit at @Cloud Expo New York Faculty. Sanjeev Sharma is an internationally known DevOps and Cloud Transformation thought leader, technology executive, and author. Sanjeev's industry experience includes tenures as CTO, Technical Sales leader, and Cloud Architect leader. As an IBM Distinguished Engineer, Sanjeev is recognized at the highest levels of IBM's core of technical leaders.
Recently, WebRTC has a lot of eyes from market. The use cases of WebRTC are expanding - video chat, online education, online health care etc. Not only for human-to-human communication, but also IoT use cases such as machine to human use cases can be seen recently. One of the typical use-case is remote camera monitoring. With WebRTC, people can have interoperability and flexibility for deploying monitoring service. However, the benefit of WebRTC for IoT is not only its convenience and interopera...
In his general session at 21st Cloud Expo, Greg Dumas, Calligo’s Vice President and G.M. of US operations, discussed the new Global Data Protection Regulation and how Calligo can help business stay compliant in digitally globalized world. Greg Dumas is Calligo's Vice President and G.M. of US operations. Calligo is an established service provider that provides an innovative platform for trusted cloud solutions. Calligo’s customers are typically most concerned about GDPR compliance, application p...
Mobile device usage has increased exponentially during the past several years, as consumers rely on handhelds for everything from news and weather to banking and purchases. What can we expect in the next few years? The way in which we interact with our devices will fundamentally change, as businesses leverage Artificial Intelligence. We already see this taking shape as businesses leverage AI for cost savings and customer responsiveness. This trend will continue, as AI is used for more sophistica...
The 22nd International Cloud Expo | 1st DXWorld Expo has announced that its Call for Papers is open. Cloud Expo | DXWorld Expo, to be held June 5-7, 2018, at the Javits Center in New York, NY, brings together Cloud Computing, Digital Transformation, Big Data, Internet of Things, DevOps, Machine Learning and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding busin...
SYS-CON Events announced today that Synametrics Technologies will exhibit at SYS-CON's 22nd International Cloud Expo®, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Synametrics Technologies is a privately held company based in Plainsboro, New Jersey that has been providing solutions for the developer community since 1997. Based on the success of its initial product offerings such as WinSQL, Xeams, SynaMan and Syncrify, Synametrics continues to create and hone inn...
Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
No hype cycles or predictions of a gazillion things here. IoT is here. You get it. You know your business and have great ideas for a business transformation strategy. What comes next? Time to make it happen. In his session at @ThingsExpo, Jay Mason, an Associate Partner of Analytics, IoT & Cybersecurity at M&S Consulting, presented a step-by-step plan to develop your technology implementation strategy. He also discussed the evaluation of communication standards and IoT messaging protocols, data...
Product connectivity goes hand and hand these days with increased use of personal data. New IoT devices are becoming more personalized than ever before. In his session at 22nd Cloud Expo | DXWorld Expo, Nicolas Fierro, CEO of MIMIR Blockchain Solutions, will discuss how in order to protect your data and privacy, IoT applications need to embrace Blockchain technology for a new level of product security never before seen - or needed.
In his session at 21st Cloud Expo, Raju Shreewastava, founder of Big Data Trunk, provided a fun and simple way to introduce Machine Leaning to anyone and everyone. He solved a machine learning problem and demonstrated an easy way to be able to do machine learning without even coding. Raju Shreewastava is the founder of Big Data Trunk (www.BigDataTrunk.com), a Big Data Training and consulting firm with offices in the United States. He previously led the data warehouse/business intelligence and B...
The past few years have brought a sea change in the way applications are architected, developed, and consumed—increasing both the complexity of testing and the business impact of software failures. How can software testing professionals keep pace with modern application delivery, given the trends that impact both architectures (cloud, microservices, and APIs) and processes (DevOps, agile, and continuous delivery)? This is where continuous testing comes in. D