PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms..win.server.scripting > Script Need to check disk space on remote servers
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Script Need to check disk space on remote servers

Réponse
 
LinkBack Outils de la discussion
Vieux 20/11/2007, 18h07   #1
screwuphead
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Script Need to check disk space on remote servers


I know i could always a program to do this but wheres the fun in that?
so I need a program that will go through a list of servers and then a
list of their drives and check to see how much free space is left on
those drives, from their if it is anything less then 30GB i need it to
send an email to me.
i am using psexec to access these remote servers and run cmd. then to
email myself i am using postie.
the problem i am having is wrapping that all up in a if-then-else
command that will look for the specified free space. It doesnt work
right now beacuse for whatever reason it is bring back a true statement
when the statement is false because i know the server its checking is
more then 30GB free.
This is what i have so far:

@echo off

for /f %%S IN (serverPClist.txt) DO (
echo Checking drives on Server %%S...
for /D %%D IN (C D F G H I J K X V E) DO (

psexec \\%%S cmd /c if exist %%D:\* dir %%D:\ | findstr /c:"bytes" >
%temp%\%%S-%%D.txt
)
)


color 0D


for /f %%S IN (serverPClist.txt) DO (
echo. & echo.
echo ********** Displaying output for server %%S... **********

for /D %%D IN (C D E F G I J K) DO (
for /f "tokens=1,2,3,4" %%F IN ('if exist %temp%\%%S-%%D.txt type
%temp%\%%S-%%D.txt') DO (
if /i "%%G" == "Dir(s)" echo For the %%D: drive: %%H bytes free space.
if /i "%%G" == "bytes" echo For the %%D: drive: %%F bytes free space.
echo.
)
)
echo Done!
)
echo Generating HTML...

REM this part of the script generates an HTML file with all the
relevant information
REM and then launches it using the default browser.

set FileName="C:\Report.html"
echo ^<HTML^> > %FileName%
echo ^<HEAD^> >> %FileName%
echo ^<TITLE^>Free Space on NRCE Servers^</TITLE^> >> %FileName%
echo ^</HEAD^> >> %FileName%
echo ^<BODY^> >> %FileName%
echo ^<CENTER^>^<FONT SIZE=6 COLOR=BLUE^>Free Hard Drive Space
Report^</FONT^>^</CENTER^>^<BR^> >> %FileName%

for /f %%S IN (serverPClist.txt) DO (
REM mark the server
echo ^<FONT SIZE=4^>^<B^>%%S^</B^>^</FONT^>^<BR^> >> %FileName%
for /D %%D IN (C D E F G I J K) DO (
for /f "tokens=1,2,3,4" %%F IN ('if exist %temp%\%%S-%%D.txt type
%temp%\%%S-%%D.txt') DO (
REM add a line for the drive and free space
if /i "%%G" == "Dir(s)" echo ^<FONT SIZE=3^>Free space on
^<B^>%%D:^</B^> drive: ^<B^>^<FONT

COLOR=GREEN^>%%H^</FONT^>^</B^> bytes free^</FONT^>^<BR^> >> %FileName%

if /i "%%G" == "bytes" echo ^<FONT SIZE=3^>Free space on
^<B^>%%D:^</B^> drive: ^<B^>^<FONT

COLOR=GREEN^>%%F^</FONT^>^</B^> bytes free^</FONT^>^<BR^> >> %FileName%

)
)
REM mark some spacing lines into the HTML file
echo ^<BR^> >> %FileName%
)

echo ^</BODY^> >> %FileName%
echo ^</HTML^> >> %FileName%

REM launch the HTML file

set positive=1
set amount="30,000,000,000"
if %%f leq %amount% set violation=1
if %%h leq %amount% set violation=1
echo %violation%
if %violation% equ %positive% postie -hostSMTP SERVER) -toMY EMAIL)
-fromNETWORK EMAIL) -s:"Server Report" -msg:"THERE IS A VIOLATION!"
-a:"C:\ServerReports\Report.html"
echo Done!

If anybody else has anything better plz show me, otherwise i will keep
playing around with this coding.


