예제 #1
0
    def get(self, host, chart_type):
        self.host = host
        self.chart_type = chart_type

        collection_perfdata = "nagios_host_perfdata"
        collection_hosts = "nagios_hosts"

        if not chart_type or not host:
            self.send_error(404)

        self.host = host
        self.chart_type = chart_type

        if chart_type == "4h":
            ago = get_four_hours_ago()
            frequency = 1
        elif chart_type == "24h":
            ago = get_one_day_ago()
            frequency = 1
        elif chart_type == "1w":
            ago = get_one_week_ago()
            frequency = 12
        elif chart_type == "1y":
            ago = get_one_year_ago()
        else:
            ago = None

        if chart_type != "1y":
            if ago:
                cursor = DB.nagios_hosts.find({"host_address": host})
                yield cursor.fetch_next
                result = cursor.next_object()

                object_id = result['object_id']
                cursor = DB.nagios_host_perfdata.find({
                    "object_id": object_id,
                    "timestamp": {
                        "$gte": ago
                    }
                })

                yield parse_perfdata(cursor, frequency, self.on_parse_finished)
            else:
                self.send_error(500)
        else:
            pass
예제 #2
0
    def get(self, host, service, chart_type):
        self.host = host
        self.chart_type = chart_type

        if not chart_type or not host or not service:
            self.send_error(404)

        self.host_address = host
        self.chart_type = chart_type
        self.service_object_id = bson.ObjectId(service)

        cursor = DB.nagios_services.find({"object_id": self.service_object_id})
        yield cursor.fetch_next
        self.service_name = cursor.next_object()['service_description']

        if chart_type == "4h":
            ago = get_four_hours_ago()
            frequency = 1
        elif chart_type == "24h":
            ago = get_one_day_ago()
            frequency = 1
        elif chart_type == "1w":
            ago = get_one_week_ago()
            frequency = 12
        elif chart_type == "1y":
            ago = get_one_year_ago()
        else:
            ago = None

        if chart_type != "1y":
            if ago:
                cursor = DB.nagios_service_perfdata.find({
                    "object_id": self.service_object_id,
                    "timestamp": {
                        "$gte": ago
                    }
                })

                yield parse_perfdata(cursor, frequency, self.on_parse_finished)
            else:
                self.send_error(500)
        else:
            pass
예제 #3
0
파일: views.py 프로젝트: jsoyee/wisemonitor
 def get(self, host, chart_type):
     self.host = host
     self.chart_type = chart_type
     
     collection_perfdata = "nagios_host_perfdata"
     collection_hosts = "nagios_hosts"
     
     if not chart_type or not host:
         self.send_error(404)
     
     self.host = host
     self.chart_type = chart_type
     
     if chart_type == "4h":
         ago = get_four_hours_ago()
         frequency = 1
     elif chart_type == "24h":
         ago = get_one_day_ago()
         frequency = 1
     elif chart_type == "1w":
         ago = get_one_week_ago()
         frequency = 12
     elif chart_type == "1y":
         ago = get_one_year_ago()
     else:
         ago = None
     
     if chart_type != "1y":
         if ago:
             cursor = DB.nagios_hosts.find({"host_address": host})
             yield cursor.fetch_next
             result = cursor.next_object()
             
             object_id = result['object_id']
             cursor = DB.nagios_host_perfdata.find({"object_id": object_id, "timestamp": {"$gte": ago}})
         
             yield parse_perfdata(cursor, frequency, self.on_parse_finished)
         else:
             self.send_error(500)
     else:
         pass
예제 #4
0
파일: views.py 프로젝트: jsoyee/wisemonitor
 def get(self, host, service, chart_type):
     self.host = host
     self.chart_type = chart_type
     
     if not chart_type or not host or not service:
         self.send_error(404)
     
     self.host_address = host
     self.chart_type = chart_type
     self.service_object_id = bson.ObjectId(service)
     
     cursor = DB.nagios_services.find({"object_id": self.service_object_id})
     yield cursor.fetch_next
     self.service_name = cursor.next_object()['service_description']
     
     if chart_type == "4h":
         ago = get_four_hours_ago()
         frequency = 1
     elif chart_type == "24h":
         ago = get_one_day_ago()
         frequency = 1
     elif chart_type == "1w":
         ago = get_one_week_ago()
         frequency = 12
     elif chart_type == "1y":
         ago = get_one_year_ago()
     else:
         ago = None
     
     if chart_type != "1y":
         if ago:
             cursor = DB.nagios_service_perfdata.find({"object_id": self.service_object_id, "timestamp": {"$gte": ago}})
         
             yield parse_perfdata(cursor, frequency, self.on_parse_finished)
         else:
             self.send_error(500)
     else:
         pass