Example #1
0
    def _is_boot_up(self):
        """Checks whether if the agent is coming up because of a reboot or not.

        Returns:
            (bool) True if system boot up detected, False otherwise.
        """

        current_uptime = systeminfo.uptime()
        boot_up = 'no'

        try:
            if os.path.exists(self._uptime_file):

                with open(self._uptime_file, 'r') as f:
                    file_uptime = f.read()

                    if current_uptime < long(file_uptime):

                        boot_up = 'yes'

        except Exception as e:

            logger.error("Could not verify system bootup.")
            logger.exception(e)

        return boot_up
Example #2
0
    def _is_boot_up(self):
        """Checks whether if the agent is coming up because of a reboot or not.

        Returns:
            (bool) True if system boot up detected, False otherwise.
        """

        current_uptime = systeminfo.uptime()
        boot_up = 'no'

        try:
            if os.path.exists(self._uptime_file):

                with open(self._uptime_file, 'r') as f:
                    file_uptime = f.read()

                    if current_uptime < long(file_uptime):

                        boot_up = 'yes'

        except Exception as e:

            logger.error("Could not verify system bootup.")
            logger.exception(e)

        return boot_up
Example #3
0
    def _save_uptime(self):
        """Saves the current uptime to a simple text file in seconds.

        Returns:
            Nothing
        """

        uptime = systeminfo.uptime()

        if os.path.exists(self._uptime_file):
            os.remove(self._uptime_file)

        with open(self._uptime_file, 'w') as f:
            f.write(str(uptime))
Example #4
0
    def _save_uptime(self):
        """Saves the current uptime to a simple text file in seconds.

        Returns:
            Nothing
        """

        uptime = systeminfo.uptime()

        if os.path.exists(self._uptime_file):
            os.remove(self._uptime_file)

        with open(self._uptime_file, 'w') as f:
            f.write(str(uptime))