コード例 #1
0
ファイル: __init__.py プロジェクト: badele/mksensors
    def startSensor(self):
        # Get hostnames list
        self.logger.debug("Start the sensor")
        while True:
            # Ping for all hostnames
            for hostname in self.hostnames:

                self.logger.debug("Check if the %(hostname)s is up" % locals())

                # Test connexion
                rping = ping.ping(destination=hostname)
                rping.run()
                result = deepcopy(rping.results)
                result["sensorname"] = self.sensorname
                result["hostname"] = hostname.replace(".", "_")

                # return value
                values = []
                datasource = (hostname, "isup")
                value = result["result"]
                values.append((datasource, value, mks.getTimestamp()))

                isup = "Yes" if value == 255 else "No"
                self.logger.debug("The %(hostname)s is up => %(isup)s" % locals())

                self.sendValues(values)

            # Sleep
            stepinterval = int(self.mksconfig.get("stepinterval", 15))
            self.flushMessages()
            self.logger.debug("Sleep for %(stepinterval)s seconds" % locals())
            time.sleep(stepinterval)
コード例 #2
0
ファイル: __init__.py プロジェクト: badele/mksensors
    def startSensor(self):

        # Set default parameters
        hostnames = self.config.get('hostnames', [])

        # Set datasource list
        datasources = []
        for hostname in hostnames:
            for filtered in self.filtered_ds:
                dsnames = (hostname, filtered)
                datasources.append(dsnames)

        self.logger.debug('Start the sensor')
        while True:
            # Ping for all hostnames
            for hostname in hostnames:
                self.logger.debug('Ping %(hostname)s' % locals())

                # Test connexion
                rping = ping.ping(destination=hostname)
                rping.run()
                result = deepcopy(rping.results)
                result['sensorname'] = self.sensorname
                result['hostname'] = hostname.replace('.', '_')

                # return value
                values = []
                for filtered in self.filtered_ds:
                    datasource = (hostname, filtered)
                    value = result[filtered]
                    values.append((datasource, value, mks.getTimestamp()))

                avg_rtt = result['avg_rtt']
                self.logger.debug(
                    'ping result for %(hostname)s => %(avg_rtt)s ms' %
                    locals())

                self.sendValues(values)

            # Sleep
            stepinterval = int(self.mksconfig.get('stepinterval', 15))
            self.flushMessages()
            self.logger.debug('Sleep for %(stepinterval)s seconds' % locals())
            time.sleep(stepinterval)
コード例 #3
0
ファイル: __init__.py プロジェクト: badele/mksensors
    def startSensor(self):

        # Set default parameters
        hostnames = self.config.get('hostnames', [])

        # Set datasource list
        datasources = []
        for hostname in hostnames:
            for filtered in self.filtered_ds:
                dsnames = (hostname, filtered)
                datasources.append(dsnames)

        self.logger.debug('Start the sensor')
        while True:
            # Ping for all hostnames
            for hostname in hostnames:
                self.logger.debug('Ping %(hostname)s' % locals())

                # Test connexion
                rping = ping.ping(destination=hostname)
                rping.run()
                result = deepcopy(rping.results)
                result['sensorname'] = self.sensorname
                result['hostname'] = hostname.replace('.', '_')

                # return value
                values = []
                for filtered in self.filtered_ds:
                    datasource = (hostname, filtered)
                    value = result[filtered]
                    values.append((datasource, value, mks.getTimestamp()))

                avg_rtt = result['avg_rtt']
                self.logger.debug('ping result for %(hostname)s => %(avg_rtt)s ms' % locals())

                self.sendValues(values)

            # Sleep
            stepinterval = int(self.mksconfig.get('stepinterval', 15))
            self.flushMessages()
            self.logger.debug('Sleep for %(stepinterval)s seconds' % locals())
            time.sleep(stepinterval)