Ejemplo n.º 1
0
    def collect(self, config):
        log.debug('{0}:Start Collection of IIS Sites'.format(config.id))
        ds0 = config.datasources[0]
        conn_info = createConnectionInfo(ds0)

        wql_iis6 = 'select name, ServerAutoStart from IIsWebServerSetting'.format(
            ds0.params['statusname'])

        wql_iis7 = 'select name, ServerAutoStart from Site'.format(
            ds0.params['statusname'])

        winrm = EnumerateClient(conn_info)
        queries = {
            create_enum_info(wql=wql_iis6, resource_uri=RESOURCE_URI_IIS6):
            'iis6',
            create_enum_info(wql=wql_iis7, resource_uri=RESOURCE_URI_IIS7):
            'iis7'
        }
        query_results = yield winrm.do_collect(queries.iterkeys())
        winrm_results = {}
        for info, data in query_results.iteritems():
            winrm_results[queries[info]] = data
        log.debug(queries)
        winrs = IISCommander(conn_info)
        winrs_results = yield winrs.get_app_pool_status()
        defer.returnValue((winrm_results, winrs_results))
    def collect(self, config):
        log.debug('{0}:Start Collection of IIS Sites'.format(config.id))
        ds0 = config.datasources[0]

        wql_iis6 = 'select ServerAutoStart from IIsWebServerSetting where name="{0}"'.format(
            ds0.params['statusname'])

        wql_iis7 = 'select ServerAutoStart from Site where name="{0}"'.format(
            ds0.params['statusname'])

        WinRMQueries = [
            create_enum_info(wql=wql_iis6, resource_uri=resource_uri_iis6),
            create_enum_info(wql=wql_iis7, resource_uri=resource_uri_iis7),
            ]

        conn_info = createConnectionInfo(ds0)
        winrm = WinrmCollectClient()
        results = None
        try:
            results = yield winrm.do_collect(conn_info, WinRMQueries)
        except Exception as e:
            log.error("IISSiteDataSource error on %s: %s",
                    config.id,
                    e)
        log.debug(WinRMQueries)
        defer.returnValue(results)
    def collect(self, config):

        ds0 = config.datasources[0]

        # build dictionary of datasource service info
        self.buildServicesDict(config.datasources)

        run_query = False
        for ds in config.datasources:
            id = ds.params['servicename']
            svc_data = self.services.get(id)
            if svc_data.get('manual') or len(svc_data.get('modes',[])) > 0:
                run_query = True
                break

        # no need to run query
        if not run_query:
            log.warn('No startmodes defined in {} and not manually monitored.  Terminating datasource collection.'.format(ds0.datasource))
            defer.returnValue(None)

        log.debug('{0}:Start Collection of Services'.format(config.id))

        WinRMQueries = [
            create_enum_info(
                'select name, state, status, displayname from Win32_Service'
            )
        ]

        conn_info = createConnectionInfo(ds0)

        winrm = WinrmCollectClient()
        results = yield winrm.do_collect(conn_info, WinRMQueries)
        log.debug(WinRMQueries)

        defer.returnValue(results)
Ejemplo n.º 4
0
    def collect(self, config):

        log.info('{0}:Start Collection of Services'.format(config.id))
        ds0 = config.datasources[0]

        scheme = ds0.zWinScheme
        port = int(ds0.zWinRMPort)
        auth_type = 'kerberos' if '@' in ds0.zWinRMUser else 'basic'
        connectiontype = 'Keep-Alive'
        keytab = ds0.zWinKeyTabFilePath
        dcip = ds0.zWinKDC

        servicename = ds0.params['servicename']

        WinRMQueries = [
            create_enum_info('select name, state, status, displayname'\
             ' from Win32_Service where name = "{0}"'.format(servicename))]

        conn_info = ConnectionInfo(ds0.manageIp, auth_type, ds0.zWinRMUser,
                                   ds0.zWinRMPassword, scheme, port,
                                   connectiontype, keytab, dcip)
        winrm = WinrmCollectClient()
        results = yield winrm.do_collect(conn_info, WinRMQueries)
        log.debug(WinRMQueries)

        defer.returnValue(results)
    def collect(self, config):

        log.info('{0}:Start Collection of Services'.format(config.id))
        ds0 = config.datasources[0]

        scheme = ds0.zWinScheme
        port = int(ds0.zWinRMPort)
        auth_type = 'kerberos' if '@' in ds0.zWinRMUser else 'basic'
        connectiontype = 'Keep-Alive'
        keytab = ds0.zWinKeyTabFilePath
        dcip = ds0.zWinKDC

        servicename = ds0.params['servicename']

        WinRMQueries = [
            create_enum_info('select name, state, status, displayname'\
             ' from Win32_Service where name = "{0}"'.format(servicename))]

        conn_info = ConnectionInfo(
            ds0.manageIp,
            auth_type,
            ds0.zWinRMUser,
            ds0.zWinRMPassword,
            scheme,
            port,
            connectiontype,
            keytab,
            dcip)
        winrm = WinrmCollectClient()
        results = yield winrm.do_collect(conn_info, WinRMQueries)
        log.debug(WinRMQueries)

        defer.returnValue(results)
Ejemplo n.º 6
0
    def collect(self, config):
        log.debug('{0}:Start Collection of IIS Sites'.format(config.id))
        ds0 = config.datasources[0]
        conn_info = createConnectionInfo(ds0)

        wql_iis6 = 'select ServerAutoStart from IIsWebServerSetting where name="{0}"'.format(
            ds0.params['statusname'])

        wql_iis7 = 'select ServerAutoStart from Site where name="{0}"'.format(
            ds0.params['statusname'])

        iis_version = ds0.params['iis_version']

        if not iis_version:
            winrs = IISCommander(conn_info)
            version = yield winrs.get_iis_version()
            # version should be in 'Version x.x' format
            # 7 and above use the same namespace/query
            try:
                iis_version = re.match('Version (\d).*',
                                       version.stdout[0]).group(1)
            except (IndexError, AttributeError):
                if version.stdout:
                    log.error("Malformed version information: {}".format(
                        version.stdout[0]))
                if version.stderr:
                    log.error("Error retrieving IIS Version: {}".format(
                        version.stderr[0]))
                defer.returnValue(None)

        if iis_version == 6:
            WinRMQueries = [
                create_enum_info(wql=wql_iis6, resource_uri=resource_uri_iis6)
            ]
        else:
            WinRMQueries = [
                create_enum_info(wql=wql_iis7, resource_uri=resource_uri_iis7)
            ]

        winrm = WinrmCollectClient()
        results = yield winrm.do_collect(conn_info, WinRMQueries)
        log.debug(WinRMQueries)
        defer.returnValue(results)
    def collect(self, config):
        log.debug('{0}:Start Collection of IIS Sites'.format(config.id))
        ds0 = config.datasources[0]
        conn_info = createConnectionInfo(ds0)

        wql_iis6 = 'select ServerAutoStart from IIsWebServerSetting where name="{0}"'.format(
            ds0.params['statusname'])

        wql_iis7 = 'select ServerAutoStart from Site where name="{0}"'.format(
            ds0.params['statusname'])

        iis_version = ds0.params['iis_version']

        if not iis_version:
            winrs = IISCommander(conn_info)
            version = yield winrs.get_iis_version()
            # version should be in 'Version x.x' format
            # 7 and above use the same namespace/query
            try:
                iis_version = re.match('Version (\d).*', version.stdout[0]).group(1)
            except (IndexError, AttributeError):
                if version.stdout:
                    log.error("Malformed version information: {}".format(version.stdout[0]))
                if version.stderr:
                    log.error("Error retrieving IIS Version: {}".format(version.stderr[0]))
                defer.returnValue(None)

        if iis_version == 6:
            WinRMQueries = [create_enum_info(wql=wql_iis6, resource_uri=resource_uri_iis6),]
        else:
            WinRMQueries = [create_enum_info(wql=wql_iis7, resource_uri=resource_uri_iis7),]

        winrm = WinrmCollectClient()
        results = None
        try:
            results = yield winrm.do_collect(conn_info, WinRMQueries)
        except Exception as e:
            log.error("IISSiteDataSource error on %s: %s",
                    config.id,
                    e)
        log.debug(WinRMQueries)
        defer.returnValue(results)
    def collect(self, config):
        log.debug('{0}:Start Collection of IIS Sites'.format(config.id))
        ds0 = config.datasources[0]

        wql_iis6 = 'select ServerAutoStart from IIsWebServerSetting where name="{0}"'.format(
            ds0.params['statusname'])

        wql_iis7 = 'select ServerAutoStart from Site where name="{0}"'.format(
            ds0.params['statusname'])

        WinRMQueries = [
            create_enum_info(wql=wql_iis6, resource_uri=resource_uri_iis6),
            create_enum_info(wql=wql_iis7, resource_uri=resource_uri_iis7),
            ]

        conn_info = createConnectionInfo(ds0)
        winrm = WinrmCollectClient()
        results = yield winrm.do_collect(conn_info, WinRMQueries)
        log.debug(WinRMQueries)

        defer.returnValue(results)
