Commit 9cb9540d009e06f79bade372b80656df520214f2

Authored by John Snowdon
1 parent 28e8c0f145
Exists in master

added some sample settings files, added a bash start script which kills and rest…

…arts the process if the LCD panel is unplugged, added a init file which resets the LCD on insertion.
README.md
... ... @@ -51,6 +51,8 @@ bash run.sh 2>&1 | tee /var/log/lcd.log
51 51  
52 52 `ERR_` Messages - Preset error text that is shown when a service or health check is failed. Customise as required. Takes: string
53 53  
  54 +`CPU_PEAK` - Controls the colour of the LCD screen when the CPU is considered to be at the highest level of load.
  55 +
54 56 `CPU_HIGH` - Controls the colour of the LCD screen when CPU use rises above a set value classed as `high`. Takes: Python dictionary with the keys 'level' - CPU use level, above which activates this colour scheme, 'r' - Red LED intensity, 'g' - Green LED intensity, 'b' - Blue LED intensity.
55 57  
56 58 `CPU_MED` - Controls the colour of the LCD screen when CPU use rises above a set value classed as `medium`. Takes: Python dictionary with the keys 'level' - CPU use level, above which activates this colour scheme, 'r' - Red LED intensity, 'g' - Green LED intensity, 'b' - Blue LED intensity.
... ... @@ -63,3 +65,4 @@ bash run.sh 2>&1 | tee /var/log/lcd.log
63 65  
64 66 John Snowdon (john.snowdon@newcastle.ac.uk)
65 67 December 2015, updated October 2016.
  68 +
... ...
data.py
... ... @@ -80,7 +80,7 @@ class data():
80 80  
81 81 if services:
82 82 self.services()
83   -
  83 +
84 84 def bandwidth(self):
85 85 """ Calculate bandwidth use """
86 86  
... ... @@ -311,7 +311,7 @@ class data():
311 311 # Check cinder
312 312 t = os.system("systemctl status openstack-cinder-api")
313 313 if t != 0:
314   - if settings.ERR_SERVICE_CINDER in self.errors:
  314 + if settings.ERR_SERVICE_CINDERa in self.errors:
315 315 pass
316 316 else:
317 317 self.errors.append(settings.ERR_SERVICE_CINDERa)
... ... @@ -322,7 +322,7 @@ class data():
322 322 # Check cinder volume
323 323 t = os.system("systemctl status openstack-cinder-volume")
324 324 if t != 0:
325   - if settings.ERR_SERVICE_CINDER in self.errors:
  325 + if settings.ERR_SERVICE_CINDERb in self.errors:
326 326 pass
327 327 else:
328 328 self.errors.append(settings.ERR_SERVICE_CINDERb)
... ...
matrix.py
... ... @@ -36,6 +36,9 @@ class Matrix():
36 36 self.scroll = False
37 37 self.cols = COLS
38 38 self.rows = ROWS
  39 + self.r = 0
  40 + self.g = 0
  41 + self.b = 0
39 42  
40 43 def matrixwritecommand(self, commandlist):
41 44 # write a command to the lcd
... ... @@ -87,7 +90,17 @@ class Matrix():
87 90 # clear screen
88 91 self.matrixwritecommand([0x58])
89 92  
  93 + def matrixPulse(self, r = 0x0, g = 0x0, b = 0x0):
  94 + # Pulse to the set RGB values, from the
  95 + # current values stored in self.r/g/b and back again
  96 +
  97 + self.matrixwritecommand([0xD0, r, g, b])
  98 + time.sleep(0.1)
  99 +
90 100 def matrixRGB(self, r = 0x200, g = 0x0, b = 0x0):
  101 + self.r = r
  102 + self.g = g
  103 + self.b = b
