<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>lupigabriel &#187; Check</title>
	<atom:link href="https://www.lupigabriel.it/tag/check/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lupigabriel.it</link>
	<description>Create something new is nice... Create something useful is important!</description>
	<lastBuildDate>Wed, 27 May 2015 01:59:17 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.9.22</generator>
	<item>
		<title>Check Disk Predictive for Nagios</title>
		<link>https://www.lupigabriel.it/check-disk-predictive-for-nagios/</link>
		<comments>https://www.lupigabriel.it/check-disk-predictive-for-nagios/#comments</comments>
		<pubDate>Tue, 28 Oct 2014 15:02:37 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[Repository]]></category>
		<category><![CDATA[Check]]></category>
		<category><![CDATA[Check Disk]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[Predictive]]></category>

		<guid isPermaLink="false">http://www.lupigabriel.it/?p=281</guid>
		<description><![CDATA[This VBScript check the status of local disks (used and free space) and performs a predictive analysis. This script can be used in all Microsoft Windows Systems running the following command&#8230; cscript.exe /nologo CheckDiskPredictive_v1.0.vbs C: 95 98 &#8230; Or can be integrated into the file nrpe.cfg of NRPE_NT (Nagios Agent for Windows) CheckDiskPredictive_v1.0.vbs [crayon-6a8f830ee2a19339186519/]]]></description>
				<content:encoded><![CDATA[<p>This VBScript check the status of local disks (used and free space) and performs a predictive analysis.</p>
<p>This script can be used in all Microsoft Windows Systems running the following command&#8230;</p>
<ul>
<li><em>cscript.exe /nologo CheckDiskPredictive_v1.0.vbs C: 95 98</em></li>
</ul>
<p>&#8230; Or can be integrated into the file <strong>nrpe.cfg</strong> of <strong>NRPE_NT (Nagios Agent for Windows)<br />
</strong></p>
<p><a href="http://www.lupigabriel.it/wp-content/uploads/2014/10/CheckDiskPredictive_v1.0.vbs_.zip" class="mtli_attachment mtli_zip" rel="mtli_filesize162kB">CheckDiskPredictive_v1.0.vbs</a></p>
<p></p><pre class="crayon-plain-tag">' ##############################################################################
' #                                Lupi Gabriel                                #
' #                             www.lupigabriel.it                             #
' #                            info@lupigabriel.it                             #
' ##############################################################################
' #            Copyright (c) 2014 Lupi Gabriel All rights reserved.            #
' ##############################################################################
' # NAME       : Nagios Windows Check Disk with Predictive Analysis            #
' # VERSION    : 1.0                                                           #
' # FILE       : CheckDiskPredictive_v1.0.vbs                                  #
' # CLASS      : Script                                                        #
' # LANGUAGE   : VB Script                                                     #
' ##############################################################################

On Error Resume Next

DriveUnit = Wscript.Arguments(0) ' Drive
PercentWarning = Wscript.Arguments(1) ' % Used Space for Warning
PercentCritical = Wscript.Arguments(2) ' % Used Space for Critical
PredictiveWarning = 3 ' Day Range for Predictive Warning
PredictiveCritical = 1 ' Day Range for Predictive Critical
PredictiveStep = 60 ' Max Log Lines 
PredictiveStepSens = 6 ' Use Log Line every # of Log Lines

PredictiveLog = "CheckDisk_" & UCase(Replace(DriveUnit, ":", "")) & "_Predictive.txt"


Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.GetDrive(DriveUnit)

UsedPercent = Round ((d.TotalSize - d.FreeSpace) * 100 / d.TotalSize, 2)
UsedSpace = "Used: " & Round ((d.TotalSize - d.FreeSpace)) & " B (" & UsedPercent & "%)"
If (d.TotalSize - d.FreeSpace) > 1023 Then
	UsedSpace = "Used: " & Round ((d.TotalSize - d.FreeSpace) / 1024 , 2) & " B (" & UsedPercent & "%)"
End If
If (d.TotalSize - d.FreeSpace) > 1048575 Then
	UsedSpace = "Used: " & Round ((d.TotalSize - d.FreeSpace) / 1024 / 1024 , 2) & " MB (" & UsedPercent & "%)"
End If
If (d.TotalSize - d.FreeSpace) > 1073741823 Then
	UsedSpace = "Used: " & Round ((d.TotalSize - d.FreeSpace) / 1024 / 1024 / 1024 , 2) & " GB (" & UsedPercent & "%)"
End If
If (d.TotalSize - d.FreeSpace) > 1099511627775 Then
	UsedSpace = "Used: " & Round ((d.TotalSize - d.FreeSpace) / 1024 / 1024 / 1024 / 1024 , 2) & " TB (" & UsedPercent & "%)"
End If

FreePercent = Round (d.FreeSpace * 100 / d.TotalSize)
FreeSpace = "Free: " & Round (d.FreeSpace) & " B (" & FreePercent & "%)"
If d.FreeSpace > 1023 Then
	FreeSpace = "Free: " & Round (d.FreeSpace / 1024 , 2) & " B (" & FreePercent & "%)"
End If
If d.FreeSpace > 1048575 Then
	FreeSpace = "Free: " & Round (d.FreeSpace / 1024 / 1024 , 2) & " MB (" & FreePercent & "%)"
End If
If d.FreeSpace > 1073741823 Then
	FreeSpace = "Free: " & Round (d.FreeSpace / 1024 / 1024 / 1024 , 2) & " GB (" & FreePercent & "%)"
End If
If d.FreeSpace > 1099511627775 Then
	FreeSpace = "Free: " & Round (d.FreeSpace / 1024 / 1024 / 1024 / 1024 , 2) & " TB (" & FreePercent & "%)"
End If

LineCount = 0
If (fso.FileExists (PredictiveLog)) Then
	Set objFile = fso.OpenTextFile(PredictiveLog, 1)
	Do Until objFile.AtEndOfStream
		Line = objFile.ReadLine
		If Line <> "" Then
			LineCount = LineCount + 1
		End If
	Loop
	objFile.Close
	Set objFile = Nothing
End If

StepCount = 0
StepAllLines = ""
If LineCount > PredictiveStep - 1 Then
	Set objFile = fso.OpenTextFile(PredictiveLog, 1)
	Do Until objFile.AtEndOfStream
		StepLine = objFile.ReadLine
		If StepLine <> "" Then
			StepCount = StepCount + 1
			If StepCount > (LineCount - PredictiveStep + 1) Then
				If StepCount = LineCount Then
					StepAllLines = StepAllLines & StepLine
				Else
					StepAllLines = StepAllLines & StepLine & vbCrLf
				End If
			End If
		End If
	Loop
	objFile.Close
	Set objFile = Nothing
	Set objFile = fso.OpenTextFile(PredictiveLog, 2, True)
	objFile.WriteLine(StepAllLines)
	objFile.Close
	Set objFile = Nothing
End If

Set objFile = fso.OpenTextFile(PredictiveLog, 8, True)
objFile.WriteLine(UsedPercent & " | " & Now)
objFile.Close
Set objFile = Nothing

LineCount = 0
LineSensTotal = 0
LineSensCount = 0
PercentStep = 0
PercentLastStep = 0
TimeStep = "FirstLine"
TimeStepLast = ""
If (fso.FileExists (PredictiveLog)) Then
	Set objFile = fso.OpenTextFile(PredictiveLog, 1)
	Do Until objFile.AtEndOfStream
		Line = objFile.ReadLine
		If Line <> "" And InStr(Line, " | ") > 0 Then
			LineSplit = Split(Line, " | ")
			LineCount = LineCount + 1
			LineSensCount = LineSensCount + 1
			If LineSensCount = 1 Then
				If TimeStep = "FirstLine" Then
					TimeStep = 0
					TimeStepLast = LineSplit(1)
					PercentLastStep = LineSplit(0)
				Else
					TimeStep = TimeStep + DateDiff("s", TimeStepLast, LineSplit(1))
					TimeStepLast = LineSplit(1)
					PercentStep = PercentStep + (LineSplit(0) - PercentLastStep)
					PercentLastStep = LineSplit(0)
				End If
				LineSensTotal = LineSensTotal + 1
			End If
			If LineSensCount = PredictiveStepSens Then LineSensCount = 0 End If
		End If
	Loop
	objFile.Close
	Set objFile = Nothing
End If

PercentStep = Round(PercentStep / (LineSensTotal - 1), 2)
TimeStep = Round(TimeStep / (LineSensTotal - 1), 2)
PredictivePercent = LineSplit(0)
PredictiveTime = LineSplit(1)
PredictiveTotalStep = Round(PredictiveWarning * 24 * 60 * 60 / TimeStep)
PredictiveStatus = 0
PredictiveBreakDate = ""
PredictiveBreakStep = 0
If PercentStep > 0 And PredictiveStep = LineCount Then
	For i = 1 to PredictiveTotalStep
		PredictivePercent = Round(PredictivePercent + PercentStep, 2)
		PredictiveTime = DateAdd("s", TimeStep, PredictiveTime)
		If PredictivePercent >= 100 Then
			PredictiveBreakStep = Round(i * TimeStep / 60 / 60 / 24, 2)
			If PredictiveBreakStep < PredictiveWarning Then PredictiveStatus = 1 End If
			If PredictiveBreakStep < PredictiveCritical Then PredictiveStatus = 2 End If
			i = PredictiveTotalStep
			PredictiveBreakDate = vbCrLf & "Predictive Disk Full: " & PredictiveTime
		End If
	Next
End If

Wscript.Echo UsedSpace & " " & FreeSpace & PredictiveBreakDate

Set d = Nothing
Set fso = Nothing

If PredictiveStatus = 1 Then Wscript.Quit 1 End If
If PredictiveStatus = 2 Then Wscript.Quit 2 End If
If CInt(UsedPercent) < CInt(PercentCritical) And CInt(UsedPercent) < CInt(PercentWarning) Then Wscript.Quit 0 End If
If CInt(UsedPercent) < CInt(PercentCritical) And CInt(UsedPercent) >= CInt(PercentWarning) Then Wscript.Quit 1 End If
If CInt(UsedPercent) >= CInt(PercentCritical) And CInt(UsedPercent) >= CInt(PercentWarning) Then Wscript.Quit 2 End If
Wscript.Quit 3</pre><p></p>
<style type="text/css">a[rel~="mtli_filesize162kB"]:after {content:" (1.62 kB)"}</style>]]></content:encoded>
			<wfw:commentRss>https://www.lupigabriel.it/check-disk-predictive-for-nagios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
