...
 
Commits (2)
## DisplayNode Scripts and Magic
Place the WorkerNode.py scripts in pi's home directory.
ALL SCRIPTS USING THE NEOPIXEL LIBRARY NEED ROOT PERMISSIONS TO RUN
WorkerNode.py args - > [startNode, endNode, numberOfIterations]
......
## Head Node Specific Items
In order to provide a pretty user interface for the project, `Web` has the scripts for controlling and submitting items to the workers. It is used in conjunction with scripts in the Workers folder.
\ No newline at end of file
In order to provide a pretty user interface for the project, `Web` has the scripts for controlling and submitting items to the workers. It is used in conjunction with scripts in the Scripts folder.
In `Scripts` there are two primary files.
`cluster.py` is the primary library for interacting with the cluster simulations. Jobs can be added by adding a key pair to the jobs dictionary. The key is used as a CLI arguement and the value is the name of the script file to control the cluster.
`LightControl.py` handles the general control of the lights as a library.
The `Web` folder goes into the root of a webserver such as Apache2 or nginx. The folders `control` and `scripts` need to be created in the web root. The contents of the `Scripts` folder goes into `scripts`.
import time
from random import randint,choice
import socket
import subprocess
import sys
from LightControl import *
def slaveNodeOn(worker):
sendNetwork("worker1",worker,2)
changeLoadState(worker,1)
def slaveNodeOff(worker):
sendNetwork(worker,"worker1",2)
changeLoadState(worker,0)
availableWorkers = []
for host in sys.argv[1].split(","):
if "worker" in host:
availableWorkers.append(host)
turnAllNodesOff()
start = time.time()
print("Starting")
sendNetwork("LegionHead","worker1",1) ### Send job data and files to the master node and turn master node lights on
sendNetwork("LegionFile","worker1",4)
changeLoadState("worker1",1)
time.sleep(2)
for i in range(0,2): ### Run two sets of mini jobs
### Turn on all of the slave worker nodes and turn off master processing node
for worker in availableWorkers: ### Send master to slave data
slaveNodeOn(worker)
changeLoadState("worker1",0)
time.sleep(1)
#for i in range(1,10): ### Random Internode chatter while they do work
# worker1 = "worker"+str(randint(2,8))
# worker2 = "worker"+str(randint(2,8))
# sendNetwork(worker1,worker2,1)
# sendNetwork(worker2,worker1,1)
for worker in availableWorkers: ### Send slave to master
slaveNodeOff(worker)
changeLoadState("worker1",1) ### Work is finished and the master distributes another load of mini jobs
### Master procerssing node finished after the mini job sets and then sends results back.
sendNetwork("worker1","LegionFile",7)
sendNetwork("worker1","LegionFile",1)
turnAllNodesOff()
import time
import socket
from random import randint,choice
import sys
from LightControl import *
turnAllNodesOff()
activeWorkers = []
deadWorkers = []
start = time.time()
### Get a list of all working workers
for host in sys.argv[1].split(","):
if "worker" in host:
deadWorkers.append(host)
while (time.time() - start) < 40: # How long to run the simulation for
if randint(0,1) == 1 and len(deadWorkers) > 0: # Add randomness and see if there are dead workers
currentWorker = choice(deadWorkers) # Choose a random worker, then send networking to it and turn it on,
sendNetwork("LegionHead", currentWorker,1)
sendNetwork("LegionFile", currentWorker,1)
time.sleep(0.05)
changeLoadState(currentWorker,1)
deadWorkers.remove(currentWorker) # Remove from the list of dead workers and add to active list
activeWorkers.append(currentWorker)
if randint(0,1) == 1 and len(activeWorkers) > 0:# Add randomness and see if there are active workers
currentWorker = choice(activeWorkers) # Choose a random worker,
if (time.time() - nodes[currentWorker]["time"]) > 5: # if its been alive for atleast 5 seconds
sendNetwork(currentWorker,"LegionFile",1) # send networking to it and turn it on,
sendNetwork(currentWorker,"LegionHead",1)
changeLoadState(currentWorker,0)
activeWorkers.remove(currentWorker) # Remove from the list of active workers and add to dead list
deadWorkers.append(currentWorker)
for worker in activeWorkers:
sendNetwork(currentWorker,"LegionFile",1) # send networking to it and turn it on,
sendNetwork(currentWorker,"LegionHead",1)
changeLoadState(currentWorker,0)
turnAllNodesOff()
### Library for interacting with the lights in the cluster.
import os
import time
###### Code for the networking LEDS
### Send commands to the Networking LEDS:
def sendNetwork(source, destination, numberOfTimes):
os.system('ssh -i ~pi/LegionKey pi@192.168.1.6 "sudo python ~pi/WorkerNetwork.py %s %s %d"' % (source, destination, numberOfTimes))
#time.sleep(0.5)
###### Code for the LED Hats on the workers
### Dictionary of nodes for use with the HATs.
nodes = {
"worker1": {"status":0,"time":0},
"worker2": {"status":0,"time":0},
"worker3": {"status":0,"time":0},
"worker4": {"status":0,"time":0},
"worker5": {"status":0,"time":0},
"worker6": {"status":0,"time":0},
"worker7": {"status":0,"time":0},
"worker8": {"status":0,"time":0},
"LegionHead":{"status":0,"time":0},
"LegionFile":{"status":0,"time":0}
}
### Change the state of a LED HAT on a node
def changeLoadState(node, state):
nodes[node]["status"] = state
nodes[node]["time"] = time.time()
writeLoadDataToWeb(nodes)
### Write the nodes dictionary to a json file hosts on the head node.
def writeLoadDataToWeb(nodes):
payload = "{"
for node in nodes.keys():
if list(nodes.keys()).index(node) < len(nodes.keys())-1: # If its not the last node in the dictionary, then have a have at the end
payload += ("\"%s\":%d," % (node,nodes[node]["status"]))
else: # If it is the last one, use a } rather than a comma to close off the
payload += ("\"%s\":%d}" % (node,nodes[node]["status"]))
with open("/var/www/html/control/index.html",'w') as f:
f.write(payload)
def turnAllNodesOff():
for node in nodes.keys():
changeLoadState(node,0)
def turnAllNodesOn():
for node in nodes.keys():
changeLoadState(node,1)
from status import *
import sys
import os
### Check that the web server is running
if not checkWeb():
exit()
### Check to see if all hosts are up
## Repeats as a double checks
hosts = checkHosts()
if 0 in hosts.values():
hosts = checkHosts()
### Check to see if lights are running
hosts = checkLights(hosts)
### Now that all alive hosts are known, we can safely start running scripts
hostArg = []
for host in hosts.keys():
if hosts[host] == 1:
hostArg.append(host)
hostString = ",".join(hostArg)
print(hostString)
####
##### Still need a way to prevent rechecks each time
####
### Dictionary of all jobs
jobs = {
"htc":"HTC.py",
"hpc":"HPC.py"
}
if sys.argv[1].lower() in jobs.keys():
os.system("python %s %s" %(jobs[sys.argv[1]], hostString))
else:
print("Invalid Job Name")
......@@ -5,34 +5,20 @@
//echo exec('whoami');
$job_name = "job";
$lights_name = "lights";
$filename = "/work/LED.txt";
exec("rm /work/LED.txt");
$file = fopen($filename, "a");
fwrite($file, $_COOKIE[$cookie_name]);
fclose($file);
if ($_COOKIE[$job_name] == "start"){
for ($x=1; $x<=8;$x++){
exec("sudo -H -u pi bash -c \"ssh -i ~pi/LegionKey worker".(string)$x." 'screen -md python /work/LightPi.py'\"");}
exec("sudo -H -u pi bash -c \"ssh -i ~pi/LegionKey 192.168.1.1 'screen -md python /work/idleControl.py'\"");
exec("sudo -H -u pi bash -c \"ssh -i ~pi/LegionKey 192.168.1.5 'screen -md python /work/idleControl.py'\"");
exec("sudo -H -u pi bash -c \"ssh -i ~pi/LegionKey 192.168.1.6 'screen -md python /work/idleNet.py'\"");
}
if ($_COOKIE[$job_name] == "HPC"){
$random = (string)rand(5,30);
exec("cd /work/; sudo -H -u pi bash -c \"python /work/HPCWeb.py\"");
exec("cd /var/www/html/scripts; sudo -H -u pi bash -c \"python cluster.py hpc\"");
}
if ($_COOKIE[$job_name] == "HTC"){
exec("cd /work/; sudo -H -u pi bash -c \"python /work/HTCWeb.py\"" );
exec("cd /var/www/html/scripts; sudo -H -u pi bash -c \"python cluster.py htc\"" );
}
if ($_COOKIE[$job_name] == "ION"){
exec("sudo -H -u pi bash -c \"bash /work/idleOn.sh\"");
exec("sudo -H -u pi bash -c \"bash ~pi/idleOn.sh\"");
}
if ($_COOKIE[$job_name] == "IOFF"){
exec("sudo -H -u pi bash -c \"bash /work/idleOff.sh\"");
exec("sudo -H -u pi bash -c \"bash ~pi/idleOff.sh\"");
}
......
## Worker Specific Items
workDir contains items to be stored in /work
\ No newline at end of file
LightPi.py is a service script that listens to the headnode for what to do. This script goes to the pi home directory on all visible nodes.
IdleNet.py is used to create an idle network state. - This still needs to be adapted to the new format of the cluster's code.
\ No newline at end of file
import time
import sys
from neopixel import *
import argparse
from random import randint,choice
import socket
import urllib2, json
# LED strip configuration:
LED_COUNT = 100 # Number of LED pixels.
LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!).
#LED_PIN = 10 # GPIO pin connected to the pixels (10 uses SPI /dev/spidev0.0).
LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz)
LED_DMA = 10 # DMA channel to use for generating signal (try 10)
LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest
LED_INVERT = False # True to invert the signal (when using NPN transistor level shift)
LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
strip.begin()
def getControlData():
rawData = urllib2.urlopen("http://192.168.1.1/network").read()
print(rawData)
controls = json.loads(rawData)
print(controls)
host = socket.gethostname()
print(controls[host])
return controls[host]
while True:
if getControlData():
r,g,b = randint(0,255),randint(0,255),randint(0,255)
strip.setPixelColor(randint(0,65),Color(r,g,b))
strip.show()
import time
import sys
from neopixel import *
import argparse
from random import randint,choice
import socket
import urllib2, json
# LED strip configuration:
LED_COUNT = 100 # Number of LED pixels.
LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!).
#LED_PIN = 10 # GPIO pin connected to the pixels (10 uses SPI /dev/spidev0.0).
LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz)
LED_DMA = 10 # DMA channel to use for generating signal (try 10)
LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest
LED_INVERT = False # True to invert the signal (when using NPN transistor level shift)
LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
strip.begin()
def getControlData():
rawData = urllib2.urlopen("http://192.168.1.1/network").read()
print(rawData)
controls = json.loads(rawData)
print(controls)
host = socket.gethostname()
print(controls[host])
return controls[host]
while True:
if getControlData():
r,g,b = randint(0,255),randint(0,255),randint(0,255)
strip.setPixelColor(randint(0,65),Color(r,g,b))
strip.show()
echo \{\"worker1\":0,\"worker2\":0,\"worker3\":0,\"worker4\":0,\"worker5\":0,\"worker6\":0,\"worker7\":0,\"worker8\":0\,\"LegionDisplay\":0,\"LegionHead\":0,\"LegionFile\":0\} > /var/www/html/control/index.html
echo \{\"worker1\":1,\"worker2\":1,\"worker3\":1,\"worker4\":1,\"worker5\":1,\"worker6\":1,\"worker7\":1,\"worker8\":1\,\"LegionDisplay\":1,\"LegionHead\":1,\"LegionFile\":1\} > /var/www/html/control/index.html
import time
import subprocess
from random import randint
import socket
def sendCommand(command):
p = subprocess.Popen(command.split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate()
def sendFile(host,command):
f = open("/work/netLogs/host%s%d" % (host,int(time.time())),'w')
f.write(command)
f.close()
###Get Master Number
host = socket.gethostname()[-1:]
workers = ["1","2","3","4","5","6","7","8"]
###Send job from head to master, M - > F - > M
sendFile(host,"head,worker"+host+",5")
sendFile(host,"worker"+host+",file,5")
sendFile(host,"file,worker"+host+",5")
for i in workers:
if i != host:
#sendCommand("bash net.sh worker"+host+" worker"+i+" 1")
time.sleep(0.25)
sendCommand("sbatch slave"+i+".sh")
sendFile(host,"worker"+host+",worker"+i+",1")
#sendCommand("ssh -i /work/LegionKey pi@192.168.1.1"+i+" \"screen -md python /work/usage.py\"")
print("ssh -i /work/LegionKey pi@192.168.1.1"+i+" \"screen -md python /work/usage.py\"")
#sendCommand("bash slaveSubmit.sh")
end = time.time() + 40
while time.time() < end:
sendFile(host,"worker"+str(randint(1,8))+",worker"+str(randint(1,8))+",1")
x = 0
sendFile(host,"worker"+host+",file,5")
sendFile(host,"worker"+host+",head,5")
import time
from random import randint
import socket
import subprocess
workers = {
"worker1": {"status":0,"time":0},
"worker2": {"status":0,"time":0},
"worker3": {"status":0,"time":0},
"worker4": {"status":0,"time":0},
"worker5": {"status":0,"time":0},
"worker6": {"status":0,"time":0},
"worker7": {"status":0,"time":0},
"worker8": {"status":0,"time":0}
}
### Format = from,To,Amount
def sendCommand(command):
p = subprocess.Popen(command.split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate()
### Format = from,To,Amount
def sendLights(command):
sendCommand("bash /work/net.sh %s" % command)
def writeWeb(data):
payload = "{\"worker1\":%s,\"worker2\":%s,\"worker3\":%s,\"worker4\":%s,\"worker5\":%s,\"worker6\":%s,\"worker7\":%s,\"worker8\":%s}" % (data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7])
f =open("/var/www/html/control/index.html",'w')
f.write(payload)
f.close()
def workersToData(workers):
data = []
for i in range(1,9):
data.append(workers["worker%d" % i]["status"])
writeWeb(data)
start = time.time()
print("Starting")
sendLights("head worker1 1") ### Send data to master
sendLights("file worker1 4")
workers["worker1"]["status"] = 1 ### Turn on master
workersToData(workers)
time.sleep(2)
time.sleep(1)
print("Master On")
for i in range(2,9): ### Send master to slave data
currentWorker = "worker"+str(i)
print(currentWorker)
sendLights("worker1 %s 2" % currentWorker)
workers[currentWorker]["status"] = 1
workersToData(workers)
workers["worker1"]["status"] = 0
workersToData(workers)
time.sleep(1)
print("Slaves on and working")
for i in range(1,10):
currentWorker = "worker"+str(randint(1,8))
w1 = "worker"+str(randint(2,8))
w2 = "worker"+str(randint(2,8))
sendLights("%s %s 1" % (w1,w2))
sendLights("%s %s 1" % (w2,w1))
workers["worker1"]["status"] = 1
workersToData(workers)
for i in range(2,9): ### Send data back
currentWorker = "worker"+str(i)
print(currentWorker)
sendLights("%s worker1 2" % currentWorker)
workers[currentWorker]["status"] = 0
workersToData(workers)
for i in range(2,9): ### Send master to slave data
currentWorker = "worker"+str(i)
print(currentWorker)
sendLights("worker1 %s 2" % currentWorker)
workers[currentWorker]["status"] = 1
workersToData(workers)
workers["worker1"]["status"] = 0
workersToData(workers)
time.sleep(1)
print("Slaves on and working")
for i in range(1,10):
currentWorker = "worker"+str(randint(1,8))
w1 = "worker"+str(randint(2,8))
w2 = "worker"+str(randint(2,8))
sendLights("%s %s 1" % (w1,w2))
sendLights("%s %s 1" % (w2,w1))
workers["worker1"]["status"] = 1
workersToData(workers)
for i in range(2,9): ### Send data back
currentWorker = "worker"+str(i)
print(currentWorker)
sendLights("%s worker1 2" % currentWorker)
workers[currentWorker]["status"] = 0
workersToData(workers)
print("Doning")
time.sleep(6)
sendLights("worker1 file 7")
sendLights("worker1 head 1") ### Send data to head
workers["worker1"]["status"] = 0 ### Turn off master
workersToData(workers)
workers = {
"worker1": {"status":0,"time":0},
"worker2": {"status":0,"time":0},
"worker3": {"status":0,"time":0},
"worker4": {"status":0,"time":0},
"worker5": {"status":0,"time":0},
"worker6": {"status":0,"time":0},
"worker7": {"status":0,"time":0},
"worker8": {"status":0,"time":0}
}
workersToData(workers)
from piglow import PiGlow
import time
import socket
import subprocess
import psutil
from random import randint
p = PiGlow()
val = 100
colour = 1
def sendCommand(command):
p = subprocess.Popen(command.split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate()
x = 0
start = time.time()
host = socket.gethostname()[-1:]
time.sleep(randint(1,3))
#sendCommand("bash /work/net.sh head worker"+host+" 3")
f = open("/work/netLogs/host%s%d" % (host,int(time.time())),'w')
#with open("/work/netlogs/host%s%d" % (host,int(time.time())),'w') as f:
f.write("head,worker"+host+",3")
f.close()
time.sleep(0.5)
while True and (time.time() - start) < randint(5,20):
print("in")
p.white(10)
time.sleep(0.1)
p.blue(20)
time.sleep(0.1)
p.green(30)
time.sleep(0.1)
p.yellow(40)
time.sleep(0.1)
p.orange(50)
time.sleep(0.1)
p.red(60)
time.sleep(0.1)
p.white(255)
time.sleep(0.1)
p.red(0)
time.sleep(0.1)
p.orange(0)
time.sleep(0.1)
p.yellow(0)
time.sleep(0.1)
p.green(0)
time.sleep(0.1)
p.blue(0)
time.sleep(0.1)
p.white(0)
time.sleep(0.1)
p.all(0)
host = socket.gethostname()[-1:]
time.sleep(3)
#sendCommand("bash /work/net.sh worker"+host+" head 2")
f = open("/work/netLogs/host%s%d" % (host,int(time.time())),'w')
f.write("worker"+host+",head,2")
f.close()
\ No newline at end of file
import time
import socket
from random import randint,choice
import subprocess
workers = {
"worker1": {"status":0,"time":0},
"worker2": {"status":0,"time":0},
"worker3": {"status":0,"time":0},
"worker4": {"status":0,"time":0},
"worker5": {"status":0,"time":0},
"worker6": {"status":0,"time":0},
"worker7": {"status":0,"time":0},
"worker8": {"status":0,"time":0}
}
def sendCommand(command):
p = subprocess.Popen(command.split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate()
### Format = from,To,Amount
def sendLights(command):
sendCommand("bash /work/net.sh %s" % command)
def writeWeb(data):
payload = "{\"worker1\":%s,\"worker2\":%s,\"worker3\":%s,\"worker4\":%s,\"worker5\":%s,\"worker6\":%s,\"worker7\":%s,\"worker8\":%s}" % (data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7])
f =open("/var/www/html/control/index.html",'w')
f.write(payload)
f.close()
def workersToData(workers):
data = []
for i in range(1,9):
data.append(workers["worker%d" % i]["status"])
writeWeb(data)
active = []
dead = []
start = time.time()
for i in range(1,9):
dead.append("worker%d" % i)
workersToData(workers)
while (time.time() - start) < 45:
if randint(0,1) == 1 and len(dead) > 0:
currentWorker = choice(dead)
workers[currentWorker]["status"] = 1
workers[currentWorker]["time"] = time.time()
sendLights("head %s 1" % currentWorker)
sendLights("file %s 1" % currentWorker)
dead.remove(currentWorker)
active.append(currentWorker)
workersToData(workers)
if randint(0,1) == 1 and len(active) > 0:
currentWorker = choice(active)
if (time.time() - workers[currentWorker]["time"]) > 5:
workers[currentWorker]["status"] = 0
sendLights("%s file 1" % currentWorker)
sendLights("%s head 1" % currentWorker)
workersToData(workers)
active.remove(currentWorker)
dead.append(currentWorker)
# for i in range(1,9):
# currentWorker = "worker%d" % i
# print(currentWorker)
# sendLights("head %s 1" % currentWorker)
# time.sleep(0.02)
# workers[currentWorker]["status"] = 1
# workersToData(workers)
# print(workers[currentWorker]["status"])
# time.sleep(0.3)
# time.sleep(8)
# for i in range(1,9):
# currentWorker = "worker%d" % i
# print(currentWorker)
# if currentWorker == "worker8":
# sendLights("%s head 1" % "worker1")
# time.sleep(0.2)
# workers["worker1"]["status"] = 1
# workersToData(workers)
# sendLights("%s head 1" % currentWorker)
# time.sleep(0.2)
# workers[currentWorker]["status"] = 0
# workersToData(workers)
# print(workers[currentWorker]["status"])
# time.sleep(0.3)
# for i in range(2,9):
# currentWorker = "worker%d" % i
# print(currentWorker)
# sendLights("head %s 1" % currentWorker)
# time.sleep(0.02)
# workers[currentWorker]["status"] = 1
# workersToData(workers)
# print(workers[currentWorker]["status"])
# time.sleep(0.3)
# time.sleep(8)
# for i in range(1,9):
# currentWorker = "worker%d" % i
# print(currentWorker)
# sendLights("%s head 1" % currentWorker)
# time.sleep(0.2)
# workers[currentWorker]["status"] = 0
# workersToData(workers)
# print(workers[currentWorker]["status"])
# time.sleep(0.3)
workers = {
"worker1": {"status":0,"time":0},
"worker2": {"status":0,"time":0},
"worker3": {"status":0,"time":0},
"worker4": {"status":0,"time":0},
"worker5": {"status":0,"time":0},
"worker6": {"status":0,"time":0},
"worker7": {"status":0,"time":0},
"worker8": {"status":0,"time":0}
}
workersToData(workers)
from piglow import PiGlow
import time
import socket
import subprocess
import psutil
from random import randint
import urllib2, json
p = PiGlow()
val = 100
colour = 1
def sendCommand(command):
p = subprocess.Popen(command.split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate()
def getControlData():
rawData = urllib2.urlopen("http://192.168.1.1/network").read()
print(rawData)
controls = json.loads(rawData)
print(controls)
host = socket.gethostname()
print(controls[host])
return controls[host]
p.green(255)
time.sleep(30)
delay = 0.05
while True:
try:
p.all(0)
if getControlData():
print("in")
p.white(10)
time.sleep(delay)
p.blue(20)
time.sleep(delay)
p.green(30)
time.sleep(delay)
p.yellow(40)
time.sleep(delay)
p.orange(50)
time.sleep(delay)
p.red(60)
time.sleep(delay)
p.white(255)
time.sleep(delay)
p.red(0)
time.sleep(delay)
p.orange(0)
time.sleep(delay)
p.yellow(0)
time.sleep(delay)
p.green(0)
time.sleep(delay)
p.blue(0)
time.sleep(delay)
p.white(0)
time.sleep(delay)
else:
p.all(0)
#time.sleep(0.5)
except Exception as e:
print(e)
p.all(0)
p.red(255)
p.white(255)
echo \{\"worker1\":0,\"worker2\":0,\"worker3\":0,\"worker4\":0,\"worker5\":0,\"worker6\":0,\"worker7\":0,\"worker8\":0\} > /var/www/html/control/index.html
echo \{\"LegionDisplay\":0,\"LegionHead\":0,\"LegionFile\":0\} > /var/www/html/network/index.html
echo \{\"worker1\":1,\"worker2\":1,\"worker3\":1,\"worker4\":1,\"worker5\":1,\"worker6\":1,\"worker7\":1,\"worker8\":1\} > /var/www/html/control/index.html
echo \{\"LegionDisplay\":1,\"LegionHead\":1,\"LegionFile\":1\} > /var/www/html/network/index.html
#!/bin/sh
#SBATCH --time=00:02:00 # Run time in hh:mm:ss
#SBATCH --mem-per-cpu=100 # Memory required in MB
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=4
#SBATCH --job-name=Master
#SBATCH --error=/work/slurm/userJob%J.err
#SBATCH --output=/work/slurm/userJob.%J.out
#SBATCH --partition=Part1
python /work/HPCMagic.py
#!/bin/sh
#SBATCH --time=00:02:00 # Run time in hh:mm:ss
#SBATCH --mem-per-cpu=100 # Memory required in MB
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=4
#SBATCH --job-name=SlurmMock
#SBATCH --error=/work/slurm/userJob%J.err
#SBATCH --output=/work/slurm/userJob.%J.out
#SBATCH --partition=Part1
python /work/HTC.py $A
from piglow import PiGlow
from time import sleep
import psutil
from random import randint
p = PiGlow()
val = 100
colour = 1
def cpu_temp():
with open('/sys/class/thermal/thermal_zone0/temp', 'r') as f:
temp = float(f.read()) / 1000.0
return temp
arm1 = [6,5,4,3,2,1]
arm2 = [12,11,10,9,8,7]
arm3 = [18,17,16,15,14,13]
arms = [arm1,arm2,arm3]
x = 0
while True:
try:
cpuLoad = psutil.cpu_percent(percpu=True)
except:
print("Math dun goofed")
if cpu_temp() > 65:
p.red(255)
p.orange(255)
p.yellow(255)
sleep(0.005)
p.all(0)
else:
LEDList = []
for i in range(0,3):
lights = randint(0,100)/17#cpuLoad[i]/17
# print(cpuLoad)
LEDload = int(round(lights))
# print("Core: " + str(i))
for j in arms[i]:
if x <= LEDload:
# print("IF: " + str(x-int(lights)), x, int(lights))
if (x-int(lights)) <=0:
p.led(j,128)
else:
# print("ELSE",j,int(round((j-int(lights)*255))))
p.led(j,int(round((j-int(lights)*64))))
LEDList.append(j)
# print(j)
x = x + 1
x = 0
for k in range(1,18):
if k not in LEDList:
p.led(k,0)
sleep(0.08)
# print("-------------------") #print(cpu)
#
# csce 435/835 practicum slurm.conf
#
# slurm.conf file generated by configurator easy.html.
# Put this file on all nodes of your cluster.
# See the slurm.conf man page for more information.
#
ControlMachine=LegionHead
ControlAddr=192.168.1.1
NodeName=LegionHead
#MailProg=/bin/mail
MpiDefault=none
#MpiParams=ports=#-#
ProctrackType=proctrack/pgid
ReturnToService=1
SlurmctldPidFile=/var/run/slurm-llnl/slurmctld.pid
#SlurmctldPort=6817
SlurmdPidFile=/var/run/slurm-llnl/slurmd.pid
#SlurmdPort=6818
SlurmdSpoolDir=/var/lib/slurm-llnl/slurmd
SlurmUser=slurm
#SlurmdUser=root
StateSaveLocation=/var/lib/slurm-llnl/slurmctld
SwitchType=switch/none
TaskPlugin=task/none
#
#
# TIMERS
#KillWait=30
#MinJobAge=300
#SlurmctldTimeout=120
#SlurmdTimeout=300
#
#
# SCHEDULING
FastSchedule=1
SchedulerType=sched/backfill
#SchedulerPort=7321
SelectType=select/cons_res
SelectTypeParameters=CR_Core_Memory,CR_CORE_DEFAULT_DIST_BLOCK
#
#
# LOGGING AND ACCOUNTING
AccountingStorageType=accounting_storage/none
ClusterName=legion
#JobAcctGatherFrequency=30
JobAcctGatherType=jobacct_gather/none
#SlurmctldDebug=3
SlurmctldLogFile=/var/log/slurm-llnl/slurmctld.log
#SlurmdDebug=3
SlurmdLogFile=/var/log/slurm-llnl/slurmd.log
#
#
# COMPUTE NODES
# NodeName=worker[1-10] CPUs=4 RealMemory=900 State=UNKNOWN
NodeName=worker[1-8] CPUs=4 RealMemory=900 State=UNKNOWN
PartitionName=Part1 Nodes=worker[1-8] Default=YES MaxTime=INFINITE State=UP