91 104 self.matrixwritecommand([0xD0, r, g, b])
92 105  
93 106 def matrixScrollOn(self):
... ...
matrix_factory_init.py
... ... @@ -0,0 +1,340 @@
  1 +'''
  2 +Test python sketch for Adafruit USB+Serial LCD backpack
  3 +---> http://www.adafruit.com/category/63_96
  4 +
  5 +Adafruit invests time and resources providing this open source code,
  6 +please support Adafruit and open-source hardware by purchasing
  7 +products from Adafruit!
  8 +
  9 +Written by Limor Fried/Ladyada for Adafruit Industries.
  10 +BSD license, check license.txt for more information
  11 +All text above must be included in any redistribution
  12 +'''
  13 +
  14 +
  15 +import serial
  16 +import sys
  17 +import time
  18 +
  19 +# 20x4 LCD
  20 +#ROWS = 4
  21 +#COLS = 20
  22 +
  23 +# 16x2 LCD:
  24 +ROWS = 2
  25 +COLS = 16
  26 +
  27 +def matrixwritecommand(commandlist):
  28 + commandlist.insert(0, 0xFE)
  29 + #ser.write(bytearray([0xFE]))
  30 + #time.sleep(0.1);
  31 + for i in range(0, len(commandlist)):
  32 + #print chr(commandlist[i]),
  33 + ser.write(chr(commandlist[i]))
  34 + #ser.write(bytearray(commandlist))
  35 +
  36 +# 1. get serial port
  37 +if len(sys.argv) != 2:
  38 + print "Usage: python test.py <serialport>"
  39 + exit(0)
  40 +
  41 +'''
  42 +# baudrate fix
  43 +ser = serial.Serial(sys.argv[1], 2400, timeout=1)
  44 +matrixwritecommand([0x39, 0x67])
  45 +time.sleep(2);
  46 +ser = serial.Serial(sys.argv[1], 4800, timeout=1)
  47 +matrixwritecommand([0x39, 0x67])
  48 +time.sleep(2);
  49 +ser = serial.Serial(sys.argv[1], 19200, timeout=1)
  50 +matrixwritecommand([0x39, 0x67])
  51 +time.sleep(2);
  52 +ser = serial.Serial(sys.argv[1], 28800, timeout=1)
  53 +matrixwritecommand([0x39, 0x67])
  54 +time.sleep(2);
  55 +ser = serial.Serial(sys.argv[1], 38400, timeout=1)
  56 +matrixwritecommand([0x39, 0x67])
  57 +time.sleep(2);
  58 +ser = serial.Serial(sys.argv[1], 57600, timeout=1)
  59 +matrixwritecommand([0x39, 0x67])
  60 +time.sleep(2);
  61 +'''
  62 +
  63 +ser = serial.Serial(sys.argv[1], 9600, timeout=1)
  64 +matrixwritecommand([0x58])
  65 +
  66 +# set size
  67 +matrixwritecommand([0xD1, COLS, ROWS]);
  68 +matrixwritecommand([0x58])
  69 +
  70 +# turn on display
  71 +ser.write("Display on");
  72 +matrixwritecommand([0x42, 0])
  73 +time.sleep(0.3);
  74 +
  75 +# contrast loop
  76 +#for i in range(0, 256):
  77 +# matrixwritecommand([0x50, i])
  78 +#time.sleep(0.1);
  79 +
  80 +matrixwritecommand([0x50, 220])
  81 +
  82 +
  83 +# turn GPIO's on
  84 +matrixwritecommand([0x57, 1])
  85 +time.sleep(0.1)
  86 +matrixwritecommand([0x57, 2])
  87 +time.sleep(0.1)
  88 +matrixwritecommand([0x57, 3])
  89 +time.sleep(0.1)
  90 +matrixwritecommand([0x57, 4])
  91 +time.sleep(0.1)
  92 +# turn GPIO's off
  93 +matrixwritecommand([0x56, 1])
  94 +time.sleep(0.1)
  95 +matrixwritecommand([0x56, 2])
  96 +time.sleep(0.1)
  97 +matrixwritecommand([0x56, 3])
  98 +time.sleep(0.1)
  99 +matrixwritecommand([0x56, 4])
  100 +time.sleep(0.1)
  101 +
  102 +# turn off display
  103 +ser.write("off");
  104 +matrixwritecommand([0x46])
  105 +time.sleep(0.3);
  106 +
  107 +# turn on display
  108 +ser.write("on");
  109 +matrixwritecommand([0x42, 0])
  110 +time.sleep(0.3);
  111 +
  112 +# create custom char
  113 +matrixwritecommand([0x4E, 0, 0, 0xA, 0x15, 0x11, 0x11, 0xA, 0x4, 0])
  114 +ser.write(chr(0))
  115 +time.sleep(0.5)
  116 +
  117 +# color loop
  118 +#matrixwritecommand([0x99, 255])
  119 +#for r in range(0, 256):
  120 +# matrixwritecommand([0xD0, r, 0, 0])
  121 +# time.sleep(0.005);
  122 +#for g in range(0, 256):
  123 +# matrixwritecommand([0xD0, 255-g, g, 0])
  124 +# time.sleep(0.005);
  125 +#for b in range(0, 256):
  126 +# matrixwritecommand([0xD0, 0, 255-b, b])
  127 +# time.sleep(0.005);
  128 +#for r in range(0, 256):
  129 +# matrixwritecommand([0xD0, r, 0, 255-r])
  130 +# time.sleep(0.005);
  131 +#for r in range(255, 0):
  132 +# matrixwritecommand([0xD0, r, 0, 0])
  133 +# time.sleep(0.005);
  134 +
  135 +#matrixwritecommand([0x99, 0])
  136 +#matrixwritecommand([0xD0, 255, 255, 255])
  137 +# brightness loop
  138 +#for i in range(0, 256):
  139 +# matrixwritecommand([0x99, i])
  140 +# time.sleep(0.01);
  141 +
  142 +# home
  143 +#matrixwritecommand([0x48])
  144 +#ser.write("home");
  145 +#time.sleep(0.5);
  146 +
  147 +#clear
  148 +#matrixwritecommand([0x58])
  149 +#ser.write("clear");
  150 +#time.sleep(0.5);
  151 +
  152 +#matrixwritecommand([0x58])
  153 +# create horizontal bars in custom chars bank #1
  154 +#matrixwritecommand([0xC1, 1, 0, 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10])
  155 +#matrixwritecommand([0xC1, 1, 1, 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18])
  156 +#matrixwritecommand([0xC1, 1, 2, 0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C])
  157 +#matrixwritecommand([0xC1, 1, 3, 0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E])
  158 +#matrixwritecommand([0xC1, 1, 4, 0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF])
  159 +#matrixwritecommand([0xC1, 1, 5, 0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x7])
  160 +#matrixwritecommand([0xC1, 1, 6, 0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3])
  161 +#matrixwritecommand([0xC1, 1, 7, 0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1])
  162 +#matrixwritecommand([0xC0, 1]) # load bank 1
  163 +#ser.write(chr(0))
  164 +#ser.write(chr(1))
  165 +#ser.write(chr(2))
  166 +#ser.write(chr(3))
  167 +#ser.write(chr(4))
  168 +#ser.write(chr(5))
  169 +#ser.write(chr(6))
  170 +#ser.write(chr(7))
  171 +#time.sleep(1)
  172 +
  173 +#matrixwritecommand([0x58])
  174 +# create vertical bars in custom chars bank #2
  175 +#matrixwritecommand([0xC1, 2, 0, 0,0,0,0,0,0,0,0x1F])
  176 +#matrixwritecommand([0xC1, 2, 1, 0,0,0,0,0,0,0x1F,0x1F])
  177 +#matrixwritecommand([0xC1, 2, 2, 0,0,0,0,0,0x1F,0x1F,0x1F])
  178 +#matrixwritecommand([0xC1, 2, 3, 0,0,0,0,0x1F,0x1F,0x1F,0x1F])
  179 +#matrixwritecommand([0xC1, 2, 4, 0,0,0,0x1F,0x1F,0x1F,0x1F,0x1F])
  180 +#matrixwritecommand([0xC1, 2, 5, 0,0,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F])
  181 +#matrixwritecommand([0xC1, 2, 6, 0,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F])
  182 +#matrixwritecommand([0xC1, 2, 7, 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F])
  183 +#matrixwritecommand([0xC0, 2])
  184 +#ser.write(chr(0))
  185 +#ser.write(chr(1))
  186 +#ser.write(chr(2))
  187 +#ser.write(chr(3))
  188 +#ser.write(chr(4))
  189 +#ser.write(chr(5))
  190 +#ser.write(chr(6))
  191 +#ser.write(chr(7))
  192 +#time.sleep(1)
  193 +
  194 +
  195 +#matrixwritecommand([0x58])
  196 +# create medium numbers in bank #3
  197 +#matrixwritecommand([0xC1, 3, 0, 0x1f,0x1f,0x03,0x03,0x03,0x03,0x03,0x03])
  198 +#matrixwritecommand([0xC1, 3, 1, 0x1f,0x1f,0x18,0x18,0x18,0x18,0x18,0x18])
  199 +#matrixwritecommand([0xC1, 3, 2, 0x03,0x03,0x03,0x03,0x03,0x03,0x1F,0x1F])
  200 +#matrixwritecommand([0xC1, 3, 3, 0x18,0x18,0x18,0x18,0x18,0x18,0x1F,0x1F])
  201 +#matrixwritecommand([0xC1, 3, 4, 0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x1F])
  202 +#matrixwritecommand([0xC1, 3, 5, 0x1F,0x1F,0x00,0x00,0x00,0x00,0x00,0x00])
  203 +#matrixwritecommand([0xC1, 3, 6, 0x1F,0x1F,0x03,0x03,0x03,0x03,0x1F,0x1F])
  204 +
  205 +#matrixwritecommand([0xC1, 3, 7, 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F])
  206 +#matrixwritecommand([0xC0, 3])
  207 +#ser.write(chr(0))
  208 +#ser.write(chr(1))
  209 +#ser.write(chr(2))
  210 +#ser.write(chr(3))
  211 +#ser.write(chr(4))
  212 +#ser.write(chr(5))
  213 +#ser.write(chr(6))
  214 +#ser.write(chr(7))
  215 +#time.sleep(1)
  216 +
  217 +#matrixwritecommand([0x58])
  218 +## write medium num #0
  219 +#matrixwritecommand([0x6F, 0, 0, 0])
  220 +#matrixwritecommand([0x6F, 2, 0, 1])
  221 +#matrixwritecommand([0x6F, 4, 0, 2])
  222 +#matrixwritecommand([0x6F, 6, 0, 3])
  223 +#time.sleep(1)
  224 +
  225 +# autoscroll on
  226 +matrixwritecommand([0x58])
  227 +matrixwritecommand([0x51])
  228 +#if (ROWS == 4):
  229 +# ser.write("Here is a long long long line of text ");
  230 +# time.sleep(1)
  231 +# ser.write("Adding more text... ");
  232 +# time.sleep(1)
  233 +# ser.write("even more text now!");
  234 +# time.sleep(1)
  235 +# ser.write(" which will scroll");
  236 +#if (ROWS == 2):
  237 +# ser.write("Here's some text");
  238 +# time.sleep(1)
  239 +# ser.write("Add some more..");
  240 +# time.sleep(1)
  241 +# ser.write(" which'll scroll");
  242 +#time.sleep(1)
  243 +
  244 +# autoscroll off
  245 +matrixwritecommand([0x58])
  246 +matrixwritecommand([0x52])
  247 +#ser.write("long long long text that ends @ top left ");
  248 +#time.sleep(1);
  249 +
  250 +# cursor test
  251 +#matrixwritecommand([0x58])
  252 +#matrixwritecommand([0x47,1,1])
  253 +#ser.write('1');
  254 +#matrixwritecommand([0x47,COLS,1])
  255 +#ser.write('2');
  256 +#matrixwritecommand([0x47,1,ROWS])
  257 +#ser.write('3');
  258 +#matrixwritecommand([0x47,COLS,ROWS])
  259 +#ser.write('4');
  260 +
  261 +#underline cursor on
  262 +#matrixwritecommand([0x4A])
  263 +# move cursor left
  264 +#matrixwritecommand([0x4C])
  265 +#time.sleep(2);
  266 +# cursor off
  267 +#matrixwritecommand([0x4B])
  268 +#time.sleep(0.5);
  269 +
  270 +# block cursor
  271 +#matrixwritecommand([0x53])
  272 +# move cursor right
  273 +#matrixwritecommand([0x4D])
  274 +#time.sleep(2);
  275 +#matrixwritecommand([0x54])
  276 +#time.sleep(0.5);
  277 +
  278 +# baudrate change
  279 +matrixwritecommand([0x39, 0x29])
  280 +time.sleep(1);
  281 +ser.close();
  282 +ser = serial.Serial(sys.argv[1], 2400, timeout=1)
  283 +matrixwritecommand([0x58])
  284 +ser.write("2400")
  285 +
  286 +matrixwritecommand([0x39, 0xCF])
  287 +time.sleep(1);
  288 +ser.close();
  289 +ser = serial.Serial(sys.argv[1], 4800, timeout=1)
  290 +matrixwritecommand([0x58])
  291 +ser.write("4800")
  292 +
  293 +matrixwritecommand([0x39, 0x67])
  294 +time.sleep(1);
  295 +ser.close();
  296 +ser.close();
  297 +ser = serial.Serial(sys.argv[1], 9600, timeout=1)
  298 +matrixwritecommand([0x58])
  299 +ser.write("9600")
  300 +
  301 +matrixwritecommand([0x39, 0x33])
  302 +time.sleep(1);
  303 +ser.close();
  304 +ser = serial.Serial(sys.argv[1], 19200, timeout=1)
  305 +matrixwritecommand([0x58])
  306 +ser.write("19200")
  307 +
  308 +matrixwritecommand([0x39, 0x22])
  309 +time.sleep(1);
  310 +ser.close();
  311 +ser = serial.Serial(sys.argv[1], 28800, timeout=1)
  312 +matrixwritecommand([0x58])
  313 +ser.write("28800")
  314 +
  315 +matrixwritecommand([0x39, 0x19])
  316 +time.sleep(1);
  317 +ser.close();
  318 +ser = serial.Serial(sys.argv[1], 38400, timeout=1)
  319 +matrixwritecommand([0x58])
  320 +ser.write("38400")
  321 +
  322 +matrixwritecommand([0x39, 0x10])
  323 +time.sleep(1);
  324 +ser.close();
  325 +ser = serial.Serial(sys.argv[1], 57600, timeout=1)
  326 +matrixwritecommand([0x58])
  327 +ser.write("57600")
  328 +
  329 +# Revert back to 9600 baud
  330 +matrixwritecommand([0x39, 0x67])
  331 +time.sleep(1);
  332 +ser.close();
  333 +ser = serial.Serial(sys.argv[1], 9600, timeout=1)
  334 +
  335 +# Splashscreen change
  336 +matrixwritecommand([0x40, ord('H'),ord('e'),ord('l'),ord('l'),ord('o'),ord(' '),ord('W'),ord('o'),ord('r'),ord('l'),ord('d'),ord('!'),ord(' '),ord(' '),ord(' '),ord(' '),ord('T'),ord('e'),ord('s'),ord('t'),ord('i'),ord('n'),ord('g'),ord(' '),ord('1'),ord('6'),ord('x'),ord('2'),ord(' '),ord('L'),ord('C'),ord('D')])
  337 +
  338 +#matrixwritecommand([0x40, ord(' '),ord(' '),ord('A'),ord('d'),ord('a'),ord('f'),ord('r'),ord('u'),ord('i'),ord('t'),ord('.'),ord('c'),ord('o'),ord('m'),ord(' '),ord(' '),ord('1'),ord('6'),ord('x'),ord('2'),ord(' '),ord('U'),ord('S'),ord('B'),ord('+'),ord('S'),ord('e'),ord('r'),ord(' '),ord('L'),ord('C'),ord('D')])
  339 +exit()
  340 +