--
screwuphead
------------------------------------------------------------------------
screwuphead's Profile: http://forums.techarena.in/member.php?userid=34605
View this thread: http://forums.techarena.in/showthread.php?t=856460

http://forums.techarena.in

  Réponse avec citation
Vieux 20/11/2007, 21h36   #2
Jeffery Hicks [MVP]
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script Need to check disk space on remote servers

You might find this easier using WMIC (PowerShell would be even easier).

A command like this will check one computer, myComputer and create a simple
HTML table with the name, size and freespace.
C:\Scripts>wmic /node:MyComputer /append:"c:\test\report.html" logicaldisk
where drivetype=3 get Name,Size,FreeSpace /format:htable.xsl > NULL

You can easily check a list of computers like this:
C:\Scripts>wmic /node:@servers.txt /append:"c:\test\report.html" logicaldisk
where drivetype=3 get Name,Size,FreeSpace /format:htable.xsl > NULL

This is reporting all fixed logical drives. I thought I'd be able to modify
the query to also check freespace, but that part isn't working. I'll have
to see why.

Here's how easy it is to create the html report in PowerShell:
PS C:\test> get-wmiobject -computer (get-content servers.txt) -query "Select
* from win32_logicaldisk where freespace <=
32212254720 and drivetype=3" | Select SystemName,DeviceID,Size,FreeSpace |
convertto-html | out-file c:\test\report.html

It may look complicated but it is one line that goes through a list of
servers (servers.txt) and uses WMI to find all logical disks with less then
30GB of free space. Any matches are sent to the HTML report. PowerShell
only needs to be installed where you run the script. Not necessarily on the
remote systems. Sending an email through PowerShell is pretty simple as
well.


--
Jeffery Hicks
Microsoft PowerShell MVP
http://www.scriptinganswers.com
http://www.powershellcommunity.org

