Generating Performance Plot & Automating the Process

From Secure Web Gateway

What is Performance Plot

Performance plot is a graphical representation of the SafeSquid’s performance log which contains data such as:

  • Process Age
  • Virtual memory
  • CPU & Memory Usage
  • Total connections, etc.

Performance plot consolidate all possible data required for analyzing and demonstrating the behavior of your SafeSquid service.

It also helps you manage and analyze server/ host machine.

Information such as:

  • Number of concurrent connections handle by the server
  • Client thread in use, waiting and spare
  • Total Memory consumption
  • Load Average, etc

Referring to performance plot for troubleshooting can also help in better identifying the root cause of your problems; example of such case scenario would be, when end users encounter with the problem of intermittent slow connections.

Using performance plot, you can check the resource usage for the time range when users were having slow connections.

Resources usage such as:

  • Total, Ideal and Waiting TCP connections
  • DNS queries
  • Memory cache
  • Connection pool, etc

Such resources can help you understand the pattern of the problems.

Default Process of Creating Performance Plot

SafeSquid’s web interface http://safesquid.cfg has an option to generate performance plot using time frequency.

Performance plot generated from SafeSquid’s web interface is snail paced and if selected time frequency contains loads of user log data, then generation time can take forever.

This can cause delay in critical troubleshooting process.

Automating plot generation based on set time intervals is not possible from web interface, example: plots to be generate every 1 hours or every day is not possible from web interface.

Performance plots generated from SafeSquid’s CLI is a better option as the generation time is comparatively lower than plots generate via SafeSquid’s web interface.

However, for using this script you will be needing to provide argument which are start time and end time using environment variables.

Getting required start time and end time can sometimes be challenging as the timestamp used in performance log is not easy to understand.

Creating Performance Plot using genPlot.sh Script

Using genPlot.sh, creation of performance plots is automated and based on set time intervals genPlot.sh generates performance plots and stores in appropriate folder.

Monit helps to automated the process of generating performance plot on custom frequency.

Note: Generation of performance plot for past 1 hour takes about 7-8 minutes using genPlot.sh script Example: You can generate performance plot every 1 hour, day, week, fortnight, month, year

You can also use genPlot.sh as a standalone script to generate reports as required.

Automating the Process of Performance Plot Creation

To set performance plot creation on custom time follow below steps:

Download the required scripts using

 wget https://<Download Location> -O /tmp/ ; tar -xzvf /tmp/setupPlot.tar.gz -C /usr/local/src/

Edit plot.monit file and comment the time frequency which will not be used to generate plot

Slide1-genPlotUpdate.png

After updating copy the plot.monit file to /etc/monit/conf.d/ using below command

 cp /usr/local/src/plot.monit /etc/monit/conf.d/

Copy genPlot.sh script to /usr/local/bin/

 cp /usr/local/src/genPlot.sh /usr/local/bin/

Update the execute permissions

 chmod 755 /usr/local/bin/genPlot.sh

Check the Monit control file and reload Monit

 monit -t && monit reload

Performance plot will be generated every hour, day and week.

How to view generated plots

Using a WebServer

To view generate plot in your browser install Apache web server.

To install Apache web server run below command

 apt install apache2

edit the /etc/apache2/sites-enabled/000-default.conf

 vim /etc/apache2/sites-enabled/000-default.conf

Update the document root from /var/www/html to /var/www/safesquid

Slide2-genPlot.png

Now reload the site configurations using below command

 a2dissite 000-default.conf && systemctl reload apache2 && a2ensite 000-default.conf && systemctl reload apache2

Now open your browser access the webserver using servers IP address

Slide1-webserver.jpg
Slide2-webserver.jpg
Slide3-webserver.jpg

On a local Machine

For users without a webserver, you can access the generated performance plot from /var/www/safesquid/performance_plot location.

To view all plots created run below command.

tree -af /var/www/safesquid
Slide4-withoutwebserver.jpg

Based on the frequency set you can access the folder and view your performance log.

For example: users who have set Monit to configure plot every hour will find the performance plot to be located inside folder Every_Hour

Copy the files to your location machine and using any image view you can view your performance plots.

Generate plot as required

To generate report as required run command

 genPlot.sh <options>

Options: Hour, Day, Week, Fortnight, Month, Year

 Example: genPlot.sh Hour

This will generate plot for the last 1 hour