Re: Postgres and GnuPlot

From: Hrishikesh Deshmukh <hdeshmuk(at)gmail(dot)com>
To: Ben <bench(at)silentmedia(dot)com>
Cc: Postgresql-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Postgres and GnuPlot
Date: 2005-05-09 15:40:49
Message-ID: 829d7fb60505090840ce0201@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hmmmm......looks like i simply can't send the query results to gnuplot
without an intermediary!! So far my search results have not yielded
anything....i guess intermediary is the only way to !! :(((

Hrishi

On 5/9/05, Ben <bench(at)silentmedia(dot)com> wrote:
> Heh. Funny you should ask; I spent a fair amount of time yesterday
> doing precisely this.
>
> Here's my gnuplot file:
>
> set terminal png small color picsize 1000 400
> set style fill solid 1.0 border
> set title "Concurrent listeners"
> set xdata time
> set xlabel "Time"
> set ylabel "Cuncurrent Logged In Listeners"
> set format x "%Y/%m/%d\n%H:%M:%S"
> set timefmt "%s"
> plot "< echo \"select t-7*3600,c from stats_concurrent_listener_count
> (extract(epoch from '2004/12/13 20:00'::timestamp)::int,null);\" |
> psql -h plur -U greenroom gr-dev -t | sed 's/|//'" using 1:2 with boxes
>
> cat file | gnuplot > image.png works perfectly.
>
> The bitch of it is that I seem to be having a hard time running this
> as a cgi. I can't figure out. Not that this question has anything to
> do with postgres, but maybe somebody else can tell me where I'm going
> wrong? My CGI is:
>
> #!/bin/bash
>
> echo -e "Content-type: image/png\n\n";
> echo -e "set terminal png small color picsize 1000 400\nset style
> fill solid 1.0 border\nset title \"Concurrent listeners\"\nset xdata
> time\nset xlabel \"Time\"\nset ylabel \"Cuncurrent Logged In Listeners
> \"\nset format x \"%Y/%m/%d\\\n%H:%M:%S\"\nset timefmt \"%s\"\nplot
> \"< echo \\\"select t-7*3600,c from stats_concurrent_listener_count
> (extract(epoch from '2004/12/13 20:00'::timestamp)::int,null);\\\" | /
> usr/bin/psql -h plur -U greenroom gr-dev -t | sed 's/|//'\" using 1:2
> with boxes" | /usr/bin/gnuplot
>
> ...and it seems that when printing to stdout, it gives a truncated
> version of the file. When redirecting, it does not. Maybe that's not
> too surprising, if apache is looking for a null to see when stdout
> stops.... but I don't know how to get around that.
>
>
> On May 9, 2005, at 7:51 AM, Hrishikesh Deshmukh wrote:
>
> > Hi All,
> >
> > Has anybody tried using gnuplot to plot results from queries; there
> > are some suggestions given in PostgreSQL Developer's Handbook but i
> > have not any luck so far!
> > Any pointers as how to send results from queries straight to a simple
> > plotting utility (ex:gnuplot)!
> >
> > Thanks,
> > Hrishi
> >
> > ---------------------------(end of
> > broadcast)---------------------------
> > TIP 4: Don't 'kill -9' the postmaster
> >
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mila Boldareva 2005-05-09 15:41:17 Re: Postgres and GnuPlot
Previous Message Ben 2005-05-09 15:37:16 Re: Postgres and GnuPlot