... ...
node.compute.settings.py
... ... @@ -0,0 +1,80 @@
  1 +######################################
  2 +#
  3 +# Settings for the lcd_panel data
  4 +# gathering script.
  5 +#
  6 +######################################
  7 +
  8 +# How long we pause between data gathering
  9 +INTERVAL = 1
  10 +
  11 +# How long between service check intervals
  12 +SERVICE_INTERVAL = 30
  13 +
  14 +# How many loops before counters are reset
  15 +ZAP_INTERVAL = 50
  16 +
  17 +# How many rotations until the extended info detail screens are shown
  18 +DETAIL_1_INTERVAL = 10
  19 +DETAIL_2_INTERVAL = 20
  20 +DETAIL_3_INTERVAL = 30
  21 +DETAIL_4_INTERVAL = 40
  22 +# How many rotations each detail screen is shown before cycling back to the main screen
  23 +DETAIL_DURATION = 3
  24 +
  25 +# Which filesystem path should we check
  26 +# the disk useage of
  27 +DISK_PATH = "/var"
  28 +
  29 +# An NFS mounted directory that we should check. Set to '/' to bypass NFS check.
  30 +NFS_PATH = "/data"
  31 +
  32 +# Name of the primary network adapter (to determine our IP address)
  33 +ETH_DEVICE = "enp2s0"
  34 +# List all of the network devices we should check are up and connected
  35 +ETH_DEVICES = ["enp2s0", "enp0s20u3c2"]
  36 +
  37 +# Serial display width - how many characters we can display before scrolling right to left
  38 +DISPLAY_WIDTH = 16
  39 +
  40 +# Time to pause between scroll updates
  41 +SCROLL_SPEED = 0.25
  42 +
  43 +# When running service checks, some are against a 'client' service, others are against a 'server' service. This
  44 +# tells the class which type of check to use. (an openstack node can only be a server or client, not both)
  45 +#SERVICE_CHECK_TYPE = "server"
  46 +SERVICE_CHECK_TYPE = "client"
  47 +
  48 +# List of enabled service checks
  49 +SERVICE_CHECKS = ["ssh", "nova", "neutron"]
  50 +#SERVICE_CHECKS = ["ssh", "mysql", "httpd", "keystone", "nova", "cinder", "cinder-volume", "glance", "neutron", "nfs"]
  51 +
  52 +# Error messages
  53 +ERR_NETWORK_STATUS = "Network error, ETH interface unconfigured."
  54 +ERR_NETWORK_MEDIA = "Network error, ETH cable disconnected."
  55 +ERR_DISK_STATUS = "Disk error, %s is not mounted." % DISK_PATH
  56 +ERR_NFS_STATUS = "NFS error, %s is not mounted or unavailable." % NFS_PATH
  57 +ERR_SERVICE_SSH = "OpenSSH error or service not running."
  58 +ERR_SERVICE_MYSQL = "MySQL error or service not running."
  59 +ERR_SERVICE_HTTPDa = "Apache httpd error, web page not available."
  60 +ERR_SERVICE_HTTPDb = "Apache httpd error, service not running."
  61 +ERR_SERVICE_KEYSTONEa = "Keystone error or service not running."
  62 +ERR_SERVICE_KEYSTONEb = "Keystone client error or unable to contact controller."
  63 +ERR_SERVICE_NOVAa = "Nova API error or service not running."
  64 +ERR_SERVICE_NOVAb = "Nova client error or unable to contact controller."
  65 +ERR_SERVICE_CINDERa = "Cinder API error or service not running."
  66 +ERR_SERVICE_CINDERb = "Cinder volume error or service not running."
  67 +ERR_SERVICE_GLANCE = "Glance API error or service not running."
  68 +ERR_SERVICE_NEUTRONa = "Neutron API error or service not running."
  69 +ERR_SERVICE_NEUTRONb = "Neutron client error or unable to contact controller."
  70 +ERR_SERVICE_NFS = "NFS Kernel server not running."
  71 +
  72 +# Trigger levels for various metrics
  73 +# and the colour to change the backlight of the lcd module
  74 +# when that mode is active
  75 +CPU_PEAK = { 'level' : 75, 'r': 255, 'g': 0, 'b': 0 }
  76 +CPU_HIGH = { 'level' : 50, 'r': 255, 'g': 102, 'b': 0 }
  77 +CPU_MED = { 'level' : 35, 'r': 204, 'g': 255, 'b': 51 }
  78 +CPU_LOW = { 'level' : 20, 'r': 0, 'g': 204, 'b': 153 }
  79 +CPU_IDLE = { 'level' : 10, 'r': 0, 'g': 100, 'b': 255 }
  80 +
