summaryrefslogtreecommitdiffstats
path: root/Monitoring/MonitoringService/Example
diff options
context:
space:
mode:
Diffstat (limited to 'Monitoring/MonitoringService/Example')
-rw-r--r--Monitoring/MonitoringService/Example/Dimensions.py42
-rw-r--r--Monitoring/MonitoringService/Example/Metrics.py68
-rw-r--r--Monitoring/MonitoringService/Example/Platforms.py10
-rw-r--r--Monitoring/MonitoringService/Example/Prefixes.py23
-rw-r--r--Monitoring/MonitoringService/Example/Resources.py61
-rw-r--r--Monitoring/MonitoringService/Example/Tools.py311
-rw-r--r--Monitoring/MonitoringService/Example/Units.py80
-rw-r--r--Monitoring/MonitoringService/Example/__init__.py0
-rw-r--r--Monitoring/MonitoringService/Example/credentials.py34
-rw-r--r--Monitoring/MonitoringService/Example/model.py14
10 files changed, 643 insertions, 0 deletions
diff --git a/Monitoring/MonitoringService/Example/Dimensions.py b/Monitoring/MonitoringService/Example/Dimensions.py
new file mode 100644
index 0000000..526ee11
--- /dev/null
+++ b/Monitoring/MonitoringService/Example/Dimensions.py
@@ -0,0 +1,42 @@
+'''
+Created on Oct 12, 2011
+
+@author: steger
+@summary: Here we declare some unit models to enable parameter conversions
+'''
+from DataProcessing.Dimension import DimensionManager
+from Example.Units import UM
+from DataProcessing.MeasurementLevel import Nominal, Interval, Ratio
+
+DM = DimensionManager(unitmanager = UM)
+
+basedimensions = [
+ ("Cardinal", "unitless", Nominal),
+ ("NameOfSomething", "unitless", Nominal),
+ ("Countable", "piece", Ratio),
+ ("InformationSize", "bit", Ratio),
+ ("IPAddress", "ipv4dotted", Nominal),
+ ("PointInTime", "unixtimestamp", Interval),
+ ]
+
+deriveddimensions = [
+ ("TimeInterval", "second", "PointInTime", DM.DifferenceDimension),
+ ("Probability", "fraction", "Countable", DM.RatioDimension),
+ ]
+
+for reference, unitreference, measurementlevel in basedimensions:
+ DM.newBaseDimension(reference, reference, UM[unitreference], measurementlevel)
+
+for reference, unitreference, ancestorreference, dimtype in deriveddimensions:
+ DM.newDerivedDimension(reference, reference, UM[unitreference], DM[ancestorreference], dimtype)
+
+
+#Some dimensions explicitely references
+nameofsomething = DM["NameOfSomething"]
+pointintime = DM["PointInTime"]
+timeinterval = DM["TimeInterval"]
+cardinal = DM["Cardinal"]
+countable = DM["Countable"]
+ipaddress = DM["IPAddress"]
+informationsize = DM["InformationSize"]
+probability = DM["Probability"]
diff --git a/Monitoring/MonitoringService/Example/Metrics.py b/Monitoring/MonitoringService/Example/Metrics.py
new file mode 100644
index 0000000..e0d2b82
--- /dev/null
+++ b/Monitoring/MonitoringService/Example/Metrics.py
@@ -0,0 +1,68 @@
+'''
+Created on Oct 12, 2011
+
+@author: steger
+@summary: Here we declare monitorable metrics and combine them with tools that are measuring them
+'''
+from Example.Tools import sshping, sonomashortping, sshtraceroute, sshmeminfo,\
+ sonomashortchirp
+from DataProcessing.Parameter import ParameterList, Parameter
+from Example.Units import UM, unitless, milli_second, Byte, piece
+from Example.Dimensions import nameofsomething, informationsize,\
+ timeinterval, cardinal, countable
+from Resource.node import node
+from Resource.path import path
+
+class FreeMemory(object):
+ name = 'Free Memory'
+ resourcetype = node
+ p_obligatory = ParameterList()
+ p_optional = ParameterList()
+
+class DiskUsage(object):
+ name = 'Disk Usage'
+ resourcetype = node
+ p_obligatory = ParameterList([
+ Parameter(name = "Directory", valuetype = str, unitmanager = UM, dimension = nameofsomething, default = ('/dev/mapper/planetlab-vservers', unitless))
+ ])
+ p_optional = ParameterList()
+
+class RoundTripDelay(object):
+ name = 'Round Trip Delay'
+ resourcetype = path
+ p_obligatory = ParameterList()
+ p_optional = ParameterList([
+ Parameter(name = "Count", valuetype = int, unitmanager = UM, dimension = countable, default = (5, piece)),
+ Parameter(name = "PacketSize", valuetype = int, unitmanager = UM, dimension = informationsize, default = (64, Byte)),
+ Parameter(name = "Delay", valuetype = float, unitmanager = UM, dimension = timeinterval, default = (200, milli_second)),
+ Parameter(name = "TimeToLive", valuetype = int, unitmanager = UM, dimension = countable, default = (32, piece)),
+ Parameter(name = "Interface", valuetype = str, unitmanager = UM, dimension = nameofsomething, default = ("eth0", unitless)),
+ ])
+
+class OnewayDelay(object):
+ name = 'One Way Delay'
+ resourcetype = path
+ p_obligatory = ParameterList()
+ p_optional = ParameterList([
+ Parameter(name = "Count", valuetype = int, unitmanager = UM, dimension = countable, default = (5, piece)),
+ Parameter(name = "Delay", valuetype = int, unitmanager = UM, dimension = timeinterval, default = (200, milli_second)),
+ Parameter(name = "TimeToLive", valuetype = int, unitmanager = UM, dimension = countable, default = (32, piece)),
+# Parameter(name = "Interface", valuetype = str, unitmanager = UM, dimension = nameofsomething, default = (novi_iface, unitless)),
+ Parameter(name = "PacketSize", valuetype = int, unitmanager = UM, dimension = informationsize, default = (64, Byte)),
+ Parameter(name = "SourcePort", valuetype = int, unitmanager = UM, dimension = cardinal, default = (7777, unitless)),
+ Parameter(name = "DestinationPort", valuetype = int, unitmanager = UM, dimension = cardinal, default = (7777, unitless)),
+ ])
+
+class HopMeasurement(object):
+ name = 'Hop Measurement'
+ resourcetype = path
+ p_obligatory = ParameterList()
+ p_optional = ParameterList()
+
+
+MonitorMetrics = {
+ FreeMemory: [sshmeminfo],
+ RoundTripDelay: [sshping, sonomashortping],
+ OnewayDelay: [sonomashortchirp],
+ HopMeasurement: [sshtraceroute]
+}
diff --git a/Monitoring/MonitoringService/Example/Platforms.py b/Monitoring/MonitoringService/Example/Platforms.py
new file mode 100644
index 0000000..5936124
--- /dev/null
+++ b/Monitoring/MonitoringService/Example/Platforms.py
@@ -0,0 +1,10 @@
+'''
+Created on Nov 20, 2012
+
+@author: steger
+'''
+from Example.model import owl_pl_conf, owl_fed_conf
+federation = {
+ 'PlanetLab': (1234, owl_pl_conf),
+ 'FEDERICA': (1235, owl_fed_conf)
+}
diff --git a/Monitoring/MonitoringService/Example/Prefixes.py b/Monitoring/MonitoringService/Example/Prefixes.py
new file mode 100644
index 0000000..54fa7b9
--- /dev/null
+++ b/Monitoring/MonitoringService/Example/Prefixes.py
@@ -0,0 +1,23 @@
+'''
+Created on Oct 12, 2011
+
+@author: steger
+@summary: Here we declare some unit models to enable parameter conversions
+'''
+from DataProcessing.Prefix import PrefixManager
+
+prefixes = [
+ ('pico', 'p', 10, -12),
+ ('nano', 'n', 10, -9),
+ ('micro', 'mu', 10, -6),
+ ('milli', 'm', 10, -3),
+ ('deco', 'd', 10, 0),
+ ('hecto', 'h', 10, 2),
+ ('kilo', 'k', 10, 3),
+ ('mega', 'M', 10, 6),
+ ('giga', 'G', 10, 9),
+]
+
+PM = PrefixManager()
+for reference, symbol, base, exponent in prefixes:
+ PM.newPrefix(reference, symbol, base, exponent)
diff --git a/Monitoring/MonitoringService/Example/Resources.py b/Monitoring/MonitoringService/Example/Resources.py
new file mode 100644
index 0000000..6c3418d
--- /dev/null
+++ b/Monitoring/MonitoringService/Example/Resources.py
@@ -0,0 +1,61 @@
+'''
+Created on Oct 12, 2011
+
+@author: steger
+@summary: Here we define the nodes that can take part in monitoring procedures
+
+@note: how to extract information
+for h in novilab.elte.hu planetlab1-novi.lab.netmode.ece.ntua.gr planetlab2-novi.lab.netmode.ece.ntua.gr smilax1.man.poznan.pl smilax2.man.poznan.pl smilax3.man.poznan.pl smilax4.man.poznan.pl smilax5.man.poznan.pl; do echo -n "\"$h\", "; ssh site_admin@$h -i ~/Private/ssh/novi_rsa /sbin/ifconfig | awk '/^[^[:space:]]/ { iface = $1} /inet addr/ { printf ("(\"%s\", \"%s\"), ", iface, $2) }' | sed s,addr.,,g | sed s/', $'// ; done
+'''
+
+from Resource.node import node
+from Resource.path import path
+from Resource.interface import interface
+from Example.Units import UM
+
+# PL node resources
+direction = interface.INGRESS | interface.EGRESS
+PLnodes = []
+def extendpl(hostname, ifaces):
+ n = node(name = hostname, resourceid = hostname)
+ for iface, ip in ifaces:
+ I = interface(name = iface, resourceid = "%s:%s" % (hostname, iface))
+ ipwu = ip, UM.ipv4dotted
+ if iface == "eth0":
+ I.setvalues(ifacename = iface, address = ipwu, ispublic = True, direction = direction, hostname = hostname)
+ else:
+ I.setvalues(ifacename = iface, address = ipwu, ispublic = False, direction = direction)
+ n.addinterface(I)
+ PLnodes.append(n)
+
+extendpl("novilab.elte.hu", [("eth0", "157.181.175.243"), ("federica", "192.168.29.45"), ("novi", "192.168.28.97"), ("novi_monitoring", "192.168.31.21")])
+extendpl("planetlab1-novi.lab.netmode.ece.ntua.gr", [("eth0", "147.102.22.66"), ("federica", "192.168.29.57"), ("novi", "192.168.28.161"), ("novi_monitoring", "192.168.31.33"), ("tun515-1", "192.168.20.1")])
+extendpl("planetlab2-novi.lab.netmode.ece.ntua.gr", [("eth0", "147.102.22.67"), ("federica", "192.168.29.61"), ("novi", "192.168.28.165"), ("tap514-1", "192.168.20.3")])
+extendpl("smilax1.man.poznan.pl", [("eth0", "150.254.160.19"), ("federica", "192.168.29.21"), ("novi", "192.168.28.29"), ("novi_fia_1", "192.168.32.5"), ("novi_monitoring", "192.168.31.13"), ("tap513-1", "192.168.20.4")])
+#extendpl("smilax2.man.poznan.pl", [("eth0", "150.254.160.20"), ("federica", "192.168.29.25"), ("novi", "192.168.28.33"), ("novi_fia_2", "192.168.32.5")])
+#extendpl("smilax3.man.poznan.pl", [("eth0", "150.254.160.21"), ("federica", "192.168.29.29"), ("novi", "192.168.28.37"), ("novi_fia_2", "192.168.32.17")])
+#extendpl("smilax4.man.poznan.pl", [("eth0", "150.254.160.22"), ("federica", "192.168.29.33"), ("novi", "192.168.28.41")])
+#extendpl("smilax5.man.poznan.pl", [("eth0", "150.254.160.23"), ("federica", "192.168.29.37"), ("novi", "192.168.28.45")])
+
+PLdict = dict(map(lambda x: (x.name, x), PLnodes))
+
+# PL are fully connected over the Internet
+PLpaths = []
+for s in PLdict.values():
+ for d in PLdict.values():
+ if s == d: continue
+ name = "%s->%s" % (s.name, d.name)
+ PLpaths.append( path(name = name, source = s, destination = d) )
+
+
+# FED node resources
+FEDnodes = []
+for nick, addr in [ ("fed.psnc", '192.168.31.1'), ("fed.dfn", '192.168.31.5'), ("fed.garr", '192.168.31.9') ]:
+ n = node(name = nick, resourceid = nick)
+ I = interface(name = "eth0", resourceid = "%s:eth0" % nick)
+ ipwu = (addr, UM.ipv4dotted)
+ I.setvalues(ifacename = "eth0", address = ipwu, ispublic = False, direction = direction)
+ n.addinterface(I)
+ FEDnodes.append(n)
+
+FEDdict = dict(map(lambda x: (x.name, x), FEDnodes))
diff --git a/Monitoring/MonitoringService/Example/Tools.py b/Monitoring/MonitoringService/Example/Tools.py
new file mode 100644
index 0000000..d842d04
--- /dev/null
+++ b/Monitoring/MonitoringService/Example/Tools.py
@@ -0,0 +1,311 @@
+'''
+Created on Oct 12, 2011
+
+@author: steger
+@summary: Here we define some monitoring tools and dress them up with parameters and work flow description
+'''
+from DataProcessing.Parameter import Parameter, ParameterList
+from Example.Resources import PLdict
+from Credential.credentialtypes import UsernamePassword, UsernameRSAKey
+from Driver.SOAPClient import SOAPClient
+from Driver.SshExec import SshExec
+from Example.Units import UM, Byte, micro_second, piece, milli_second,\
+ nano_second, unitless, nano_unixtimestamp, unixtimestamp, fraction,\
+ kilo_Byte, second
+from Example.Dimensions import cardinal, countable, ipaddress, timeinterval,\
+ informationsize, pointintime, nameofsomething, probability
+from DataProcessing.DataHeader import DataHeaderGeneratedByDescription
+
+DOM_SUBSTRATE = 1
+DOM_SLICE = 2
+
+sonoma_url = "http://complex.elte.hu/~steger/sonoma/user.wsdl"
+
+nodes = map(lambda x:(x.get_hostname("eth0"), unitless), PLdict.values())
+
+class sonomashortping:
+ driver = SOAPClient
+ name = "SONoMAPing"
+ domain = DOM_SUBSTRATE
+ dataheaderdeclaration = DataHeaderGeneratedByDescription('ping', [('Run', countable),
+ ('Sequence Number', countable),
+ ('Source Address', ipaddress),
+ ('Destination Address', ipaddress),
+ ('Packet Size', informationsize, Byte),
+ ('Time To Live', countable),
+ ('Round Trip Delay', timeinterval, micro_second)])
+
+ authtype = (UsernamePassword, )
+ kwargs = { "url": sonoma_url, "MAserviceport": 11123 }
+ hooks = {
+ "prehook" : """
+from base64 import b64decode
+self.decode = b64decode
+self.pattern = re.compile('^(\d+)\s+(\d+\.\d+\.\d+\.\d+)\s+(\d+\.\d+\.\d+\.\d+)\s+(\d+)\s+(\d+)\s+(\d+)$')
+self.username=self.credential.username
+self.password=self.credential.password
+self.client = self.driver(kw.get('url'))
+self.sessionId = self.client.service.requestSession(self.username, self.password, 'CSV', False)
+self.port = kw.get('MAserviceport')
+self.template = self.data.getTemplate(size = 1)
+ """,
+ "retrievehook" : """
+source = "%s:%d" % (self.parameters.get('SourceAddress', self.um.ipv4dotted), self.port)
+res = self.client.service.shortPing(self.sessionId,
+ source, self.parameters.get('DestinationAddress', self.um.ipv4dotted), self.parameters.get('Count', self.um.piece),
+ self.parameters.get('Delay', self.um.micro_second), self.parameters.get('PacketSize', self.um.Byte))
+rec = self.decode(res).splitlines()
+for r in rec:
+ if self.pattern.match(r):
+ self.template.clear()
+ ex = self.pattern.split(r)[:-1]
+ ex[0] = self.runcount
+ self.template.updateMany( ('Run', 'Sequence Number', 'Source Address', 'Destination Address', 'Packet Size', 'Time To Live', 'Round Trip Delay'), [ex,] )
+ self.data.saveRecord(self.template)
+return True
+ """,
+ "posthook": "self.client.service.closeSession(self.username, self.password, self.sessionId)"}
+ parameters = ParameterList([ Parameter(name = "SourceAddress", valuetype = str, unitmanager = UM, dimension = ipaddress),
+ Parameter(name = "DestinationAddress", valuetype = str, unitmanager = UM, dimension = ipaddress),
+ Parameter(name = "Count", valuetype = int, unitmanager = UM, dimension = countable, default = (5, piece)),
+ Parameter(name = "Delay", valuetype = int, unitmanager = UM, dimension = timeinterval, default = (100, milli_second)),
+ Parameter(name = "PacketSize", valuetype = int, unitmanager = UM, dimension = informationsize, default = (64, Byte)) ])
+
+class sonomashortchirp:
+ driver = SOAPClient
+ name = "SONoMAChirp"
+ domain = DOM_SUBSTRATE
+ dataheaderdeclaration = DataHeaderGeneratedByDescription('onewaydelay', [('Run', countable),
+ ('SequenceNumber', countable),
+ ('SourceAddress', ipaddress),
+ ('DestinationAddress', ipaddress),
+ ('TimestampSend', pointintime, nano_unixtimestamp),
+ ('OnewayDelay', timeinterval, nano_second) ])
+ authtype = (UsernamePassword, )
+ kwargs = { "url": sonoma_url, "MAserviceport": 11123 }
+ hooks = {
+ "prehook" : """
+from base64 import b64decode
+self.decode = b64decode
+self.pattern = re.compile('^(\d+)\s+(\d+\.\d+\.\d+\.\d+)\s+(\d+\.\d+\.\d+\.\d+)\s+(\d+)\s+(\d+)$')
+self.username=self.credential.username
+self.password=self.credential.password
+self.client = self.driver(kw.get('url'))
+self.sessionId = self.client.service.requestSession(self.username, self.password, 'CSV', False)
+self.port = kw.get('MAserviceport')
+self.template = self.data.getTemplate(size = 1)
+self.delaylist = self.client.factory.create("delayList")
+self.delaylist.gap = [100000,100000]
+ """,
+ "retrievehook" : """
+source = "%s:%d" % (self.parameters.get('SourceAddress', self.um.ipv4dotted), self.port)
+destination = "%s:%d" % (self.parameters.get('DestinationAddress', self.um.ipv4dotted), self.port)
+res = self.client.service.shortChirp(self.sessionId,
+ source, self.parameters.get('SourcePort', self.um.unitless),
+ destination, self.parameters.get('DestinationPort', self.um.unitless),
+ self.parameters.get('Count', self.um.piece), self.parameters.get('Delay', self.um.milli_second),
+ self.parameters.get('PacketSize', self.um.Byte), self.delaylist)
+rec = self.decode(res).splitlines()
+data = []
+for r in rec:
+ if self.pattern.match(r):
+ self.template.clear()
+ ex = self.pattern.split(r)[:-1]
+ ex[0] = self.runcount
+ ex[-1] = int(ex[-1])-int(ex[-2])
+ data.append( ex )
+self.template.clear(size = len(data))
+self.template.updateMany( ('Run', 'SequenceNumber', 'SourceAddress', 'DestinationAddress', 'TimestampSend', 'OnewayDelay'), data )
+self.data.saveRecord(self.template)
+return True
+ """,
+ "posthook": "self.client.service.closeSession(self.username, self.password, self.sessionId)"}
+ parameters = ParameterList([ Parameter(name = "SourceAddress", valuetype = str, unitmanager = UM, dimension = ipaddress),
+ Parameter(name = "DestinationAddress", valuetype = str, unitmanager = UM, dimension = ipaddress),
+ Parameter(name = "Count", valuetype = int, unitmanager = UM, dimension = countable, default = (5, piece)),
+ Parameter(name = "Delay", valuetype = int, unitmanager = UM, dimension = timeinterval, default = (100, milli_second)),
+ Parameter(name = "PacketSize", valuetype = int, unitmanager = UM, dimension = informationsize, default = (64, Byte)),
+ Parameter(name = "SourcePort", valuetype = int, unitmanager = UM, dimension = cardinal, default = (7777, unitless)),
+ Parameter(name = "DestinationPort", valuetype = int, unitmanager = UM, dimension = cardinal, default = (7777, unitless)), ])
+
+
+class sshping:
+ driver = SshExec
+ name = "sshPing"
+ domain = DOM_SLICE
+ dataheaderdeclaration = DataHeaderGeneratedByDescription('ping', [('Run', cardinal),
+ ('TimeReceived', pointintime),
+ ('PacketSize', informationsize),
+ ('DestinationAddress', ipaddress),
+ ('SequenceNumber', countable), ('TimeToLive', countable),
+ ('RoundTripDelay', timeinterval, milli_second)])
+ authtype = (UsernameRSAKey, UsernamePassword)
+ kwargs = {}
+ hooks = {
+ "prehook" : """
+self.pattern = re.compile('^\[(\d+\.?\d*)\]\s*(\d+)\s*bytes\s*from\s*(\d+\.\d+\.\d+\.\d+):\s*icmp_req=(\d+)\s*ttl=(\d+)\s*time=(\d+\.?\d*)\s*(\w*)')
+self.template = self.data.getTemplate(size = self.parameters.get('Count', self.um.piece))
+command = "ping -D -n -c %d -i %f -t %d -I %s %s" % (
+ self.parameters.get('Count', self.um.piece), self.parameters.get('Delay', self.um.second),
+ self.parameters.get('TimeToLive', self.um.piece), self.parameters.get('Interface', self.um.unitless),
+ self.parameters.get('DestinationAddress', self.um.ipv4dotted))
+self.client = self.driver(host = self.parameters.get('SourceAddress', self.um.ipv4dotted), credential = self.credential, command = command)
+ """,
+ "retrievehook" : """
+data = []
+for r in self.client.execute().readlines():
+ if self.pattern.match(r):
+ ex = self.pattern.split(r)[:-2]
+ ex[0] = self.runcount
+ data.append( ex )
+self.template.clear(size = len(data))
+self.template.updateMany( ('Run', 'TimeReceived', 'PacketSize', 'DestinationAddress', 'SequenceNumber', 'TimeToLive', 'RoundTripDelay'), data )
+self.data.saveRecord(self.template)
+return True
+ """}
+ parameters = ParameterList([ Parameter(name = "SourceAddress", valuetype = str, unitmanager = UM, dimension = ipaddress),
+ Parameter(name = "DestinationAddress", valuetype = str, unitmanager = UM, dimension = ipaddress),
+ Parameter(name = "Count", valuetype = int, unitmanager = UM, dimension = countable, default = (5, piece)),
+ Parameter(name = "Delay", valuetype = float, unitmanager = UM, dimension = timeinterval, default = (200, milli_second)),
+ Parameter(name = "TimeToLive", valuetype = int, unitmanager = UM, dimension = countable, default = (32, piece)),
+ Parameter(name = "Interface", valuetype = str, unitmanager = UM, dimension = nameofsomething, default = ("eth0", unitless)) ] )
+
+class sshmeminfo:
+ driver = SshExec
+ name = "sshMeminfo"
+ domain = DOM_SLICE | DOM_SUBSTRATE
+ dataheaderdeclaration = DataHeaderGeneratedByDescription('meminfo', [('Run', cardinal),
+ ('AvailableMemory', informationsize),
+ ('FreeMemory', informationsize)])
+ authtype = (UsernameRSAKey, UsernamePassword)
+ kwargs = {}
+ hooks = {
+ "prehook" : """
+self.pattern = re.compile('^(.*):\s*(\d+)\s+(.B)$')
+self.template = self.data.getTemplate(size = 1)
+command = "cat /proc/meminfo"
+self.client = self.driver(host = self.parameters.get('SourceAddress', self.um.ipv4dotted), credential = self.credential, command = command)
+ """,
+ "retrievehook" : """
+self.template.clear()
+self.template.update('Run', (self.runcount,))
+for r in self.client.execute().readlines():
+ if self.pattern.match(r):
+ n, v, u = self.pattern.split(r)[1:-1]
+ if n == 'MemTotal' and u == 'kB':
+ self.template.update('AvailableMemory', (v,))
+ elif n == 'MemFree' and u == 'kB':
+ self.template.update('FreeMemory', (v,))
+self.data.saveRecord(self.template)
+return True
+ """}
+ parameters = ParameterList([ Parameter(name = "SourceAddress", valuetype = str, unitmanager = UM, dimension = ipaddress), ])
+
+class sshdf:
+ driver = SshExec
+ name = "sshDiskinfo"
+ domain = DOM_SLICE | DOM_SUBSTRATE
+ dataheaderdeclaration = DataHeaderGeneratedByDescription('diskinfo', [('Run', cardinal),
+ ('Available', informationsize, kilo_Byte),
+ ('Used', informationsize, kilo_Byte)])
+ authtype = (UsernameRSAKey, UsernamePassword)
+ kwargs = {}
+ hooks = {
+ "prehook" : """
+self.pattern = re.compile('^.*\s+\d+\s+(\d+)\s+(\d+)\s+\d+%\s+.*$')
+self.template = self.data.getTemplate(size = 1)
+command = "df %s" % self.parameters.get('Directory', self.um.unitless)
+self.client = self.driver(host = self.parameters.get('SourceAddress', self.um.ipv4dotted), credential = self.credential, command = command)
+ """,
+ "retrievehook" : """
+self.template.clear()
+self.template.update('Run', (self.runcount,))
+for r in self.client.execute().readlines():
+ if self.pattern.match(r):
+ u, a = self.pattern.split(r)[1:-1]
+ self.template.update('Available', (a,))
+ self.template.update('Used', (u,))
+self.data.saveRecord(self.template)
+return True
+ """}
+ parameters = ParameterList([
+ Parameter(name = "SourceAddress", valuetype = str, unitmanager = UM, dimension = ipaddress),
+ Parameter(name = "Directory", valuetype = str, unitmanager = UM, dimension = nameofsomething),
+ ])
+
+
+class sshtraceroute:
+ driver = SshExec
+ name = "sshTraceroute"
+ domain = DOM_SLICE
+ dataheaderdeclaration = DataHeaderGeneratedByDescription('traceroute', [('Run', cardinal),
+ ('Hop', countable),
+ ('Raw', nameofsomething)])
+ authtype = (UsernameRSAKey, UsernamePassword)
+ kwargs = {}
+ hooks = {
+ "prehook" : """
+self.pattern = re.compile('^\s*(\d+)\s+(.*)$')
+self.template = self.data.getTemplate(size = 1)
+command = "traceroute -n %s" % (self.parameters.get('DestinationAddress', self.um.ipv4dotted))
+self.client = self.driver(host = self.parameters.get('SourceAddress', self.um.ipv4dotted), credential = self.credential, command = command)
+ """,
+ "retrievehook" : """
+data = []
+for r in self.client.execute().readlines():
+ if self.pattern.match(r):
+ ex = self.pattern.split(r)[:-1]
+ ex[0] = self.runcount
+ data.append( ex )
+self.template.clear(size = len(data))
+self.template.updateMany( ('Run', 'Hop', 'Raw'), data )
+self.data.saveRecord(self.template)
+return True
+ """}
+ parameters = ParameterList([ Parameter(name = "SourceAddress", valuetype = str, unitmanager = UM, dimension = ipaddress),
+ Parameter(name = "DestinationAddress", valuetype = str, unitmanager = UM, dimension = ipaddress),
+ Parameter(name = "Count", valuetype = int, unitmanager = UM, dimension = countable, default = (5, piece)), ])
+
+class sshhades:
+ driver = SshExec
+ name = "HADESaggregates"
+ domain = DOM_SUBSTRATE
+ dataheaderdeclaration = DataHeaderGeneratedByDescription('hadestable', [('Run', cardinal),
+ ('Time', pointintime, unixtimestamp),
+ ('MinDelay', timeinterval, second),
+ ('MedianDelay', timeinterval, second),
+ ('MaxDelay', timeinterval, second),
+ ('Loss', probability, fraction),
+ ])
+ authtype = (UsernameRSAKey, UsernamePassword)
+ kwargs = { 'repository': '194.132.52.212', 'samplecount': 9 }
+ hooks = {
+ "prehook" : """
+self.repository = kw.get('repository')
+self.pattern = re.compile('^(\d+)\s+(-?\d+\.?\d*)\s+(-?\d+\.?\d*)\s+(-?\d+\.?\d*)\s+(\d+)\s+.*$')
+self.template = self.data.getTemplate(size = 1)
+lookup = { '192.168.31.1': 'PSNC_FED', '192.168.31.5': 'DFN_FED', '192.168.31.9': 'GARR_FED' }
+root = "/home/novi-monitoring"
+source = lookup[ self.parameters.get('SourceAddress', self.um.ipv4dotted) ]
+destination = lookup[ self.parameters.get('DestinationAddress', self.um.ipv4dotted) ]
+lookupcommand = "echo %s/data/hades/novi/www/*/*/*/%s.%s.0.qos_ai.dat" % (root, source, destination)
+self.client = self.driver(host = self.repository, credential = self.credential)
+files = self.client.execute(lookupcommand).read().split()
+self.command = "%s/hades/bin/hades-show-data.pl --config=novi %s" % (root, files[-1])
+self.nsamples = int(kw.get('samplecount'))
+ """,
+ "retrievehook" : """
+data = []
+for r in self.client.execute(self.command).readlines():
+ print r
+ if self.pattern.match(r):
+ ts, dtmin, dtmed, dtmax, loss = self.pattern.split(r)[1:-1]
+ data.append( [ self.runcount, ts, dtmin, dtmed, dtmax, float(loss)/self.nsamples ] )
+self.template.clear(size = len(data))
+self.template.updateMany( ('Run', 'Time', 'MinDelay', 'MedianDelay', 'MaxDelay', 'Loss'), data )
+self.data.saveRecord(self.template)
+return True
+ """}
+ parameters = ParameterList([ Parameter(name = "SourceAddress", valuetype = str, unitmanager = UM, dimension = ipaddress),
+ Parameter(name = "DestinationAddress", valuetype = str, unitmanager = UM, dimension = ipaddress),
+ ])
diff --git a/Monitoring/MonitoringService/Example/Units.py b/Monitoring/MonitoringService/Example/Units.py
new file mode 100644
index 0000000..83ac386
--- /dev/null
+++ b/Monitoring/MonitoringService/Example/Units.py
@@ -0,0 +1,80 @@
+'''
+Created on Oct 12, 2011
+
+@author: steger
+@summary: Here we declare some unit models to enable parameter conversions
+'''
+from DataProcessing.Unit import UnitManager
+from Example.Prefixes import PM
+from DataProcessing.DataError import PrefixError
+
+UM = UnitManager()
+
+def getPrefixBySymbol(symbol):
+ '''
+ @summary: look up the prefix in the PrefixManager based on its symbol
+ @param symbol: the symbol of the unit prefix
+ @type symbol: str
+ @return: the unit prefix found
+ @rtype: Prefix
+ @raise PrefixError: Prefix with symbol not found
+ '''
+ for prefix in PM.prefixes.values():
+ if prefix.symbol == symbol:
+ return prefix
+ raise PrefixError("Prefix with symbol %s not found" % symbol)
+
+
+basicunits = [
+ ("piece", "(1)", None),
+ ("unitless", "", None),
+ ("fraction", "", None),
+ ("second", "s", ['m', 'mu', 'n', 'p']),
+ ("unixtimestamp", "tss", ['n']),
+ ("ipv4dotted", "", None),
+ ("bit", "bit", ['k', 'M' ]),
+ ]
+
+lintransformedunits = [
+ ("dozen", "(12)", "piece", 12, None),
+ ("Byte", "B", "bit", 8, ['k', 'M' ]),
+ ]
+
+def storeprefixes(u, prefixes):
+ if prefixes:
+ for ps in prefixes:
+ p = getPrefixBySymbol(ps)
+ nr = "%s_%s" % (p.reference, u.reference)
+ ns = "%s%s" % (p.symbol, u.symbol)
+ UM.addLinearTransformedUnit(nr, ns, u, p.scale)
+
+for reference, symbol, prefixes in basicunits:
+ u = UM.newBasicUnit(reference, symbol)
+ storeprefixes(u, prefixes)
+
+for reference, symbol, ancientref, scale, prefixes in lintransformedunits:
+ u = UM.addLinearTransformedUnit(reference, symbol, UM[ancientref], scale)
+ storeprefixes(u, prefixes)
+
+
+# Some units explicitely referenced
+pico_second = UM["pico_second"]
+nano_second = UM["nano_second"]
+micro_second = UM["micro_second"]
+milli_second = UM["milli_second"]
+second = UM["second"]
+
+Byte = UM["Byte"]
+kilo_Byte = UM["kilo_Byte"]
+
+piece = UM["piece"]
+dozen = UM["dozen"]
+
+unitless = UM["unitless"]
+
+unixtimestamp = UM["unixtimestamp"]
+nano_unixtimestamp = UM["nano_unixtimestamp"]
+
+fraction = UM["fraction"]
+
+ipv4dotted = UM["ipv4dotted"] \ No newline at end of file
diff --git a/Monitoring/MonitoringService/Example/__init__.py b/Monitoring/MonitoringService/Example/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Monitoring/MonitoringService/Example/__init__.py
diff --git a/Monitoring/MonitoringService/Example/credentials.py b/Monitoring/MonitoringService/Example/credentials.py
new file mode 100644
index 0000000..1abcdaf
--- /dev/null
+++ b/Monitoring/MonitoringService/Example/credentials.py
@@ -0,0 +1,34 @@
+'''
+Created on Oct 27, 2011
+
+@author: steger
+'''
+from Credential.credentialtypes import UsernameRSAKey, UsernamePassword
+from os import path
+
+noviCredentialIARGS = { 'username': 'novi_novi', 'rsakey': path.expanduser("~/Private/ssh/novi_rsa") }
+noviCredential = UsernameRSAKey(**noviCredentialIARGS)
+
+novisaCredentialIARGS = { 'username': 'root', 'rsakey': path.expanduser("~/Private/ssh/novi_rsa") }
+novisaCredential = UsernameRSAKey(**novisaCredentialIARGS)
+
+novihadesCredentialIARGS = { 'username': 'novi-monitoring', 'rsakey': path.expanduser("~/Private/ssh/novimonitoring_rsa") }
+novihadesCredential = UsernameRSAKey(**novihadesCredentialIARGS)
+
+sonomaCredentialIARGS = {'username': "guest", 'password': "guest"}
+sonomaCredential = UsernamePassword(**sonomaCredentialIARGS)
+
+g3CredentialIARGS = {'username': "monitor1", 'password': "m/n.t,r1"}
+g3Credential = UsernamePassword(**g3CredentialIARGS)
+
+fedsubstrateCredentialIARGS = {'username': "novi-reader", 'password': "JS5no6vi7JS"}
+fedsubstrateCredential = UsernamePassword(**fedsubstrateCredentialIARGS)
+
+
+#mykeyring = [ noviCredentialIARGS, sonomaCredentialIARGS, novihadesCredentialIARGS ]
+
+ple_credentials = [ novisaCredentialIARGS, sonomaCredentialIARGS ]
+fed_credentials = [ novisaCredentialIARGS, novihadesCredentialIARGS, g3CredentialIARGS, fedsubstrateCredentialIARGS ]
+
+if __name__ == '__main__':
+ pass \ No newline at end of file
diff --git a/Monitoring/MonitoringService/Example/model.py b/Monitoring/MonitoringService/Example/model.py
new file mode 100644
index 0000000..c7ec71a
--- /dev/null
+++ b/Monitoring/MonitoringService/Example/model.py
@@ -0,0 +1,14 @@
+model_dir = "/home/steger/repo/git/novi/Software/information-model/monitoring-model"
+
+owl_unit = "%s/unit.owl" % model_dir
+owl_param = "%s/monitoring_parameters.owl" % model_dir
+owl_features = "%s/monitoring_features.owl" % model_dir
+owl_task = "%s/monitoring_task.owl" % model_dir
+owl_query = "%s/monitoring_query.owl" % model_dir
+owl_stat = "%s/monitoring_stat.owl" % model_dir
+owl_core = "%s/novi-im.owl" % model_dir
+
+owl_pl_conf = "%s/config_planetlab.owl" % model_dir
+owl_fed_conf = "%s/config_federica.owl" % model_dir
+
+owl_qry_example = "%s/monitoringQuery_example.owl" % model_dir