Now Available: WSH and VBScript Core: TFM
Coming Soon: Windows PowerShell: TFM 2nd Ed.
"screwuphead" <screwuphead.30czze@DoNotSpam.com> wrote in message
news:screwuphead.30czze@DoNotSpam.com...
>
> I know i could always a program to do this but wheres the fun in that?
> so I need a program that will go through a list of servers and then a
> list of their drives and check to see how much free space is left on
> those drives, from their if it is anything less then 30GB i need it to
> send an email to me.
> i am using psexec to access these remote servers and run cmd. then to
> email myself i am using postie.
> the problem i am having is wrapping that all up in a if-then-else
> command that will look for the specified free space. It doesnt work
> right now beacuse for whatever reason it is bring back a true statement
> when the statement is false because i know the server its checking is
> more then 30GB free.
> This is what i have so far:
>
> @echo off
>
> for /f %%S IN (serverPClist.txt) DO (
> echo Checking drives on Server %%S...
> for /D %%D IN (C D F G H I J K X V E) DO (
>
> psexec \\%%S cmd /c if exist %%D:\* dir %%D:\ | findstr /c:"bytes" >
> %temp%\%%S-%%D.txt
> )
> )
>
>
> color 0D
>
>
> for /f %%S IN (serverPClist.txt) DO (
> echo. & echo.
> echo ********** Displaying output for server %%S... **********
>
> for /D %%D IN (C D E F G I J K) DO (
> for /f "tokens=1,2,3,4" %%F IN ('if exist %temp%\%%S-%%D.txt type
> %temp%\%%S-%%D.txt') DO (
> if /i "%%G" == "Dir(s)" echo For the %%D: drive: %%H bytes free space.
> if /i "%%G" == "bytes" echo For the %%D: drive: %%F bytes free space.
> echo.
> )
> )
> echo Done!
> )
> echo Generating HTML...
>
> REM this part of the script generates an HTML file with all the
> relevant information
> REM and then launches it using the default browser.
>
> set FileName="C:\Report.html"
> echo ^<HTML^> > %FileName%
> echo ^<HEAD^> >> %FileName%
> echo ^<TITLE^>Free Space on NRCE Servers^</TITLE^> >> %FileName%
> echo ^</HEAD^> >> %FileName%
> echo ^<BODY^> >> %FileName%
> echo ^<CENTER^>^<FONT SIZE=6 COLOR=BLUE^>Free Hard Drive Space
> Report^</FONT^>^</CENTER^>^<BR^> >> %FileName%
>
> for /f %%S IN (serverPClist.txt) DO (
> REM mark the server
> echo ^<FONT SIZE=4^>^<B^>%%S^</B^>^</FONT^>^<BR^> >> %FileName%
> for /D %%D IN (C D E F G I J K) DO (
> for /f "tokens=1,2,3,4" %%F IN ('if exist %temp%\%%S-%%D.txt type
> %temp%\%%S-%%D.txt') DO (
> REM add a line for the drive and free space
> if /i "%%G" == "Dir(s)" echo ^<FONT SIZE=3^>Free space on
> ^<B^>%%D:^</B^> drive: ^<B^>^<FONT
>
> COLOR=GREEN^>%%H^</FONT^>^</B^> bytes free^</FONT^>^<BR^> >> %FileName%
>
> if /i "%%G" == "bytes" echo ^<FONT SIZE=3^>Free space on
> ^<B^>%%D:^</B^> drive: ^<B^>^<FONT
>
> COLOR=GREEN^>%%F^</FONT^>^</B^> bytes free^</FONT^>^<BR^> >> %FileName%
>
> )
> )
> REM mark some spacing lines into the HTML file
> echo ^<BR^> >> %FileName%
> )
>
> echo ^</BODY^> >> %FileName%
> echo ^</HTML^> >> %FileName%
>
> REM launch the HTML file
>
> set positive=1
> set amount="30,000,000,000"
> if %%f leq %amount% set violation=1
> if %%h leq %amount% set violation=1
> echo %violation%
> if %violation% equ %positive% postie -hostSMTP SERVER) -toMY EMAIL)
> -fromNETWORK EMAIL) -s:"Server Report" -msg:"THERE IS A VIOLATION!"
> -a:"C:\ServerReports\Report.html"
> echo Done!
>
> If anybody else has anything better plz show me, otherwise i will keep
> playing around with this coding.
>
>
> --
> screwuphead
> ------------------------------------------------------------------------
> screwuphead's Profile: http://forums.techarena.in/member.php?userid=34605
> View this thread: http://forums.techarena.in/showthread.php?t=856460
>
> http://forums.techarena.in
>


  Réponse avec citation
Vieux 21/11/2007, 14h43   #3
screwuphead
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script Need to check disk space on remote servers


hmm alright ill give it a try!
THANKS!


--
screwuphead
------------------------------------------------------------------------
screwuphead's Profile: http://forums.techarena.in/member.php?userid=34605
View this thread: http://forums.techarena.in/showthread.php?t=856460

http://forums.techarena.in

  Réponse avec citation
Vieux 22/11/2007, 13h53   #4
Dominic Johnson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script Need to check disk space on remote servers

If you are looking for an email notification when a server's disk
breaches the 30GB free space mark then a permanent event subscription
in WMI may give you what you need.

The event subscription consists of a an event filter and an event
consumer. Events matching the filter criteria are delivered to an
event consumer for action. The filter and consumer are registered and
bound in WMI so there isn't a requirement for a continuously running
script and there should be little or no impact on the CPU usage.

There is no script to run or list of servers to maintain, the setup is
generic and the same registration can be applied to all your servers
(with a minor change depending on the OS). Each server will report
the threshold breach directly and automatically, via built in email
notification, as soon as the event is recognised. This can also be
applied to monitoring criteria other than just disk freespace.

Probably the simplest way to setup a permanent event subscription is
to create a Managed Object Format (mof) file that describes the event
filter and consumer actions (there is a built in SMTP consumer and a
script consumer).

The mof file is then compiled into the relevant WMI namespace using
the mofcomp utility (e.g. mofcomp myfile.mof):

This is an example of a mof file that sets up an event subscription
for disks that drop below 30GB of freespace. It polls WMI every 10
minutes for an event (this interval can be changed) and when a event
of this type is seem it then sends an email to the configured address.

// #pragma namespace ("\\\\.\\root\\subscription")
// for Windows 2000 use #pragma namespace ("\\\\.\\root\\cimv2")

instance of __EventFilter as $FILTER
{
Name = "Disk Space Filter";

// Windows Server 2003 and Windows XP only
EventNamespace = "root\\cimv2";

Query = "SELECT * FROM __InstanceModificationEvent
WITHIN 10
WHERE TargetInstance
ISA \"Win32_LogicalDisk\"
AND TargetInstance.DriveType = 3
AND TargetInstance.FreeSpace < 32212254720 ";

QueryLanguage = "WQL";
};


instance of SMTPEventConsumer as $CONSUMER
{
Name = "Disk Space";
ToLine = "my.name@mydomain.com";
SMTPServer = "mailserver.mydomain.com";
Subject = "WARNING: Free Space on
%TargetInstance.SystemName%
disk %TargetInstance.Name% is below
30GB";
Message = " ";
};

instance of __FilterToConsumerBinding
{
Consumer = $CONSUMER ;
Filter = $FILTER ;
};


Don't be put off if the syntax isn't already familiar to you - it's
fairly straightforward and loading it into WMI on a remote server is
no more complicated than running the command:

mofcomp -n:\\myserver\root\subscription myfile.mof

There's more information available here:

http://msdn2.microsoft.com/en-us/library/aa393014.aspx

You can also create, view, modify and delete filter and consumer
instances using Event Registration in WMI Administrative Tools:

http://www.microsoft.com/downloads/d...DisplayLang=en



Dominic
  Réponse avec citation
Vieux 10/12/2007, 22h39   #5
drew
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script Need to check disk space on remote servers

hi
this thread was a real eye opener.

i have three questions;
Is it possible to include the remote computer name in the query or its
result ?
Is it possible to keept the process running by skipping over remote computer
name in server.txt for which i do not know or do not have adequate
credentials?
Is it possible to get SQL Server database and log information (like
sp_file for example) from wmi, or must i write SQL Server Alerts and push
them into the Error Log, then retrieve them from there?

I just found out i have 85 SQL Servers to mind, and this looks like a great
leg up!
thanks
drew


"Jeffery Hicks [MVP]" wrote:

> You might find this easier using WMIC (PowerShell would be even easier).
>
> A command like this will check one computer, myComputer and create a simple
> HTML table with the name, size and freespace.
> C:\Scripts>wmic /node:MyComputer /append:"c:\test\report.html" logicaldisk
> where drivetype=3 get Name,Size,FreeSpace /format:htable.xsl > NULL
>
> You can easily check a list of computers like this:
> C:\Scripts>wmic /node:@servers.txt /append:"c:\test\report.html" logicaldisk
> where drivetype=3 get Name,Size,FreeSpace /format:htable.xsl > NULL
>
> This is reporting all fixed logical drives. I thought I'd be able to modify
> the query to also check freespace, but that part isn't working. I'll have
> to see why.
>
> Here's how easy it is to create the html report in PowerShell:
> PS C:\test> get-wmiobject -computer (get-content servers.txt) -query "Select
> * from win32_logicaldisk where freespace <=
> 32212254720 and drivetype=3" | Select SystemName,DeviceID,Size,FreeSpace |
> convertto-html | out-file c:\test\report.html
>
> It may look complicated but it is one line that goes through a list of
> servers (servers.txt) and uses WMI to find all logical disks with less then
> 30GB of free space. Any matches are sent to the HTML report. PowerShell
> only needs to be installed where you run the script. Not necessarily on the
> remote systems. Sending an email through PowerShell is pretty simple as
> well.
>
>
> --
> Jeffery Hicks
> Microsoft PowerShell MVP
> http://www.scriptinganswers.com
> http://www.powershellcommunity.org
>
> Now Available: WSH and VBScript Core: TFM
> Coming Soon: Windows PowerShell: TFM 2nd Ed.
> "screwuphead" <screwuphead.30czze@DoNotSpam.com> wrote in message
> news:screwuphead.30czze@DoNotSpam.com...
> >
> > I know i could always a program to do this but wheres the fun in that?
> > so I need a program that will go through a list of servers and then a
> > list of their drives and check to see how much free space is left on
> > those drives, from their if it is anything less then 30GB i need it to
> > send an email to me.
> > i am using psexec to access these remote servers and run cmd. then to
> > email myself i am using postie.
> > the problem i am having is wrapping that all up in a if-then-else
> > command that will look for the specified free space. It doesnt work
> > right now beacuse for whatever reason it is bring back a true statement
> > when the statement is false because i know the server its checking is
> > more then 30GB free.
> > This is what i have so far:
> >
> > @echo off
> >
> > for /f %%S IN (serverPClist.txt) DO (
> > echo Checking drives on Server %%S...
> > for /D %%D IN (C D F G H I J K X V E) DO (
> >
> > psexec \\%%S cmd /c if exist %%D:\* dir %%D:\ | findstr /c:"bytes" >
> > %temp%\%%S-%%D.txt
> > )
> > )
> >
> >
> > color 0D
> >
> >
> > for /f %%S IN (serverPClist.txt) DO (
> > echo. & echo.
> > echo ********** Displaying output for server %%S... **********
> >
> > for /D %%D IN (C D E F G I J K) DO (
> > for /f "tokens=1,2,3,4" %%F IN ('if exist %temp%\%%S-%%D.txt type
> > %temp%\%%S-%%D.txt') DO (
> > if /i "%%G" == "Dir(s)" echo For the %%D: drive: %%H bytes free space.
> > if /i "%%G" == "bytes" echo For the %%D: drive: %%F bytes free space.
> > echo.
> > )
> > )
> > echo Done!
> > )
> > echo Generating HTML...
> >
> > REM this part of the script generates an HTML file with all the
> > relevant information
> > REM and then launches it using the default browser.
> >
> > set FileName="C:\Report.html"
> > echo ^<HTML^> > %FileName%
> > echo ^<HEAD^> >> %FileName%
> > echo ^<TITLE^>Free Space on NRCE Servers^</TITLE^> >> %FileName%
> > echo ^</HEAD^> >> %FileName%
> > echo ^<BODY^> >> %FileName%
> > echo ^<CENTER^>^<FONT SIZE=6 COLOR=BLUE^>Free Hard Drive Space
> > Report^</FONT^>^</CENTER^>^<BR^> >> %FileName%
> >
> > for /f %%S IN (serverPClist.txt) DO (
> > REM mark the server
> > echo ^<FONT SIZE=4^>^<B^>%%S^</B^>^</FONT^>^<BR^> >> %FileName%
> > for /D %%D IN (C D E F G I J K) DO (
> > for /f "tokens=1,2,3,4" %%F IN ('if exist %temp%\%%S-%%D.txt type
> > %temp%\%%S-%%D.txt') DO (
> > REM add a line for the drive and free space
> > if /i "%%G" == "Dir(s)" echo ^<FONT SIZE=3^>Free space on
> > ^<B^>%%D:^</B^> drive: ^<B^>^<FONT
> >
> > COLOR=GREEN^>%%H^</FONT^>^</B^> bytes free^</FONT^>^<BR^> >> %FileName%
> >
> > if /i "%%G" == "bytes" echo ^<FONT SIZE=3^>Free space on
> > ^<B^>%%D:^</B^> drive: ^<B^>^<FONT
> >
> > COLOR=GREEN^>%%F^</FONT^>^</B^> bytes free^</FONT^>^<BR^> >> %FileName%
> >
> > )
> > )
> > REM mark some spacing lines into the HTML file
> > echo ^<BR^> >> %FileName%
> > )
> >
> > echo ^</BODY^> >> %FileName%
> > echo ^</HTML^> >> %FileName%
> >
> > REM launch the HTML file
> >
> > set positive=1
> > set amount="30,000,000,000"
> > if %%f leq %amount% set violation=1
> > if %%h leq %amount% set violation=1
> > echo %violation%
> > if %violation% equ %positive% postie -hostSMTP SERVER) -toMY EMAIL)
> > -fromNETWORK EMAIL) -s:"Server Report" -msg:"THERE IS A VIOLATION!"
> > -a:"C:\ServerReports\Report.html"
> > echo Done!
> >
> > If anybody else has anything better plz show me, otherwise i will keep
> > playing around with this coding.
> >
> >
> > --
> > screwuphead
> > ------------------------------------------------------------------------
> > screwuphead's Profile: http://forums.techarena.in/member.php?userid=34605
> > View this thread: http://forums.techarena.in/showthread.php?t=856460
> >
> > http://forums.techarena.in
> >

>

  Réponse avec citation
Vieux 12/12/2007, 16h27   #6
drew
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script Need to check disk space on remote servers

forgive me. i was an idiot.
i see machine name after the pipe
drew

"drew" wrote:

> hi
> this thread was a real eye opener.
>
> i have three questions;
> Is it possible to include the remote computer name in the query or its
> result ?
> Is it possible to keept the process running by skipping over remote computer
> name in server.txt for which i do not know or do not have adequate
> credentials?
> Is it possible to get SQL Server database and log information (like
> sp_file for example) from wmi, or must i write SQL Server Alerts and push
> them into the Error Log, then retrieve them from there?
>
> I just found out i have 85 SQL Servers to mind, and this looks like a great
> leg up!
> thanks
> drew
>
>
> "Jeffery Hicks [MVP]" wrote:
>
> > You might find this easier using WMIC (PowerShell would be even easier).
> >
> > A command like this will check one computer, myComputer and create a simple
> > HTML table with the name, size and freespace.
> > C:\Scripts>wmic /node:MyComputer /append:"c:\test\report.html" logicaldisk
> > where drivetype=3 get Name,Size,FreeSpace /format:htable.xsl > NULL
> >
> > You can easily check a list of computers like this:
> > C:\Scripts>wmic /node:@servers.txt /append:"c:\test\report.html" logicaldisk
> > where drivetype=3 get Name,Size,FreeSpace /format:htable.xsl > NULL
> >
> > This is reporting all fixed logical drives. I thought I'd be able to modify
> > the query to also check freespace, but that part isn't working. I'll have
> > to see why.
> >
> > Here's how easy it is to create the html report in PowerShell:
> > PS C:\test> get-wmiobject -computer (get-content servers.txt) -query "Select
> > * from win32_logicaldisk where freespace <=
> > 32212254720 and drivetype=3" | Select SystemName,DeviceID,Size,FreeSpace |
> > convertto-html | out-file c:\test\report.html
> >
> > It may look complicated but it is one line that goes through a list of
> > servers (servers.txt) and uses WMI to find all logical disks with less then
> > 30GB of free space. Any matches are sent to the HTML report. PowerShell
> > only needs to be installed where you run the script. Not necessarily on the
> > remote systems. Sending an email through PowerShell is pretty simple as
> > well.
> >
> >
> > --
> > Jeffery Hicks
> > Microsoft PowerShell MVP
> > http://www.scriptinganswers.com
> > http://www.powershellcommunity.org
> >
> > Now Available: WSH and VBScript Core: TFM
> > Coming Soon: Windows PowerShell: TFM 2nd Ed.
> > "screwuphead" <screwuphead.30czze@DoNotSpam.com> wrote in message
> > news:screwuphead.30czze@DoNotSpam.com...
> > >
> > > I know i could always a program to do this but wheres the fun in that?
> > > so I need a program that will go through a list of servers and then a
> > > list of their drives and check to see how much free space is left on
> > > those drives, from their if it is anything less then 30GB i need it to
> > > send an email to me.
> > > i am using psexec to access these remote servers and run cmd. then to
> > > email myself i am using postie.
> > > the problem i am having is wrapping that all up in a if-then-else
> > > command that will look for the specified free space. It doesnt work
> > > right now beacuse for whatever reason it is bring back a true statement
> > > when the statement is false because i know the server its checking is
> > > more then 30GB free.
> > > This is what i have so far:
> > >
> > > @echo off
> > >
> > > for /f %%S IN (serverPClist.txt) DO (
> > > echo Checking drives on Server %%S...
> > > for /D %%D IN (C D F G H I J K X V E) DO (
> > >
> > > psexec \\%%S cmd /c if exist %%D:\* dir %%D:\ | findstr /c:"bytes" >
> > > %temp%\%%S-%%D.txt
> > > )
> > > )
> > >
> > >
> > > color 0D
> > >
> > >
> > > for /f %%S IN (serverPClist.txt) DO (
> > > echo. & echo.
> > > echo ********** Displaying output for server %%S... **********
> > >
> > > for /D %%D IN (C D E F G I J K) DO (
> > > for /f "tokens=1,2,3,4" %%F IN ('if exist %temp%\%%S-%%D.txt type
> > > %temp%\%%S-%%D.txt') DO (
> > > if /i "%%G" == "Dir(s)" echo For the %%D: drive: %%H bytes free space.
> > > if /i "%%G" == "bytes" echo For the %%D: drive: %%F bytes free space.
> > > echo.
> > > )
> > > )
> > > echo Done!
> > > )
> > > echo Generating HTML...
> > >
> > > REM this part of the script generates an HTML file with all the
> > > relevant information
> > > REM and then launches it using the default browser.
> > >
> > > set FileName="C:\Report.html"
> > > echo ^<HTML^> > %FileName%
> > > echo ^<HEAD^> >> %FileName%
> > > echo ^<TITLE^>Free Space on NRCE Servers^</TITLE^> >> %FileName%
> > > echo ^</HEAD^> >> %FileName%
> > > echo ^<BODY^> >> %FileName%
> > > echo ^<CENTER^>^<FONT SIZE=6 COLOR=BLUE^>Free Hard Drive Space
> > > Report^</FONT^>^</CENTER^>^<BR^> >> %FileName%
> > >
> > > for /f %%S IN (serverPClist.txt) DO (
> > > REM mark the server
> > > echo ^<FONT SIZE=4^>^<B^>%%S^</B^>^</FONT^>^<BR^> >> %FileName%
> > > for /D %%D IN (C D E F G I J K) DO (
> > > for /f "tokens=1,2,3,4" %%F IN ('if exist %temp%\%%S-%%D.txt type
> > > %temp%\%%S-%%D.txt') DO (
> > > REM add a line for the drive and free space
> > > if /i "%%G" == "Dir(s)" echo ^<FONT SIZE=3^>Free space on
> > > ^<B^>%%D:^</B^> drive: ^<B^>^<FONT
> > >
> > > COLOR=GREEN^>%%H^</FONT^>^</B^> bytes free^</FONT^>^<BR^> >> %FileName%
> > >
> > > if /i "%%G" == "bytes" echo ^<FONT SIZE=3^>Free space on
> > > ^<B^>%%D:^</B^> drive: ^<B^>^<FONT
> > >
> > > COLOR=GREEN^>%%F^</FONT^>^</B^> bytes free^</FONT^>^<BR^> >> %FileName%
> > >
> > > )
> > > )
> > > REM mark some spacing lines into the HTML file
> > > echo ^<BR^> >> %FileName%
> > > )
> > >
> > > echo ^</BODY^> >> %FileName%
> > > echo ^</HTML^> >> %FileName%
> > >
> > > REM launch the HTML file
> > >
> > > set positive=1
> > > set amount="30,000,000,000"
> > > if %%f leq %amount% set violation=1
> > > if %%h leq %amount% set violation=1
> > > echo %violation%
> > > if %violation% equ %positive% postie -hostSMTP SERVER) -toMY EMAIL)
> > > -fromNETWORK EMAIL) -s:"Server Report" -msg:"THERE IS A VIOLATION!"
> > > -a:"C:\ServerReports\Report.html"
> > > echo Done!
> > >
> > > If anybody else has anything better plz show me, otherwise i will keep
> > > playing around with this coding.
> > >
> > >
> > > --
> > > screwuphead
> > > ------------------------------------------------------------------------
> > > screwuphead's Profile: http://forums.techarena.in/member.php?userid=34605
> > > View this thread: http://forums.techarena.in/showthread.php?t=856460
> > >
> > > http://forums.techarena.in
> > >

> >

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 10h30.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,30658 seconds with 14 queries