... ...
node.management.settings.py
... ... @@ -0,0 +1,80 @@
  1 +######################################
  2 +#
  3 +# Settings for the lcd_panel data
  4 +# gathering script.
  5 +#
  6 +######################################
  7 +
  8 +# How long we pause between data gathering
  9 +INTERVAL = 1
  10 +
  11 +# How long between service check intervals
  12 +SERVICE_INTERVAL = 30
  13 +
  14 +# How many loops before counters are reset
  15 +ZAP_INTERVAL = 50
  16 +
  17 +# How many rotations until the extended info detail screens are shown
  18 +DETAIL_1_INTERVAL = 10
  19 +DETAIL_2_INTERVAL = 20
  20 +DETAIL_3_INTERVAL = 30
  21 +DETAIL_4_INTERVAL = 40
  22 +# How many rotations each detail screen is shown before cycling back to the main screen
  23 +DETAIL_DURATION = 3
  24 +
  25 +# Which filesystem path should we check
  26 +# the disk useage of
  27 +DISK_PATH = "/var"
  28 +
  29 +# An NFS mounted directory that we should check. Set to '/' to bypass NFS check.
  30 +NFS_PATH = "/data"
  31 +
  32 +# Name of the primary network adapter (to determine our IP address)
  33 +ETH_DEVICE = "enp0s20u4c2"
  34 +# List all of the network devices we should check are up and connected
  35 +ETH_DEVICES = ["enp0s20u4c2", "enp2s0", "enp0s20u3c2"]
  36 +
  37 +# Serial display width - how many characters we can display before scrolling right to left
  38 +DISPLAY_WIDTH = 16
  39 +
  40 +# Time to pause between scroll updates
  41 +SCROLL_SPEED = 0.25
  42 +
  43 +# When running service checks, some are against a 'client' service, others are against a 'server' service. This
  44 +# tells the class which type of check to use. (an openstack node can only be a server or client, not both)
  45 +SERVICE_CHECK_TYPE = "server"
  46 +#SERVICE_CHECK_TYPE = "client"
  47 +
  48 +# List of enabled service checks
  49 +SERVICE_CHECKS = ["ssh", "mysql", "http", "keystone", "nova", "cinder", "glance", "neutron"]
  50 +#SERVICE_CHECKS = ["ssh", "mysql", "httpd", "keystone", "nova", "cinder", "cinder-volume", "glance", "neutron", "nfs"]
  51 +
  52 +# Error messages
  53 +ERR_NETWORK_STATUS = "Network error, ETH interface unconfigured."
  54 +ERR_NETWORK_MEDIA = "Network error, ETH cable disconnected."
  55 +ERR_DISK_STATUS = "Disk error, %s is not mounted." % DISK_PATH
  56 +ERR_NFS_STATUS = "NFS error, %s is not mounted or unavailable." % NFS_PATH
  57 +ERR_SERVICE_SSH = "OpenSSH error or service not running."
  58 +ERR_SERVICE_MYSQL = "MySQL error or service not running."
  59 +ERR_SERVICE_HTTPDa = "Apache httpd error, web page not available."
  60 +ERR_SERVICE_HTTPDb = "Apache httpd error, service not running."
  61 +ERR_SERVICE_KEYSTONEa = "Keystone error or service not running."
  62 +ERR_SERVICE_KEYSTONEb = "Keystone client error or unable to contact controller."
  63 +ERR_SERVICE_NOVAa = "Nova API error or service not running."
  64 +ERR_SERVICE_NOVAb = "Nova client error or unable to contact controller."
  65 +ERR_SERVICE_CINDERa = "Cinder API error or service not running."
  66 +ERR_SERVICE_CINDERb = "Cinder volume error or service not running."
  67 +ERR_SERVICE_GLANCE = "Glance API error or service not running."
  68 +ERR_SERVICE_NEUTRONa = "Neutron API error or service not running."
  69 +ERR_SERVICE_NEUTRONb = "Neutron client error or unable to contact controller."
  70 +ERR_SERVICE_NFS = "NFS Kernel server not running."
  71 +
  72 +# Trigger levels for various metrics
  73 +# and the colour to change the backlight of the lcd module
  74 +# when that mode is active
  75 +CPU_PEAK = { 'level' : 75, 'r': 255, 'g': 0, 'b': 0 }
  76 +CPU_HIGH = { 'level' : 50, 'r': 255, 'g': 102, 'b': 0 }
  77 +CPU_MED = { 'level' : 35, 'r': 204, 'g': 255, 'b': 51 }
  78 +CPU_LOW = { 'level' : 20, 'r': 0, 'g': 204, 'b': 153 }
  79 +CPU_IDLE = { 'level' : 10, 'r': 0, 'g': 100, 'b': 255 }
  80 +
