There are 3 parts to this article:
Part 1 – Part 2 – Part 3
In the introduction to this series we showed a graph of Apache processes (httpd). This article will show how to create the scale of the graph and the initial fig file entries. See Xfig.org for more details on the graphing program we use. One advantage is that we can generate the fig file from a Perl script, and then use the fig2dev command to render the fig file. Here is the Perl script that generates the initial fig file and scale:
open (HTTPDBACK, "> /path/to/fig/file/httpd.fig"); print HTTPDBACK "#FIG 3.2 Landscape Center Metric Letter 100.00 Single -2 1200 2 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 -45 0 64800 0 64800 22545 -45 22545 -45 0 "; for ($i=1;$i <= 23;$i++){ print HTTPDBACK "4 0 0 50 -1 14 90 0.0000 4 360 345 "; print HTTPDBACK $i*2700-1000; print HTTPDBACK " 23940 "; if ($i < 13){ print HTTPDBACK $i; } else{ print HTTPDBACK $i-12; } print HTTPDBACK "\\001\n"; } $i=2; while($i < 50){ print HTTPDBACK "4 0 0 50 -1 14 90 0.0000 4 360 345 -1800 "; print HTTPDBACK 22500-$i*450; print HTTPDBACK " ".$i; print HTTPDBACK "\\001\n"; $i=$i+3; } close HTTPDBACK; |
Probably the best way to go about this is to first draw the type of graph you want in Xfig, and then change the numbers above to match your design. The graph we used is specified in the beginning, before the first for loop. After the initial specification of the graph, we draw the numbers across the bottom of the graph with a for loop. There is an if clause to set the displayed numbers to a 12 hour display of the hour. The final piece is the loop that creates the numbers on the left side of the graph that show the scale of the number of Apache processes. That is it for the initial creation of the scale. set up a cron job to reset the fig file at midnight and archive the current file for reference:
0 0 * * * /bin/cp /path/to/httpd.png /path/to/httpdyest.png > /dev/null 2>&1;/usr/bin/perl /path/to/backhttpd.pl > /dev/null 2>&1 |
We discuss the script that draws the blue bars in this article.