• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 951
  • Last Modified:

Need to create a batch file to save a list periodically.

Hi folks, 500 pointer here :)

Need to create a batch file that creates a Log file for a citrix server farm. I see no way of doing it within Citrix, but am willing to be told whereabouts it is :)

I am trying to log the Load Management Score of a server farm as we are trying to pinpoint what effect is bringing down the servers, but after the event is too late.

Anyway, I can run the following command "QFARM /ZONELOAD" which produces the list, if I add the "> test.txt" pipe it sends that to a text file. I want this to occur every minute or so to build up a picture of how best to set up the server load management on the farm.

Now I would like to either export this to a single file, I can then drag into a spreadsheet (ideal!) OR export to multiple files (one each time) using a filename structure of something like "xxxxLOAD.TXT" where xxxx is a sequential number.

I am imagining this would need to be run as a scheduled task on one of the servers, as I cannot be logged in all the time.

We are using Presentation Manager 4.0, on Windows 2003 Standard servers.
0
Jeremy Bromley
Asked:
Jeremy Bromley
2 Solutions
 
QlemoC++ DeveloperCommented:
Did you try and have a look at PerfMon if there are counters for your purpose? I suppose there are, and using PerfMon locally or remote would be a much better option.
0
 
PeteJThomasCommented:
Hi, there's probably an infinitely better way of doing this, but one way might be be -

@echo off
Date /T >> filename.txt
Time /T >> filename.txt
QFARM /ZONELOAD >> filename.txt

Where "filename.csv" is a set file you want all the data in.

The >> will just append the info on to the end of the file, instead of overwriting it's contents, and the 2 time and date lines just literally print the time and date just prior to running the command. Then just schedule the batch file to run however often you want.

Although I'm not convinced I've understood what result you're after... lol O.o

Pete
0
 
AmazingTechCommented:
Put this into a batch file on the Citrix Server.

Schedule the task to run every ??? (minute).

Once you have the data you want to look at in Excel run this code in the comment to make your 1 file.

Set LogFolder=C:\Logs
Set TimeNow=%Time:~0,-3%
Set TimeNow=%Time: =%
Set TimeNow=%Time::=.%
Set DateNow=%Date:~-10%
Set DateNow=%Date:/=%
copy nul ALL_QFARM_%DateNow%_%TimeNow%.csv
for /f %%a in ('dir /od /b "%LogFolder%\QFARM-*.TXT"') do copy "%LogFolder%ALL_QFARM_%DateNow%_%TimeNow%.csv" + "%LogFolder%\%%a" "%LogFolder%\ALL_QFARM_%DateNow%_%TimeNow%.csv"
Set LogFolder=C:\Logs
Set TimeNow=%Time:~0,-3%
Set TimeNow=%Time: =%
Set TimeNow=%Time::=.%
Set DateNow=%Date:~-10%
Set DateNow=%Date:/=%
QFARM /ZONELOAD>%LogFolder%\QFARM_%DateNow%_%TimeNow%.txt"

Open in new window

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Jeremy BromleyIT ConsultantAuthor Commented:
@AmazingTech - It nearly works :)