... ...
node.storage.settings.py
... ... @@ -0,0 +1,80 @@
  1 +######################################
  2 +#
  3 +# Settings for the lcd_panel data
  4 +# gathering script.
  5 +#
  6 +######################################
  7 +
  8 +# How long we pause between data gathering
  9 +INTERVAL = 1
  10 +
  11 +# How long between service check intervals
  12 +SERVICE_INTERVAL = 30
  13 +
  14 +# How many loops before counters are reset
  15 +ZAP_INTERVAL = 50
  16 +
  17 +# How many rotations until the extended info detail screens are shown
  18 +DETAIL_1_INTERVAL = 10
  19 +DETAIL_2_INTERVAL = 20
  20 +DETAIL_3_INTERVAL = 30
  21 +DETAIL_4_INTERVAL = 40
  22 +# How many rotations each detail screen is shown before cycling back to the main screen
  23 +DETAIL_DURATION = 3
  24 +
  25 +# Which filesystem path should we check
  26 +# the disk useage of
  27 +DISK_PATH = "/data"
  28 +
  29 +# An NFS mounted directory that we should check. Set to '/' to bypass NFS check.
  30 +NFS_PATH = "/data"
  31 +
  32 +# Name of the primary network adapter (to determine our IP address)
  33 +ETH_DEVICE = "enp2s0"
  34 +# List all of the network devices we should check are up and connected
  35 +ETH_DEVICES = ["enp2s0"]
  36 +
  37 +# Serial display width - how many characters we can display before scrolling right to left
  38 +DISPLAY_WIDTH = 16
  39 +
  40 +# Time to pause between scroll updates
  41 +SCROLL_SPEED = 0.25
  42 +
  43 +# When running service checks, some are against a 'client' service, others are against a 'server' service. This
  44 +# tells the class which type of check to use. (an openstack node can only be a server or client, not both)
  45 +SERVICE_CHECK_TYPE = "server"
  46 +#SERVICE_CHECK_TYPE = "client"
  47 +
  48 +# List of enabled service checks
  49 +SERVICE_CHECKS = ["ssh", "cinder-volume"]
  50 +#SERVICE_CHECKS = ["ssh", "mysql", "httpd", "keystone", "nova", "cinder", "cinder-volume", "glance", "neutron", "nfs"]
  51 +
  52 +# Error messages
  53 +ERR_NETWORK_STATUS = "Network error, ETH interface unconfigured."
  54 +ERR_NETWORK_MEDIA = "Network error, ETH cable disconnected."
  55 +ERR_DISK_STATUS = "Disk error, %s is not mounted." % DISK_PATH
  56 +ERR_NFS_STATUS = "NFS error, %s is not mounted or unavailable." % NFS_PATH
  57 +ERR_SERVICE_SSH = "OpenSSH error or service not running."
  58 +ERR_SERVICE_MYSQL = "MySQL error or service not running."
  59 +ERR_SERVICE_HTTPDa = "Apache httpd error, web page not available."
  60 +ERR_SERVICE_HTTPDb = "Apache httpd error, service not running."
  61 +ERR_SERVICE_KEYSTONEa = "Keystone error or service not running."
  62 +ERR_SERVICE_KEYSTONEb = "Keystone client error or unable to contact controller."
  63 +ERR_SERVICE_NOVAa = "Nova API error or service not running."
  64 +ERR_SERVICE_NOVAb = "Nova client error or unable to contact controller."
  65 +ERR_SERVICE_CINDERa = "Cinder API error or service not running."
  66 +ERR_SERVICE_CINDERb = "Cinder volume error or service not running."
  67 +ERR_SERVICE_GLANCE = "Glance API error or service not running."
  68 +ERR_SERVICE_NEUTRONa = "Neutron API error or service not running."
  69 +ERR_SERVICE_NEUTRONb = "Neutron client error or unable to contact controller."
  70 +ERR_SERVICE_NFS = "NFS Kernel server not running."
  71 +
  72 +# Trigger levels for various metrics
  73 +# and the colour to change the backlight of the lcd module
  74 +# when that mode is active
  75 +CPU_PEAK = { 'level' : 75, 'r': 255, 'g': 0, 'b': 0 }
  76 +CPU_HIGH = { 'level' : 50, 'r': 255, 'g': 102, 'b': 0 }
  77 +CPU_MED = { 'level' : 35, 'r': 204, 'g': 255, 'b': 51 }
  78 +CPU_LOW = { 'level' : 20, 'r': 0, 'g': 204, 'b': 153 }
  79 +CPU_IDLE = { 'level' : 10, 'r': 0, 'g': 100, 'b': 255 }
  80 +
