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
For organizations that have amassed large sums of software complexity, taking a microservices approach is the first step toward DevOps and continuous improvement / development. Integrating system-level analysis with microservices makes it easier to change and add functionality to applications at any time without the increase of risk. Before you start big transformation projects or a cloud migration, make sure these changes won’t take down your entire organization.
SYS-CON Events announced today that Loom Systems will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Founded in 2015, Loom Systems delivers an advanced AI solution to predict and prevent problems in the digital business. Loom stands alone in the industry as an AI analysis platform requiring no prior math knowledge from operators, leveraging the existing staff to succeed in the digital era. With offices in S...
With billions of sensors deployed worldwide, the amount of machine-generated data will soon exceed what our networks can handle. But consumers and businesses will expect seamless experiences and real-time responsiveness. What does this mean for IoT devices and the infrastructure that supports them? More of the data will need to be handled at - or closer to - the devices themselves.
DevOps is often described as a combination of technology and culture. Without both, DevOps isn't complete. However, applying the culture to outdated technology is a recipe for disaster; as response times grow and connections between teams are delayed by technology, the culture will die. A Nutanix Enterprise Cloud has many benefits that provide the needed base for a true DevOps paradigm.
My team embarked on building a data lake for our sales and marketing data to better understand customer journeys. This required building a hybrid data pipeline to connect our cloud CRM with the new Hadoop Data Lake. One challenge is that IT was not in a position to provide support until we proved value and marketing did not have the experience, so we embarked on the journey ourselves within the product marketing team for our line of business within Progress. In his session at @BigDataExpo, Sum...
The taxi industry never saw Uber coming. Startups are a threat to incumbents like never before, and a major enabler for startups is that they are instantly “cloud ready.” If innovation moves at the pace of IT, then your company is in trouble. Why? Because your data center will not keep up with frenetic pace AWS, Microsoft and Google are rolling out new capabilities In his session at 20th Cloud Expo, Don Browning, VP of Cloud Architecture at Turner, will posit that disruption is inevitable for c...
SYS-CON Events announced today that Telecom Reseller has been named “Media Sponsor” of SYS-CON's 20th International Cloud Expo, which will take place on June 6–8, 2017, at the Javits Center in New York City, NY. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.
SYS-CON Events announced today that Ocean9will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Ocean9 provides cloud services for Backup, Disaster Recovery (DRaaS) and instant Innovation, and redefines enterprise infrastructure with its cloud native subscription offerings for mission critical SAP workloads.
Providing the needed data for application development and testing is a huge headache for most organizations. The problems are often the same across companies - speed, quality, cost, and control. Provisioning data can take days or weeks, every time a refresh is required. Using dummy data leads to quality problems. Creating physical copies of large data sets and sending them to distributed teams of developers eats up expensive storage and bandwidth resources. And, all of these copies proliferating...
In recent years, containers have taken the world by storm. Companies of all sizes and industries have realized the massive benefits of containers, such as unprecedented mobility, higher hardware utilization, and increased flexibility and agility; however, many containers today are non-persistent. Containers without persistence miss out on many benefits, and in many cases simply pass the responsibility of persistence onto other infrastructure, adding additional complexity.
SYS-CON Events announced today that Cloudistics, an on-premises cloud computing company, has been named “Bronze Sponsor” of SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Cloudistics delivers a complete public cloud experience with composable on-premises infrastructures to medium and large enterprises. Its software-defined technology natively converges network, storage, compute, virtualization, and management into a ...
DevOps is often described as a combination of technology and culture. Without both, DevOps isn't complete. However, applying the culture to outdated technology is a recipe for disaster; as response times grow and connections between teams are delayed by technology, the culture will die. A Nutanix Enterprise Cloud has many benefits that provide the needed base for a true DevOps paradigm. In his Day 3 Keynote at 20th Cloud Expo, Chris Brown, a Solutions Marketing Manager at Nutanix, will explore t...
SYS-CON Events announced today that CA Technologies has been named “Platinum Sponsor” of SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY, and the 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CA Technologies helps customers succeed in a future where every business – from apparel to energy – is being rewritten by software. From ...
Pentaho has announced orchestration capabilities that streamline the entire machine learning workflow and enable teams of data scientists, engineers and analysts to train, tune, test and deploy predictive models. Pentaho’s Data Integration and analytics platform ends the ‘gridlock’ associated with machine learning by enabling smooth team collaboration, maximizing limited data science resources and putting predictive models to work on big data faster – regardless of use case, industry, or languag...
SYS-CON Events announced today that T-Mobile will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. As America's Un-carrier, T-Mobile US, Inc., is redefining the way consumers and businesses buy wireless services through leading product and service innovation. The Company's advanced nationwide 4G LTE network delivers outstanding wireless experiences to 67.4 million customers who are unwilling to compromise on ...