Code Duplication    Length = 23-25 lines in 2 locations

glances/plugins/glances_ports.py 2 locations

@@ 105-129 (lines=25) @@
102
        """Return the key of the list."""
103
        return 'indice'
104
105
    def get_ports_alert(self, port, header="", log=False):
106
        """Return the alert status relative to the port scan return value."""
107
        ret = 'OK'
108
        if port['status'] is None:
109
            ret = 'CAREFUL'
110
        elif port['status'] == 0:
111
            ret = 'CRITICAL'
112
        elif (isinstance(port['status'], (float, int)) and
113
              port['rtt_warning'] is not None and
114
              port['status'] > port['rtt_warning']):
115
            ret = 'WARNING'
116
117
        # Get stat name
118
        stat_name = self.get_stat_name(header=header)
119
120
        # Manage threshold
121
        self.manage_threshold(stat_name, ret)
122
123
        # Manage action
124
        self.manage_action(stat_name,
125
                           ret.lower(),
126
                           header,
127
                           port[self.get_key()])
128
129
        return ret
130
131
    def get_web_alert(self, web, header="", log=False):
132
        """Return the alert status relative to the web/url scan return value."""
@@ 131-153 (lines=23) @@
128
129
        return ret
130
131
    def get_web_alert(self, web, header="", log=False):
132
        """Return the alert status relative to the web/url scan return value."""
133
        ret = 'OK'
134
        if web['status'] is None:
135
            ret = 'CAREFUL'
136
        elif web['status'] not in [200, 301, 302]:
137
            ret = 'CRITICAL'
138
        elif web['rtt_warning'] is not None and web['elapsed'] > web['rtt_warning']:
139
            ret = 'WARNING'
140
141
        # Get stat name
142
        stat_name = self.get_stat_name(header=header)
143
144
        # Manage threshold
145
        self.manage_threshold(stat_name, ret)
146
147
        # Manage action
148
        self.manage_action(stat_name,
149
                           ret.lower(),
150
                           header,
151
                           web[self.get_key()])
152
153
        return ret
154
155
    def msg_curse(self, args=None, max_width=None):
156
        """Return the dict to display in the curse interface."""