Example #1
0
    def get_data(self):
        try:
            agent_data = get_agent_info(agent_id)
            agent_data[AgentKey.LastAgentUpdate] = (
                int(agent_data[AgentKey.LastAgentUpdate].strftime('%s'))
            )
            if agent_data:
                agent_data['tags'] = get_tags_by_agent_id(agent_id=self.agent_id)
                agent_data[CommonAppKeys.BASIC_RV_STATS] = (
                    get_all_app_stats_by_agentid(self.agent_id)
                )
                status = (
                    GenericResults(
                        self.username, uri, method
                        ).information_retrieved(agent_data, 1)
                )
                logger.info(status['message'])
            else:
                status = (
                    GenericResults(
                        self.username, uri, method
                        ).invalid_id(self.agent_id, 'agent_id')
                )
                logger.info(status['message'])

        except Exception as e:
            agent_data = None
            status = (
                GenericResults(
                    self.username, uri, method
                ).something_broke(self.agent_id, 'agents', e)
            )
            logger.error(status['message'])

        return(status)
Example #2
0
def get_all_agentids(username,
                     customer_name,
                     count=30,
                     offset=0,
                     uri=None,
                     method=None,
                     conn=None):

    try:
        count = (r.table(AgentsCollection).get_all(
            customer_name, index=AgentKey.CustomerName).count().run(conn))

        data = list(
            r.table(AgentsCollection).get_all(
                customer_name,
                index=AgentKey.CustomerName).pluck(AgentKey.AgentId).order_by(
                    AgentKey.ComputerName).skip(offset).limit(count).run(conn))

        if data:
            for agent in data:
                agent[BASIC_RV_STATS] = (get_all_app_stats_by_agentid(
                    agent[AgentKey.AgentId]))
        status = (GenericResults(username, uri,
                                 method).information_retrieved(data, count))
        logger.info(status['message'])

    except Exception as e:
        status = (GenericResults(username, uri, method).something_broke(
            'get_all_agents', 'agent', e))
        return (status)
Example #3
0
def get_all_agentids(username, customer_name, count=30, offset=0, 
        uri=None, method=None, conn=None):

    try:
        count = (
                r
                .table(AgentsCollection)
                .get_all(customer_name, index=AgentKey.CustomerName)
                .count()
                .run(conn)
                )

        data = list(
                r
                .table(AgentsCollection)
                .get_all(customer_name, index=AgentKey.CustomerName)
                .pluck(AgentKey.AgentId)
                .order_by(AgentKey.ComputerName)
                .skip(offset)
                .limit(count)
                .run(conn)
            )

        if data:
            for agent in data:
                agent[BASIC_RV_STATS] = (
                    get_all_app_stats_by_agentid(agent[AgentKey.AgentId])
                )
        status = (
                GenericResults(
                    username,  uri, method
                    ).information_retrieved(data, count)
                )
        logger.info(status['message'])
    
    except Exception as e:
        status = (
                GenericResults(
                    username,  uri, method
                    ).something_broke('get_all_agents', 'agent', e)
                )
        return(status)