Esempio n. 1
0
    def check(self):
        code, output = self.combined_output()

        if code == 0:
            print(
                utils.get_status_mark("HARDWARE", code) +
                "All hardware work fine.")
        else:
            print(
                utils.get_status_mark("HARDWARE", code) +
                "Modules with problems: " +
                ";".join(map(lambda x: x.split()[0], output[code])) + " | ")
        print('------\n'.join(output[code]).replace("|", ""))
        return code
Esempio n. 2
0
 def inner(*args, **kwargs):
     try:
         return func(*args, **kwargs)
     except requests.ConnectionError:
         code = 1  # set to warning status
         status_mark = utils.get_status_mark(sys.argv[-1:][0], code)
         first_line = ("ConnectionError occurred, "
                       "the array is offline or unreachable.")
         print(status_mark + first_line + " | ")
         return code
Esempio n. 3
0
    def check(self):
        all_status = ok, warning, critical, unknown = utils.get_all_status(
            self.memory_modules)
        code = utils.max_if_not_empty(ok + warning + critical + unknown,
                                      key=lambda i: i[0])
        code = code[0]
        status_mark = utils.get_status_mark("MEMORY MODULE", code)
        first_line = "Total memory modules #{}, Failed modules: {}".format(
            len(ok + warning + critical + unknown), [c[1] for c in critical])
        # Status line
        print(status_mark + first_line + " | ")

        # Failed details
        utils.print_if_failure(all_status[code], self.memory_modules)
        return code
Esempio n. 4
0
    def check(self):
        all_status = ok, warning, critical, unknown = utils.get_all_status(
            self.power_supplies)
        code = utils.max_if_not_empty(ok + warning + critical + unknown,
                                      key=lambda i: i[0])
        code = code[0]
        status_mark = utils.get_status_mark("POWER SUPPLY", code)
        first_line = "Total power supplies #{}, Failed supplies: {}".format(
            len(ok + warning + critical + unknown), [c[1] for c in critical])
        # Status line
        print(status_mark + first_line + " | ")

        # Failed details
        utils.print_if_failure(all_status[code], self.power_supplies)
        return code
Esempio n. 5
0
    def check(self):
        code = 0
        status_mark = utils.get_status_mark("SYSTEM", code)
        first_line = "Name: {}, MODEL: {}, VERSION: {}".format(
            self.unity.name, self.unity.model, self.unity.system_version)
        # Status line
        print(status_mark + first_line + " | ")

        # Performance detail
        for license in self.licenses:
            print("{}: Status={}, Reason={}".format(
                license.name, self.__class__.get_license_status(license),
                (None if not license.feature.reason
                 else license.feature.reason.description)
            ))
        return code
Esempio n. 6
0
    def check(self):
        all_status = ok, warning, critical, unknown = utils.get_all_status(
            self.luns)
        code = utils.max_if_not_empty(ok + warning + critical + unknown,
                                      key=lambda i: i[0])
        code = code[0]
        status_mark = utils.get_status_mark("LUN", code)
        first_line = "Total LUNs #{}, Failed LUNs: {}".format(
            len(ok + warning + critical + unknown), ', '.join(
                [utils.get_by_id(c[1], self.luns).name for c in critical]))
        # Status line
        print(status_mark + first_line + " | ")

        # Failed details
        utils.print_if_failure(all_status[code], self.luns)
        return code
Esempio n. 7
0
    def check(self):
        code = 0
        all_status = ok, warning, critical, unknown = utils.get_all_status(
            self.ssds)
        if len(self.ssds):
            code = utils.max_if_not_empty(ok + warning + critical + unknown,
                                          key=lambda i: i[0])
            code = code[0]
        status_mark = utils.get_status_mark("SSD", code)
        first_line = "Total SSDs #{}, Failed SSDs: {}".format(
            len(ok + warning + critical + unknown), [c[1] for c in critical])
        # Status line
        print(status_mark + first_line + " | ")

        # Failed details
        utils.print_if_failure(all_status[code], self.ssds)
        return code
Esempio n. 8
0
    def check(self):
        all_status = ok, warning, critical, unknown = utils.get_all_status(
            self.disks)
        code = utils.max_if_not_empty(ok + warning + critical + unknown,
                                      key=lambda i: i[0])
        code = code[0]
        status_mark = utils.get_status_mark("DISK", code)
        first_line = "Total Disks #{}, Failed Disks: {}, Hot spares: {}, " \
                     "Unbounded: {}".format(
                      len(ok + warning + critical + unknown),
                      [c[1] for c in critical], self.get_hot_spares(),
                      self.get_unbounded_disks())
        # Status line
        print(status_mark + first_line + " | ")

        # Failed details
        utils.print_if_failure(all_status[code], self.disks)
        return code
