[INFO] Displaying work shifts only

If you figure out how to do something interesting/cool in Cacti and want to share it with the community, please post your experience here.

Moderators: Developers, Moderators

Post Reply
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

[INFO] Displaying work shifts only

Post by gandalf »

This information was taken from the rrdtool users mailing list and is not prooved yet
You want localtime 8:00 to 18:00. 10 hours per 24 hours. Keep that interval each day, set the rest to unknown or to zero. You want monday to friday. Keep that interval (which has undesired time removed already) and set the rest to unknown or to zero.
Remaining: office hours. The average computed may be too low. This will be the case if you used zero to mask out the other hours. Compensate by multiplying by 24/10 and by 7/5.
Without generating complete CDEFs, and without testing and debugging, I think the following should get you started:

Code: Select all

if (localtime more than 08:00 and less or equal to 18:00) {
    then use ds0
    else use value zero
}

ds0_modified1=LTIME,86400,%,28801,64800,LIMIT,UN,0,ds0,IF
if (localtime between saturday and sunday) {
    then use value zero
    else use outcome of previous CDEF
}
ds0_modified2=LTIME,604800,%,21000,28000,LIMIT,UN,ds0_modified1,0,IF
You will need to tweak the numbers 21000 and 28000 so that they match the beginning of saturday and the end of sunday. The numbers are no magic. Modulo 86400 gives the hour in a day, modulo 604800 gives the hour in a week. Weeks do not start on monday, they start on friday 00:00 UTC.

CDEF compiled should look like

Code: Select all

CDEF:ds0_officehours=LTIME,604800,%,3600,47,*,3600,47,48,
+,*,LIMIT,UN,LTIME,86400,%,3600,8,*,1,+,3600,17,*,LIMIT,UN,UNKN,ds0,IF,UNKN,IF
My office hours are 8h - 17h in this example (see digits 8 and 17).
Instead of setting values outside office hours to 0 I set it to UNKN.

48 is the length in hours of the weekend beginning on Sat 0h.

One correction: The "week" begins on Thursday (1.1.1970), not on Friday. This is the reason for the 47 in the CDEF.
There were already several posts asking for this. It may be useful as a starting point
Reinhard
romain.quinat
Posts: 15
Joined: Wed Sep 21, 2005 8:50 am

ERROR: invalid rpn expression

Post by romain.quinat »

are you still working on this CDEF expression ?

I have ERROR when I applied it :

ERROR: invalid rpn expression 'ds0_officehours=LTIME,604800,%,3600,47,*,3600,47,48,+,*,LIMIT,UN,LTIME,86400,%,3600,8,*,1,+,3600,19,*,LIMIT,UN,UNKN,a,IF,UNKN,IF,8,*'


Here is my CDEF :
cdef=ds0_officehours=LTIME,604800,%,3600,47,*,3600,47,48,+,*,LIMIT,UN,LTIME,86400,%,3600,8,*,1,+,3600,19,*,LIMIT,UN,UNKN,CURRENT_DATA_SOURCE,IF,UNKN,IF,8,*


Thanks LVM
romain.quinat
Posts: 15
Joined: Wed Sep 21, 2005 8:50 am

That's all folks

Post by romain.quinat »

It works, i only made a bad CDEF expression
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Would you consider Shift Displays as a good extension to http://forums.cacti.net/viewtopic.php?t=12192? Would the definition of one shift be enough? Per whole cacti system or per user config?
Reinhard
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests