source: people/peter.buschman/backup_monitoring/backmon/commands/check/subcommands/puredisk.py@ 1071

Last change on this file since 1071 was 976, checked in by peter, on Dec 6, 2011 at 10:19:33 AM

Raw checkin of current NetBackup / TSM parsing code.

File size: 3.3 KB
Line 
1#!/usr/bin/python26
2###
3### backmon.commands.check.puredisk
4###
5
6import sys
7import os
8import os.path
9import glob
10import re
11
12from optparse import OptionParser
13
14from ....lib import *
15
16from backup_monitoring.debug import *
17from backup_monitoring.math import *
18
19from backup_monitoring.parsing.parsers import puredisk_status
20
21service_list = [
22 'ldap_server',
23 'vxatd_daemon',
24 'memory_cache_daemon',
25 'database_server',
26 'web_server',
27 'spa_authorization_service',
28 'controller',
29 'controller_monitor',
30 'server_agent',
31 'content_router',
32 'workflow_engine',
33 'metabase_engine',
34 'java_gui',
35 'cron_daemon',
36]
37
38usage = """usage: %prog -s [server] check puredisk [service]
39
40 available services:
41
42""" + '\n'.join([' %s' % (service) for service in service_list])
43
44parser = OptionParser(usage=usage)
45
46SERVICE_NAMES = {
47
48 'ldap_server' : 'LDAP-server',
49 'vxatd_daemon' : 'VxATd daemon',
50 'memory_cache_daemon' : 'PureDisk Memory Cache Daemon',
51 'database_server' : 'PureDisk Database Server',
52 'web_server' : 'PureDisk WebServer',
53 'spa_authorization_service' : 'PureDisk SPA Authorization Service',
54 'controller' : 'PureDisk Controller',
55 'controller_monitor' : 'PureDisk Controller Monitor',
56 'server_agent' : 'PureDisk Server Agent',
57 'content_router' : 'PureDisk ContentRouter',
58 'workflow_engine' : 'PureDisk Workflow Engine',
59 'metabase_engine' : 'PureDisk MetabaseEngine',
60 'java_gui' : 'PureDisk JAVA GUI',
61 'cron_daemon' : 'CRON daemon',
62 'test' : 'Test',
63
64}
65
66def run(args, kwargs):
67
68 #
69 # add kwargs to local namespace
70 #
71 for key in kwargs.keys():
72
73 if re.compile('^[A-Z][A-Z_]+$').match(key):
74 exec(key + ' = kwargs[\'' + key + '\']')
75
76 (options, args) = parser.parse_args(args)
77
78 if len(args) == 0:
79 ERROR('Must specify service!')
80 else:
81 SERVICE = args[0]
82
83 if not SERVER:
84 ERROR('Must specify puredisk server!')
85 sys.exit(1)
86
87 if SERVICE not in SERVICE_NAMES:
88 ERROR('Invalid service %s!' % (SERVICE))
89 sys.exit(1)
90
91 else:
92
93 updates = Updates(LOGGER, SERVER_PATH)
94
95 try:
96
97 SERVICE_NAME = SERVICE_NAMES[SERVICE]
98
99 stream = puredisk_status.stream(updates.feed('puredisk_status'))
100 status = puredisk_status.parse(stream.records()[0])
101 perfdata = ''
102
103 if SERVICE_NAME not in status:
104
105 print('PureDisk service "%s" not found in monitoring data!' % (SERVICE_NAME))
106 sys.exit(2)
107
108 elif SERVICE_NAME in status:
109
110 state = status[SERVICE_NAME]
111
112 if state == 'running':
113
114 print('OK: %s is running | %s' % (SERVICE_NAME, perfdata))
115 sys.exit(0)
116
117 else:
118
119 print('%s is %s | %s' % (SERVICE_NAME, state, perfdata))
120 sys.exit(2)
121
122 else:
123
124 print('Unknown error! | %s' % (perfdata))
125 sys.exit(3)
126
127 except Exception, e:
128
129 raise
130
Note: See TracBrowser for help on using the repository browser.