Changeset 7038 for luci/branches/luci-0.10/libs/sys/luasrc/sys.lua
- Timestamp:
- 05/10/11 00:04:26 (2 years ago)
- Location:
- luci/branches/luci-0.10/libs/sys
- Files:
-
- 2 modified
-
. (modified) (1 prop)
-
luasrc/sys.lua (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
luci/branches/luci-0.10/libs/sys
- Property svn:mergeinfo deleted
-
luci/branches/luci-0.10/libs/sys/luasrc/sys.lua
r6790 r7038 172 172 local meminfo = fs.readfile("/proc/meminfo") 173 173 174 local system = cpuinfo:match("system typ.-:%s*([^\n]+)")175 local model = ""176 174 local memtotal = tonumber(meminfo:match("MemTotal:%s*(%d+)")) 177 175 local memcached = tonumber(meminfo:match("\nCached:%s*(%d+)")) 178 176 local memfree = tonumber(meminfo:match("MemFree:%s*(%d+)")) 179 177 local membuffers = tonumber(meminfo:match("Buffers:%s*(%d+)")) 180 local bogomips = tonumber(cpuinfo:match("BogoMIPS.-:%s*([^\n]+)")) 181 182 if not system then 183 system = nixio.uname().machine 184 model = cpuinfo:match("model name.-:%s*([^\n]+)") 185 if not model then 186 model = cpuinfo:match("Processor.-:%s*([^\n]+)") 187 end 188 else 189 model = cpuinfo:match("cpu model.-:%s*([^\n]+)") 190 end 178 local bogomips = tonumber(cpuinfo:match("[Bb]ogo[Mm][Ii][Pp][Ss].-: ([^\n]+)")) or 0 179 180 local system = 181 cpuinfo:match("system type\t+: ([^\n]+)") or 182 cpuinfo:match("Processor\t+: ([^\n]+)") or 183 cpuinfo:match("model name\t+: ([^\n]+)") 184 185 local model = 186 cpuinfo:match("machine\t+: ([^\n]+)") or 187 cpuinfo:match("Hardware\t+: ([^\n]+)") or 188 luci.util.pcdata(fs.readfile("/proc/diag/model")) or 189 nixio.uname().machine or 190 system 191 191 192 192 return system, model, memtotal, memcached, membuffers, memfree, bogomips … … 241 241 line = line:match "^(.-( [^ =]+=).-)%2" 242 242 local entry, flags = _parse_mixed_record(line, " +") 243 entry.layer3 = flags[1] 244 entry.layer4 = flags[3] 245 for i=1, #entry do 246 entry[i] = nil 247 end 248 249 if callback then 250 callback(entry) 251 else 252 connt[#connt+1] = entry 243 if flags[6] ~= "TIME_WAIT" then 244 entry.layer3 = flags[1] 245 entry.layer4 = flags[3] 246 for i=1, #entry do 247 entry[i] = nil 248 end 249 250 if callback then 251 callback(entry) 252 else 253 connt[#connt+1] = entry 254 end 253 255 end 254 256 end … … 257 259 line = line:match "^(.-( [^ =]+=).-)%2" 258 260 local entry, flags = _parse_mixed_record(line, " +") 259 entry.layer3 = "ipv4" 260 entry.layer4 = flags[1] 261 for i=1, #entry do 262 entry[i] = nil 263 end 264 265 if callback then 266 callback(entry) 267 else 268 connt[#connt+1] = entry 261 if flags[4] ~= "TIME_WAIT" then 262 entry.layer3 = "ipv4" 263 entry.layer4 = flags[1] 264 for i=1, #entry do 265 entry[i] = nil 266 end 267 268 if callback then 269 callback(entry) 270 else 271 connt[#connt+1] = entry 272 end 269 273 end 270 274 end … … 303 307 304 308 net.routes6(function(rt) 305 if rt.dest:prefix() == 0 and (not route or route.metric > rt.metric) then 309 if rt.dest:prefix() == 0 and rt.device ~= "lo" and 310 (not route or route.metric > rt.metric) 311 then 306 312 route = rt 307 313 end 308 314 end) 315 316 if not route then 317 local global_unicast = luci.ip.IPv6("2000::/3") 318 net.routes6(function(rt) 319 if rt.dest:equal(global_unicast) and 320 (not route or route.metric > rt.metric) 321 then 322 route = rt 323 end 324 end) 325 end 309 326 310 327 return route
