Beispiel #1
0
#!/usr/bin/env python2

import sys, subprocess
from nacoma.hooks import Change

reportable_types = ['host', 'service', 'hostgroup', 'servicegroup']

for line in sys.stdin:
    change = Change(line)
    if change.type not in reportable_types:
        continue
    if change.is_renamed():
        output = subprocess.Popen(['/usr/bin/php', '/opt/monitor/op5/ninja/index.php', 'cli/handle_rename/%s/%s/%s' % (change.type, change.oldname, change.newname)], stdout=subprocess.PIPE).communicate()[0]
    elif change.is_deleted():
        output = subprocess.Popen(['/usr/bin/php', '/opt/monitor/op5/ninja/index.php', 'cli/handle_deletion/%s/%s' % (change.type, change.oldname)], stdout=subprocess.PIPE).communicate()[0]
Beispiel #2
0
#!/usr/bin/env python

import sys
from nacoma.hooks import Change
reportable_types = ['host', 'service']

libexec_dir = "@@LIBEXECDIR@@/mon/modules"
sys.path.insert(0, libexec_dir)
import merlin_conf as mconf
mconf.parse()
import merlin_db
conn = merlin_db.connect(mconf)
cursor = conn.cursor()

for line in sys.stdin:
    change = Change(line)
    if change.type not in reportable_types:
        continue
    if change.is_renamed():
        if change.type == 'host':
            arg = (change.oldname, change.newname)
            query = 'INSERT INTO rename_log(from_host_name, from_service_description, to_host_name, to_service_description) VALUES (%s, NULL, %s, NULL)'
            cursor.execute(query, arg)
        else:
            arg = change.oldname.split(';') + change.newname.split(';')
            query = 'INSERT INTO rename_log(from_host_name, from_service_description, to_host_name, to_service_description) VALUES (%s, %s, %s, %s)'
            cursor.execute(query, arg)
conn.commit()
conn.close()
Beispiel #3
0
#!/usr/bin/env python

import sys, subprocess
from nacoma.hooks import Change

reportable_types = ['host', 'service', 'hostgroup', 'servicegroup']

for line in sys.stdin:
    change = Change(line)
    if change.type not in reportable_types:
        continue
    if change.is_renamed():
        output = subprocess.Popen(['/usr/bin/php', '/opt/monitor/op5/ninja/index.php', 'cli/handle_rename/%s/%s/%s' % (change.type, change.oldname, change.newname)], stdout=subprocess.PIPE).communicate()[0]
    elif change.is_deleted():
        output = subprocess.Popen(['/usr/bin/php', '/opt/monitor/op5/ninja/index.php', 'cli/handle_deletion/%s/%s' % (change.type, change.oldname)], stdout=subprocess.PIPE).communicate()[0]
Beispiel #4
0
import merlin_conf as mconf
mconf.parse()
import merlin_db
conn = merlin_db.connect(mconf)
cursor = conn.cursor()

# this terrible kludge is required because merlin_db gives us no way to access the database module
mysqlparamstyle = 'format'
oracleparamstyle = 'named'
if 'Oracle' in str(type(conn)):
    paramstyle = oracleparamstyle
else:
    paramstyle = mysqlparamstyle

for line in sys.stdin:
    change = Change(line)
    if change.type not in reportable_types:
        continue
    if change.is_renamed():
        if change.type == 'host':
            arg = (change.oldname, change.newname)
            if paramstyle == 'named':
                arg = dict(zip(('oldhost', 'newhost'), arg))
                query = 'INSERT INTO rename_log(from_host_name, from_service_description, to_host_name, to_service_description) VALUES (:oldhost, NULL, :newhost, NULL)'
            elif paramstyle == 'format':
                query = 'INSERT INTO rename_log(from_host_name, from_service_description, to_host_name, to_service_description) VALUES (%s, NULL, %s, NULL)'
            cursor.execute(query, arg)
        else:
            arg = change.oldname.split(';') + change.newname.split(';')
            if paramstyle == 'named':
                arg = dict(zip(('oldhost', 'oldservice', 'newhost', 'newservice'), arg))