Introduce a colour scheme and fix design of the graphs
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Dec 2015 20:38:38 +0000 (21:38 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Dec 2015 20:42:45 +0000 (21:42 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
14 files changed:
src/collecty/colours.py
src/collecty/constants.py
src/collecty/plugins/conntrack.py
src/collecty/plugins/contextswitches.py
src/collecty/plugins/disk.py
src/collecty/plugins/entropy.py
src/collecty/plugins/interface.py
src/collecty/plugins/interrupts.py
src/collecty/plugins/ipfrag.py
src/collecty/plugins/latency.py
src/collecty/plugins/loadavg.py
src/collecty/plugins/memory.py
src/collecty/plugins/processor.py
src/collecty/util.py

index 6aaa207..21299e4 100644 (file)
 #                                                                             #
 ###############################################################################
 
+from . import util
+
 BLACK        = "#000000"
 WHITE        = "#FFFFFF"
+GREY         = "#9E9E9E"
+LIGHT_GREY   = "#F5F5F5"
 
-YELLOW       = "#FFFF33"
+RED          = "#F44336"
+LIGHT_RED    = "#CC0033"
+YELLOW       = "#FFEB3B"
 LIGHT_YELLOW = "#FFFF66"
+GREEN        = "#4CAF50"
+LIGHT_GREEN  = "#8BC34A"
+BLUE         = "#2196F3"
+LIGHT_BLUE   = "#03A9F4"
 
-LIGHT_GREEN  = "#00CC33"
-LIGHT_RED    = "#CC0033"
+AMBER        = "#FFC107"
+BROWN        = "#795548"
+CYAN         = "#00BCD4"
+INDIGO       = "#3F51B5"
+LIME         = "#CDDC39"
+ORANGE       = "#FF9800"
+DEEP_ORANGE  = "#FF5722"
+PINK         = "#E91E63"
+PURPLE       = "#9C27B0"
+DEEP_PURPLE  = "#673AB7"
+TEAL         = "#009688"
+
+COLOUR_OK       = LIGHT_GREEN
+COLOUR_CRITICAL = LIGHT_RED
+COLOUR_ERROR    = COLOUR_CRITICAL
+COLOUR_WARN     = LIGHT_YELLOW
+COLOUR_TEXT     = util.lighten(BLACK, 0.87) # 87% grey
+
+PRIMARY      = INDIGO
+ACCENT       = PINK
+
+# Lighten the areas by this factor
+AREA_OPACITY   = 0.25
+STDDEV_OPACITY = 0.33
+
+# Receive and transmit
+COLOUR_RX    = RED
+COLOUR_TX    = GREEN
+
+# I/O
+COLOUR_READ  = GREEN
+COLOUR_WRITE = RED
+
+# IPv6 + IPv4
+COLOUR_IPV6  = INDIGO
+COLOUR_IPV4  = PINK
+COLOUR_IPVX  = GREY # other
+
+COLOUR_TCP     = INDIGO
+COLOUR_UDP     = YELLOW
+COLOUR_ICMP    = PURPLE
+COLOUR_IGMP    = TEAL
+COLOUR_UDPLITE = DEEP_ORANGE
+COLOUR_SCTP    = LIGHT_GREEN
+COLOUR_DCCP    = LIGHT_BLUE
+COLOUR_OTHER   = COLOUR_IPVX
+
+# Processor
+CPU_USER     = LIGHT_GREEN
+CPU_NICE     = BLUE
+CPU_SYS      = RED
+CPU_WAIT     = DEEP_PURPLE
+CPU_IRQ      = ORANGE
+CPU_SIRQ     = YELLOW
+CPU_IDLE     = LIGHT_GREY
+
+# Memory
+MEMORY_USED     = GREEN
+MEMORY_BUFFERED = BLUE
+MEMORY_CACHED   = YELLOW
+MEMORY_SWAP     = RED
+
+# Load average
+LOAD_AVG_COLOURS = (
+       RED,    #  1m
+       ORANGE, #  5m
+       YELLOW, # 15m
+)
+
+COLOURS_PROTOCOL_STATES = {
+       # General states
+       "NONE"              : GREY,
+       "TIME_WAIT"         : AMBER,
+
+       # TCP
+       "CLOSE"             : BLACK,
+       "CLOSE_WAIT"        : util.lighten(BLACK, 0.25),
+       "ESTABLISHED"       : LIGHT_GREEN,
+       "FIN_WAIT"          : ORANGE,
+       "LAST_ACK"          : PURPLE,
+       "SYN_RECV"          : CYAN,
+       "SYN_SENT"          : TEAL,
+       "SYN_SENT2"         : AMBER,
+
+       # DCCP
+       "CLOSEREQ"          : util.lighten(BLACK, 0.5),
+       "CLOSING"           : util.lighten(BLACK, 0.25),
+       "IGNORE"            : WHITE,
+       "INVALID"           : RED,
+       "OPEN"              : LIGHT_GREEN,
+       "PARTOPEN"          : YELLOW,
+       "REQUEST"           : CYAN,
+       "RESPOND"           : TEAL,
 
-COLOUR_OK    = LIGHT_GREEN
-COLOUR_ERROR = LIGHT_RED
-COLOUR_WARN  = LIGHT_YELLOW
+       # SCTP
+       "CLOSED"            : BLACK,
+       "COOKIE_ECHOED"     : AMBER,
+       "COOKIE_WAIT"       : CYAN,
+       "SHUTDOWN_ACK_SENT" : TEAL,
+       "SHUTDOWN_RECD"     : PURPLE,
+       "SHUTDOWN_SENT"     : LIGHT_BLUE,
+}
index 082203e..dcfe2d8 100644 (file)
@@ -19,7 +19,6 @@
 #                                                                             #
 ###############################################################################
 
-from .colours import *
 from .i18n import _
 
 from .__version__ import *
index 22fcd60..efd062d 100644 (file)
@@ -23,6 +23,7 @@ import os
 
 from . import base
 
+from ..colours import *
 from ..i18n import _
 
 CONNTRACK_FILE = "/proc/net/nf_conntrack"
@@ -132,8 +133,9 @@ class ConntrackLayer3ProtocolsGraphTemplate(base.GraphTemplate):
        _protocols = ConntrackTable._layer3_protocols
 
        protocol_colours = {
-               "ipv6"  : "#cc0033",
-               "ipv4"  : "#cccc33",
+               "ipv6"  : COLOUR_IPV6,
+               "ipv4"  : COLOUR_IPV4,
+               "other" : COLOUR_IPVX,
        }
 
        def get_objects(self, *args):
@@ -184,7 +186,7 @@ class ConntrackLayer3ProtocolsGraphTemplate(base.GraphTemplate):
 
                for proto in self.protocols:
                        i = {
-                               "colour"      : self.protocol_colours.get(proto, "#000000"),
+                               "colour"      : self.protocol_colours.get(proto, COLOUR_OTHER),
                                "description" : self.protocol_descriptions.get(proto, proto),
                                "proto"       : proto,
                                "type"        : type,
@@ -216,13 +218,13 @@ class ConntrackLayer4ProtocolsGraphTemplate(ConntrackLayer3ProtocolsGraphTemplat
        name = "conntrack-layer4-protocols"
 
        protocol_colours = {
-               "tcp"     : "#336600",
-               "udp"     : "#666633",
-               "icmp"    : "#336666",
-               "igmp"    : "#666699",
-               "udplite" : "#3366cc",
-               "sctp"    : "#6666ff",
-               "dccp"    : "#33cc00",
+               "tcp"     : COLOUR_TCP,
+               "udp"     : COLOUR_UDP,
+               "icmp"    : COLOUR_ICMP,
+               "igmp"    : COLOUR_IGMP,
+               "udplite" : COLOUR_UDPLITE,
+               "sctp"    : COLOUR_SCTP,
+               "dccp"    : COLOUR_DCCP,
        }
 
        @property
@@ -271,43 +273,6 @@ class ConntrackProtocolWithStatesGraphTemplate(base.GraphTemplate):
 
        lower_limit = 0
 
-       states_colours = {
-               "dccp" : {
-                       "CLOSEREQ"          : "#000000",
-                       "CLOSING"           : "#111111",
-                       "IGNORE"            : "#222222",
-                       "INVALID"           : "#333333",
-                       "NONE"              : "#444444",
-                       "OPEN"              : "#555555",
-                       "PARTOPEN"          : "#666666",
-                       "REQUEST"           : "#777777",
-                       "RESPOND"           : "#888888",
-                       "TIME_WAIT"         : "#999999",
-               },
-               "sctp" : {
-                       "CLOSED"            : "#000000",
-                       "COOKIE_ECHOED"     : "#111111",
-                       "COOKIE_WAIT"       : "#222222",
-                       "ESTABLISHED"       : "#333333",
-                       "NONE"              : "#444444",
-                       "SHUTDOWN_ACK_SENT" : "#555555",
-                       "SHUTDOWN_RECD"     : "#666666",
-                       "SHUTDOWN_SENT"     : "#777777",
-               },
-               "tcp" : {
-                       "CLOSE"             : "#ffffff",
-                       "CLOSE_WAIT"        : "#999999",
-                       "ESTABLISHED"       : "#000000",
-                       "FIN_WAIT"          : "#888888",
-                       "LAST_ACK"          : "#777777",
-                       "NONE"              : "#000000",
-                       "SYN_RECV"          : "#111111",
-                       "SYN_SENT"          : "#222222",
-                       "SYN_SENT2"         : "#333333",
-                       "TIME_WAIT"         : "#444444",
-               },
-       }
-
        states_descriptions = {
                "dccp" : {},
                "sctp" : {},
@@ -377,7 +342,7 @@ class ConntrackProtocolWithStatesGraphTemplate(base.GraphTemplate):
 
                for state in reversed(self.states):
                        i = {
-                               "colour"      : self.states_colours[self.protocol].get(state, "#000000"),
+                               "colour"      : COLOURS_PROTOCOL_STATES.get(state, BLACK),
                                "description" : self.states_descriptions[self.protocol].get(state, state),
                                "proto"       : self.protocol,
                                "state"       : state,
index 18fa4d8..c1299aa 100644 (file)
@@ -23,6 +23,7 @@ import re
 
 from . import base
 
+from ..colours import *
 from ..i18n import _
 
 class GraphTemplateContextSwitches(base.GraphTemplate):
@@ -33,10 +34,14 @@ class GraphTemplateContextSwitches(base.GraphTemplate):
                _ = self.locale.translate
 
                return [
-                       "AREA:ctxt#90EE90:%-15s" % _("Context Switches"),
+                       "AREA:ctxt%s:%-15s" % (
+                               util.lighten(PRIMARY, AREA_OPACITY),
+                               _("Context Switches"),
+                       ),
                        "GPRINT:ctxt_max:%12s\:" % _("Maximum") + " %6.2lf" ,
                        "GPRINT:ctxt_min:%12s\:" % _("Minimum") + " %6.2lf" ,
                        "GPRINT:ctxt_avg:%12s\:" % _("Average") + " %6.2lf\\n",
+                       "LINE1:ctxt%s" % PRIMARY,
                ]
 
        lower_limit = 0
index 3c220bf..1b12c5c 100644 (file)
@@ -35,7 +35,7 @@ class GraphTemplateDiskBadSectors(base.GraphTemplate):
                _ = self.locale.translate
 
                return [
-                       "AREA:bad_sectors#ff0000:%s" % _("Bad Sectors"),
+                       "AREA:bad_sectors%s:%s" % (COLOUR_CRITICAL,_("Bad Sectors")),
                        "GPRINT:bad_sectors_cur:%12s\:" % _("Current") + " %9.2lf",
                        "GPRINT:bad_sectors_max:%12s\:" % _("Maximum") + " %9.2lf\\n",
                ]
@@ -62,13 +62,13 @@ class GraphTemplateDiskBytes(base.GraphTemplate):
                        "CDEF:read_bytes=read_sectors,512,*",
                        "CDEF:write_bytes=write_sectors,512,*",
 
-                       "LINE1:read_bytes#ff0000:%-15s" % _("Read"),
+                       "LINE1:read_bytes%s:%-15s" % (COLOUR_READ, _("Read")),
                        "GPRINT:read_bytes_cur:%12s\:" % _("Current") + " %9.2lf",
                        "GPRINT:read_bytes_max:%12s\:" % _("Maximum") + " %9.2lf",
                        "GPRINT:read_bytes_min:%12s\:" % _("Minimum") + " %9.2lf",
                        "GPRINT:read_bytes_avg:%12s\:" % _("Average") + " %9.2lf\\n",
 
-                       "LINE1:write_bytes#00ff00:%-15s" % _("Written"),
+                       "LINE1:write_bytes%s:%-15s" % (COLOUR_WRITE, _("Written")),
                        "GPRINT:write_bytes_cur:%12s\:" % _("Current") + " %9.2lf",
                        "GPRINT:write_bytes_max:%12s\:" % _("Maximum") + " %9.2lf",
                        "GPRINT:write_bytes_min:%12s\:" % _("Minimum") + " %9.2lf",
@@ -98,13 +98,13 @@ class GraphTemplateDiskIoOps(base.GraphTemplate):
                _ = self.locale.translate
 
                rrd_graph = [
-                       "LINE1:read_ios#ff0000:%-15s" % _("Read"),
+                       "LINE1:read_ios%s:%-15s" % (COLOUR_READ, _("Read")),
                        "GPRINT:read_ios_cur:%12s\:" % _("Current") + " %6.2lf",
                        "GPRINT:read_ios_max:%12s\:" % _("Maximum") + " %6.2lf",
                        "GPRINT:read_ios_min:%12s\:" % _("Minimum") + " %6.2lf",
                        "GPRINT:read_ios_avg:%12s\:" % _("Average") + " %6.2lf\\n",
 
-                       "LINE1:write_ios#00ff00:%-15s" % _("Written"),
+                       "LINE1:write_ios%s:%-15s" % (COLOUR_WRITE, _("Written")),
                        "GPRINT:write_ios_cur:%12s\:" % _("Current") + " %6.2lf",
                        "GPRINT:write_ios_max:%12s\:" % _("Maximum") + " %6.2lf",
                        "GPRINT:write_ios_min:%12s\:" % _("Minimum") + " %6.2lf",
@@ -140,7 +140,7 @@ class GraphTemplateDiskTemperature(base.GraphTemplate):
                        "VDEF:temp_max=celsius,MAXIMUM",
                        "VDEF:temp_avg=celsius,AVERAGE",
 
-                       "LINE2:celsius#ff0000:%s" % _("Temperature"),
+                       "LINE2:celsius%s:%s" % (PRIMARY, _("Temperature")),
                        "GPRINT:temp_cur:%12s\:" % _("Current") + " %3.2lf",
                        "GPRINT:temp_max:%12s\:" % _("Maximum") + " %3.2lf",
                        "GPRINT:temp_min:%12s\:" % _("Minimum") + " %3.2lf",
index 3c7e6c5..352b6a3 100644 (file)
@@ -23,6 +23,7 @@ import os
 
 from . import base
 
+from ..colours import *
 from ..i18n import _
 
 ENTROPY_FILE = "/proc/sys/kernel/random/entropy_avail"
@@ -35,7 +36,7 @@ class GraphTemplateEntropy(base.GraphTemplate):
                _ = self.locale.translate
 
                return [
-                       "LINE3:entropy#ff0000:%-15s" % _("Available entropy"),
+                       "LINE2:entropy%s:%-15s" % (PRIMARY, _("Available entropy")),
                        "GPRINT:entropy_max:%12s\:" % _("Maximum") + " %5.0lf",
                        "GPRINT:entropy_min:%12s\:" % _("Minimum") + " %5.0lf",
                        "GPRINT:entropy_avg:%12s\:" % _("Average") + " %5.0lf\\n",
index 8cdb221..7b45d09 100644 (file)
@@ -23,14 +23,10 @@ import os
 
 from . import base
 from .. import util
+from ..colours import *
 
 from ..i18n import _
 
-COLOUR_RX = "B22222"
-COLOUR_RX_AREA = "%sAA" % COLOUR_RX
-COLOUR_TX = "228B22"
-COLOUR_TX_AREA = "%sAA" % COLOUR_TX
-
 class GraphTemplateInterfaceBase(base.GraphTemplate):
        @property
        def interface(self):
@@ -54,26 +50,26 @@ class GraphTemplateInterfaceBits(GraphTemplateInterfaceBase):
                        "VDEF:bits_tx_95p=bits_tx,95,PERCENT",
 
                        # Draw the received area.
-                       "AREA:bits_rx#%s:%-15s" % (COLOUR_RX_AREA, _("Received")),
+                       "AREA:bits_rx%s:%-15s" % (util.lighten(COLOUR_RX, AREA_OPACITY), _("Received")),
                        "GPRINT:bits_rx_max:%12s\: " % _("Maximum") + _("%8.2lf %sbps"),
                        "GPRINT:bits_rx_min:%12s\: " % _("Minimum") + _("%8.2lf %sbps"),
                        "GPRINT:bits_rx_avg:%12s\: " % _("Average") + _("%8.2lf %sbps") + "\\n",
 
                        # Draw the transmitted area.
-                       "AREA:bits_tx#%s:%-15s" % (COLOUR_TX_AREA, _("Transmitted")),
+                       "AREA:bits_tx%s:%-15s" % (util.lighten(COLOUR_TX, AREA_OPACITY), _("Transmitted")),
                        "GPRINT:bits_tx_max:%12s\: " % _("Maximum") + _("%8.2lf %sbps"),
                        "GPRINT:bits_tx_min:%12s\: " % _("Minimum") + _("%8.2lf %sbps"),
                        "GPRINT:bits_tx_avg:%12s\: " % _("Average") + _("%8.2lf %sbps") + "\\n",
 
                        # Draw outlines.
-                       "LINE1:bits_rx#%s" % COLOUR_RX,
-                       "LINE1:bits_tx#%s" % COLOUR_TX,
+                       "LINE1:bits_rx%s" % COLOUR_RX,
+                       "LINE1:bits_tx%s" % COLOUR_TX,
 
                        # Draw the 95% lines.
                        "COMMENT:--- %s ---\\n" % _("95th percentile"),
-                       "LINE2:bits_rx_95p#%s:%-15s" % (COLOUR_RX, _("Received")),
+                       "LINE2:bits_rx_95p%s:%-15s" % (COLOUR_RX, _("Received")),
                        "GPRINT:bits_rx_95p:%s" % _("%8.2lf %sbps") + "\\n",
-                       "LINE2:bits_tx_95p#%s:%-15s" % (COLOUR_TX, _("Transmitted")),
+                       "LINE2:bits_tx_95p%s:%-15s" % (COLOUR_TX, _("Transmitted")),
                        "GPRINT:bits_tx_95p:%s" % _("%8.2lf %sbps") + "\\n",
                ]
 
@@ -97,20 +93,24 @@ class GraphTemplateInterfacePackets(GraphTemplateInterfaceBase):
 
                return [
                        # Draw the received area.
-                       "AREA:packets_rx#%s:%-15s" % (COLOUR_RX_AREA, _("Received")),
+                       "AREA:packets_rx%s:%-15s" % (
+                               util.lighten(COLOUR_RX, AREA_OPACITY), _("Received"),
+                       ),
                        "GPRINT:packets_rx_max:%12s\: " % _("Maximum") + _("%8.0lf %spps"),
                        "GPRINT:packets_rx_min:%12s\: " % _("Minimum") + _("%8.0lf %spps"),
                        "GPRINT:packets_rx_avg:%12s\: " % _("Average") + _("%8.2lf %spps") + "\\n",
 
                        # Draw the transmitted area.
-                       "AREA:packets_tx#%s:%-15s" % (COLOUR_TX_AREA, _("Transmitted")),
+                       "AREA:packets_tx%s:%-15s" % (
+                               util.lighten(COLOUR_TX, AREA_OPACITY), _("Transmitted"),
+                       ),
                        "GPRINT:packets_tx_max:%12s\: " % _("Maximum") + _("%8.0lf %spps"),
                        "GPRINT:packets_tx_min:%12s\: " % _("Minimum") + _("%8.0lf %spps"),
                        "GPRINT:packets_tx_avg:%12s\: " % _("Average") + _("%8.2lf %spps") + "\\n",
 
                        # Draw outlines of the areas on top.
-                       "LINE1:packets_rx#%s" % COLOUR_RX,
-                       "LINE1:packets_tx#%s" % COLOUR_TX,
+                       "LINE1:packets_rx%s" % COLOUR_RX,
+                       "LINE1:packets_tx%s" % COLOUR_TX,
                ]
 
        @property
@@ -137,35 +137,43 @@ class GraphTemplateInterfaceErrors(GraphTemplateInterfaceBase):
                        "CDEF:dropped_tx_inv=dropped_tx,-1,*",
 
                        # Draw the receive errors.
-                       "AREA:errors_rx#228B2277:%-15s" % _("Receive errors"),
+                       "AREA:errors_rx%s:%-15s" % (
+                               util.lighten(COLOUR_RX, AREA_OPACITY), _("Receive errors"),
+                       ),
                        "GPRINT:errors_rx_max:%12s\: " % _("Maximum") + _("%8.0lf %spps"),
                        "GPRINT:errors_rx_min:%12s\: " % _("Minimum") + _("%8.0lf %spps"),
                        "GPRINT:errors_rx_avg:%12s\: " % _("Average") + _("%8.2lf %spps") + "\\n",
-                       "LINE1:errors_rx#228B22",
+                       "LINE1:errors_rx%s" % COLOUR_RX,
 
                        # Draw the transmit errors.
-                       "AREA:errors_tx_inv#B2222277:%-15s" % _("Transmit errors"),
+                       "AREA:errors_tx_inv%s:%-15s" % (
+                               util.lighten(COLOUR_TX, AREA_OPACITY), _("Transmit errors"),
+                       ),
                        "GPRINT:errors_tx_max:%12s\: " % _("Maximum") + _("%8.0lf %spps"),
                        "GPRINT:errors_tx_min:%12s\: " % _("Minimum") + _("%8.0lf %spps"),
                        "GPRINT:errors_tx_avg:%12s\: " % _("Average") + _("%8.2lf %spps") + "\\n",
-                       "LINE1:errors_tx_inv#B22222",
+                       "LINE1:errors_tx_inv%s" % COLOUR_TX,
 
                        # Draw the receive drops.
-                       "LINE2:dropped_rx#228B22:%-15s" % _("Receive drops"),
+                       "LINE2:dropped_rx%s:%-15s" % (
+                               util.lighten(AMBER, AREA_OPACITY), _("Receive drops"),
+                       ),
                        "GPRINT:dropped_rx_max:%12s\: " % _("Maximum") + _("%8.0lf %spps"),
                        "GPRINT:dropped_rx_min:%12s\: " % _("Minimum") + _("%8.0lf %spps"),
                        "GPRINT:dropped_rx_avg:%12s\: " % _("Average") + _("%8.2lf %spps") + "\\n",
                        "LINE1:dropped_rx#228B22",
 
                        # Draw the transmit drops.
-                       "LINE2:dropped_tx#B22222:%-15s" % _("Transmit drops"),
+                       "LINE2:dropped_tx%s:%-15s" % (
+                               util.lighten(TEAL, AREA_OPACITY), _("Transmit drops"),
+                       ),
                        "GPRINT:dropped_tx_max:%12s\: " % _("Maximum") + _("%8.0lf %spps"),
                        "GPRINT:dropped_tx_min:%12s\: " % _("Minimum") + _("%8.0lf %spps"),
                        "GPRINT:dropped_tx_avg:%12s\: " % _("Average") + _("%8.2lf %spps") + "\\n",
-                       "LINE1:dropped_tx#B22222",
+                       "LINE1:dropped_tx%s" % TEAL,
 
                        # Draw the collisions as a line.
-                       "LINE3:collisions#8B0000:%-15s" % _("Collisions") + "\\n",
+                       "LINE2:collisions%s:%-15s\l" % (COLOUR_CRITICAL, _("Collisions")),
                ]
 
        @property
index c43a9bc..e17d576 100644 (file)
@@ -23,6 +23,7 @@ import re
 
 from . import base
 
+from ..colours import *
 from ..i18n import _
 
 class GraphTemplateSystemInterrupts(base.GraphTemplate):
@@ -33,10 +34,13 @@ class GraphTemplateSystemInterrupts(base.GraphTemplate):
                _ = self.locale.translate
 
                return [
-                       "AREA:intr#90EE90:%-15s" % _("System Interrupts"),
+                       "AREA:intr%s:%-15s" % (
+                               util.lighten(PRIMARY, AREA_OPACITY), _("System Interrupts"),
+                       ),
                        "GPRINT:intr_max:%12s\:" % _("Maximum") + " %6.2lf" ,
                        "GPRINT:intr_min:%12s\:" % _("Minimum") + " %6.2lf" ,
                        "GPRINT:intr_avg:%12s\:" % _("Average") + " %6.2lf\\n",
+                       "LINE1:intr%s" % PRIMARY,
                ]
 
        lower_limit = 0
index 23c2ef8..941ca52 100644 (file)
@@ -24,6 +24,7 @@ import os
 from .. import util
 from . import base
 
+from ..colours  import *
 from ..constants import *
 from ..i18n import _
 
index c7ffc9c..a3d9110 100644 (file)
@@ -24,6 +24,8 @@ import socket
 import collecty._collecty
 from . import base
 
+from .. import util
+from ..colours import *
 from ..i18n import _
 
 PING_HOSTS = [
@@ -39,6 +41,7 @@ class GraphTemplateLatency(base.GraphTemplate):
        def rrd_graph(self):
                _ = self.locale.translate
 
+               colour_bg = AMBER
                return [
                        # Compute the biggest loss and convert into percentage
                        "CDEF:ploss=loss6,loss4,MAX,100,*",
@@ -55,28 +58,42 @@ class GraphTemplateLatency(base.GraphTemplate):
                        "CDEF:l050=ploss,25,50,LIMIT,UN,UNKN,INF,IF",
                        "CDEF:l099=ploss,50,99,LIMIT,UN,UNKN,INF,IF",
 
-                       "LINE1:latency6_avg#00ff0066:%s" % _("Average latency (IPv6)"),
-                       "LINE1:latency4_avg#ff000066:%s\\r" % _("Average latency (IPv4)"),
+                       "LINE2:latency6_avg%s:%s" % (
+                               util.transparency(COLOUR_IPV6, .5),
+                               _("Average latency (IPv6)"),
+                       ),
+                       "LINE2:latency4_avg%s:%s\\r" % (
+                               util.transparency(COLOUR_IPV4, .5),
+                               _("Average latency (IPv4)"),
+                       ),
 
                        "COMMENT:%s" % _("Packet Loss"),
-                       "AREA:l005#ffffff:%s" % _("0-5%%"),
-                       "AREA:l010#cccccc:%s" % _("5-10%%"),
-                       "AREA:l025#999999:%s" % _("10-25%%"),
-                       "AREA:l050#666666:%s" % _("25-50%%"),
-                       "AREA:l099#333333:%s" % _("50-99%%") + "\\r",
+                       "AREA:l005%s:%s" % (
+                               util.transparency(colour_bg, .2), _("0-5%"),
+                       ),
+                       "AREA:l010%s:%s" % (
+                               util.transparency(colour_bg, .4), _("5-10%"),
+                       ),
+                       "AREA:l025%s:%s" % (
+                               util.transparency(colour_bg, .6), _("10-25%"),
+                       ),
+                       "AREA:l050%s:%s" % (
+                               util.transparency(colour_bg, .8), _("25-50%"),
+                       ),
+                       "AREA:l099%s:%s\\r" % (colour_bg, _("50-99%")),
 
                        "COMMENT: \\n", # empty line
 
                        "AREA:spacer4",
-                       "AREA:stddevarea4#ff000033:STACK",
-                       "LINE2:latency4#ff0000:%s" % _("Latency (IPv4)"),
+                       "AREA:stddevarea4%s:STACK" % util.lighten(COLOUR_IPV4, STDDEV_OPACITY),
+                       "LINE2:latency4%s:%s" % (COLOUR_IPV4, _("Latency (IPv4)")),
                        "GPRINT:latency4_max:%12s\:" % _("Maximum") + " %6.2lf",
                        "GPRINT:latency4_min:%12s\:" % _("Minimum") + " %6.2lf",
                        "GPRINT:latency4_avg:%12s\:" % _("Average") + " %6.2lf\\n",
 
                        "AREA:spacer6",
-                       "AREA:stddevarea6#00ff0033:STACK",
-                       "LINE2:latency6#00ff00:%s" % _("Latency (IPv6)"),
+                       "AREA:stddevarea6%s:STACK" % util.lighten(COLOUR_IPV6, STDDEV_OPACITY),
+                       "LINE2:latency6%s:%s" % (COLOUR_IPV6, _("Latency (IPv6)")),
                        "GPRINT:latency6_max:%12s\:" % _("Maximum") + " %6.2lf",
                        "GPRINT:latency6_min:%12s\:" % _("Minimum") + " %6.2lf",
                        "GPRINT:latency6_avg:%12s\:" % _("Average") + " %6.2lf\\n",
index 8ac398a..f3e249a 100644 (file)
@@ -23,6 +23,7 @@ import os
 
 from . import base
 
+from ..colours import *
 from ..i18n import _
 
 class GraphTemplateLoadAvg(base.GraphTemplate):
@@ -32,38 +33,37 @@ class GraphTemplateLoadAvg(base.GraphTemplate):
        def rrd_graph(self):
                _ = self.locale.translate
 
-               return [
-                       "AREA:load1#ff0000:%s" % _("Load average  1m"),
-                       "GPRINT:load1_max:%12s\:" % _("Maximum") + " %6.2lf",
-                       "GPRINT:load1_min:%12s\:" % _("Minimum") + " %6.2lf",
-                       "GPRINT:load1_avg:%12s\:" % _("Average") + " %6.2lf\\n",
-
-                       "AREA:load5#ff9900:%s" % _("Load average  5m"),
-                       "GPRINT:load5_max:%12s\:" % _("Maximum") + " %6.2lf",
-                       "GPRINT:load5_min:%12s\:" % _("Minimum") + " %6.2lf",
-                       "GPRINT:load5_avg:%12s\:" % _("Average") + " %6.2lf\\n",
-
-                       "AREA:load15#ffff00:%s" % _("Load average 15m"),
-                       "GPRINT:load15_max:%12s\:" % _("Maximum") + " %6.2lf",
-                       "GPRINT:load15_min:%12s\:" % _("Minimum") + " %6.2lf",
-                       "GPRINT:load15_avg:%12s\:" % _("Average") + " %6.2lf\\n",
-
-                       "LINE:load5#dd8800",
-                       "LINE:load1#dd0000",
-               ]
+               rrd_graph = []
+
+               for id, colour, when in zip(self.object.rrd_schema_names,
+                               LOAD_AVG_COLOURS, ("1m", "5m", "15m")):
+                       rrd_graph = [
+                               "LINE2:%s%s:%s" % (id, colour, _("Load Average %s") % when),
+                               "GPRINT:%s_max:%12s\: %%6.2lf" % (id, _("Maximum")),
+                               "GPRINT:%s_min:%12s\: %%6.2lf" % (id, _("Minimum")),
+                               "GPRINT:%s_avg:%12s\: %%6.2lf\l" % (id, _("Average")),
+                       ] + rrd_graph
+
+               return rrd_graph
 
        lower_limit = 0
 
        @property
        def graph_title(self):
                _ = self.locale.translate
-               return _("Load average")
+               return _("Load Average")
 
        @property
        def graph_vertical_label(self):
                _ = self.locale.translate
                return _("Load")
 
+       @property
+       def rrd_graph_args(self):
+               return [
+                       "--legend-direction=bottomup",
+               ]
+
 
 class LoadAvgObject(base.Object):
        rrd_schema = [
index 6569a80..bc04918 100644 (file)
@@ -22,6 +22,8 @@
 from . import base
 
 from ..i18n import _
+from .. import util
+from ..colours import *
 
 class GraphTemplateMemory(base.GraphTemplate):
        name = "memory"
@@ -34,17 +36,17 @@ class GraphTemplateMemory(base.GraphTemplate):
                _ = self.locale.translate
 
                return [
-                       "AREA:used#90EE90:%-15s" % _("Used memory"),
+                       "AREA:used%s:%-15s" % (util.lighten(MEMORY_USED, AREA_OPACITY), _("Used memory")),
                        "GPRINT:used_max:%12s\:" % _("Maximum") + " %6.2lf" ,
                        "GPRINT:used_min:%12s\:" % _("Minimum") + " %6.2lf",
                        "GPRINT:used_avg:%12s\:" % _("Average") + " %6.2lf\\n",
 
-                       "STACK:buffered#4169E1:%-15s" % _("Buffered data"),
+                       "STACK:buffered%s:%-15s" % (util.lighten(MEMORY_BUFFERED, AREA_OPACITY), _("Buffered data")),
                        "GPRINT:buffered_max:%12s\:" % _("Maximum") + " %6.2lf" ,
                        "GPRINT:buffered_min:%12s\:" % _("Minimum") + " %6.2lf",
                        "GPRINT:buffered_avg:%12s\:" % _("Average") + " %6.2lf\\n",
 
-                       "STACK:cached#FFD700:%-15s" % _("Cached data"),
+                       "STACK:cached%s:%-15s" % (util.lighten(MEMORY_CACHED, AREA_OPACITY), _("Cached data")),
                        "GPRINT:cached_max:%12s\:" % _("Maximum") + " %6.2lf" ,
                        "GPRINT:cached_min:%12s\:" % _("Minimum") + " %6.2lf",
                        "GPRINT:cached_avg:%12s\:" % _("Average") + " %6.2lf\\n",
@@ -54,10 +56,15 @@ class GraphTemplateMemory(base.GraphTemplate):
 #                      "GPRINT:free_min:%12s\:" % _("Minimum") + " %6.2lf",
 #                      "GPRINT:free_avg:%12s\:" % _("Average") + " %6.2lf\\n",
 
-                       "LINE3:swap#ff0000:%-15s" % _("Used Swap space"),
+                       "LINE3:swap%s:%-15s" % (MEMORY_SWAP, _("Used Swap space")),
                        "GPRINT:swap_max:%12s\:" % _("Maximum") + " %6.2lf" ,
                        "GPRINT:swap_min:%12s\:" % _("Minimum") + " %6.2lf",
                        "GPRINT:swap_avg:%12s\:" % _("Average") + " %6.2lf\\n",
+
+                       # Draw the outlines of the areas
+                       "LINE1:used%s" % MEMORY_USED,
+                       "LINE1:buffered%s::STACK" % MEMORY_BUFFERED,
+                       "LINE1:cached%s::STACK" % MEMORY_CACHED,
                ]
 
        @property
index 8768df2..cd722b1 100644 (file)
 #                                                                             #
 ###############################################################################
 
-
-
 from . import base
 
+from ..colours import *
 from ..i18n import _
 
 class GraphTemplateProcessor(base.GraphTemplate):
@@ -33,37 +32,37 @@ class GraphTemplateProcessor(base.GraphTemplate):
                _ = self.locale.translate
 
                return [
-                       "AREA:user#90EE90:%-15s" % _("User"),
+                       "AREA:user%s:%-15s" % (CPU_USER, _("User")),
                        "GPRINT:user_max:%12s\:" % _("Maximum") + " %6.2lf" ,
                        "GPRINT:user_min:%12s\:" % _("Minimum") + " %6.2lf",
                        "GPRINT:user_avg:%12s\:" % _("Average") + " %6.2lf\\n",
 
-                       "STACK:nice#4169E1:%-15s" % _("Nice"),
+                       "STACK:nice%s:%-15s" % (CPU_NICE, _("Nice")),
                        "GPRINT:nice_max:%12s\:" % _("Maximum") + " %6.2lf" ,
                        "GPRINT:nice_min:%12s\:" % _("Minimum") + " %6.2lf",
                        "GPRINT:nice_avg:%12s\:" % _("Average") + " %6.2lf\\n",
 
-                       "STACK:sys#DC143C:%-15s" % _("System"),
+                       "STACK:sys%s:%-15s" % (CPU_SYS, _("System")),
                        "GPRINT:sys_max:%12s\:" % _("Maximum") + " %6.2lf" ,
                        "GPRINT:sys_min:%12s\:" % _("Minimum") + " %6.2lf",
                        "GPRINT:sys_avg:%12s\:" % _("Average") + " %6.2lf\\n",
 
-                       "STACK:wait#483D8B:%-15s" % _("Wait"),
+                       "STACK:wait%s:%-15s" % (CPU_WAIT, _("Wait")),
                        "GPRINT:wait_max:%12s\:" % _("Maximum") + " %6.2lf" ,
                        "GPRINT:wait_min:%12s\:" % _("Minimum") + " %6.2lf",
                        "GPRINT:wait_avg:%12s\:" % _("Average") + " %6.2lf\\n",
 
-                       "STACK:irq#DAA520:%-15s" % _("Interrupt"),
+                       "STACK:irq%s:%-15s" % (CPU_IRQ, _("Interrupt")),
                        "GPRINT:irq_max:%12s\:" % _("Maximum") + " %6.2lf" ,
                        "GPRINT:irq_min:%12s\:" % _("Minimum") + " %6.2lf",
                        "GPRINT:irq_avg:%12s\:" % _("Average") + " %6.2lf\\n",
 
-                       "STACK:sirq#FFD700:%-15s" % _("Soft interrupt"),
+                       "STACK:sirq%s:%-15s" % (CPU_SIRQ, _("Soft Interrupt")),
                        "GPRINT:sirq_max:%12s\:" % _("Maximum") + " %6.2lf" ,
                        "GPRINT:sirq_min:%12s\:" % _("Minimum") + " %6.2lf",
                        "GPRINT:sirq_avg:%12s\:" % _("Average") + " %6.2lf\\n",
 
-                       "STACK:idle#EFEFEF:%-15s" % _("Idle"),
+                       "STACK:idle%s:%-15s" % (CPU_IDLE, _("Idle")),
                        "GPRINT:idle_max:%12s\:" % _("Maximum") + " %6.2lf" ,
                        "GPRINT:idle_min:%12s\:" % _("Minimum") + " %6.2lf",
                        "GPRINT:idle_avg:%12s\:" % _("Average") + " %6.2lf\\n",
index 72fc0c1..2cba52b 100644 (file)
@@ -57,6 +57,12 @@ def darken(colour, scale=0.1):
        """
        return __add_colour(colour, 0xff * -scale)
 
+def transparency(colour, scale=0.1):
+       """
+               Adds transparency to the given colour code
+       """
+       return "%s%02X" % (colour, 0xff * scale)
+
 def get_network_interfaces():
        """
                Returns all real network interfaces