Jeremy Bromley
asked on
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.
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.
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.
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
@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
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%_%TimeN ow%.csv
for /f %%a in ('dir /od /b "%LogFolder%\QFARM-*.TXT"' ) do copy "%LogFolder%ALL_QFARM_%Dat eNow%_%Tim eNow%.csv" + "%LogFolder%\%%a" "%LogFolder%\ALL_QFARM_%Da teNow%_%Ti meNow%.csv "
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%_%TimeN
for /f %%a in ('dir /od /b "%LogFolder%\QFARM-*.TXT"'
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"
ASKER
@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.
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"
Sorry my error here.
OK. This should be correct now.
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"
ASKER
Hmm, unfortunately still creating nul file :(
ASKER
Ah, sussed it now... it was because you had put "QFARM-" instead of "QFARM_" in the code.
ASKER
One thing that is missing is in the final created file, there is no indication of what the date/time of the output is.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Bloomin' marvellous :)
ASKER
Many thanks, your help has been invaluable.
Thanks for the grade.
I'm glad we got to a working solution.
I'm glad we got to a working solution.