Esempio n. 9
0
    def check(self):
        all_status = ok, warning, critical, unknown = utils.get_all_status(
            self.sas_ports)
        code = utils.max_if_not_empty(ok + warning + critical + unknown,
                                      key=lambda i: i[0])
        code = code[0]
        status_mark = utils.get_status_mark("SAS_PORT", code)
        first_line = "Total SAS ports #{}, Failed ports(ID): {}".format(
            len(ok + warning + critical + unknown), [c[1] for c in critical])
        # Status line
        print(status_mark + first_line + " | ")

        # Failed details
        utils.print_if_failure(all_status[code], self.sas_ports)
        # Performance detail
        for port in self.sas_ports:
            print("{}: Link status={}, Current Speed={}".format(
                port.name, self.get_link_status(port),
                utils.format_enum(port.current_speed)))
        return code
Esempio n. 10
0
    def check(self):
        all_status = ok, warning, critical, unknown = utils.get_all_status(
            self.pools)
        code = utils.max_if_not_empty(ok + warning + critical + unknown,
                                      key=lambda i: i[0])
        code = code[0]
        status_mark = utils.get_status_mark("POOL", code)
        first_line = "Total POOLs #{}, Failed POOLs: {}".format(
            len(ok + warning + critical + unknown), ', '.join(
                [utils.get_by_id(c[1], self.pools).name for c in critical]))
        # Status line
        print(status_mark + first_line + " | ")

        # Failed details
        utils.print_if_failure(all_status[code], self.pools)
        # Performance detail
        for p in self.pools:
            print("{}: Total Cap={} GiB, "
                  "Available Cap={} GiB({:.2f}%) ".format(
                      p.name, utils.byte_to_GiB(p.size_total),
                      utils.byte_to_GiB(p.size_free),
                      (p.size_free / p.size_total) * 100))
        return code
Esempio n. 11
0
    def check(self):
        all_status = ok, warning, critical, unknown = utils.get_all_status(
            self.dae)
        code = utils.max_if_not_empty(ok + warning + critical + unknown,
                                      key=lambda i: i[0])
        code = code[0]
        status_mark = utils.get_status_mark("DAE", code)
        first_line = "Total DAEs #{}, Failed DAE(ID): {}".format(
            len(ok + warning + critical + unknown), [c[1] for c in critical])
        # Status line
        print(status_mark + first_line + " | ")

        # Failed details
        utils.print_if_failure(all_status[code], self.dae)
        # Performance detail
        for d in self.dae:
            print("{}: Power(curr/avg/max_if_not_empty)={}/{}/{} watts, "
                  "Temperature(curr/avg/max_if_not_empty)={}/{}/{} degrees , "
                  "Speed(curr/max)={}/{} GB".format(
                      d.name, d.current_power, d.avg_power, d.max_power,
                      d.current_temperature, d.avg_temperature,
                      d.max_temperature, utils.byte_to_GB(d.current_speed),
                      utils.byte_to_GB(d.max_speed)))
        return code
Esempio n. 12
0
 def check(self):
     all_status = ok, warning, critical, unknown = utils.get_all_status(
         self.ethernet_ports)
     code = utils.max_if_not_empty(ok + warning + critical + unknown,
                                   key=lambda i: i[0])
     code = code[0]
     status_mark = utils.get_status_mark("ETHERNET_PORT", code)
     first_line = "Total ethernet ports #{}, Failed ports(ID): {}".format(
         len(ok + warning + critical + unknown), ', '.join([
             utils.get_by_id(c[1], self.ethernet_ports).name
             for c in critical
         ]))
     # Status line
     print(status_mark + first_line + " | ")
     # Failed details
     utils.print_if_failure(all_status[code], self.ethernet_ports)
     # Performance detail
     for port in self.ethernet_ports:
         print("{}: Link status={}, Requested Speed={}, "
               "Current Speed={}".format(
                   port.name, "UP" if port.is_link_up else "DOWN",
                   utils.format_enum(port.requested_speed),
                   utils.format_enum(port.speed)))
     return code
Esempio n. 13
0
 def test_get_status_mark(self):
     status = utils.get_status_mark("DISK", 0)
     self.assertEqual("DISK OK: ", status)