Tcl docs?

View: New views
10 Messages — Rating Filter:   Alert me  

Tcl docs?

by Thomas Sattler-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi there ...

I'd like to use RRD from within Tcl/Tk. Is there some
(up to date) documentation about RRD and Tcl online?

All I found so far is http://wiki.tcl.tk/8386 and
http://linux.about.com/cs/linux101/g/rrdtool-tcl.htm

Thanks,
Thomas

_______________________________________________
rrd-users mailing list
rrd-users@...
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users

rrdtool graph confusion

by echouin12 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm having 2 issues with the rrdtool graph command.

1st I can't seem to get the new line command to work, this is what I
have in my code 'GPRINT:avgN:"Avg %6.2lf%%\n"', and when graphed the /n
gives a character that look like a box ,[], and I don't know how to deal
with this.

2nd I'm trying to comment the current date at the bottom of my graph but
am so far unsuccessful. I've tried  COMMENT:"%m/%d/%Y %H\:%M\:%S",  and
I tried declaring cur_date = '%m/%d/%Y %H\:%M\:%S' and then commenting
cur_date COMMENT:"' + cur_date + '" and neither are working for me.  I
get the following error:

 Traceback (most recent call last):
  File "cpu_usage.py", line 78, in ?
 ' COMMENT:"' + cur_date + '"')
rrdtool.error: Could not make sense out of ' COMMENT:"%m/%d/%Y %H\:%M\:%S"'

I'm probably missing something very basic (oh and I'm using python so
thats why everything is being passed as a string)

Thanks for all your help so far, I've really appreciated it!!!

_______________________________________________
rrd-users mailing list
rrd-users@...
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users

Parent Message unknown Re: rrdtool graph confusion

by echouin12 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Henrik Lindhe wrote:

> On Tue, Jul 1, 2008 at 17:23, Emily Chouinard <cousin17@...> wrote:
>  
>> I'm having 2 issues with the rrdtool graph command.
>>
>> 1st I can't seem to get the new line command to work, this is what I
>> have in my code 'GPRINT:avgN:"Avg %6.2lf%%\n"', and when graphed the /n
>> gives a character that look like a box ,[], and I don't know how to deal
>> with this.
>>    
>
> In some languages you need to escape the \, so try \\n
>
>  
Yeah I tried that and then is displayed '\n' instead, is there a
different command for new line? I also tried COMMENT: /n and that too
didn't work!

>> 2nd I'm trying to comment the current date at the bottom of my graph but
>> am so far unsuccessful. I've tried  COMMENT:"%m/%d/%Y %H\:%M\:%S",  and
>> I tried declaring cur_date = '%m/%d/%Y %H\:%M\:%S' and then commenting
>> cur_date COMMENT:"' + cur_date + '" and neither are working for me.  I
>> get the following error:
>>
>>  Traceback (most recent call last):
>>  File "cpu_usage.py", line 78, in ?
>>  ' COMMENT:"' + cur_date + '"')
>> rrdtool.error: Could not make sense out of ' COMMENT:"%m/%d/%Y %H\:%M\:%S"'
>>    
>
> You need to get python to convert your datestring to a string, without
> % variables.
>  
How else would I do that? Python isn't complaining about the % variable,
rrdtool is? I'm sorry I'm just confused.
 Thanks for your help!

>  
>> I'm probably missing something very basic (oh and I'm using python so
>> thats why everything is being passed as a string)
>>
>> Thanks for all your help so far, I've really appreciated it!!!
>>
>> _______________________________________________
>> rrd-users mailing list
>> rrd-users@...
>> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
>>
>>    
>
>
>  

_______________________________________________
rrd-users mailing list
rrd-users@...
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users

Re: rrdtool graph confusion

by Simon Hobson-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Emily Chouinard wrote:

>2nd I'm trying to comment the current date at the bottom of my graph but
>am so far unsuccessful. I've tried  COMMENT:"%m/%d/%Y %H\:%M\:%S",  and
>I tried declaring cur_date = '%m/%d/%Y %H\:%M\:%S' and then commenting
>cur_date COMMENT:"' + cur_date + '" and neither are working for me.  I
>get the following error:
>
>  Traceback (most recent call last):
>   File "cpu_usage.py", line 78, in ?
>  ' COMMENT:"' + cur_date + '"')
>rrdtool.error: Could not make sense out of ' COMMENT:"%m/%d/%Y %H\:%M\:%S"'