Ejemplo n.º 9
0
    def collect(self, config):

        log.debug('{0}:Start Collection of Services'.format(config.id))

        WinRMQueries = [
            create_enum_info(
                'select name, state, status, displayname from Win32_Service')
        ]

        conn_info = createConnectionInfo(config.datasources[0])

        winrm = WinrmCollectClient()
        results = yield winrm.do_collect(conn_info, WinRMQueries)

        defer.returnValue(results)
Ejemplo n.º 10
0
    def collect(self, config):

        ds0 = config.datasources[0]

        log.debug('{0}:Start WinRM connection test.'.format(config.id))

        conn_info = createConnectionInfo(ds0)

        WinRMQueries = [
            create_enum_info('select * from Win32_OperatingSystem')
        ]

        winrm = EnumerateClient(conn_info)
        results = yield winrm.do_collect(WinRMQueries)

        defer.returnValue(results)
    def collect(self, config):

        ds0 = config.datasources[0]

        log.debug('{0}:Start WinRM connection test.'.format(config.id))

        conn_info = createConnectionInfo(ds0)

        WinRMQueries = [
            create_enum_info(
                'select * from Win32_OperatingSystem'
            )
        ]

        winrm = WinrmCollectClient()
        results = yield winrm.do_collect(conn_info, WinRMQueries)

        defer.returnValue(results)
Ejemplo n.º 12
0
    def collect(self, config):

        log.info('{0}:Start Collection of Services'.format(config.id))
        ds0 = config.datasources[0]

        servicename = ds0.params['servicename']

        WinRMQueries = [
            create_enum_info(
                'select name, state, status, displayname'
                ' from Win32_Service where name = "{0}"'.format(servicename))
        ]

        conn_info = createConnectionInfo(ds0)

        winrm = WinrmCollectClient()
        results = yield winrm.do_collect(conn_info, WinRMQueries)
        log.debug(WinRMQueries)

        defer.returnValue(results)
    def collect(self, config):

        ds0 = config.datasources[0]

        servicename = ds0.params['servicename']
        log.debug('{0}:Start Collection of Service {1}'.format(config.id, servicename))

        WinRMQueries = [
            create_enum_info(
                'select name, state, status, displayname'
                ' from Win32_Service where name = "{0}"'.format(servicename)
            )
        ]

        conn_info = createConnectionInfo(ds0)

        winrm = WinrmCollectClient()
        results = yield winrm.do_collect(conn_info, WinRMQueries)
        log.debug(WinRMQueries)

        defer.returnValue(results)
