Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I wrote a bash script that draws simple diagrams from numeric input data (web traffic averages) using ImageMagick (convert), which works OK.
However, I need a blank image on which the diagram objects will be drawn.
Is it possible to create such a blank image with Image Magick, or some other tools from a bash script?
I want that the script be self-containing, i.e. it should create the image itself.
# Create a blank 120x100 pixels gif image (diagram.gif) with green background for the diagram:
convert -size 120x100 xc:#00FF00 diagram.gif
# Draw a multipoint diagram line using the data in the first column ($1) of the last 120 lines (tail -120) in data.txt.
# The value 50000 below should be replaced by a value equal to <maximum possible value of input data>/100 (because the y dimension of the diagram is 100 pixels in my case)
#If your input data file contains, say... one-minute averages, but you want to draw a diagram with say... five minute averages, then you can sum up the data "on the fly" and draw the corresponding diagram line like this:
convert -stroke red -fill none -linewidth 2 -draw "polyline `tail -600 data.txt | awk 'BEGIN {szum=0} {szum=szum+$1} {if (int(NR/5)==NR/5) ix=ix+1} { if (int(NR/5)==NR/5) printf ix "," 100-int(szum/250000) " " } { if (int(NR/5)==NR/5) szum=0 }'`" diagram.gif diagram.gif
Additional diagram lines can be drawn by repeating the "line drawing" convert command using the new data.
Some text and scales can be drawn on the diagram by adding them (line and text primitives of the -draw command) to the first, "image creating" convert command.
Somewhere between 120 and 200 diagram points some internal limit of ImageMagick is reached, and it returns an error rather than drawing the diagram.
My data txt is nothing special, it only contains some space-separated numbers in each line like this:
12454 23456
236543 4564564
...
4534534 453464
Some byte-counting rules are inserted among my ipfw firewall rules during boot up; and an other script of mine reads out the positions of the counters once in each minute; calculates the traffic (ActualCounterPosition - PrevCounterPosition) of the last minute and appends it to data.txt.
So, data.txt contains web traffic data in my case; and the diagrams show my webtraffic
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.