Changeset 1372
- Timestamp:
- 02/20/07 11:59:05 (6 years ago)
- File:
-
- 1 edited
-
ccsd/private/modules/ccs_monitor_status.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ccsd/private/modules/ccs_monitor_status.py
r1371 r1372 144 144 return -1 145 145 146 def getMadwifiBase(mac, interfaces): 147 """Searches the provided list of interfaces for base madwifi interface 148 matching the supplied MAC address""" 149 150 for iface in interfaces: 151 # If the last 5 octets of the mac don't match, ignore 152 if mac[3:] != iface["mac"][3:]: 153 continue 154 # If the iface is of type link/ieee802.11 rathern than link/ether 155 # then it is the base interface 156 fd = os.popen("/sbin/ip link ls dev %s" % iface["name"]) 157 lines = fd.readlines() 158 fd.close() 159 if lines[-1].find("link/ieee802.11") != -1: 160 return iface["name"] 161 return None 162 146 163 def getAthStats(oiface, interfaces): 147 164 """Gets stats from Athstats""" 148 phy = 0149 crc = 0165 phy = -1 166 crc = -1 150 167 base = None 151 168 try: 152 mac = oiface["mac"][3:] 153 #Find the base wifi* interface 154 for iface in interfaces: 155 if iface == oiface: 169 mac = oiface["mac"] 170 # Find the base interface 171 base = getMadwifiBase(mac, interfaces) 172 if not base: return phy, crc 173 # Run athstats and retrieve output 174 lines = os.popen("athstats -i %s" % base).readlines() 175 if len(lines) == 0: return phy, crc 176 # Parse athstats output 177 for line in lines: 178 # Look for key text 179 if line.find("PHY errors") != -1: 180 # Store PHY errors 181 phy = int(line.strip().split()[0]) 182 elif line.find("rx failed due to bad CRC") != -1: 183 # Store CRC errors 184 crc = int(line.strip().split()[0]) 185 else: 186 # Ignored line 156 187 continue 157 if mac == iface["mac"][3:] and iface["name"][:4] == "wifi":158 base = iface["name"]188 # Ignore the rest if we've found both values 189 if phy != -1 and crc != -1: 159 190 break 160 161 #Run athstats162 if base:163 lines = os.popen("athstats -i %s" % base).readlines()164 if len(lines) == 0:165 phy = -1166 crc = -1167 for line in lines:168 line = line.strip('\n')169 sline = line.split(' ')170 if len(sline) > 1:171 value = sline[0]172 line = line[len(value)+1:]173 if line == "PHY errors":174 phy = int(value)175 if line == "rx failed due to bad CRC":176 crc = int(value)177 else:178 phy = -1179 crc = -1180 191 except: 181 phu = -1 192 log_error("Failed to fetch ath stats for %s" % oiface["name"], 193 sys.exc_info()) 194 phy = -1 182 195 crc = -1 183 196 return phy, crc 184 185 197 186 198 Cache = None
Note: See TracChangeset
for help on using the changeset viewer.