... ...
node.test.settings.py
... ... @@ -0,0 +1,80 @@
  1 +######################################
  2 +#
  3 +# Settings for the lcd_panel data
  4 +# gathering script.
  5 +#
  6 +######################################
  7 +
  8 +# How long we pause between data gathering
  9 +INTERVAL = 1
  10 +
  11 +# How long between service check intervals
  12 +SERVICE_INTERVAL = 30
  13 +
  14 +# How many loops before counters are reset
  15 +ZAP_INTERVAL = 50
  16 +
  17 +# How many rotations until the extended info detail screens are shown
  18 +DETAIL_1_INTERVAL = 10
  19 +DETAIL_2_INTERVAL = 20
  20 +DETAIL_3_INTERVAL = 30
  21 +DETAIL_4_INTERVAL = 40
  22 +# How many rotations each detail screen is shown before cycling back to the main screen
  23 +DETAIL_DURATION = 3
  24 +
  25 +# Which filesystem path should we check
  26 +# the disk useage of
  27 +DISK_PATH = "/var"
  28 +
  29 +# An NFS mounted directory that we should check. Set to '/' to bypass NFS check.
  30 +NFS_PATH = "/"
  31 +
  32 +# Name of the primary network adapter (to determine our IP address)
  33 +ETH_DEVICE = "eno1"
  34 +# List all of the network devices we should check are up and connected
  35 +ETH_DEVICES = ["eno1"]
  36 +
  37 +# Serial display width - how many characters we can display before scrolling right to left
  38 +DISPLAY_WIDTH = 16
  39 +
  40 +# Time to pause between scroll updates
  41 +SCROLL_SPEED = 0.25
  42 +
  43 +# When running service checks, some are against a 'client' service, others are against a 'server' service. This
  44 +# tells the class which type of check to use. (an openstack node can only be a server or client, not both)
  45 +#SERVICE_CHECK_TYPE = "server"
  46 +SERVICE_CHECK_TYPE = "client"
  47 +
  48 +# List of enabled service checks
  49 +SERVICE_CHECKS = ["ssh"]
  50 +#SERVICE_CHECKS = ["ssh", "mysql", "httpd", "keystone", "nova", "cinder", "cinder-volume", "glance", "neutron", "nfs"]
  51 +
  52 +# Error messages
  53 +ERR_NETWORK_STATUS = "Network error, ETH interface unconfigured."
  54 +ERR_NETWORK_MEDIA = "Network error, ETH cable disconnected."
  55 +ERR_DISK_STATUS = "Disk error, %s is not mounted." % DISK_PATH
  56 +ERR_NFS_STATUS = "NFS error, %s is not mounted or unavailable." % NFS_PATH
  57 +ERR_SERVICE_SSH = "OpenSSH error or service not running."
  58 +ERR_SERVICE_MYSQL = "MySQL error or service not running."
  59 +ERR_SERVICE_HTTPDa = "Apache httpd error, web page not available."
  60 +ERR_SERVICE_HTTPDb = "Apache httpd error, service not running."
  61 +ERR_SERVICE_KEYSTONEa = "Keystone error or service not running."
  62 +ERR_SERVICE_KEYSTONEb = "Keystone client error or unable to contact controller."
  63 +ERR_SERVICE_NOVAa = "Nova API error or service not running."
  64 +ERR_SERVICE_NOVAb = "Nova client error or unable to contact controller."
  65 +ERR_SERVICE_CINDERa = "Cinder API error or service not running."
  66 +ERR_SERVICE_CINDERb = "Cinder volume error or service not running."
  67 +ERR_SERVICE_GLANCE = "Glance API error or service not running."
  68 +ERR_SERVICE_NEUTRONa = "Neutron API error or service not running."
  69 +ERR_SERVICE_NEUTRONb = "Neutron client error or unable to contact controller."
  70 +ERR_SERVICE_NFS = "NFS Kernel server not running."
  71 +
  72 +# Trigger levels for various metrics
  73 +# and the colour to change the backlight of the lcd module
  74 +# when that mode is active
  75 +CPU_PEAK = { 'level' : 75, 'r': 255, 'g': 0, 'b': 0 }
  76 +CPU_HIGH = { 'level' : 50, 'r': 255, 'g': 102, 'b': 0 }
  77 +CPU_MED = { 'level' : 35, 'r': 204, 'g': 255, 'b': 51 }
  78 +CPU_LOW = { 'level' : 20, 'r': 0, 'g': 204, 'b': 153 }
  79 +CPU_IDLE = { 'level' : 10, 'r': 0, 'g': 100, 'b': 255 }
  80 +
