├── ZenPacks ├── JanGaraj │ ├── DataMirroring │ │ ├── lib │ │ │ ├── __init__.py │ │ │ └── collectd.py │ │ ├── COPYRIGHT.txt │ │ ├── __init__.py │ │ └── LICENSE.txt │ └── __init__.py └── __init__.py ├── MANIFEST.in ├── README.md ├── setup.py └── LICENSE /ZenPacks/JanGaraj/DataMirroring/lib/__init__.py: -------------------------------------------------------------------------------- 1 | # __init__.py 2 | -------------------------------------------------------------------------------- /ZenPacks/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /ZenPacks/JanGaraj/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | # This graft causes all files located under the ZenPacks/ subdirectory to be 2 | # included in the built ZenPack .egg. Files located in the top-level directory 3 | # of the ZenPack will not be explicitly included. 4 | # 5 | # You can read more about the format and available options available in this 6 | # MANIFEST.in file at the following URL. 7 | # http://docs.python.org/distutils/sourcedist.html 8 | graft ZenPacks 9 | -------------------------------------------------------------------------------- /ZenPacks/JanGaraj/DataMirroring/COPYRIGHT.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Jan Garaj - www.jangaraj.com 2 | # 3 | # This program is free software; you can redistribute it and/or modify it 4 | # under the terms of the GNU General Public License version 2 or (at your 5 | # option) any later version as published by the Free Software Foundation. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 15 | # USA. 16 | # -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ZenPacks.JanGaraj.DataMirroring 2 | =============================== 3 | 4 | About 5 | ===== 6 | 7 | This ZenPack is not standard Zenpack Install&Use. It provides only example code 8 | to mirror Zenoss data into another (monitoring) systems. It's monkey patch for 9 | Products.ZenRRD.RRDUtil.RRDUtil.put() method, so you have to be 100% sure about 10 | your ZenPack code. Mirror tasks are executed in new threads and they don't block 11 | Zenoss RRDUtil code. It depends on your requirements, but probably you will need 12 | to implement some performance improvements (persistent connections/connection 13 | pool/...) for serious production service. Keep in mind also concurrency and 14 | timeouts problems in your code. 15 | 16 | Please donate to author, so he can continue to publish other awesome projects 17 | for free: 18 | 19 | [![Paypal donate button](http://jangaraj.com/img/github-donate-button02.png)] 20 | (https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8LB6J222WRUZ4) 21 | 22 | Example codes are provided for mirroring to: 23 | 24 | - Carbon (Graphite)/Dataloop/InfluxDB 25 | - Horizon (Skyline) 26 | - OpenTSDB 27 | - collectd 28 | - Zabbix 29 | - MySQL/MariaDB 30 | - file 31 | 32 | Use case 33 | ======== 34 | 35 | You want to test some cool feature (graphing/anomaly detection/analyzing/reporting/alerting) 36 | of another system, but you don't want to make full installation. You can realtime 37 | mirror current data from Zenoss to another system and you can test it. 38 | 39 | Requirements 40 | ============ 41 | 42 | Zenoss 43 | ------ 44 | 45 | You must first have, or install, Zenoss 4. This ZenPack was tested 46 | against Zenoss 4.2.5. You can download the free Core 47 | version of Zenoss from http://community.zenoss.org/community/download. 48 | 49 | Installation 50 | ============ 51 | 52 | Normal Installation (packaged egg) 53 | ---------------------------------- 54 | 55 | Download the ZenPack code, edit __init__.py file and create your own egg file. 56 | Copy this file to your Zenoss server and run the following commands as the zenoss 57 | user. 58 | 59 | ``` 60 | zenpack --install ZenPacks.JanGaraj.DataMirroring-1.0.0.egg 61 | zenoss restart 62 | ``` 63 | 64 | 65 | Developer Installation (link mode) 66 | ---------------------------------- 67 | 68 | If you wish to further develop and possibly contribute back to the DataMirroring 69 | ZenPack you should clone the [git repository] 70 | (https://github.com/monitoringartist/ZenPacks.JanGaraj.DataMirroring.git), then install 71 | the ZenPack in developer mode using the following commands. 72 | 73 | ``` 74 | git clone git://github.com/monitoringartist/ZenPacks.JanGaraj.DataMirroring.git 75 | zenpack --link --install ZenPacks.JanGaraj.DataMirroring 76 | zenoss restart 77 | ``` 78 | 79 | Author 80 | ====== 81 | 82 | [Devops Monitoring zExpert](http://www.jangaraj.com), who loves monitoring 83 | systems, which start with letter Z. Those are Zabbix and Zenoss. 84 | 85 | Professional monitoring services: 86 | 87 | [![Monitoring Artist](http://monitoringartist.com/img/github-monitoring-artist-logo.jpg)] 88 | (http://www.monitoringartist.com) 89 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | ################################ 2 | # These variables are overwritten by Zenoss when the ZenPack is exported 3 | # or saved. Do not modify them directly here. 4 | # NB: PACKAGES is deprecated 5 | NAME = "ZenPacks.JanGaraj.DataMirroring" 6 | VERSION = "1.0.0" 7 | AUTHOR = "Jan Garaj" 8 | LICENSE = "GPLv3" 9 | NAMESPACE_PACKAGES = ['ZenPacks', 'ZenPacks.JanGaraj'] 10 | PACKAGES = ['ZenPacks', 'ZenPacks.JanGaraj', 'ZenPacks.JanGaraj.DataMirroring'] 11 | INSTALL_REQUIRES = [] 12 | COMPAT_ZENOSS_VERS = "" 13 | PREV_ZENPACK_NAME = "" 14 | # STOP_REPLACEMENTS 15 | ################################ 16 | # Zenoss will not overwrite any changes you make below here. 17 | 18 | import os 19 | from subprocess import Popen, PIPE 20 | from setuptools import setup, find_packages 21 | 22 | # Run "make build" if a GNUmakefile is present. 23 | if os.path.isfile('GNUmakefile'): 24 | print 'GNUmakefile found. Running "make build" ..' 25 | p = Popen('make build', stdout=PIPE, stderr=PIPE, shell=True) 26 | print p.communicate()[0] 27 | if p.returncode != 0: 28 | raise Exception('"make build" exited with an error: %s' % p.returncode) 29 | 30 | setup( 31 | # This ZenPack metadata should usually be edited with the Zenoss 32 | # ZenPack edit page. Whenever the edit page is submitted it will 33 | # overwrite the values below (the ones it knows about) with new values. 34 | name=NAME, 35 | version=VERSION, 36 | author=AUTHOR, 37 | license=LICENSE, 38 | 39 | # This is the version spec which indicates what versions of Zenoss 40 | # this ZenPack is compatible with 41 | compatZenossVers=COMPAT_ZENOSS_VERS, 42 | 43 | # previousZenPackName is a facility for telling Zenoss that the name 44 | # of this ZenPack has changed. If no ZenPack with the current name is 45 | # installed then a zenpack of this name if installed will be upgraded. 46 | prevZenPackName=PREV_ZENPACK_NAME, 47 | 48 | # Indicate to setuptools which namespace packages the zenpack 49 | # participates in 50 | namespace_packages=NAMESPACE_PACKAGES, 51 | 52 | # Tell setuptools what packages this zenpack provides. 53 | packages=find_packages(), 54 | 55 | # Tell setuptools to figure out for itself which files to include 56 | # in the binary egg when it is built. 57 | include_package_data=True, 58 | 59 | # The MANIFEST.in file is the recommended way of including additional files 60 | # in your ZenPack. package_data is another. 61 | #package_data = {} 62 | 63 | # Indicate dependencies on other python modules or ZenPacks. This line 64 | # is modified by zenoss when the ZenPack edit page is submitted. Zenoss 65 | # tries to put add/delete the names it manages at the beginning of this 66 | # list, so any manual additions should be added to the end. Things will 67 | # go poorly if this line is broken into multiple lines or modified to 68 | # dramatically. 69 | install_requires=INSTALL_REQUIRES, 70 | 71 | # Every ZenPack egg must define exactly one zenoss.zenpacks entry point 72 | # of this form. 73 | entry_points={ 74 | 'zenoss.zenpacks': '%s = %s' % (NAME, NAME), 75 | }, 76 | 77 | # All ZenPack eggs must be installed in unzipped form. 78 | zip_safe=False, 79 | ) 80 | -------------------------------------------------------------------------------- /ZenPacks/JanGaraj/DataMirroring/lib/collectd.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Source: https://collectd.googlecode.com/hg/collectd.py 3 | 4 | import re 5 | import time 6 | import socket 7 | import struct 8 | import logging 9 | import traceback 10 | from functools import wraps 11 | from Queue import Queue, Empty 12 | from collections import defaultdict 13 | from threading import RLock, Thread, Semaphore 14 | 15 | 16 | __all__ = ["Connection", "start_threads"] 17 | 18 | logger = logging.getLogger("collectd") 19 | 20 | SEND_INTERVAL = 10 # seconds 21 | MAX_PACKET_SIZE = 1024 # bytes 22 | 23 | PLUGIN_NAME = "any" 24 | PLUGIN_TYPE = "gauge" 25 | 26 | TYPE_HOST = 0x0000 27 | TYPE_TIME = 0x0001 28 | TYPE_PLUGIN = 0x0002 29 | TYPE_PLUGIN_INSTANCE = 0x0003 30 | TYPE_TYPE = 0x0004 31 | TYPE_TYPE_INSTANCE = 0x0005 32 | TYPE_VALUES = 0x0006 33 | TYPE_INTERVAL = 0x0007 34 | LONG_INT_CODES = [TYPE_TIME, TYPE_INTERVAL] 35 | STRING_CODES = [TYPE_HOST, TYPE_PLUGIN, TYPE_PLUGIN_INSTANCE, TYPE_TYPE, TYPE_TYPE_INSTANCE] 36 | 37 | VALUE_COUNTER = 0 38 | VALUE_GAUGE = 1 39 | VALUE_DERIVE = 2 40 | VALUE_ABSOLUTE = 3 41 | VALUE_CODES = { 42 | VALUE_COUNTER: "!Q", 43 | VALUE_GAUGE: " MAX_PACKET_SIZE: 91 | packets.append("".join(curr)) 92 | curr, curr_len = [start], len(start) 93 | curr.append(part) 94 | curr_len += len(part) 95 | packets.append("".join(curr)) 96 | return packets 97 | 98 | 99 | 100 | def sanitize(s): 101 | return re.sub(r"[^a-zA-Z0-9]+", "_", s).strip("_") 102 | 103 | def swallow_errors(func): 104 | @wraps(func) 105 | def wrapped(*args, **kwargs): 106 | try: 107 | return func(*args, **kwargs) 108 | except: 109 | try: 110 | logger.error("unexpected error", exc_info = True) 111 | except: 112 | pass 113 | return wrapped 114 | 115 | def synchronized(method): 116 | @wraps(method) 117 | def wrapped(self, *args, **kwargs): 118 | with self._lock: 119 | return method(self, *args, **kwargs) 120 | return wrapped 121 | 122 | class Counter(object): 123 | def __init__(self, category): 124 | self.category = category 125 | self._lock = RLock() 126 | self.counts = defaultdict(lambda: defaultdict(float)) 127 | 128 | @swallow_errors 129 | @synchronized 130 | def record(self, *args, **kwargs): 131 | for specific in list(args) + [""]: 132 | assert isinstance(specific, basestring) 133 | for stat, value in kwargs.items(): 134 | assert isinstance(value, (int, float)) 135 | self.counts[specific][stat] += value 136 | 137 | @swallow_errors 138 | @synchronized 139 | def set_exact(self, **kwargs): 140 | for stat, value in kwargs.items(): 141 | #logger.error("kwargs: %s" % kwargs.items()) 142 | #logger.error("xxx value: %s, stat: %s" % (value, stat)) 143 | assert isinstance(value, (int, float)) 144 | self.counts[""][stat] = value 145 | 146 | @synchronized 147 | def snapshot(self): 148 | totals = {} 149 | for specific,counts in self.counts.items(): 150 | for stat in counts: 151 | name_parts = map(sanitize, [self.category, specific, stat]) 152 | name = "-".join(name_parts).replace("--", "-") 153 | totals[name] = counts[stat] 154 | counts[stat] = 0.0 155 | return totals 156 | 157 | class Connection(object): 158 | _lock = RLock() # class-level lock, only used for __new__ 159 | instances = {} 160 | 161 | @synchronized 162 | def __new__(cls, hostname = socket.gethostname(), 163 | collectd_host = "localhost", collectd_port = 25826, 164 | plugin_inst = ""): 165 | id = (hostname, collectd_host, collectd_port, plugin_inst) 166 | if id in cls.instances: 167 | return cls.instances[id] 168 | else: 169 | inst = object.__new__(cls) 170 | cls.instances[id] = inst 171 | return inst 172 | 173 | def __init__(self, hostname = socket.gethostname(), 174 | collectd_host = "localhost", collectd_port = 25826, 175 | plugin_inst = ""): 176 | self._lock = RLock() 177 | self._counters = {} 178 | self._plugin_inst = plugin_inst 179 | self._hostname = hostname 180 | self._collectd_addr = (collectd_host, collectd_port) 181 | 182 | @synchronized 183 | def __getattr__(self, name): 184 | if name not in self._counters: 185 | self._counters[name] = Counter(name) 186 | return self._counters[name] 187 | 188 | @synchronized 189 | def _snapshot(self): 190 | return [c.snapshot() for c in self._counters.values() if c.counts] 191 | 192 | 193 | 194 | snaps = Queue() 195 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 196 | 197 | def take_snapshots(): 198 | for conn in Connection.instances.values(): 199 | snapshots = conn._snapshot() 200 | if snapshots: 201 | stats = {} 202 | for snapshot in snapshots: 203 | stats.update(snapshot) 204 | snaps.put([int(time.time()), stats, conn]) 205 | 206 | def send_stats(raise_on_empty = False): 207 | try: 208 | when, stats, conn = snaps.get(timeout = 0.1) 209 | for message in messages(stats, when, conn._hostname, conn._plugin_inst): 210 | sock.sendto(message, conn._collectd_addr) 211 | except Empty: 212 | if raise_on_empty: 213 | raise 214 | 215 | def daemonize(func, sleep_for = 0): 216 | @wraps(func) 217 | def wrapped(): 218 | while True: 219 | try: 220 | func() 221 | except: 222 | try: 223 | logger.error("unexpected error", exc_info = True) 224 | except: 225 | traceback.print_exc() 226 | time.sleep(sleep_for) 227 | 228 | t = Thread(target = wrapped) 229 | t.daemon = True 230 | t.start() 231 | 232 | single_start = Semaphore() 233 | def start_threads(): 234 | assert single_start.acquire(blocking = False) 235 | daemonize(take_snapshots, sleep_for = SEND_INTERVAL) 236 | daemonize(send_stats) 237 | -------------------------------------------------------------------------------- /ZenPacks/JanGaraj/DataMirroring/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | ** __init__.py - Monkey Patch for Products.ZenRRD.RRDUtil.RRDUtil 3 | ** Copyright (C) 2015 Jan Garaj - www.jangaraj.com 4 | ** 5 | ** This code goes into the __init__.py of a ZenPack. It patches the 6 | ** Products.ZenRRD.RRDUtil.RRDUtil.put() method. This allows 7 | ** executing custom code for every RRD update that's made. 8 | ** When you change a code, then zenprocess restart is required. 9 | ** Logs are stored in standard zenprocess log: /opt/zenoss/log/zenprocess.log 10 | ** 11 | ** This program is free software; you can redistribute it and/or modify 12 | ** it under the terms of the GNU General Public License as published by 13 | ** the Free Software Foundation; either version 2 of the License, or 14 | ** (at your option) any later version. 15 | ** 16 | ** This program is distributed in the hope that it will be useful, 17 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ** GNU General Public License for more details. 20 | ** 21 | ** You should have received a copy of the GNU General Public License 22 | ** along with this program; if not, write to the Free Software 23 | ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 24 | ''' 25 | 26 | from Products.ZenUtils.Utils import monkeypatch, rrd_daemon_running 27 | import thread, threading, time, logging 28 | from time import gmtime, strftime 29 | log = logging.getLogger("zen.RRDUtil") 30 | 31 | @monkeypatch('Products.ZenRRD.RRDUtil.RRDUtil') 32 | def put(self, path, value, rrdType, rrdCommand=None, cycleTime=None, 33 | min='U', max='U', useRRDDaemon=True, timestamp='N', start=None, 34 | allowStaleDatapoint=True): 35 | """ 36 | Save the value provided in the command to the RRD file specified in path. 37 | 38 | If the RRD file does not exist, use the rrdType, rrdCommand, min and 39 | max parameters to create the file. 40 | 41 | @param path: name for a datapoint in a path (eg device/component/datasource_datapoint) 42 | @type path: string 43 | @param value: value to store into the RRD file 44 | @type value: number 45 | @param rrdType: RRD data type (eg ABSOLUTE, DERIVE, COUNTER) 46 | @type rrdType: string 47 | @param rrdCommand: RRD file creation command 48 | @type rrdCommand: string 49 | @param cycleTime: length of a cycle 50 | @type cycleTime: number 51 | @param min: minimum value acceptable for this metric 52 | @type min: number 53 | @param max: maximum value acceptable for this metric 54 | @type max: number 55 | @param allowStaleDatapoint: attempt to write datapoint even if a newer datapoint has already been written 56 | @type allowStaleDatapoint: boolean 57 | @return: the parameter value converted to a number 58 | @rtype: number or None 59 | """ 60 | 61 | # run mirror task in separated thread, so it won't block RRD update 62 | thread = threading.Thread(target=self.mirror, args=(path, value)) 63 | thread.start() 64 | # imports and inits required for put() method 65 | import os 66 | import re 67 | import rrdtool 68 | import string 69 | from Products.ZenUtils.Utils import zenPath, rrd_daemon_args, rrd_daemon_retry 70 | EMPTY_RRD = zenPath('perf', 'empty.rrd') 71 | _UNWANTED_CHARS = ''.join( 72 | set(string.punctuation + string.ascii_letters) - set(['.', '-', '+', 'e']) 73 | ) 74 | _LAST_RRDFILE_WRITE = {} 75 | 76 | # rest of original put() code - Zenoss 4.2.5 77 | if value is None: return None 78 | 79 | self.dataPoints += 1 80 | self.cycleDataPoints += 1 81 | 82 | if cycleTime is None: 83 | cycleTime = self.defaultCycleTime 84 | 85 | filename = self.performancePath(path) + '.rrd' 86 | if not rrdCommand: 87 | rrdCommand = self.defaultRrdCreateCommand 88 | if not os.path.exists(filename): 89 | log.debug("Creating new RRD file %s", filename) 90 | dirname = os.path.dirname(filename) 91 | if not os.path.exists(dirname): 92 | os.makedirs(dirname, 0750) 93 | 94 | min, max = map(_checkUndefined, (min, max)) 95 | dataSource = 'DS:%s:%s:%d:%s:%s' % ( 96 | 'ds0', rrdType, self.getHeartbeat(cycleTime), min, max) 97 | args = [str(filename), "--step", 98 | str(self.getStep(cycleTime)),] 99 | if start is not None: 100 | args.extend(["--start", "%d" % start]) 101 | elif timestamp != 'N': 102 | args.extend(["--start", str(int(timestamp) - 10)]) 103 | 104 | args.append(str(dataSource)) 105 | args.extend(rrdCommand.split()) 106 | rrdtool.create(*args), 107 | 108 | daemon_args = rrd_daemon_args() if useRRDDaemon else tuple() 109 | 110 | # remove unwanted chars (this is actually pretty quick) 111 | value = str(value).translate(None, _UNWANTED_CHARS) 112 | 113 | if rrdType in ('COUNTER', 'DERIVE'): 114 | try: 115 | # cast to float first because long('100.0') will fail with a 116 | # ValueError 117 | value = long(float(value)) 118 | except (TypeError, ValueError): 119 | return None 120 | else: 121 | try: 122 | value = float(value) 123 | except (TypeError, ValueError): 124 | return None 125 | try: 126 | @rrd_daemon_retry 127 | def rrdtool_fn(): 128 | return rrdtool.update(str(filename), *(daemon_args + ('%s:%s' % (timestamp, value),))) 129 | if timestamp == 'N' or allowStaleDatapoint: 130 | rrdtool_fn() 131 | else: 132 | # try to detect when the last datasample was collected 133 | lastTs = _LAST_RRDFILE_WRITE.get(filename, None) 134 | if lastTs is None: 135 | try: 136 | lastTs = _LAST_RRDFILE_WRITE[filename] = rrdtool.last( 137 | *(daemon_args + (str(filename),))) 138 | except Exception as ex: 139 | lastTs = 0 140 | log.exception("Could not determine last update to %r", filename) 141 | # if the current datapoint is newer than the last datapoint, then write 142 | if lastTs < timestamp: 143 | _LAST_RRDFILE_WRITE[filename] = timestamp 144 | if log.getEffectiveLevel() < logging.DEBUG: 145 | log.debug('%s: %r, currentTs = %s, lastTs = %s', filename, value, timestamp, lastTs) 146 | rrdtool_fn() 147 | else: 148 | if log.getEffectiveLevel() < logging.DEBUG: 149 | log.debug("ignoring write %s:%s", filename, timestamp) 150 | return None 151 | 152 | log.debug('%s: %r, @ %s', str(filename), value, timestamp) 153 | except rrdtool.error, err: 154 | # may get update errors when updating too quickly 155 | log.error('rrdtool reported error %s %s', err, path) 156 | 157 | return value 158 | 159 | @monkeypatch('Products.ZenRRD.RRDUtil.RRDUtil') 160 | def mirror(self, *args): 161 | # args example: 162 | # ('Devices/localhost/laLoadInt1_laLoadInt1', 3) 163 | # TODO implement thread execution timeout 164 | 165 | log.info('Mirroring thread %s starting %s' % (thread.get_ident(), args)) 166 | 167 | start_time = time.time() 168 | datetime = strftime("%Y-%m-%d %H:%M:%S", gmtime()) 169 | timestamp = int(round(time.time())) 170 | host = args[0].split('/')[1] 171 | metric = '.'.join(args[0].replace('Devices/', '').split('/')[1:]) 172 | log.info('Mirroring - host: %s, metric: %s, value: %s' % (host, metric, args[1])) 173 | 174 | ''' 175 | # insert data into file 176 | mirrorFile = "/tmp/zenoss_mirrored_data.txt" 177 | log.debug("Mirroring data into file %s", mirrorFile) 178 | try: 179 | text_file = open(mirrorFile, "a") 180 | text_file.write("%s\t%s\t%s\t%s\n" % (datetime, host, metric, args[1])) 181 | text_file.close() 182 | except Exception, e: 183 | log.error("Mirroring data into file: %s - exception: %s", mirrorFile, e) 184 | 185 | # insert data into MySQL/MariaDB - www.mysql.com/www.mariadb.org 186 | database = 'zenoss' 187 | db_host = '0.0.0.0' 188 | db_user = 'dbuser' 189 | db_password = 'dbpasswd' 190 | db_port = 3310 191 | import _mysql 192 | import sys 193 | try: 194 | con = _mysql.connect(host=db_host, user=db_user, passwd=db_password, port=db_port, db=database) 195 | query = "INSERT INTO zenoss (`insert_date`, `host`, `key`, `value`) " + \ 196 | "VALUES (\"" + datetime + "\", \"" + host + "\", \"zenoss." + metric + "\", \"" + str(args[1]) + "\")" 197 | con.query(query) 198 | log.debug("Mirroring MySQL query: %s", query) 199 | except Exception, e: 200 | log.error("Mirroring data into database: %s - error: %s", database, e) 201 | finally: 202 | if con: 203 | con.close() 204 | 205 | # send data to Carbon (Graphite) - www.graphite.wikidot.com 206 | # send data to Dataloop (Carbon) - www.dataloop.io 207 | # send data to InfluxDB (input_plugins.graphite) - www.influxdb.com 208 | carbon_server = '0.0.0.0' 209 | carbon_port = 2003 210 | carbon_timeout = 10 211 | import socket 212 | message = "zenoss.%s.%s %s %d\n" % (host,metric, args[1], int(timestamp)) 213 | log.debug("Mirroring to Carbon server (Graphite/Dataloop/InfluxDB) - message: %s", message) 214 | try: 215 | carbon = socket.socket() 216 | carbon.connect((carbon_server, carbon_port)) 217 | carbon.settimeout(carbon_timeout) 218 | carbon.sendall(message) 219 | except Exception, e: 220 | log.error('Error while sending data to Carbon: ' + str(e)) 221 | finally: 222 | carbon.close() 223 | 224 | # send data to Zabbix - www.zabbix.com 225 | # create Zabbix trapper item with relevant metric key 226 | zabbix_server = '0.0.0.0' 227 | zabbix_port = 10051 228 | zabbix_timeout = 10 229 | import socket 230 | import struct 231 | import json 232 | metrics_data = [] 233 | j = json.dumps 234 | metrics_data.append(('\t\t{\n' 235 | '\t\t\t"host":%s,\n' 236 | '\t\t\t"key":%s,\n' 237 | '\t\t\t"value":%s,\n' 238 | '\t\t\t"clock":%s}') % (j('zenoss'), j(metric), j(args[1]), int(timestamp))) 239 | json_data = ('{\n' 240 | '\t"request":"sender data",\n' 241 | '\t"data":[\n%s]\n' 242 | '}') % (',\n'.join(metrics_data)) 243 | log.debug(json_data) 244 | data_len = struct.pack(' 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /ZenPacks/JanGaraj/DataMirroring/LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | --------------------------------------------------------------------------------