Time stamp on graphs

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Time stamp on graphs

Devante
Hello,

I am trying to add timestamps to my graphs. I use a scheduled PowerShell script to execute the rrdtool to generate the graphs. I typically do it in the format of:

$CMD = "C:\path\to\rrdtool.exe" 
$arg1 = "graph" 
$arg2 = "graph.png" 
$arg3 = "--title"
$arg4 = "Graph title" 
$arg5 = "--width" 
$arg6 = "400"
$arg7 = "--vertical-label" 
$arg8 = "Percentage" 
$arg9 = "--rigid" 
$arg10 = "DEF:sload=rrdfile.rrd:load:LAST" 
$arg11 = "DEF:sservers=rrdfile.rrd:servers:LAST" 
$arg12 = "DEF:balanced=rrdfile.rrd:lbo:LAST" 
$arg13 = "GPRINT:sservers:LAST:%4.lf\j"

& $CMD $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 $arg7 $arg8 $arg9 $arg10 $arg11 $arg12 $arg13

I googled around and found someone adding "Date\: $(date "+%F %T" | sed 's/:/\\:/g')\r" but not sure how this would get added in the context above.

Any suggestions?

Thanks,

Devante

 

_______________________________________________
rrd-users mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
Reply | Threaded
Open this post in threaded view
|

Re: Time stamp on graphs

Devante
I know there is a Get-Time cmdlet in powershell which outputs as an example, Thursday, October 08, 2015 9:33:39 AM

Above the $CMD line I added:

$date = Get-Date

then I added:

$arg24 = "COMMENT: $date "

then when I execute the script it has a problem with the colons in the time:

rrdtool.exe : ERROR: I don't understand ':35:08 ' in command: 'COMMENT: 10/08/2015 09:33:39 '

Is there a way to get rrdtool to accept that time format?

Thanks again!
Reply | Threaded
Open this post in threaded view
|

Re: Time stamp on graphs

Alceu
In reply to this post by Devante
There are specific commands to be used on a Unix shell. You will have to adapt/convert those commands to Powershell.

The date commands provides a date in the specific format. Just to give you some more information (form the data manpage):

FORMAT controls the output.  Interpreted sequences are:
%F     full date; same as %Y-%m-%d
%T     time; same as %H:%M:%S

sed is replacing the text ":" with "\:", probably to escape the character. Maybe you won't need to do that if your Date object on Powershell does the right thing you need.


De: Devante Vargas <[hidden email]>
Para: "[hidden email] rrdtool" <[hidden email]>
Enviadas: Quinta-feira, 8 de Outubro de 2015 11:21
Assunto: [rrd-users] Time stamp on graphs

Hello,

I am trying to add timestamps to my graphs. I use a scheduled PowerShell script to execute the rrdtool to generate the graphs. I typically do it in the format of:

$CMD = "C:\path\to\rrdtool.exe" 
$arg1 = "graph" 
$arg2 = "graph.png" 
$arg3 = "--title"
$arg4 = "Graph title" 
$arg5 = "--width" 
$arg6 = "400"
$arg7 = "--vertical-label" 
$arg8 = "Percentage" 
$arg9 = "--rigid" 
$arg10 = "DEF:sload=rrdfile.rrd:load:LAST" 
$arg11 = "DEF:sservers=rrdfile.rrd:servers:LAST" 
$arg12 = "DEF:balanced=rrdfile.rrd:lbo:LAST" 
$arg13 = "GPRINT:sservers:LAST:%4.lf\j"

& $CMD $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 $arg7 $arg8 $arg9 $arg10 $arg11 $arg12 $arg13

I googled around and found someone adding "Date\: $(date "+%F %T" | sed 's/:/\\:/g')\r" but not sure how this would get added in the context above.

Any suggestions?

Thanks,

Devante

 

_______________________________________________
rrd-users mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users



_______________________________________________
rrd-users mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
Reply | Threaded
Open this post in threaded view
|

Re: Time stamp on graphs

Alceu
In reply to this post by Devante
Maybe you will need to escape ":" as is being done with the shell script.

Try passing a hardcoded values to rrdtool and validate that.


De: Devante <[hidden email]>
Para: [hidden email]
Enviadas: Quinta-feira, 8 de Outubro de 2015 11:51
Assunto: Re: [rrd-users] Time stamp on graphs

I know there is a Get-Time cmdlet in powershell which outputs as an example,
Thursday, October 08, 2015 9:33:39 AM

Above the $CMD line I added:

$date = Get-Date

then I added:

$arg24 = "COMMENT: $date "

then when I execute the script it has a problem with the colons in the time:

rrdtool.exe : ERROR: I don't understand ':35:08 ' in command: 'COMMENT:
10/08/2015 09:33:39 '

Is there a way to get rrdtool to accept that time format?

Thanks again!



--
View this message in context: http://rrd-mailinglists.937164.n2.nabble.com/Time-stamp-on-graphs-tp7583154p7583155.html
Sent from the RRDtool Users Mailinglist mailing list archive at Nabble.com.




_______________________________________________
rrd-users mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users



_______________________________________________
rrd-users mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users