Beispiel #1
0
    def test_016_hddsmart(self):
        """Check hard disk SMART data plugin."""
        try:
            from glances.compat import is_admin
        except ImportError:
            print(
                "INFO: [TEST_016] pySMART not found, not running SMART plugin test"
            )
            return

        stat = 'DeviceName'
        print('INFO: [TEST_016] Check SMART stats: {}'.format(stat))
        stats_grab = stats.get_plugin('smart').get_raw()
        if not is_admin():
            print("INFO: Not admin, SMART list should be empty")
            assert len(stats_grab) == 0
        elif stats_grab == {}:
            print("INFO: Admin but SMART list is empty")
            assert len(stats_grab) == 0
        else:
            print(stats_grab)
            self.assertTrue(stat in stats_grab[0].keys(),
                            msg='Cannot find key: %s' % stat)

        print('INFO: SMART stats: %s' % stats_grab)
Beispiel #2
0
    def __init__(self, args=None, config=None, stats_init_value=[]):
        """Init the plugin."""
        # check if user is admin
        if not is_admin():
            disable(args, "smart")
            logger.debug(
                "Current user is not admin, HDD SMART plugin disabled.")

        super(Plugin, self).__init__(args=args, config=config)

        # We want to display the stat in the curse interface
        self.display_curse = True