The first part (in the code section) creates the log files no problems (the only change I've made is to change the location to H:\Logs - as this is the data folder across the server farm), I have made this change in both bits of code.

However, after running about 20 log files when I run the "compilation code" it just creates a blank file :(

I have attached the code as I have entered it, just for checking.
Set LogFolder=h:\Logs
Set TimeNow=%Time:0,-3%
Set TimeNow=%Time: =%
Set Timenow=%Time::=.%
Set DateNow=%Date:~-10%
Set DateNow=%Date:/=%
QFARM /Zoneload>%LogFolder%\QFARM_%DateNow%_%TimeNow%.txt
 
------------------------------------------------------------------------
 
Set LogFolder=H:\logs
Set TimeNow=%Time:~0,-3%
Set TimeNow=%Time: =%
Set TimeNow=%Time::=.%
Set DateNow=%Date:~-10%
Set DateNow=%Date:/=%
copy nul ALL_QFARM_%DateNow%_%TimeNow%.csv
for /f %%a in ('dir /od /b "%LogFolder%\QFARM-*.TXT"') do copy "%LogFolder%ALL_QFARM_%DateNow%_%TimeNow%.csv" + "%LogFolder%\%%a" "%LogFolder%\ALL_QFARM_%DateNow%_%TimeNow%.csv"

Open in new window

0
 
AmazingTechCommented:
Sorry my error here.

OK. This should be correct now.
Set LogFolder=h:\Logs
Set TimeNow=%Time:0,-3%
Set TimeNow=%TimeNow: =%
Set Timenow=%TimeNow::=.%
Set DateNow=%Date:~-10%
Set DateNow=%DateNow:/=%
QFARM /Zoneload>%LogFolder%\QFARM_%DateNow%_%TimeNow%.txt
 
------------------------------------------------------------------------
 
Set LogFolder=H:\logs
Set TimeNow=%Time:~0,-3%
Set TimeNow=%TimeNow: =%
Set TimeNow=%TimeNow::=.%
Set DateNow=%Date:~-10%
Set DateNow=%DateNow:/=%
copy nul "%LogFolder%\ALL_QFARM_%DateNow%_%TimeNow%.csv"
for /f %%a in ('dir /od /b "%LogFolder%\QFARM-*.TXT"') do copy "%LogFolder%\ALL_QFARM_%DateNow%_%TimeNow%.csv" + "%LogFolder%\%%a" "%LogFolder%\ALL_QFARM_%DateNow%_%TimeNow%.csv"
 

Open in new window

0
 
Jeremy BromleyIT ConsultantAuthor Commented:
Hmm, unfortunately still creating nul file :(
0
 
Jeremy BromleyIT ConsultantAuthor Commented:
Ah, sussed it now... it was because you had put "QFARM-" instead of "QFARM_" in the code.
0
 
Jeremy BromleyIT ConsultantAuthor Commented:
One thing that is missing is in the final created file, there is no indication of what the date/time  of the output is.
0
 
AmazingTechCommented:
Hmm.. Getting closer I guess is a good thing.
Set LogFolder=h:\Logs
Set TimeNow=%Time:0,-3%
Set TimeNow=%TimeNow: =%
Set Timenow=%TimeNow::=.%
Set DateNow=%Date:~-10%
Set DateNow=%DateNow:/=%
QFARM /Zoneload>%LogFolder%\QFARM_%DateNow%_%TimeNow%.txt
 
------------------------------------------------------------------------
 
Set LogFolder=H:\logs
Set TimeNow=%Time:~0,-3%
Set TimeNow=%TimeNow: =%
Set TimeNow=%TimeNow::=.%
Set DateNow=%Date:~-10%
Set DateNow=%DateNow:/=%
copy nul "%LogFolder%\ALL_QFARM_%DateNow%_%TimeNow%.csv"
for /f %%a in ('dir /od /b "%LogFolder%\QFARM_*.TXT"') do ECHO %%a>>"%LogFolder%\ALL_QFARM_%DateNow%_%TimeNow%.csv" & copy "%LogFolder%\ALL_QFARM_%DateNow%_%TimeNow%.csv" + "%LogFolder%\%%a" "%LogFolder%\ALL_QFARM_%DateNow%_%TimeNow%.csv" & ECHO.>>"%LogFolder%\ALL_QFARM_%DateNow%_%TimeNow%.csv"
 

Open in new window

0
 
AmazingTechCommented:
This is probably a little easier to read and modify.
Set LogFolder=h:\Logs
Set TimeNow=%Time:0,-3%
Set TimeNow=%TimeNow: =%
Set Timenow=%TimeNow::=.%
Set DateNow=%Date:~-10%
Set DateNow=%DateNow:/=%
QFARM /Zoneload>%LogFolder%\QFARM_%DateNow%_%TimeNow%.txt
 
------------------------------------------------------------------------
 
Set LogFolder=H:\logs
Set TimeNow=%Time:~0,-3%
Set TimeNow=%TimeNow: =%
Set TimeNow=%TimeNow::=.%
Set DateNow=%Date:~-10%
Set DateNow=%DateNow:/=%
copy nul "%LogFolder%\ALL_QFARM_%DateNow%_%TimeNow%.csv"
for /f %%a in ('dir /od /b "%LogFolder%\QFARM_*.TXT"') do (
    ECHO ****Start of %%a>>"%LogFolder%\ALL_QFARM_%DateNow%_%TimeNow%.csv"
    copy "%LogFolder%\ALL_QFARM_%DateNow%_%TimeNow%.csv" + "%LogFolder%\%%a" "%LogFolder%\ALL_QFARM_%DateNow%_%TimeNow%.csv"
    ECHO ****End of %%a>>"%LogFolder%\ALL_QFARM_%DateNow%_%TimeNow%.csv"
    ECHO.>>"%LogFolder%\ALL_QFARM_%DateNow%_%TimeNow%.csv"
)

Open in new window

0
 
Jeremy BromleyIT ConsultantAuthor Commented:
Bloomin' marvellous :)
0
 
Jeremy BromleyIT ConsultantAuthor Commented:
Many thanks, your help has been invaluable.
0
 
AmazingTechCommented:
Thanks for the grade.

I'm glad we got to a working solution.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now