Hi all,
I'm getting to grips with Cacti. Steep learning curve but I'm getting good results from it.
I've got a GPRINT which is the total number of seconds the device has been running for.
It's not quite the same as uptime as it's a sub processor for the main system which provides the SNMP data and will have started at a different point in time and maybe restarted.
The is output in seconds. It can obviously come to be a rather big number.
I'm looking for a way to reformat this into DD:HH:MM:SS.
Searching for somehing I'm surprised that I cannot find a way of doing it. Have searched google and the fourm so perhaps I'm not putting in the right parameters.
Converting to minutes or hours alone seems to be no problem, but to represent it as a formatted string containing all seems a lot harder.
I'd happily ditch the DD field if it would help.
So I believe I need to be using a CDEF, but really would appreciate some help/pointers please.
CDEF convert seconds to DD:HH:MM:SS
Moderators: Developers, Moderators
Re: CDEF convert seconds to DD:HH:MM:SS
It won't be a CDEF, you will want to use a format string on your GPRINT.
Take a look here http://oss.oetiker.ch/rrdtool/doc/rrdgr ... tml#___top
I'm pretty sure you should be able to do something with that (may possibly have to mix in a CDEF to get the right number to pass to GPRINT)
Take a look here http://oss.oetiker.ch/rrdtool/doc/rrdgr ... tml#___top
I'm pretty sure you should be able to do something with that (may possibly have to mix in a CDEF to get the right number to pass to GPRINT)
Re: CDEF convert seconds to DD:HH:MM:SS
Had a look at that page previously.
n00b who RTFM
WHat I got from it was that there were various % options one could put in for time, but the manual suggests that these are taking the system time and allowing it to be formatted into the GPRINT, rather than the formatting of a number as time which is the current variable one is trying to apply the changes too.
If I could understand if it's possible to use CDEF to take the variable and then pass out 3 variables to GPRINT hours, mins, secs) but I get the impression it's just one at a time?
Just surpised this hasn't come up before, or that I can't find it either
I note from my SNMP host that it's overall up time is display as part of the standard SNMP data as hh:mm:ss
Fastest way out might just be to change the format that the host outputs to delimited values. But that's just cheating and not really learning anything
Been having a monster of a day with missing data templates and mysql errors.
Once you figure out why something isn't working it obvious. Shame that doesn't come first
n00b who RTFM
WHat I got from it was that there were various % options one could put in for time, but the manual suggests that these are taking the system time and allowing it to be formatted into the GPRINT, rather than the formatting of a number as time which is the current variable one is trying to apply the changes too.
If I could understand if it's possible to use CDEF to take the variable and then pass out 3 variables to GPRINT hours, mins, secs) but I get the impression it's just one at a time?
Just surpised this hasn't come up before, or that I can't find it either
I note from my SNMP host that it's overall up time is display as part of the standard SNMP data as hh:mm:ss
Fastest way out might just be to change the format that the host outputs to delimited values. But that's just cheating and not really learning anything
Been having a monster of a day with missing data templates and mysql errors.
Once you figure out why something isn't working it obvious. Shame that doesn't come first
Re: CDEF convert seconds to DD:HH:MM:SS
Did anyone manage to turn ticks into dd:hh:mm:ss ?
Re: CDEF convert seconds to DD:HH:MM:SS
Maybe you can do like this:
#get the day portion from the timeticks.
CDEF:days=uptime,8640000,/,0.5,- \
#get the hour portion from the timeticks.
CDEF:hours=uptime,360000,/,24,%,0.5,- \
#get the minute portion from the timeticks.
CDEF:minutes=uptime,6000,/,60,%,0.5,- \
Because the GPRINT %lf result is a rounded value, so I need to minus 0.5 to get the floor value.
COMMENT:"UP Time: \" \
GPRINT:uptime:LAST:"LAST \\: %16.0lf\\n" \
GPRINT:days:LAST:"Day: %4.0lf" \
GPRINT:hours:LAST:"Hour: %2.0lf" \
GPRINT:minutes:LAST:"Min: %2.0lf\\n"
#get the day portion from the timeticks.
CDEF:days=uptime,8640000,/,0.5,- \
#get the hour portion from the timeticks.
CDEF:hours=uptime,360000,/,24,%,0.5,- \
#get the minute portion from the timeticks.
CDEF:minutes=uptime,6000,/,60,%,0.5,- \
Because the GPRINT %lf result is a rounded value, so I need to minus 0.5 to get the floor value.
COMMENT:"UP Time: \" \
GPRINT:uptime:LAST:"LAST \\: %16.0lf\\n" \
GPRINT:days:LAST:"Day: %4.0lf" \
GPRINT:hours:LAST:"Hour: %2.0lf" \
GPRINT:minutes:LAST:"Min: %2.0lf\\n"
Who is online
Users browsing this forum: No registered users and 1 guest