Ejemplo n.º 14
0
    def collect(self, config):

        log.debug('{0}:Start Collection of Services'.format(config.id))

        WinRMQueries = [
            create_enum_info(
                'select name, state, status, displayname from Win32_Service'
            )
        ]

        conn_info = createConnectionInfo(config.datasources[0])

        winrm = EnumerateClient(conn_info)
        try:
            results = yield winrm.do_collect(WinRMQueries)
        except Exception as e:
            if 'referenced context has expired' in e.message:
                results = yield winrm.do_collect(WinRMQueries)
            else:
                raise

        defer.returnValue(results)
    def collect(self, config):
        log.debug("{0}:Start Collection of IIS Sites".format(config.id))
        ds0 = config.datasources[0]
        scheme = ds0.zWinScheme
        port = int(ds0.zWinRMPort)
        auth_type = "kerberos" if "@" in ds0.zWinRMUser else "basic"
        connectiontype = "Keep-Alive"
        keytab = ds0.zWinKeyTabFilePath
        dcip = ds0.zWinKDC

        wql = 'select ServerAutoStart from IIsWebServerSetting where name="{0}"'.format(ds0.params["statusname"])

        WinRMQueries = [create_enum_info(wql=wql, resource_uri=resource_uri)]

        conn_info = ConnectionInfo(
            ds0.manageIp, auth_type, ds0.zWinRMUser, ds0.zWinRMPassword, scheme, port, connectiontype, keytab, dcip
        )
        winrm = WinrmCollectClient()
        results = yield winrm.do_collect(conn_info, WinRMQueries)
        log.debug(WinRMQueries)

        defer.returnValue(results)
    def collect(self, config):

        ds0 = config.datasources[0]

        if ds0.params['startmode'] == 'None':
            log.debug('No startmodes defined in {}.  Terminating datasource collection.'.format(ds0.datasource))
            defer.returnValue(None)

        log.debug('{0}:Start Collection of Services'.format(config.id))

        WinRMQueries = [
            create_enum_info(
                'select name, state, status, displayname from Win32_Service'
            )
        ]

        conn_info = createConnectionInfo(ds0)

        winrm = WinrmCollectClient()
        results = yield winrm.do_collect(conn_info, WinRMQueries)
        log.debug(WinRMQueries)

        defer.returnValue(results)
Ejemplo n.º 17
0
    def collect(self, config):
        log.debug('{0}:Start Collection of IIS Sites'.format(config.id))
        ds0 = config.datasources[0]
        scheme = ds0.zWinScheme
        port = int(ds0.zWinRMPort)
        auth_type = 'kerberos' if '@' in ds0.zWinRMUser else 'basic'
        connectiontype = 'Keep-Alive'
        keytab = ds0.zWinKeyTabFilePath
        dcip = ds0.zWinKDC

        wql = 'select ServerAutoStart from IIsWebServerSetting where name="{0}"'.format(
            ds0.params['statusname'])

        WinRMQueries = [create_enum_info(wql=wql, resource_uri=resource_uri)]

        conn_info = ConnectionInfo(ds0.manageIp, auth_type, ds0.zWinRMUser,
                                   ds0.zWinRMPassword, scheme, port,
                                   connectiontype, keytab, dcip)
        winrm = WinrmCollectClient()
        results = yield winrm.do_collect(conn_info, WinRMQueries)
        log.debug(WinRMQueries)

        defer.returnValue(results)
Ejemplo n.º 18
0
 def run_query(self, conn_info, wql, log):
     self.winrm = EnumerateClient(conn_info)
     wql = create_enum_info(wql=wql, resource_uri=self.uri)
     result = yield self.winrm.do_collect([wql])
     defer.returnValue(result)
Ejemplo n.º 19
0
 def run_query(self, conn_info, wql, log):
     self.winrm = EnumerateClient(conn_info)
     wql = create_enum_info(wql=wql, resource_uri=self.uri)
     result = yield self.winrm.do_collect([wql])
     defer.returnValue(result)