Well in my scripts (Bash) I use these statements to get the date on
the graphs :

Early in the bash script :
   Etime=`/bin/date +%s`
   Etime=$(( ${Etime} / ${Step} * ${Step} ))
   PrintedTime=$(/bin/date -d "19700101 00:00 +0000 ${Etime}sec"
+"%H\:%M %a %d %b %Y")

Then in the graph definition :
   COMMENT:"    Data to ${PrintedTime}\n"

What is happening here is that I get the current time in seconds
since epoch, round it down to the last whole multiple of the step
size, then get date to convert this to a textual representation. Note
that "%H\:%M %a %d %b %Y" is converted by date to a text string like
"20\:10 Tue 01 Jul 2008", it is NOT processed by the rrd tools.

The end result id my graph has a string like "20:10 Tue 01 Jul 2008" on it.

It looks like you are trying to get rrd to interpret the date string,
something I don't think I managed to get exactly right IIRC - it's a
long time now since I wrote my first script, and newer ones have been
"copy and adapt" derivatives.

_______________________________________________
rrd-users mailing list
rrd-users@...
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users

Parent Message unknown Re: rrdtool graph confusion

by Yiannis Vavouranakis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



> I'm having 2 issues with the rrdtool graph command.
>
> 1st I can't seem to get the new line command to work, this is what I
> have in my code 'GPRINT:avgN:"Avg %6.2lf%%\n"', and when graphed the /n
> gives a character that look like a box ,[], and I don't know how to deal
> with this.
>
> 2nd I'm trying to comment the current date at the bottom of my graph but
> am so far unsuccessful. I've tried  COMMENT:"%m/%d/%Y %H\:%M\:%S",  and
> I tried declaring cur_date = '%m/%d/%Y %H\:%M\:%S' and then commenting
> cur_date COMMENT:"' + cur_date + '" and neither are working for me.  I
> get the following error:
>
>  Traceback (most recent call last):
>   File "cpu_usage.py", line 78, in ?
>  ' COMMENT:"' + cur_date + '"')
> rrdtool.error: Could not make sense out of ' COMMENT:"%m/%d/%Y
%H\:%M\:%S"'
>
> I'm probably missing something very basic (oh and I'm using python so
> thats why everything is being passed as a string)
>
> Thanks for all your help so far, I've really appreciated it!!!

Hello.

a) As regards the issue with \l and \n, my guess is that python is messing
with the strings. Probably it actually escapes \n within the string, so
instead of passing the literal "blablabla\n" to the rrdtool  backend
library, it parses the string, replaces the sequence "\n" with the actual
newline character and passes "blabla[newline]". The rrdtool library, in
turn, receives "blabla[newline]", and renders it as such. The net result is
that you get an uninterpretable character (the box) instead of a newline.
Probably the same happens with \l. Try escaping the escapes, (so instead of
\n, write \\n). If that doesn't work, try using raw strings (prepend the
string with r, so that instead of "blabla\n" you'll have r"blabla\n" -
notice the r is OUTSIDE the quotes). For more on escape sequences and raw
strings in python, I suggest you study the python manuals (they come bundled
with python itself).

b) I can't seem to make out ehat you're trying to do. Maybe post a larger
snippet of the code, so that I can understand what you're trying to achieve?

Regards,
Yiannis Vavouranakis

_______________________________________________
rrd-users mailing list
rrd-users@...
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users

Parent Message unknown Re: rrdtool graph confusion

by Yiannis Vavouranakis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> 2nd I'm trying to comment the current date at the bottom of my graph but
> am so far unsuccessful. I've tried  COMMENT:"%m/%d/%Y %H\:%M\:%S",  and
> I tried declaring cur_date = '%m/%d/%Y %H\:%M\:%S' and then commenting
> cur_date COMMENT:"' + cur_date + '" and neither are working for me.  I
> get the following error:
>
>  Traceback (most recent call last):
>   File "cpu_usage.py", line 78, in ?
>  ' COMMENT:"' + cur_date + '"')
> rrdtool.error: Could not make sense out of ' COMMENT:"%m/%d/%Y
%H\:%M\:%S"'
>
> I'm probably missing something very basic (oh and I'm using python so
> thats why everything is being passed as a string)

