Dear monks,
I am writing a short script to become more familiar with the RRD graph tool that it looks really interesting. I read at the rrdgraph page that the output of the graph it can be defined as .eps otherwise by default .png. Since I would like to add the graphs in my reports by using LaTeX it would be really nice to find a way to produce .eps files.
Correct me if I am wrong, but I thought that modifying the filename is the correct possition to apply the change.
I can not found relevant information at RRD::Simple graph.
I have tried several approaches by adding the .eps extension on the basename => "graph_basename.eps" as an example but unfortunately not successfully.
A working example is provided below. Has anybody encounter similar situation and found a solution to this problem?
Thanks in advance for everyones time and effort.
Update (23/05/2014)#!/usr/bin/perl use strict; use warnings; use RRD::Simple (); use Data::Dumper; $| = 1; # Flush the output my ($unixtime,$rrd); my $file = "perl.txt"; my $path = '/home/tiny_os/Desktop/Test_Perl/'; my $period = '3years'; my $rrdfile = 'myfile'; while (sleep 1) { open(FH, ">>", $file) || die "Unable to open $file: $!\n"; my $range = 50; my $minimum = 100; my $random_number_in = int(rand($range)) + $minimum; my $random_number_out = int(rand($range)) + $minimum; my $random_number_sec = int(rand($range)) + $minimum; $rrd = RRD::Simple->new( file => "".$rrdfile."", rrdtool => "/usr/bin/rrdtool", #optional /usr/bin/rrdtool tmpdir => "/tmp", #optional cf => [ qw( AVERAGE MIN MAX LAST ) ], #optional default_dstype => "COUNTER", #optional on_missing_ds => "add", #optional ); =comment # Create an interface object $rrd = RRD::Simple->new( file => $rrdfile, cf => [qw( AVERAGE MIN MAX LAST )], #default_dstype => "DERIVE", ); =cut # Create a new RRD file with 3 data sources called # bytesIn, bytesOut and faultsPerSec. unless (-e $rrdfile) { $rrd->create( $period, bytesIn => "COUNTER", bytesOut => "COUNTER", faultsPerSec => "COUNTER" ); RRDs::tune("".$rrdfile.".rrd", "-i", "Source_Name:0"), #optional - +i or --minimum RRDs::tune("".$rrdfile.".rrd", "-a", "Source_Name:4294967295") #op +tional -a or --maximum } =comment 32-bit = 2^32-1 = 4294967295 (counter ticks) 64-bit = 2^64-1 = 18446744073709551615 (counter ticks) 64-bit counter (caution!!!) different oid's // ifInOctets (OID: 1.3.6.1.2.1.2.2.1.10) // ifOutOctets (OID: 1.3.6.1.2.1.2.2.1.16) // sysUpTime (OID: 1.3.6.1.2.1.1.3) =cut # Put some arbitary data values in the RRD file for the same # 3 data sources called bytesIn, bytesOut and faultsPerSec. $rrd->update( bytesIn => $random_number_in, bytesOut => $random_number_out, faultsPerSec => $random_number_sec ); print FH "This is the bytes_in: $random_number_in\n"; print FH "This is the bytes_out: $random_number_out\n"; print FH "This is the bytes_sec: $random_number_sec\n"; # Generate graphs: # /home/tiny_os/Desktop/Test_Perl/myfile-hourly.png, /home/tiny_os +/Desktop/Test_Perl/myfile-daily.png # /home/tiny_os/Desktop/Test_Perl/myfile-weekly.png, /home/tiny_os +/Desktop/Test_Perl/myfile-monthly.png my %rtn = $rrd->graph( $rrdfile, destination => $path, basename => "".$rrdfile."_graph", timestamp => "both", # graph, rrd, both or + none periods => [qw(hour day week month)], # omit to generate al +l graphs sources => [qw(bytesIn bytesOut faultsPerSec)], source_colors => [qw(9932CC 0000CD FFFF00)], source_labels => [("Bytes In", "Bytes Out", "Faults Per Second" +)], source_drawtypes => [qw(LINE LINE LINE)], # AREA , LINE, LINE1 line_thickness => 2, extended_legend => 1, title => "Network Interface eth0", vertical_label => "Bytes/Faults", width => 800, height => 500, interlaced => "", # If images are interlaced they become vis +ible to browsers more quickly ); #printf("Created %s\n", join(", ", map { $rtn{$_}->[0] } keys %rtn +)); # Return information about an RRD file my $info = $rrd->info($rrdfile); # This method will return a compl +ex data structure containing details about the RRD file, including RR +A and data source information. #print Data::Dumper::Dumper($info); my @sources = $rrd->sources($rrdfile); my $seconds = $rrd->retention_period($rrdfile); # This method will + return the maximum period of time (in seconds) that the RRD file wil +l store data for. # Get unixtime of when RRD file was last updated $unixtime = $rrd->last($rrdfile); print FH "".$rrdfile.".rrd was last updated at " . scalar(localtim +e($unixtime)) . "\n"; # Get list of data source names from an RRD file my @dsnames = $rrd->sources; print "Available data sources: " . join(", ", @dsnames) . "\n"; my $heartbeat_In = $rrd->heartbeat($rrdfile, "bytesIn"); # Define + the name to use the heartbeat my $heartbeat_Out = $rrd->heartbeat($rrdfile, "bytesOut"); my $heartbeat_sec = $rrd->heartbeat($rrdfile, "faultsPerSec"); # +This method will return the current heartbeat of a data source. printf "This is the heartbeat_in: %s\n", $heartbeat_In; my @rtn_In = $rrd->heartbeat($rrdfile, "bytesIn", 10); # Bas +ed on the predifined name set the step my @rtn_Out = $rrd->heartbeat($rrdfile, "bytesOut", 10); my @rtn_sec = $rrd->heartbeat($rrdfile, "faultsPerSec", 10); # +This method will set a new heartbeat of a data source. close(FH); }
With RRD::Simple is impossible to produce EPS files, but with RRD::OO it is possible. More information and working examples can be found at RRDTool::OO.
In reply to RRD::Simple .eps Format by thanos1983
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |