Code Duplication    Length = 23-25 lines in 2 locations

glances/plugins/glances_ports.py 2 locations

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