... ...
output.py
... ... @@ -10,6 +10,7 @@ class Output():
10 10 def __init__(self, mode = "terminal"):
11 11 self.mode = mode
12 12 self.errors = False
  13 + self.disk_show = True
13 14 if mode == "lcd":
14 15 self.matrix = Matrix(device="/dev/ttyACM0")
15 16 self.matrix.matrixOn()
... ... @@ -36,7 +37,7 @@ class Output():
36 37 error = False
37 38 if len(data.errors) > 0:
38 39 # On detection of errors, screen goes red
39   - self.matrix.matrixRGB(255,0,0)
  40 + self.matrix.matrixRGB(settings.CPU_PEAK['r'],settings.CPU_PEAK['g'],settings.CPU_PEAK['b'])
40 41 # Loop over and scroll each error - ignore the normal cycle process in the outer call
41 42 e_num = 1
42 43 for e in data.errors:
... ... @@ -81,11 +82,13 @@ class Output():
81 82  
82 83 # If CPU load is above a trigger level,
83 84 # If no errors, screen defaults back to green
84   - if data.cpu_percent_avg >= settings.CPU_HIGH['level']:
  85 + if data.cpu_percent_avg >= settings.CPU_PEAK['level']:
  86 + self.matrix.matrixRGB(settings.CPU_PEAK['r'],settings.CPU_PEAK['g'],settings.CPU_PEAK['b'])
  87 + elif data.cpu_percent_avg >= settings.CPU_HIGH['level']:
85 88 self.matrix.matrixRGB(settings.CPU_HIGH['r'],settings.CPU_HIGH['g'],settings.CPU_HIGH['b'])
86 89 elif data.cpu_percent_avg >= settings.CPU_MED['level']:
87 90 self.matrix.matrixRGB(settings.CPU_MED['r'],settings.CPU_MED['g'],settings.CPU_MED['b'])
88   - elif data.cpu_percent_avg >= settings.CPU_LOW['level']:
  91 + elif (data.cpu_percent_avg >= settings.CPU_LOW['level']) or (data.cpu_percent_avg > settings.CPU_IDLE['level']):
89 92 self.matrix.matrixRGB(settings.CPU_LOW['r'],settings.CPU_LOW['g'],settings.CPU_LOW['b'])
90 93 else:
91 94 self.matrix.matrixRGB(settings.CPU_IDLE['r'],settings.CPU_IDLE['g'],settings.CPU_IDLE['b'])
... ... @@ -111,29 +114,20 @@ class Output():
111 114 # Show Disk space
112 115 if (interval >= settings.DETAIL_3_INTERVAL) and (interval <= (settings.DETAIL_3_INTERVAL + settings.DETAIL_DURATION)):
113 116 self.matrix.matrixWrite("CPU %2d%% %sMHz" % (data.cpu_percent_avg, data.cpu_mhz))
114   - self.matrix.matrixWrite("DSK %s/%s" % (self.sizeof_fmt(num = data.disk_space), self.sizeof_fmt(num = data.disk_size)))
  117 + if self.disk_show:
  118 + self.matrix.matrixWrite("DSK %s/%s" % (self.sizeof_fmt(num = data.disk_space), self.sizeof_fmt(num = data.disk_size)))
  119 + self.disk_show = False
  120 + else:
  121 + self.matrix.matrixWrite("NFS %s/%s" % (self.sizeof_fmt(num = data.nfs_space), self.sizeof_fmt(num = data.nfs_size)))
  122 + self.disk_show = True
115 123 return
116 124  
117 125 # Are we showing alternate screen 4?
118 126 # Show CPU
119 127 # Show RAM use
120   - if (interval == settings.DETAIL_4_INTERVAL):
  128 + if (interval >= settings.DETAIL_4_INTERVAL) and (interval <= (settings.DETAIL_4_INTERVAL + settings.DETAIL_DURATION)):
