Purpose: Use Iguana as a webserver to send it a beginning and an end date. Iguana will then move those logs from a backup folder to the active Iguana logs directory so that they can be viewed.
Some history: We recommend storing 3-6 months worth of logs typically. This is just because the logs are typically used to research recent transactions and you can get most issues resolved within that time frame. However, we do recommend that you keep a backup of the logs. I was backing mine up into another folder on the same machine and I wrote this channel so that I could send Iguana a beginning date and an end date.
Links:
- Example Link to Call= http://localhost:6544/logs?beginning=04/01/12&ending=05/09/12
Steps to Build the Channel:
- Source = From https
your url path can be anything I chose ‘Logs’
example of web call http://localhost:6544/logs?beginning=04/01/12&ending=05/09/12 - Destination = to Queue
Writing the Code:
- You can just import the whole file from here that has everything
Log_Viewer_From_HTTPS.zip - The above has the vb scripts and the BAT file that are necessary to stop and start the Iguana service. This must be done in order to search the logs
- If you would just like to look through some of the code you can see that below. As you can see my logs were in the D:\backup folder and i was moving them into the D:\logs directory. This is the one I have Iguana setup to store the logs
require 'dateparse' require 'datediff' require 'split' function trace(A) return end Source = 'D:\\backup' Destination = 'D:\\logs\\' function main(Data) details = '' queue.push{data=Data} local Success, Err, getB, getE = pcall(ckParse, Data) if Success then ckErrors(getB, getE) else details = 'ERROR RETURNED: '..Err net.http.respond{body=details} return end end function restartIguana() local T = io.popen('dir /B') T:read('*a') local T = io.popen('cd "edit\\admin\\other\\" && 01-StopService.vbs') -- local T = io.popen('cd C:\\Updates && 01-StopService.vbs') end function ckErrors(getB, getE) Berror = 0 if getB == nil or getB == '' then trace('you here') details = details..'<BR>'..'You are Missing a proper beginning date should be parameter beginning=mm/dd/yy' Berror = Berror + 1 end if getE == nil or getE == '' then trace('you here') details = details..'<BR>'..'You are Missing a proper ending date should be parameter ending=mm/dd/yy' Berror = Berror + 1 end if Berror > 0 then net.http.respond{body=details} else moveFiles(getB, getE) trace(details) net.http.respond{body=details} end return end function ckParse(Data) local R = net.http.parseRequest{data=Data} getB = R.params.beginning getE = R.params.ending return _,getB, getE end function moveFiles(B,E) local Days = daysbetween(B,E) pullLog(Days, B) return end function pullLog(Days, B) local i=1 mo = B:sub(1,2) da = B:sub(4,5) da = da -1 ye = B:sub(7,8) while i < Days+1 do mo, da, ye = newdate(mo,da,ye,1) if mo <=9 then mo = '0'..mo end if da <=9 then da = '0'..da end local redate = '20'..ye..mo..da..'.log' movelog(redate) trace(mo) trace(da) trace(ye) i = i+1 end if iguana.isTest() then trace('Do nothing you are testing') else restartIguana() end end function movelog(A) trace(A) if Check4File(Source..A) then --copy file copyLog(Source..A, Destination..A) details = details..'<BR>'..'COPIED FILE '..A else iguana.logInfo('FILEMOVE: no file '..A..' to move') details = details..'<BR>'..'NON EXISTENT FILE '..A return end end function copyLog(src,dest) io.popen('copy "'..src..'" "'..dest..'"') end function Check4File(FileName) ckFile = io.open(FileName) if ckFile == nil then return false else io.close(ckFile) return true end end