Page 2 of 2

Re: Performance Graph

Posted: Thu Apr 05, 2012 7:32 am
by lamin
See attachment.

Re: Performance Graph

Posted: Thu Apr 05, 2012 7:51 am
by scottwilkerson
Excellent, now without changing anything, can you post the current contents of your script.

thanks

Re: Performance Graph

Posted: Thu Apr 05, 2012 7:56 am
by lamin
"directory_file_count.wsf"
'
' 07/11/2003 ver 0.1
'
' Author: Joe Garfunkel - [email protected]
'
' Credits to Ethan Galstad / Hagen Deike for the script
' design of "check_fileage", which I copied and modified.
'
' --------------------------------------------------------------
'
' This script counts the number of files contained within a
' directory path. For example, the number of files contained
' in an email queue directory.
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

<job>
<runtime>
<description>
directory_file_count (nrpe_nt-plugin) 1.1
The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute
copies of the plugins under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

This plugin was developed on Microsoft Windows 2000, using "Windows
Script Host" version 5.6 . The current version of the Script Host
can be downloaded from msdn.microsoft.com/scripting/

This plugin also requires the use of Microsoft "Windows Management
Instrumentation" (WMI), which is included in the default Win2K,
but the "Core WMI" must be installed manually on Windows NT. The
download site for WMI can be found by going to:
http://www.microsoft.com/downloads/rele ... seID=18491

(It seems that Microsoft has hiddent this NT download in the darkest
crevice to make it as difficult as possible to find. Make sure
you download the correct version for NT, and not the '95, '98, ME
version.)

This plugin will count the number of files that are contained within a
specific directory path. For example, the number of files contained in
an mail queue directory.

This version of the "directory_file_count" plugin does not perform
any validation on your command-line options. Please follow the
syntax provided, and double-check that you have typed your
options correctly. -Thanks!

An example execution command to run this plugin from the nrpe.cfg follows.
The command should all be entered on one line, but is wrapped here for
readability.

command[directory_file_count]=c:\winnt\system32\cscript.exe
//NoLogo //T:30
c:\nrpe_nt\directory_file_count.wsf c: \\temp\\servstat\\ 10 15


</description>
<named
name="h"
helpstring="Help"
type="simple"
required="false"
/>
<unnamed
name="drive"
helpstring="Disk Drive Letter."
many="false"
required="true"
/>
<unnamed
name="directory-path"
helpstring="Path to the location of your files."
many="false"
required="true"
/>
<unnamed
name="warning-value"
helpstring="Number of files for Warning condition."
many="false"
required="true"
/>
<unnamed
name="critical-value"
helpstring="Number of files for Critical condition."
many="false"
required="true"
/>
<example>
Example: directory_file_count.wsf c: \\Temp\\Queue\\ 5 10
</example>
</runtime>
<script language="VBScript">

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

If Wscript.Arguments.Named.Exists("h") Or Wscript.Arguments.Count = 0 Then
Wscript.Echo "Plugin help screen:"
Wscript.Arguments.ShowUsage()
Wscript.Quit(0)
End If

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Const's and Var's
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

strDiskDrive = Wscript.Arguments.Unnamed.Item(0)
strPath = Wscript.Arguments.Unnamed.Item(1)
strWarningValue = Wscript.Arguments.Unnamed.Item(2)
strCriticalValue = Wscript.Arguments.Unnamed.Item(3)

'Wscript.Echo "strDiskDrive: " & strDiskDrive
'Wscript.Echo "strPath: " & strPath
'Wscript.Echo "strWarningValue: " & strWarningValue
'Wscript.Echo "strCriticalValue: " & strCriticalValue

FileCount = 0

Const intOK = 0
Const intWarning = 1
Const intCritical = 2
Const intUnknown = 3

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

strComputer = "."

'Wscript.Echo "Before set objWMIService ."

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

'Wscript.Echo "Before set objWMIService.ExecQuery ."

Set colFiles = objWMIService.ExecQuery _
( "SELECT * FROM CIM_DataFile WHERE Drive = '" & strDiskDrive & "' AND Path = '" & strPath & "' ")


FileCount = 0
For Each objFile in colFiles
'Wscript.Echo objFile.Name
FileCount = FileCount + 1
Next


'Wscript.Echo "Total number of files is: " & FileCount


FileCount = Int(FileCount)
strWarningValue = Int(strWarningValue)
strCriticalValue = Int(strCriticalValue)


If ( FileCount > strWarningValue ) or ( FileCount > strCriticalValue ) Then
'Wscript.Echo "Inside outer If statement."

If (FileCount > strCriticalValue) Then
'Wscript.Echo "Inside CriticalValue If statement."
Wscript.Echo "CRITICAL: File count is " & FileCount & ".|count=" & FileCount
Wscript.Quit(intCritical)
End If


If (FileCount > strWarningValue) Then
'Wscript.Echo "Inside WarningValue If statement."
Wscript.Echo "WARNING: File count is " & FileCount & ".|count=" & FileCount
Wscript.Quit(intWarning)
End If

End If


Wscript.Echo "OK: File count is " & FileCount & ".|count=" & FileCount
Wscript.Quit(intOK)


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

</script>
</job>

Re: Performance Graph

Posted: Thu Apr 05, 2012 8:54 am
by scottwilkerson
I'm not a big vbscript programmer, but I thing the | symbol in the echo's needs to be escaped.

Can you try replacing | with ^^^|

Re: Performance Graph

Posted: Mon Apr 09, 2012 12:03 pm
by lamin
Hey guys,
It is working now. Thanks for the support