Monitoring B.O. Web Intelligence Servers

by techpilot007 28. April 2012 13:33

A few months ago we started to have some issues where we would find that one or more Web Intelligence (Webi server) servers in Business Objects on a physical Windows server would stop. I was asked to come up with a way to monitor the number of Webi’s on the physical server using Nagios.  Because not all of our machines are running the same version of Powershell I decided to go with vbScript in a wsf.  I call the wsf using Nagios and NSClient++. The script allows for the input of a few command line arguments (/s:Name_of_Process, /w:Warning_Level, /c:Critical_Level). An example of the command to call the script is:

 

cscript check_BOWebiProcess.wsf /s:explorer /w:1 /c:0

In the NSC.ini file I added this line.

 

check_BOWebiProcess=cscript.exe //nologo //T:60 check_BOWebiProcess.wsf "$ARG1$" "$ARG2$" "$ARG3$"

I've included the script below. Let me know what you think, leave your thoughts in the comments section below.

 

'
'***********************************************************************
' "check_BOWebiProcess.wsf"
' Checks for service status on a Windows platform.
'************************************************************************
' Copyright (c) 2012 Jeremy McEachron (techpilot007)
' All rights reserved.
'
' Redistribution and use in source and binary forms, with or without
' modification, are permitted provided that the following conditions
' are met:
' 1. Redistributions of source code must retain the above copyright
'    notice, this list of conditions and the following disclaimer.
' 2. Redistributions in binary form must reproduce the above copyright
'    notice, this list of conditions and the following disclaimer in the
'    documentation and/or other materials provided with the distribution.
'
' THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
' ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
' IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
' ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
' FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
' DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
' OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
' HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
' LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
' OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
' SUCH DAMAGE.
'

<job>
<runtime>
  <description>

check_services (nrpe_nt-plugin) 1.5
This nrpe_nt plugin come with ABSOLUTELY NO WARRANTY. You may redistribute
copies of the plugins under the terms of the GNU General Public License.

  </description>
    <named
      name="h"
      helpstring="Help"
      type="simple"
      required="false" 
    />
  />

  <example>
         
  You need to provide a string for this plugin.
         	
  This script checks the current status of a specified service. If using a wildcard character 
  for the name of your service then you need to use the percent symbol (%).
  
  w = Number of processes to trigger warning state
  c = Number of processes to trigger critical state

  Usage: command[check_BOWebiProcess]=c:\Windows\system32\cscript.exe //nologo //T:60 check_BOWebiProcess.wsf "$ARG1$" "$ARG2$" "$ARG3$"
  cscript check_BOWebiProcess.wsf /s:explorer /w:1 /c:0

  </example>

</runtime>

<script language="VBScript">


'*******************************************************************
' Help
'*******************************************************************
If Wscript.Arguments.Named.Exists("h") Then
      Wscript.Echo "Plugin help screen:"
      Wscript.Arguments.ShowUsage()
      Wscript.Quit(3)
End If

'*******************************************************************
' Main
'*******************************************************************


Dim OutputCode, objWMIService, colItems, ComputerName, strOutput, ServiceFound

' Default to an UNKNOWN error
OutputCode = 3

' Have we found this site yet?
ServiceFound = 0

args = WScript.Arguments.Count

If args < 1 Then
   WScript.Echo "Usage:  check_services.vbs [service name]"
   WScript.Echo ""
   WScript.Echo "Note:  The service name is the name listed in the properties of the"
   WScript.Echo "       service, NOT the virtual host name or IIS site number,"
   WScript.Echo "       and is case sensitive."
   WScript.Echo ""
   WScript.Quit( OutputCode )
End If

'*******************************************************************
' load args
'*******************************************************************
Set colNamedArguments = WScript.Arguments.Named
strServiceName = colNamedArguments.Item("s")
intWarningLevel = CInt(colNamedArguments.Item("w"))
intCriticalLevel = cInt(colNamedArguments.Item("c"))

ComputerName = "."

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & ComputerName & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name Like '" & strServiceName & "'")
	
Err.Clear


'output code 0 = OK
'output code 1 = Warning
'output code 2 = Critical
'output code 2 = Unknown

intProcesses = colItems.Count
intIndex = 0
intstatus = 0

' Gather info on each matching process.
For Each objItem in colItems
        ServiceFound = 1
	intIndex = intIndex + 1

	strProcessInfo = objItem.Name & "(" & intIndex & ")" & " ProcessID: " & objItem.ProcessId & " Memory: " & (objItem.WorkingSetSize / 1024) & " KB"
	strProcessPerfInfo = " '" & objItem.Name & "(" & intIndex & ") Memory KB'=" & (objItem.WorkingSetSize / 1024) & "KB"

	'WSCript.Echo objItem.Name & "(" & intIndex & ") " & objItem.ProcessId & " " & (objItem.WorkingSetSize / 1024) & " K"
        
	if strAllProcessInfo <> "" Then
  	        strAllProcessInfo =  strProcessInfo & ", " & vbCRLF & strAllProcessInfo
		strAllProcessPerfInfo =  strProcessPerfInfo & strAllProcessPerfInfo
	else
  	    	strAllProcessInfo = strProcessInfo
		strAllProcessPerfInfo = strProcessPerfInfo
	end if

Next

if intProcesses <= intCriticalLevel Then	
	   intstatus = 2
	   strResultError = "The number of processes is at or below the Critical Level of " & intCriticalLevel & " processes."	
ElseIf intProcesses <= intWarningLevel Then
           intstatus = 1
           strResultWarning = "The number of processes is at or below the Warning Level of " & intWarningLevel & " processes."
end if

Select Case intstatus
  Case 0 wscript.echo "Number of processes is good. Process(es) checked: " & vbCRLF & strAllProcessInfo & "|" & strAllProcessPerfInfo
         wscript.quit(0)
  Case 1 wscript.echo strResultWarning & "|" & strAllProcessPerfInfo
         wscript.quit(1)
  Case 2 wscript.echo strResultError & "|" & strAllProcessPerfInfo
         wscript.quit(2)
  Case else wscript.echo " Unknown result |" & strAllProcessPerfInfo
         wscript.quit(3)
End Select

'*******************************************************************
</script>
</job>

 

 

Comments are closed

Jeremy

Welcome to the blog of an Configuration Manager. This blog is meant to share my thoughts, ideas, and the story of my ever expanding journey to acquire knowledge. It may, at times, include rants about or an expression of excitement over something in the computer realm. The majority of my work is with Windows servers. However, it has started to also include Linux machines. Lately I’ve become the Nagios “expert” within our company as I work towards creating culture of being proactive vs. reactive in regards to Application/Configuration Management.

 

(The information in this blog is provided “AS IS” with no warranties, and confers no rights implied or otherwise. The views, opinions, and ideas, expressed here are my own, and may not necessarily represent the views and opinions of my employer, past, current, or future.)

 

Calendar

<<  December 2017  >>
MoTuWeThFrSaSu
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

View posts in large calendar