Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-08-2006, 09:27 PM   #1
Registered: May 2006
Distribution: CentOS 4.4
Posts: 185

Rep: Reputation: 30
how do i install this script?

this is a script from another form, ive been unable to contact the guy for help installing it, i think its pretty basic so i thought id ask here. this is the script:

#!/usr/bin/perl -w

# queuegraph -- a postfix queue statistics rrdtool frontend
# based on mailgraph, which is
# copyright (c) 2000-2002 David Schweikert <>
# released under the GNU General Public License
# Modified by Damien Mascord for DTC

use RRDs;
use POSIX qw(uname);

my $VERSION = "1.1";

my $host = (POSIX::uname())[1];
my $scriptname = 'netusegraph.cgi';
my $xpoints = 800;
my $points_per_sample = 3;
my $ypoints = 160;
my $ypoints_err = 80;
my $rrd = '/etc/postfix/netusage.rrd'; # path to where the RRD database is
my $tmp_dir = '/tmp/netusegraph'; # temporary directory where to store the images
my $rrdtool_1_0 = ($RRDs::VERSION < 1.199908);

my @graphs = (
{ title => 'Day Graph', seconds => 3600*24, },
{ title => 'Week Graph', seconds => 3600*24*7, },
{ title => 'Month Graph', seconds => 3600*24*31, },
{ title => 'Year Graph', seconds => 3600*24*365, },

my %color = (
sent => '000099', # rrggbb in hex
received => '00FF00',
rejected => '999999',
bounced => '993399',
virus => 'FFFF00',
spam => 'FF0000',

sub graph($$$)
my $range = shift;
my $file = shift;
my $title = shift;
my $step = $range*$points_per_sample/$xpoints;
my $date = localtime(time);
$date =~ s|:|\\:|g unless $rrdtool_1_0;

my ($graphret,$xs,$ys) = RRDs::graph($file,
'--imgformat', 'PNG',
'--width', $xpoints,
'--height', $ypoints,
'--start', "-$range",
'--end', "-".int($range*0.01),
'--vertical-label', 'Network transfer',
'--title', $title,
$rrdtool_1_0 ? () : (


'LINE2:bytesin#00ff00:Incoming network traffic in bytes\:',
'GPRINT:bytesin:MAX:Maximum\: %0.0lf ',
'GPRINT:bytesin:AVERAGE:Average\: %0.0lf/min\n',

'LINE1:bytesout#0000ff:Outgoing network traffic in bytes\:',
'GPRINT:bytesout:MAX:Maximum\: %0.0lf ',
'GPRINT:bytesout:AVERAGE:Average\: %0.0lf/min\l',

my $ERR=RRDs::error;
die "ERROR: $ERR\n" if $ERR;

sub print_html()
print "Content-Type: text/html\n\n";

print <<HEADER;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">
<TITLE>Network usage statistics for $host</TITLE>
<style type="text/css">
h1 {
font: 12px Helvetica, Arial, sans-serif;
font-weight: bold;
color: #1C3029;

print "<H1>Network Usage Statistics for $host</H1>\n<center>";
for my $n (0..$#graphs) {
# print "<H2>$graphs[$n]{title}</H2>\n";
print "<IMG BORDER=\"0\" SRC=\"$scriptname/queuegraph_${n}.png\" ALT=\"Netusage graph\"><br>";

print <<FOOTER;
</center><table border="0" width="400"><tr><td align="left">
<A href="">queuegraph</A> $VERSION
by <A href="">Ralf Hildebrandt</A>,
based on <A href="">mailgraph</A>
by <A href="">David Schweikert</A></td>
<td ALIGN="right">
<a HREF=""><img border="0" src="" alt="" width="120" height="34"></a>

sub send_image($)
my $file = shift;
-r $file or do {
print "Content-Type: text/plain\n\nERROR: can't find $file\n";
exit 1;

print "Content-Type: image/png\n";
print "Content-Length: ".((stat($file))[7])."\n";
print "\n";
open(IMG, $file) or die;
my $data;
print $data while read IMG, $data, 1;

sub main()
my $uri = $ENV{REQUEST_URI};
$uri =~ s/\/[^\/]+$//;
$uri =~ s/\//,/g;
$uri =~ s/\~/tilde,/g;
mkdir $tmp_dir, 0777 unless -d $tmp_dir;
mkdir "$tmp_dir/$uri", 0777 unless -d "$tmp_dir/$uri";
my $file = "$tmp_dir/$uri$ENV{PATH_INFO}";
if($ENV{PATH_INFO} =~ /^\/queuegraph_(\d+)\.png$/) {
graph($graphs[$1]{seconds}, $file, $graphs[$1]{title});
else {
print "Content-Type: text/plain\n\nERROR: unknown image $ENV{PATH_INFO}\n";
exit 1;
else {

and these are the instructions he left
For what comes with installing, there is nothing special to do, only setting-up the rrd file (using something like /var/netusage), then setup a cron job (for example, add the following in your /etc/crontab : * * * * * root /root/ /var/netusage eth0), then setup the cgi-bin script in perl to display the datas (should be easy as well, just put it in a cgi-bin script folder, then modify the path on top of the script).

i have very little of an idea of what any of that means

could somebody explain it to me maybe with "do this command then this command" instructions or lead me to a webpage that would explain how to install a script like this

Old 07-08-2006, 09:51 PM   #2
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,398
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
This would seem to be a cgi-bin script. As such, it only makes sense when run by a web server, as a cgi command.

If you have a web server, like Apache, you can put the file in the cgi-bin directory of your web server. You must then make it executable:

cd /your/webservers/cgi-=bin/directory
chmod +x

This assumes the name of the script is '', as the cooments at the top of the file suggest.

You would access the script with a web browser at the url:


There is apparently some data that the script expects to find, which is generated offline by programs and scripts which I do not recognize as standard linux fare.

It also uses a perl library 'RRDs' which is not installed on my Fedora 4 system, and which appears to be something related to the aforementioned offline processing programs.

Are you sure that you got a complete package from whoever gave you this?

--- rod.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
building a bash script from an install script paranoid times Programming 6 07-29-2006 03:24 AM
livecd install script oldstinkyfish Linux - Software 6 07-26-2005 06:10 PM
simple install script acidjuice Linux - Software 2 03-13-2005 12:50 PM
Saving the install script WindowsBurner Slackware 2 02-23-2005 02:05 PM
Postfix Install Via Script joelhop Linux - Software 3 11-17-2004 11:32 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:22 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration