Page 1 of 1 1
Topic Options
#157163 - 2006-02-14 09:02 AM Diskspace / Filesize check problems
ilovetechno Offline
Fresh Scripter

Registered: 2004-11-17
Posts: 13
I have problem whil doing some basic checks. I am a kixtart beginner and after a lot of searching and trying I am stuck.

Code:
 
IF Open( 3 , "dagelijkse_checks.txt" , 5 ) = 0
$sp1c = GetDiskSpace( "\\Sharepoint1\C$\" )
$sp1d = GetDiskSpace( "\\Sharepoint1\D$\" )
$sp2c = GetDiskSpace( "\\Sharepoint2\C$\" )
$sp2d = GetDiskSpace( "\\Sharepoint2\D$\" )
$sp2e = GetDiskSpace( "\\Sharepoint2\E$\" )
$sp4c = GetDiskSpace( "\\Sharepoint4\C$\" )
$sp4d = GetDiskSpace( "\\Sharepoint4\D$\" )
$sp5c = GetDiskSpace( "\\Sharepoint5\C$\" )
$sp5d = GetDiskSpace( "\\Sharepoint5\D$\" )
$cap11c = GetDiskSpace( "\\Capture11\C$\" )
$cap11d = GetDiskSpace( "\\Capture11\D$\" )
$size1 = GetFileSize("\\Sharepoint4\D$\Data\Microsoft SQL Server\MSSQL\Data\SHAREPOINT5_Config_db.mdf")
$size2 = GetFileSize("\\Sharepoint4\D$\Data\Microsoft SQL Server\MSSQL\Data\SHAREPOINT5_Config_db_log.LDF")
$size3 = GetFileSize("\\Sharepoint4\D$\Data\Microsoft SQL Server\MSSQL\Data\VSP1_PROF_Data.MDF")
$size4 = GetFileSize("\\Sharepoint4\D$\Data\Microsoft SQL Server\MSSQL\Data\VSP1_PROF_Log.LDF")
$size5 = GetFileSize("\\Sharepoint4\D$\Data\Microsoft SQL Server\MSSQL\Data\VSP1_SERV_Data.MDF")
$size6 = GetFileSize("\\Sharepoint4\D$\Data\Microsoft SQL Server\MSSQL\Data\VSP1_SERV_Log.LDF")
$size7 = GetFileSize("\\Sharepoint4\D$\Data\Microsoft SQL Server\MSSQL\Data\VSP1_SITE_Data.MDF")
$size8 = GetFileSize("\\Sharepoint4\D$\Data\Microsoft SQL Server\MSSQL\Data\VSP1_SITE_Log.LDF")
$size9 = GetFileSize("\\Sharepoint4\D$\Data\Microsoft SQL Server\MSSQL\Data\VSP Utilities_Data.MDF")
$size0 = GetFileSize("\\Sharepoint4\D$\Data\Microsoft SQL Server\MSSQL\Data\VSP Utilities_Log.LDF")
$sizea = GetFileSize("\\Sharepoint4\D$\Data\Microsoft SQL Server\MSSQL\Data\VSP_Data.MDF")
$sizeb = GetFileSize("\\Sharepoint4\D$\Data\Microsoft SQL Server\MSSQL\Data\VSP_Log.MDF")
$sizec = GetFileSize("\\Sharepoint4\D$\Data\Microsoft SQL Server\MSSQL\Data\medewerkerCompetentie\medewerkerCompetentie.mdf")
$sized = GetFileSize("\\Sharepoint4\D$\Data\Microsoft SQL Server\MSSQL\Data\medewerkerCompetentie\medewerkerCompetentie_Log.ldf")
/* Wegschrijven data binnen tekstbestand*/
$x = WriteLine( 3 , "-------------------------------------------------" + @CRLF)
$x = WriteLine( 3 , "Sharepoint portal omgeving VSP BV: Dagelijkse checks van: " + @DATE + @CRLF)
$x = WriteLine( 3 , "-------------------------------------------------" + @CRLF)
$x = WriteLine( 3 , "Beschikbare disc space" + @CRLF)
$x = WriteLine( 3 , "-------------------------------------------------" + @CRLF)
$x = WriteLine( 3 , "Diskspace Sharepoint1 C: " + $sp1c + " KB" + @CRLF)
$x = WriteLine( 3 , "Diskspace Sharepoint1 D: " + $sp1d + " KB" + @CRLF)
$x = WriteLine( 3 , "Diskspace Sharepoint2 C: " + $sp2c + " KB" + @CRLF)
$x = WriteLine( 3 , "Diskspace Sharepoint2 D: " + $sp2d + " KB" + @CRLF)
$x = WriteLine( 3 , "Diskspace Sharepoint2 E: " + $sp2e + " KB" + @CRLF)
$x = WriteLine( 3 , "Diskspace Sharepoint4 C: " + $sp4c + " KB" + @CRLF)
$x = WriteLine( 3 , "Diskspace Sharepoint4 D: " + $sp4d + " KB" + @CRLF)
$x = WriteLine( 3 , "Diskspace Sharepoint5 C: " + $sp5c + " KB" + @CRLF)
$x = WriteLine( 3 , "Diskspace Sharepoint5 D: " + $sp5d + " KB" + @CRLF)
$x = WriteLine( 3 , "Diskspace Capture11 C: " + $cap11c + " KB" + @CRLF)
$x = WriteLine( 3 , "Diskspace Capture11 D: " + $cap11d + " KB" +@CRLF)
$x = WriteLine( 3 , "-------------------------------------------------" + @CRLF)
$x = WriteLine( 3 , "SQL Database bestanden" + @CRLF)
$x = WriteLine( 3 , "-------------------------------------------------" + @CRLF)
$x = WriteLine( 3 , "SHAREPOINT5_Config_db DB bestan : " + $size1 + @CRLF)
$x = WriteLine( 3 , "SHAREPOINT5_Config_db LOG bestand : " + $size2 + @CRLF)
$x = WriteLine( 3 , "VSP1_PROF DB bestand : " + $size3 + @CRLF)
$x = WriteLine( 3 , "VSP1_PROF LOG bestand : " + $size4 + @CRLF)
$x = WriteLine( 3 , "VSP1_SERV DB bestand : " + $size5 + @CRLF)
$x = WriteLine( 3 , "VSP1_SERV LOG bestand : " + $size6 + @CRLF)
$x = WriteLine( 3 , "VSP1_SITE DB bestand : " + $size7 + @CRLF)
$x = WriteLine( 3 , "VSP1_SITE LOG bestand : " + $size8 + @CRLF)
$x = WriteLine( 3 , "VSP Utilities DB bestand : " + $size9 + @CRLF)
$x = WriteLine( 3 , "VSP Utilities LOG bestand : " + $size0 + @CRLF)
$x = WriteLine( 3 , "VSP DB bestand : " + $sizea + @CRLF)
$x = WriteLine( 3 , "VSP LOG bestand : " + $sizeb + @CRLF)
$x = WriteLine( 3 , "medewerkerCompetentie DB bestand : " + $sizec + @CRLF)
$x = WriteLine( 3 , "medewerkerCompetentie LOG bestand : " + $sized + @CRLF)

/* Alerts */

/* Sharepoint1 C schijf 1,5GB */
IF $sp1c < 1500000
Shell 'sharepoint1c.bat'
ENDIF

/* Sharepoint1 D schijf 3GB */
IF $sp1d < 50000000
Shell 'sharepoint1c.bat'
ENDIF

/* Sharepoint2 C schijf 50GB */
IF $sp2c < 3000000
Shell 'sharepoint2c.bat'
ENDIF

/* Sharepoint2 D schijf 100GB */
IF $sp2d < 50000000
Shell 'sharepoint2c.bat'
ENDIF

/* Sharepoint4 D schijf 30GB */
IF $sp4d < 30000000
Shell 'sharepoint4d.bat'
ENDIF

ELSE
BEEP
? "failed to open file, error code : [" + @ERROR + "]"
ENDIF




Problems:

1. GetFileSize: I have some files that are over 2GB. That gives a problem. I have found some methods on this forum but they dont work and some make my system crash.

2 How to write to CSV. I want to run this script and save all the values in a CSV file like this "value1","value2","value3","value4". And add a line every time i run the script. How can i do this


Please help me!

Top
#157164 - 2006-02-14 09:20 AM Re: Diskspace / Filesize check problems
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
-1 What code do you have that makes your system crash? Could you post it?

-2 This example will get the values separated by a comma and on a new line each time the script runs.

Code:

If Open( 3 , "somefile.csv" , 5 ) = 0
WriteLine (3, "Stuff to write" + ",")
WriteLine (3, "More stuff to write" + ",")
WriteLine (3, "Even more stuff to write" + ",")
WriteLine (3, @CRLF)
EndIf
Close (3)

_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#157165 - 2006-02-14 10:16 AM Re: Diskspace / Filesize check problems
ilovetechno Offline
Fresh Scripter

Registered: 2004-11-17
Posts: 13
Thank you for the feedback..

I have tried this but it results in a file without comma´s

Code:

If Open( 3 , "somefile.csv" , 5 ) = 0
Writeline (3, @DATE)
WriteLine (3, $sp1c + ",")
WriteLine (3, $sp1d + ",")
WriteLine (3, $sp1c + ",")
WriteLine (3, $sp1d + ",")
WriteLine (3, $sp2c + ",")
WriteLine (3, $sp2d + ",")
WriteLine (3, $sp2e + ",")
WriteLine (3, $sp4c + ",")
WriteLine (3, $sp4d + ",")
WriteLine (3, $sp5c + ",")
WriteLine (3, $sp5d + ",")
WriteLine (3, $cap11c + ",")
WriteLine (3, $cap11d + ",")
WriteLine (3, "Even more stuff to write" + ",")
WriteLine (3, @CRLF)
EndIf
Close (3)


Top
#157166 - 2006-02-14 10:36 AM Re: Diskspace / Filesize check problems
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Just ran it and it gives me lots of comma’s. I filled your variables with the variable name to get some output in the file and I get a comma separated file just fine (besides from the date and the first var not being separated by a comma).
What OS and kix version are you using?

Quote:


2006/02/14sp1c,sp1d,sp1c,sp1d,sp2c,sp2d,sp2e,sp4c,sp4d,sp5c,sp5d,cap11c,cap11d,Even more stuff to write,



_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#157167 - 2006-02-14 11:29 AM Re: Diskspace / Filesize check problems
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
If $splc is a number then $splc+"," is a mathematical expression, *not* a string expression. Depending on you language settings this may or may not give you an error.

Explicitly casting the expression will avoid this problem, for example CStr($splc)+"," is guaranteed to be a string expression.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1471 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.044 seconds in which 0.014 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org