cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Tip: perl script to check that specific agents be instrumented

antonio_villar1
Participant

Hi,

Recently, we had to create a perl script to check that some agents (in this case web server) be connected AND in an instrumented state.

Attached is the perl script. Before using it you have to install these packages:

For Red hat:

perl-libwww-perl, perl-LWP-Protocol-https,perl-XML-LibXML, perl-Crypt-CBC, perl-Crypt-DES

For Ubuntu:

libxml-libxml-perl, libwww-perl, liblwp-protocol-https-perl, libcrypt-cbc-perl, libcrypt-des-perl

Check all is ok running:

perl -c list_dyna_agents.pl

This script reads the dynatrace user password from an encrypted file called .dyna. To create it do this:

perl list_dyna_agents.pl --setup-pass <dynatrace user>

Now, you can run it in two ways:

1.- Summarized mode (Total agents, total java agents, total web server agents):

perl list_dyna_agents.pl https://:8021/rest/management/agents>:8021/rest/management/agents <dynatrace user>

Sample output:

Conn OK: 200


Total agents 4

Total Java 2, Total OK: 2

Total Web 1, Total OK: 1

2.- Detailed mode (list all agents printing these attributes: name, state, technology)

perl list_dyna_agents.pl https://:8021/rest/management/agents>:8021/rest/management/agents <dynatrace user> --list-all

Sample output:

Conn OK: 200

BusinessBackend_easyTravel;Java;Instrumentation enabled;1
CustomerFrontend_easyTravel_8080;Java;Instrumentation enabled;2
CreditCardAuthorization_easyTravel;Native;Instrumentation enabled;2
dtwsagent;Web Server;Instrumentation enabled;2

Total agents 4

Total Java 2, Total OK: 2

Total Web 1, Total OK: 1

So if you need to check that an agent be instrumented, create a bash/shell script and run this:

perl list_dyna_agents.pl https://:8021/rest/management/agents>:8021/rest/management/agents <dynatrace user> --list-all | grep enabled | grep <agentname>

checking that the output is not "".

Or in my case, print the number of web server agents:

list-dyna-agentspl.txt

If it is 0 or less than a fixed number, alert.

Good news is that Perl is also available for Windows, check Strawberry Perl (http://strawberryperl.com).

Good luck!

1 REPLY 1

antonio_villar1
Participant

Just to make sure, to check for web servers:

perl list_dyna_agents.pl https://:8021/rest/management/agents>:8021/rest/management/agents <dynatrace user> --list-all | grep enabled | grep "Web Server"