121 129 self.matrix.matrixWrite("CPU %2d%% %sMHz" % (data.cpu_percent_avg, data.cpu_mhz))
122   - display_text = ""
123   - t = "RAM %s of %s used, %s buffers." % (self.sizeof_fmt(num = data.ram_avail), self.sizeof_fmt(num = data.ram_total), (self.sizeof_fmt(num = data.ram_buffer)))
124   - t = ' '.join(t.split())
125   - for i in range (0, len(t)):
126   - data.update()
127   - self.matrix.matrixClear()
128   - self.matrix.matrixWrite("CPU %2d%% %sMHz" % (data.cpu_percent_avg, data.cpu_mhz))
129   - display_text = t[i:(i+settings.DISPLAY_WIDTH)]
130   - self.matrix.matrixWrite(display_text)
131   - if i == 0:
132   - # Pause the first time we show the beginning of the error.
133   - time.sleep(1)
134   - else:
135   - # Slight gap between each character scrolling by.
136   - time.sleep(settings.SCROLL_SPEED)
  130 + self.matrix.matrixWrite("RAM %s/%s" % (self.sizeof_fmt(num = data.ram_avail), self.sizeof_fmt(num = data.ram_total)))
137 131 return
138 132  
139 133 # Show the normal screen
... ...
run.sh
... ... @@ -5,9 +5,11 @@ while true
5 5 do
6 6 echo "[`date`] - First attempt to kill any existing LCD console process"
7 7 su root -c "pkill run.py"
  8 + su root -c "python matrix_factory_init.py /dev/ttyACM0"
8 9 sleep 5
9 10 echo "[`date`] - Running new LCD console process"
10 11 su root -c "cd ~ncsteam/lcd ; python run.py"
11 12 echo "[`date`] - Terminated, clean up old LCD console process"
12 13 su root -c "pkill run.py"
  14 + sleep 30
13 15 done
... ...
settings.py
... ... @@ -1,79 +0,0 @@
1   -######################################
2   -#
3   -# Settings for the lcd_panel data
4   -# gathering script.
5   -#
6   -######################################
7   -
8   -# How long we pause between data gathering
9   -INTERVAL = 1
10   -
11   -# How long between service check intervals
12   -SERVICE_INTERVAL = 30
13   -
14   -# How many loops before counters are reset
15   -ZAP_INTERVAL = 50
16   -
17   -# How many rotations until the extended info detail screens are shown
18   -DETAIL_1_INTERVAL = 10
19   -DETAIL_2_INTERVAL = 20
20   -DETAIL_3_INTERVAL = 30
21   -DETAIL_4_INTERVAL = 40
22   -# How many rotations each detail screen is shown before cycling back to the main screen
23   -DETAIL_DURATION = 3
24   -
25   -# Which filesystem path should we check
26   -# the disk useage of
27   -DISK_PATH = "/var"
28   -
29   -# An NFS mounted directory that we should check. Set to '/' to bypass NFS check.
30   -NFS_PATH = "/"
31   -
32   -# Name of the primary network adapter (to determine our IP address)
33   -ETH_DEVICE = "enp0s20u4c2"
34   -# List all of the network devices we should check are up and connected
35   -ETH_DEVICES = ["enp0s20u4c2", "enp2s0", "enp0s20u3c2"]
36   -
37   -# Serial display width - how many characters we can display before scrolling right to left
38   -DISPLAY_WIDTH = 16
39   -
40   -# Time to pause between scroll updates
41   -SCROLL_SPEED = 0.25
42   -
43   -# When running service checks, some are against a 'client' service, others are against a 'server' service. This
44   -# tells the class which type of check to use. (an openstack node can only be a server or client, not both)
45   -SERVICE_CHECK_TYPE = "server"
46   -#SERVICE_CHECK_TYPE = "client"
47   -
48   -# List of enabled service checks
49   -SERVICE_CHECKS = ["ssh", "mysql", "http", "keystone", "nova", "cinder", "glance", "neutron"]
50   -#SERVICE_CHECKS = ["ssh", "mysql", "httpd", "keystone", "nova", "cinder", "cinder-volume", "glance", "neutron", "nfs"]
51   -
52   -# Error messages
53   -ERR_NETWORK_STATUS = "Network error, ETH interface unconfigured."
54   -ERR_NETWORK_MEDIA = "Network error, ETH cable disconnected."
55   -ERR_DISK_STATUS = "Disk error, %s is not mounted." % DISK_PATH
56   -ERR_NFS_STATUS = "NFS error, %s is not mounted or unavailable." % NFS_PATH
57   -ERR_SERVICE_SSH = "OpenSSH error or service not running."
58   -ERR_SERVICE_MYSQL = "MySQL error or service not running."
59   -ERR_SERVICE_HTTPDa = "Apache httpd error, web page not available."
60   -ERR_SERVICE_HTTPDb = "Apache httpd error, service not running."
61   -ERR_SERVICE_KEYSTONEa = "Keystone error or service not running."
62   -ERR_SERVICE_KEYSTONEb = "Keystone client error or unable to contact controller."
63   -ERR_SERVICE_NOVAa = "Nova API error or service not running."
64   -ERR_SERVICE_NOVAb = "Nova client error or unable to contact controller."
65   -ERR_SERVICE_CINDERa = "Cinder API error or service not running."
66   -ERR_SERVICE_CINDERb = "Cinder volume error or service not running."
67   -ERR_SERVICE_GLANCE = "Glance API error or service not running."
68   -ERR_SERVICE_NEUTRONa = "Neutron API error or service not running."
69   -ERR_SERVICE_NEUTRONb = "Neutron client error or unable to contact controller."
70   -ERR_SERVICE_NFS = "NFS Kernel server not running."
71   -
72   -# Trigger levels for various metrics
73   -# and the colour to change the backlight of the lcd module
74   -# when that mode is active
75   -CPU_HIGH = { 'level' : 65, 'r': 255, 'g': 0, 'b': 0 }
76   -CPU_MED = { 'level' : 40, 'r': 165, 'g': 255, 'b': 0 }
77   -CPU_LOW = { 'level' : 20, 'r': 165, 'g': 165, 'b': 0 }
78   -CPU_IDLE = { 'level' : 10, 'r': 0, 'g': 255, 'b': 0 }
79   -
settings.py
... ... @@ -0,0 +1 @@
  1 +node.test.settings.py
0 2 \ No newline at end of file
... ...