Actually, I figured out what you're trying to do here. My guess is that the
COMMENT does not understand sequences like %m/%d/%Y. Try the following:
instead of saying cur_date = '%m/%d/%Y %H\:%M\:%S', declare cur_date as a
datetime object, then use an appropriate string representation of it to
concatenate with COMMENT.

Hope it helps.

Regards,
Yiannis Vavouranakis

_______________________________________________
rrd-users mailing list
rrd-users@...
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users

Re: rrdtool graph confusion

by Raimund Berger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Simon Hobson <linux@...> writes:

> It looks like you are trying to get rrd to interpret the date string,
> something I don't think I managed to get exactly right IIRC - it's a
> long time now since I wrote my first script, and newer ones have been
> "copy and adapt" derivatives.

Just an observation: while I didn't use those date formatter strings
yet myself, a brief glimpse over the docs reveals

 PRINT:vname:format[:strftime]
 GPRINT:vname:format
 COMMENT:text

where those date/time formatter strings are explained to be part of
the *strftime* format string.

This means they won't work with COMMENT or GPRINT anyway, so when used
in those the date has to be computed and formatted on script level as
you say.

In my experience, when running into problems, paying some attention to
the docs often helps a lot.

Regards, R.

_______________________________________________
rrd-users mailing list
rrd-users@...
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users

Re: rrdtool graph confusion

by echouin12 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks everyone for your help, I got it all under control. I just got
rid of my " and used /l and that seemed to work just right. And the
issue with the time was that I needed to declare the current date as
cur_date = time.strftime('%m/%d/%Y %H\:%M\:%S', time.localtime()) and
now everything is working fine, but thank you all for offering you
suggestions I really appreciated it!

Yiannis Vavouranakis wrote:

>> 2nd I'm trying to comment the current date at the bottom of my graph but
>> am so far unsuccessful. I've tried  COMMENT:"%m/%d/%Y %H\:%M\:%S",  and
>> I tried declaring cur_date = '%m/%d/%Y %H\:%M\:%S' and then commenting
>> cur_date COMMENT:"' + cur_date + '" and neither are working for me.  I
>> get the following error:
>>
>>  Traceback (most recent call last):
>>   File "cpu_usage.py", line 78, in ?
>>  ' COMMENT:"' + cur_date + '"')
>> rrdtool.error: Could not make sense out of ' COMMENT:"%m/%d/%Y
>>    
> %H\:%M\:%S"'
>  
>> I'm probably missing something very basic (oh and I'm using python so
>> thats why everything is being passed as a string)
>>    
>
> Actually, I figured out what you're trying to do here. My guess is that the
> COMMENT does not understand sequences like %m/%d/%Y. Try the following:
> instead of saying cur_date = '%m/%d/%Y %H\:%M\:%S', declare cur_date as a
> datetime object, then use an appropriate string representation of it to
> concatenate with COMMENT.
>
> Hope it helps.
>
> Regards,
> Yiannis Vavouranakis
>
> _______________________________________________
> rrd-users mailing list
> rrd-users@...
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
>
>
>  

_______________________________________________
rrd-users mailing list
rrd-users@...
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users

Re: rrdtool graph confusion

by echouin12 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

So now that I have those small issues cleared up, I have another issue
that I'm trying to discern.
I've created a graph that show the percent of CPU usage for the user,
system,nice and idle and since I'm ssh-ing into another linux box to do
all this idle processes are of the highest percent, around 98.6% but the
problem I'm having is the area for idle goes above zero?
Here's the code I've written for this graph b
 'AREA:idl#EEFFFF:Idle:STACK',
 'LINE2:1#DDDDDD::STACK', The question I have is when you use STACK does
that add to the value of the area, because my Average was 98.06% but the
line was showing up above the 100 mark? I'm trying to get the graph, but
if anyone has any insight into why this is I'm open to suggestions.

Thanks!!!

