local sensekeys = {
["0"] = "NO SENSE",
["1"] = "RECOVERED ERROR",
["2"] = "NOT READY",
["3"] = "MEDIUM ERROR",
["4"] = "HARDWARE ERROR",
["5"] = "ILLEGAL REQUEST",
["6"] = "UNIT ATTENTION",
["7"] = "DATA PROTECT",
["8"] = "BLANK CHECK",
["9"] = "VENDOR SPECIFIC",
A = "COPY ABORTED",
B = "ABORTED COMMAND",
D = "VOLUME OVERFLOW",
E = "MISCOMPARE",
F = "COMPLETED",
}
ngx.say("
Opti Drive Control Error Decoder")
local args = ngx.req.get_uri_args()
if type(args.errorcode) == "string" then
args.errorcode = string.upper(args.errorcode)
if string.len(args.errorcode) == 6 and tonumber(args.errorcode,16) and string.sub(args.errorcode,1,1) == "0" then
ngx.say("Error code "..args.errorcode.." means:
")
local sk = string.sub(args.errorcode,2,2)
ngx.say((sensekeys[sk] or "(invalid sense key)").."
")
local asc = string.format("%sh/%sh",string.sub(args.errorcode,3,4),string.sub(args.errorcode,5,6))
local found = false
for line in io.lines("/var/www/odcerror/asc-num.txt") do
if string.sub(line,1,7) == asc then
ngx.say(string.sub(line,25,-1))
found = true
end
end
if not found then ngx.say("(invalid ASC/ASCQ)") end
if asc == "27h/08h" then ngx.say("
") end
else
ngx.say("Invalid error code - Opti Drive Control error codes are 6-digit hexadecimal numbers beginning with 0.")
end
ngx.say("
")
end
ngx.say("")
ngx.say("")