Generating .csv files for multiple folders
Moderator: DosItHelp
Generating .csv files for multiple folders
Hi,
This is my first task with batch and need help with the following:
I have multiple folders in a directory. Every folder has two files system.kernel.cpu.idlepct and system.memory.free.
I need to generate .csv files for these two files in every folder by running -tmin 20150101 -tmax 20150228 -x on these two files.
Could any of you please help me with this?
Thank you
This is my first task with batch and need help with the following:
I have multiple folders in a directory. Every folder has two files system.kernel.cpu.idlepct and system.memory.free.
I need to generate .csv files for these two files in every folder by running -tmin 20150101 -tmax 20150228 -x on these two files.
Could any of you please help me with this?
Thank you
Re: Generating .csv files for multiple folders
smaddela wrote:I need to generate .csv files for these two files in every folder by running -tmin 20150101 -tmax 20150228 -x on these two files.
Thank you
Might want to explain this task with more detail. I have no idea what your comment above means.
Re: Generating .csv files for multiple folders
Hi,
We have a monitoring tool that runs on client servers. Every month our customer uploads the data collected by our tool for these 10 servers as zipped files on Ftp.
We then unzip these folders and save it in a directory C:\Customer\Server1...C:\Customer\Server8 and so on.These folders have multiple file types *.dats, *.dlls, *.exes etc
But we are interested in generating reports as .csv files for cpu (i.e. system.kernel.cpu.idlepct which is IDLEPCT file) and memory (i.e. system.memory.free which is free file) consumption for every server. To generate these we are currently running the below commands in a notepad (executed as .bat file)
C:\Customer\server1\monitool -tmin 20150101 -tmax 20150228 -x system.kernel.cpu.idlepct > server1_idlepct.csv
C:\Customer\server1\monitool -tmin 20150101 -tmax 20150228 -x system.memory.free > server1_memfree.csv
C:\Customer\server2\monitool -tmin 20150101 -tmax 20150228 -x system.kernel.cpu.idlepct > server2_idlepct.csv
C:\Customer\server2\monitool -tmin 20150101 -tmax 20150228 -x system.memory.free > server2_memfree.csv
.......
........
C:\Customer\server10\monitool -tmin 20150101 -tmax 20150228 -x system.kernel.cpu.idlepct > server10_idlepct.csv
C:\Customer\server10\monitool -tmin 20150101 -tmax 20150228 -x system.memory.free > server10_memfree.csv
The task is now to run a batch script to generate .csv files for every server(folder) that can automatically go through the directory for servernames(folders names) and generate those two .csv files for every server(folder).
I hope this is little clear now.
Thank you.
We have a monitoring tool that runs on client servers. Every month our customer uploads the data collected by our tool for these 10 servers as zipped files on Ftp.
We then unzip these folders and save it in a directory C:\Customer\Server1...C:\Customer\Server8 and so on.These folders have multiple file types *.dats, *.dlls, *.exes etc
But we are interested in generating reports as .csv files for cpu (i.e. system.kernel.cpu.idlepct which is IDLEPCT file) and memory (i.e. system.memory.free which is free file) consumption for every server. To generate these we are currently running the below commands in a notepad (executed as .bat file)
C:\Customer\server1\monitool -tmin 20150101 -tmax 20150228 -x system.kernel.cpu.idlepct > server1_idlepct.csv
C:\Customer\server1\monitool -tmin 20150101 -tmax 20150228 -x system.memory.free > server1_memfree.csv
C:\Customer\server2\monitool -tmin 20150101 -tmax 20150228 -x system.kernel.cpu.idlepct > server2_idlepct.csv
C:\Customer\server2\monitool -tmin 20150101 -tmax 20150228 -x system.memory.free > server2_memfree.csv
.......
........
C:\Customer\server10\monitool -tmin 20150101 -tmax 20150228 -x system.kernel.cpu.idlepct > server10_idlepct.csv
C:\Customer\server10\monitool -tmin 20150101 -tmax 20150228 -x system.memory.free > server10_memfree.csv
The task is now to run a batch script to generate .csv files for every server(folder) that can automatically go through the directory for servernames(folders names) and generate those two .csv files for every server(folder).
I hope this is little clear now.
Thank you.
Re: Generating .csv files for multiple folders
Which part are you having trouble with?
Re: Generating .csv files for multiple folders
foxidrive wrote:Which part are you having trouble with?
Ditto!
Still not understanding what you are having problems with.
Re: Generating .csv files for multiple folders
I think automatically going through server directories versus having them hardcoded is the task at hand.smaddela wrote:The task is now to run a batch script to generate .csv files for every server(folder) that can automatically go through the directory for servernames(folders names) and generate those two .csv files for every server(folder).
A couple of questions:
- Are the server directories the only ones in this particular part of the tree?
- Do the server directories always follow the 'ServerX' nomenclature?
- What is the highest number of the server? Will it increase in the future?
Re: Generating .csv files for multiple folders
Hi,
Thank you for the reply.
Please find my answers to your questions below:
- Are the server directories the only ones in this particular part of the tree? Yes
- Do the server directories always follow the 'ServerX' nomenclature? Yes
- What is the highest number of the server? Will it increase in the future? 17 and they will not change (as of now)
What we have now is all hard coded. But the idea is to have some kind of loop or functions to make it look simple.
Thank you for the reply.
Please find my answers to your questions below:
- Are the server directories the only ones in this particular part of the tree? Yes
- Do the server directories always follow the 'ServerX' nomenclature? Yes
- What is the highest number of the server? Will it increase in the future? 17 and they will not change (as of now)
What we have now is all hard coded. But the idea is to have some kind of loop or functions to make it look simple.
Re: Generating .csv files for multiple folders
This should work with all the rem's removed and executed from c:\customer\:smaddela wrote:Hi,
Thank you for the reply.
Please find my answers to your questions below:
- Are the server directories the only ones in this particular part of the tree? Yes
- Do the server directories always follow the 'ServerX' nomenclature? Yes
- What is the highest number of the server? Will it increase in the future? 17 and they will not change (as of now)
What we have now is all hard coded. But the idea is to have some kind of loop or functions to make it look simple.
Code: Select all
for /d %%f in (server*) do
(
rem C:\Customer\%%f\monitool -tmin 20150101 -tmax 20150228 -x system.kernel.cpu.idlepct > %%f_idlepct.csv
rem C:\Customer\%%f\monitool -tmin 20150101 -tmax 20150228 -x system.memory.free > %%f_memfree.csv)
Re: Generating .csv files for multiple folders
Samir wrote:This should work with all the rem's removed and executed from c:\customer\:This will result in all the csv files in c:\customer.Code: Select all
for /d %%f in (server*) do
(
rem C:\Customer\%%f\monitool -tmin 20150101 -tmax 20150228 -x system.kernel.cpu.idlepct > %%f_idlepct.csv
rem C:\Customer\%%f\monitool -tmin 20150101 -tmax 20150228 -x system.memory.free > %%f_memfree.csv)
Error, Will Robinson!!
Re: Generating .csv files for multiple folders
Where? I ran this locally and it worked fine.foxidrive wrote:Samir wrote:This should work with all the rem's removed and executed from c:\customer\:This will result in all the csv files in c:\customer.Code: Select all
for /d %%f in (server*) do
(
rem C:\Customer\%%f\monitool -tmin 20150101 -tmax 20150228 -x system.kernel.cpu.idlepct > %%f_idlepct.csv
rem C:\Customer\%%f\monitool -tmin 20150101 -tmax 20150228 -x system.memory.free > %%f_memfree.csv)
Error, Will Robinson!!
Re: Generating .csv files for multiple folders
Pretty sure that left parentheses needs to be up on the same line as the DO.
Re: Generating .csv files for multiple folders
Ran the script but it doesn't work!