_______________________________________________
rrd-users mailing list
rrd-users@...
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users

Re: rrdtool graph confusion

by echouin12 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry I meant idle appears above the 100 mark and I'm not sure why. I've
attached my graph and hopefully someone can help me out!
And here's my entire graph command
   rrdtool.graph('cpu.png',
         '--start','now-3600',
          '--end','now',
          'DEF:uj=cpu.rrd:user:AVERAGE', #define number of jiffies
          'DEF:nj=cpu.rrd:nice:AVERAGE',#which are the number of ticks
         'DEF:sj=cpu.rrd:sys:AVERAGE',
         'DEF:ij=cpu.rrd:idle:AVERAGE',
          'CDEF:tj=uj,nj,+,sj,+,ij,+',
          'CDEF:bo=uj,UN,0,uj,IF,0,GT,UNKN,INF,IF', #creates a gray region when
user jiffies is undefined
         'AREA:bo#DDDDDD:',
         'CDEF:usr=100,uj,*,tj,/',
         'CDEF:nic=100,nj,*,tj,/',
          'CDEF:sys=100,sj,*,tj,/',
         'CDEF:idl=100,ij,*,tj,/',
         'CDEF:tot=100,tj,*,tj,/',
          'AREA:nic#0040A2:Nice',
          'VDEF:maxN=nic,MAXIMUM',
         'VDEF:minN=nic,MINIMUM',
         'VDEF:avgN=nic,AVERAGE',
         'GPRINT:maxN:  Max %6.2lf%%',
         'GPRINT:minN:  Min %6.2lf%%',
         'GPRINT:avgN:  Avg %6.2lf%%\l',
          'AREA:sys#90C5CC:System:STACK',
         'LINE2:1#70A5AC::STACK',
          'VDEF:maxS=sys,MAXIMUM',
         'VDEF:minS=sys,MINIMUM',
         'VDEF:avgS=sys,AVERAGE',
         'GPRINT:maxS:Max %6.2lf%%',
         'GPRINT:minS:  Min %6.2lf%%',
         'GPRINT:avgS:  Avg %6.2lf%%\l',
         'AREA:usr#B0E5EC:User:STACK',
         'LINE2:1#90C5CC::STACK',
         'VDEF:maxU=usr,MAXIMUM',
         'VDEF:minU=usr,MINIMUM',
         'VDEF:avgU=usr,AVERAGE',
         'GPRINT:maxU:  Max %6.2lf%%',
         'GPRINT:minU:  Min %6.2lf%%',
         'GPRINT:avgU:  Avg %6.2lf%%\l',
          'AREA:idl#EEFFFF:Idle:STACK',
          'LINE:1#DDDDDD::STACK',
         'VDEF:maxI=idl,MAXIMUM',
   'VDEF:minI=idl,MINIMUM',
   'VDEF:avgI=idl,AVERAGE',
   'GPRINT:maxI:  Max %6.2lf%%',
   'GPRINT:minI:  Min %6.2lf%%',
   'GPRINT:avgI:  Avg %6.2lf%%\l',
          '--vertical-label','Ticks',
          '--title','Hourly CPU Usage',
          'COMMENT:' + cur_date + '')

Emily Chouinard writes:

> So now that I have those small issues cleared up, I have another issue
> that I'm trying to discern.
> I've created a graph that show the percent of CPU usage for the user,
> system,nice and idle and since I'm ssh-ing into another linux box to do
> all this idle processes are of the highest percent, around 98.6% but the
> problem I'm having is the area for idle goes above zero?
> Here's the code I've written for this graph b
>  'AREA:idl#EEFFFF:Idle:STACK',
>  'LINE2:1#DDDDDD::STACK', The question I have is when you use STACK does
> that add to the value of the area, because my Average was 98.06% but the
> line was showing up above the 100 mark? I'm trying to get the graph, but
> if anyone has any insight into why this is I'm open to suggestions.
>
> Thanks!!!
>
> _______________________________________________
> rrd-users mailing list
> rrd-users@...
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users 
>
 




_______________________________________________
rrd-users mailing list
rrd-users@...
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users

cpu.png (26K) Download Attachment
LightInTheBox - Buy quality products at wholesale price!