How to take a last log from the Servers?

Posted Sunday, 22 July 2007 by Michael Khanin
Digg!
I’ve a few servers those same times I have to take a log from them.  I’m interesting just in the LAST log from each server. Because of the huge numbers of the servers I’ve created a script Logs-from-Servers.bat, which helps me in my task.  Additionally, this script takes a screenshot from each server.

Before show the content of my script I’d like to say what the prerequirements. I used a few tools in the script for simplify it. One is LINEX.exe the other one is LSGRAB.exe and the last 7za.exe

LINEX.exe helps to analyze and manipulate with each line in the TXT fail.
LSGRAB.exe – command line tools, which takes a screenshot from the remote server.
7za.exe - command line tools, which create a  ZIP-archive of all logs.

Logs-from-Servers.bat analyzes a file SRVLIST.txt. In the SRVLIST.txt located a list of all my servers. This is an example of the SRVLIST.txt:

172.1.1.10
172.1.1.12
172.1.1.14


So, this is a content of the Logs-from-Servers.bat:

@echo off
SET IP-SRV=
SET LoopNum=
SET Line=
SET I=
SET SAM=
SET Line=0

FOR /F "TOKENS=*" %%a in ('C:\Tools\LINEX -c ^<%TEMP%\SRVLIST.txt') do set IP-SRV=%%a
SET /a LoopNum=%IP-SRV% + 1

:LOOP1
SET /a I=%I% + 1
SET /a Line=%Line% + 1
IF "%I%"=="%LoopNum%" goto END
FOR /F "TOKENS=*" %%a in ('C:\Tools\LINEX -l %Line% ^<%TEMP%\SRVLIST.txt') do set SAM=%%a

MD %TEMP%\LASTLOG\%SAM%

C:\Tools\lsgrab.exe /c:%SAM% /p:%TEMP%\LASTLOG\%SAM%\

DIR \\%SAM%\c$\Inetpub\wwwroot\GSPortal\Logs /b /o:d > %TEMP%\portal.txt
for /f "TOKENS=*" %%a in ('T:\Tools\LINEX -t 1 ^<%TEMP%\portal.txt') do set PLOG=%%a

COPY \\%SAM%\c$\Inetpub\wwwroot\GSPortal\Logs\%PLOG% %TEMP%\LASTLOG\%SAM%\
DEL %TEMP%\portal.txt /Q

SET Line=%Line%
GOTO LOOP1

:END
SET IP-SRV=
SET LoopNum=
SET Line=
SET I=
SET SAM=
SET Line=0

DEL %TEMP%\SRVLIST.txt /Q
C:\Tools\7za.exe a -tzip %TEMP%\LogFile.zip "%TEMP%\LASTLOG"
RD %TEMP%\LASTLOG\. /Q /S

@echo All Log Files located in directory %TEMP%

The end :).






Reddit!Del.icio.us!Google!Facebook!Slashdot!Netscape!Technorati!StumbleUpon!Newsvine!Furl!Yahoo!Ma.gnolia!Free social bookmarking plugins and extensions for Joomla! websites! title=
 

Add comment

You have no rights to add a new comment. May be you need to register on the site.