Ad Widget

Collapse

Post your Windows examples here

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Hotzenwalder
    Junior Member
    • Apr 2008
    • 11

    #16
    Does anyone have detailed info on the settings for the item to use the uLastWinUpdate.vbs script? I keep getting a ZBX_NOTSUPPORTED.

    Thanks in advance!

    Comment

    • Raph
      Junior Member
      • Jan 2007
      • 12

      #17
      i'm having an issue, i really hope someone can help.

      I have been running the uraidchk script to monitor software raid status on multiple windows servers, with no issue. Recently we have added 2 new servers to our topology that have 2 software raids (2 partitions, being mirrored to the mirror drive), i mention this because all the other servers have 1 partition, being mirrored.

      If i run in command cscript.exe /nologo "c:\raidchk.vbs", it returns the correct value of 0 indicating raid is healthy. However, through zabbix it always returns 3, which means "Error reading configuration".

      i can't figure out why this is happening , any help would be greatly appreciated.

      Technical info:
      Running server 1.4.5 on Centos, agent is also 1.4.5 running on windows server 2003

      uraidchk.vbs (as previously posted in this thread):
      Code:
      ' **************************************************  ******************
      ' ** Check the status of Windows Software RAID                      **
      ' **************************************************  ******************
      '
      ' Version 1.01
      '
      ' 14/09/2006 Peter Field
      ' - Updated to report if diskpart doesn't return any data (i.e. diskpart doesn't exist on Win2000)
      ' - Disabled the initial check for "Mirror" or "RAID-5"
      ' - Changed return value to a number for easier handling in Zabbix
      '
      ' Based off original script by Oliver Hookins, Anchor Systems
      ' http://www.shipyard.com.au/articles/sysadmin/windows-software-raid-check.py
      '
      ' Return value (status of all volumes):
      ' 0 = Healthy
      ' 1 = Rebuilding
      ' 2 = Failed
      ' 3 = Error reading configuration
      '
      
      Option Explicit
      
      Dim WshShell, oExec
      Dim Line, RE1, RE2, RE3
      Dim Failure
      
      Failure = 0
      
      Set WshShell = CreateObject("WScript.Shell")
      
      ' Execute the DISKPART program and grab the output
      Set oExec = WshShell.Exec("%comspec% /c echo list volume | diskpart")
      
      ' Set up some regular expression objects
      'Set RE1 = New RegExp
      Set RE2 = New RegExp
      Set RE3 = New RegExp
      'RE1.Pattern = "Mirror|RAID-5"
      RE2.Pattern = "Failed|(At Risk)"  ' At Risk indicates errors have been reported for a disk and it may need to be reactivated.
      RE3.Pattern = "Rebuild"
      
      If oExec.StdOut.AtEndOfStream Then
          Failure = 3
      Else
          While Not oExec.StdOut.AtEndOfStream
              Line = oExec.StdOut.ReadLine
          
              ' Tests for Mirrored or RAID-5 volumes
              'If RE1.Test(Line) Then
          
                ' Tests for Failed RAID volumes
                If RE2.Test(Line) Then
                  If Failure < 2 Then Failure = 2
          
                ' Tests for Rebuilding volumes
                ElseIf RE3.Test(Line) Then
                  If Failure = 0 Then Failure = 1
          
                End If
              'End If
          WEnd
      End If
      
      ' Print out the appropriate test result
      Wscript.Echo(Failure)
      
      WScript.Quit(Failure)
      zabbix_agentd.conf:
      Code:
      Server=******
      ServerPort=****
      Hostname=********
      ListenPort=****
      DebugLevel=3  
      LogFile=c:\zabbix_agentd.log 
      Timeout=3 
      UserParameter=uRaidChk,cscript.exe /nologo "c:\raidchk.vbs"

      Comment

      • elvar
        Senior Member
        • Feb 2008
        • 226

        #18
        Originally posted by peter_field
        It is handy to know any Windows services that are set to start automatically that are no longer running. This script will report a list of auto start services not running.
        Code:
        Option Explicit
        ' -------------------------
        ' Auto Services Not Running
        ' -------------------------
        '
        ' Version 1.00
        ' 11 August 2006, Peter Field
        '
        ' Original script source unknown.
        '
        ' Displays a list of Windows services that are set to start Automatically,
        ' but are not currently running.
        '
        Dim strComputer, wbemServices, wbemObjectSet, wbemObject, strMessage
        On Error Resume Next
        Set wbemServices = GetObject("winmgmts:\\.")
        Set wbemObjectSet = wbemServices.InstancesOf("Win32_Service")
        strMessage=""
        For Each wbemObject In wbemObjectSet
          if wbemObject.StartMode = "Auto" Then
              if wbemObject.State <> "Running" Then
        '       Wscript.Echo """" & wbemObject.Name & """,""" & wbemObject.State & """,""" & wbemObject.DisplayName & """"
                If strMessage<>"" Then strMessage=strMessage & ", "
                strMessage=strMessage & wbemObject.DisplayName
              End If
          End If
        Next
        If strMessage="" Then
        	Wscript.Echo "None"
        Else
        	Wscript.Echo strMessage
        End If
        Save it as 'Auto-Services-Not-Running.vbs' in your Zabbix agent folder. Put a line in your agent config like:
        UserParameter=uServicesNotRunning,cscript.exe /nologo "c:\zabbix\Auto-Services-Not-Running.vbs"

        Then create an item in Zabbix:
        key: uServicesNotRunning
        type: character
        update interval: high (mine is 14400 as the script is slow)

        Then create a trigger in Zabbix:
        Expression: {Windows_t:uServicesNotRunning.str(None)}=0

        You might want to change your action to include
        Value: {{HOSTNAME}:{TRIGGER.KEY}.last(0)}
        in the message so you can see the services not running right in the alert email.

        Enjoy.

        Is there a way to put exclusions into this? For example, the Performance Logs & Alert service is always set to automatic but only runs when needed. Being able to exclude certain services would be excellent.

        Thanks for this contribution!

        Kind regards,
        Elvar

        Comment

        • peter_field
          Member
          • Jun 2006
          • 71

          #19
          Exclusions on the Windows services check

          Originally posted by elvar
          Is there a way to put exclusions into this? For example, the Performance Logs & Alert service is always set to automatic but only runs when needed. Being able to exclude certain services would be excellent.

          Thanks for this contribution!

          Kind regards,
          Elvar
          This took me back to the dim dark ages of VBscript, used to PowerShell now, but here goes:

          Code:
          Option Explicit
          ' -------------------------
          ' Auto Services Not Running
          ' -------------------------
          '
          ' Version 1.10
          ' 11 August 2006, Peter Field
          '
          ' 1.10 27/04/2009 - Added ability to exclude specific services.
          ' 1.00 11/08/2006 - Original script source unknown.
          '
          ' Displays a list of Windows services that are set to start Automatically, ' but are not currently running.
          '
          Dim strComputer, wbemServices, wbemObjectSet, wbemObject, strMessage, excludedServices
          On Error Resume Next
          Set excludedServices=CreateObject("Scripting.Dictionary")
          excludedServices.Add "Performance Logs and Alerts", "Excluded because its almost never running"
          
          Set wbemServices = GetObject("winmgmts:\\.")
          Set wbemObjectSet = wbemServices.InstancesOf("Win32_Service")
          strMessage=""
          For Each wbemObject In wbemObjectSet
              If wbemObject.StartMode = "Auto" Then
                  If wbemObject.State <> "Running" Then
                      If Not excludedServices.Exists(wbemObject.DisplayName) Then
                          'Wscript.Echo """" & wbemObject.Name & """,""" & wbemObject.State & """,""" & wbemObject.DisplayName & """"
                          If strMessage <> "" Then strMessage = strMessage & ", "
                          strMessage = strMessage & wbemObject.DisplayName
                      End If
                  End If
              End If
          Next
          If strMessage="" Then
              Wscript.Echo "None"
          Else
              Wscript.Echo strMessage
          End If

          Comment

          • elvar
            Senior Member
            • Feb 2008
            • 226

            #20
            Originally posted by peter_field
            This took me back to the dim dark ages of VBscript, used to PowerShell now, but here goes:

            Code:
            Option Explicit
            ' -------------------------
            ' Auto Services Not Running
            ' -------------------------
            '
            ' Version 1.10
            ' 11 August 2006, Peter Field
            '
            ' 1.10 27/04/2009 - Added ability to exclude specific services.
            ' 1.00 11/08/2006 - Original script source unknown.
            '
            ' Displays a list of Windows services that are set to start Automatically, ' but are not currently running.
            '
            Dim strComputer, wbemServices, wbemObjectSet, wbemObject, strMessage, excludedServices
            On Error Resume Next
            Set excludedServices=CreateObject("Scripting.Dictionary")
            excludedServices.Add "Performance Logs and Alerts", "Excluded because its almost never running"
            
            Set wbemServices = GetObject("winmgmts:\\.")
            Set wbemObjectSet = wbemServices.InstancesOf("Win32_Service")
            strMessage=""
            For Each wbemObject In wbemObjectSet
                If wbemObject.StartMode = "Auto" Then
                    If wbemObject.State <> "Running" Then
                        If Not excludedServices.Exists(wbemObject.DisplayName) Then
                            'Wscript.Echo """" & wbemObject.Name & """,""" & wbemObject.State & """,""" & wbemObject.DisplayName & """"
                            If strMessage <> "" Then strMessage = strMessage & ", "
                            strMessage = strMessage & wbemObject.DisplayName
                        End If
                    End If
                End If
            Next
            If strMessage="" Then
                Wscript.Echo "None"
            Else
                Wscript.Echo strMessage
            End If

            Wow, thanks for the quick reply! I will try this out asap. Just out of curiosity, why do you have the update interval set to something so high? Maybe I'm not understanding correctly, but when I manually run the script it completes in under 10 seconds. Wouldn't 30 seconds or 60 seconds for the update interval be sufficient?


            Thanks,
            Elvar

            Comment

            • elvar
              Senior Member
              • Feb 2008
              • 226

              #21
              Originally posted by peter_field
              This took me back to the dim dark ages of VBscript, used to PowerShell now, but here goes:

              Code:
              Option Explicit
              ' -------------------------
              ' Auto Services Not Running
              ' -------------------------
              '
              ' Version 1.10
              ' 11 August 2006, Peter Field
              '
              ' 1.10 27/04/2009 - Added ability to exclude specific services.
              ' 1.00 11/08/2006 - Original script source unknown.
              '
              ' Displays a list of Windows services that are set to start Automatically, ' but are not currently running.
              '
              Dim strComputer, wbemServices, wbemObjectSet, wbemObject, strMessage, excludedServices
              On Error Resume Next
              Set excludedServices=CreateObject("Scripting.Dictionary")
              excludedServices.Add "Performance Logs and Alerts", "Excluded because its almost never running"
              
              Set wbemServices = GetObject("winmgmts:\\.")
              Set wbemObjectSet = wbemServices.InstancesOf("Win32_Service")
              strMessage=""
              For Each wbemObject In wbemObjectSet
                  If wbemObject.StartMode = "Auto" Then
                      If wbemObject.State <> "Running" Then
                          If Not excludedServices.Exists(wbemObject.DisplayName) Then
                              'Wscript.Echo """" & wbemObject.Name & """,""" & wbemObject.State & """,""" & wbemObject.DisplayName & """"
                              If strMessage <> "" Then strMessage = strMessage & ", "
                              strMessage = strMessage & wbemObject.DisplayName
                          End If
                      End If
                  End If
              Next
              If strMessage="" Then
                  Wscript.Echo "None"
              Else
                  Wscript.Echo strMessage
              End If

              This is working perfect so far as I can tell. Thank you very much!


              Kind regards,
              Elvar

              Comment

              • gospodin.horoshiy
                Senior Member
                • Sep 2008
                • 272

                #22
                Anyone want to see my solution for tracking Win Software being installed/removed? Its kinda strange, but works well in my enviroment.
                Zbx 2.0.4 on Debian and MYSQL5 on Ubuntu Server 64bit 8.04,
                200+ Win Agents, 50+ Linux Agents, 150+ Network Devices

                Comment

                • gospodin.horoshiy
                  Senior Member
                  • Sep 2008
                  • 272

                  #23
                  Ok, few guys PMed me so here it is:

                  1. To get full list of software:
                  1.1 Create script in C:\Program Files\Zabbix Agent\
                  called uAllPrograms.vbs:
                  with
                  WScript.Echo strConvert(InstalledApplications("."),"Windows-1251","cp866")

                  Function InstalledApplications(node)
                  Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
                  Set oRegistry = GetObject("winmgmts://" _
                  & node & "/root/default:StdRegProv")
                  sBaseKey = _
                  "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninsta ll\"
                  iRC = oRegistry.EnumKey(HKLM, sBaseKey, arSubKeys)

                  For Each sKey In arSubKeys

                  iRC = oRegistry.GetStringValue( _
                  HKLM, sBaseKey & sKey, "DisplayName", sValue)
                  If iRC <> 0 Then
                  oRegistry.GetStringValue _
                  HKLM, sBaseKey & sKey, "QuietDisplayName", sValue
                  End If
                  If sValue <> "" and instr(sValue, "KB")=0 and instr(InstalledApplications, sValue&vbCrLf)=0 Then
                  InstalledApplications = _
                  InstalledApplications & sValue & vbCrLf
                  End If
                  Next
                  End Function

                  '================================================= ============================
                  Function StrConvert(strText, strSourceCharset, strDestCharset)
                  Const adTypeText = 2
                  Const adModeReadWrite = 3

                  Dim objStream

                  Set objStream = WScript.CreateObject("ADODB.Stream")

                  With objStream
                  .Type = adTypeText
                  .Mode = adModeReadWrite

                  .Open
                  .Charset = strSourceCharset
                  .WriteText strText
                  .Position = 0
                  .Charset = strDestCharset
                  strConvert = .ReadText
                  End With

                  Set objStream = Nothing
                  End Function
                  '================================================= ============================
                  1.2Create user parameter in your zabbix_agentd.conf
                  UserParameter=uAllPrograms, cscript.exe /nologo "C:\Program Files\Zabbix Agent\uAllPrograms.vbs"

                  1.3 Create item in Zabbix called uAllPrograms and type of Text

                  2. To get only new software/uninstalled software since last check:
                  2.1
                  Create script in C:\Program Files\Zabbix Agent\
                  called uDiffPrograms.vbs:
                  with
                  'KNOWN BUG: If Application name conatins '-' symbol then e-mail alert containing software list will be sent all on one line instead of each packet on a single line
                  variable=InstalledApplications(".")
                  'WScript.Echo strConvert(variable,"Windows-1251","cp866")

                  'Whats this
                  Const ForReading = 1
                  Set objFSO = CreateObject("Scripting.FileSystemObject")
                  'Create old file if does not exist
                  If objFSO.FileExists("C:\Program Files\Zabbix Agent\uDiffPrograms_old.txt")=0 Then
                  Set objFile4 = objFSO.CreateTextFile("C:\Program Files\Zabbix Agent\uDiffPrograms_old.txt")
                  objFile4.WriteLine variable
                  objFile4.Close
                  'Wscript.Echo "No C:\Program Files\Zabbix Agent\uDiffPrograms_old.txt file"
                  Wscript.Echo "0x0"
                  WScript.Quit
                  End if
                  'Create 'new' file
                  Set objFile3 = objFSO.CreateTextFile("C:\Program Files\Zabbix Agent\uDiffPrograms_new.txt")
                  objFile3.WriteLine variable
                  objFile3.Close


                  'Compare old and new files
                  Set objArgs = Wscript.Arguments
                  Set objFile5= objFSO.GetFile("C:\Program Files\Zabbix Agent\uDiffPrograms_new.txt")
                  Set objFile6 = objFSO.GetFile("C:\Program Files\Zabbix Agent\uDiffPrograms_old.txt")

                  If objFile5.Size <> objFile6.Size Then
                  ' Wscript.Echo "The file is different."
                  Else
                  'Wscript.Echo "They are the same."

                  objFSO.DeleteFile "C:\Program Files\Zabbix Agent\uDiffPrograms_new.txt"
                  Wscript.Echo "0x0"
                  WScript.Quit

                  End If
                  'Search for removed applications
                  Set objFile2 = objFSO.OpenTextFile("C:\Program Files\Zabbix Agent\uDiffPrograms_old.txt", ForReading)

                  Do Until objFile2.AtEndOfStream
                  strAddress2 = objFile2.ReadLine
                  If InStr(variable, strAddress2&vbCrLf) = 0 Then
                  strNotCurrent2 = strNotCurrent2 & strAddress2 & vbCrLf
                  End If
                  Loop
                  objFile2.Close



                  'Search for installed applications
                  Set objFile1 = objFSO.OpenTextFile("C:\Program Files\Zabbix Agent\uDiffPrograms_old.txt", ForReading)

                  oldvar = objFile1.ReadAll

                  objFile1.Close
                  objFSO.DeleteFile "C:\Program Files\Zabbix Agent\uDiffPrograms_old.txt"
                  Set objFile2 = objFSO.OpenTextFile("C:\Program Files\Zabbix Agent\uDiffPrograms_new.txt", ForReading)

                  Do Until objFile2.AtEndOfStream
                  strAddress = objFile2.ReadLine
                  If InStr(oldvar, strAddress&vbCrLf) = 0 Then
                  strNotCurrent = strNotCurrent & strAddress & vbCrLf
                  End If
                  Loop
                  objFile2.Close
                  'Rename C:\Program Files\Zabbix Agent\uDiffPrograms_new.txt to C:\Program Files\Zabbix Agent\uDiffPrograms_old.txt
                  objFSO.MoveFile "C:\Program Files\Zabbix Agent\uDiffPrograms_new.txt" , "C:\Program Files\Zabbix Agent\uDiffPrograms_old.txt"
                  'Output
                  if strNotCurrent <> "" and strNotCurrent2 <> "" then
                  WScript.Echo strConvert("New software installed:" & vbCrLf & strNotCurrent & vbCrLf & "Software uninstalled:" & vbCrLf & strNotCurrent2,"Windows-1251","cp866")
                  'WScript.Echo strConvert("Новые программы были установлены:" & vbCrLf & strNotCurrent & vbCrLf & "Следующие программы были удалены:" & vbCrLf & strNotCurrent2,"Windows-1251","cp866")
                  Wscript.Quit
                  End if
                  if strNotCurrent <> "" then
                  WScript.Echo strConvert("New software installed:" & vbCrLf & strNotCurrent,"Windows-1251","cp866")
                  'WScript.Echo strConvert("Новые программы были установлены:" & vbCrLf & strNotCurrent,"Windows-1251","cp866")
                  End if
                  if strNotCurrent2 <> "" then
                  WScript.Echo strConvert("Software uninstalled:" & vbCrLf & strNotCurrent2,"Windows-1251","cp866")
                  'WScript.Echo strConvert("Следующие программы были удалены:" & vbCrLf & strNotCurrent2,"Windows-1251","cp866")
                  End If

                  Function InstalledApplications(node)
                  Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
                  Set oRegistry = GetObject("winmgmts://" _
                  & node & "/root/default:StdRegProv")
                  sBaseKey = _
                  "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninsta ll\"
                  iRC = oRegistry.EnumKey(HKLM, sBaseKey, arSubKeys)

                  For Each sKey In arSubKeys

                  iRC = oRegistry.GetStringValue( _
                  HKLM, sBaseKey & sKey, "DisplayName", sValue)
                  If iRC <> 0 Then
                  oRegistry.GetStringValue _
                  HKLM, sBaseKey & sKey, "QuietDisplayName", sValue
                  End If

                  If sValue <> "" and instr(sValue, "KB")=0 and instr(InstalledApplications, sValue&vbCrLf)=0 Then
                  'and instr(InstalledApplications, sValue&vbCrLf)=0 - to exlude possible dublicates
                  'instr(sValue, "KB")=0 - to exlude KB-indexed Microsoft Patches
                  InstalledApplications = _
                  InstalledApplications & sValue & vbCrLf
                  End If
                  Next
                  End Function

                  '================================================= ============================
                  Function StrConvert(strText, strSourceCharset, strDestCharset)
                  Const adTypeText = 2
                  Const adModeReadWrite = 3

                  Dim objStream

                  Set objStream = WScript.CreateObject("ADODB.Stream")

                  With objStream
                  .Type = adTypeText
                  .Mode = adModeReadWrite

                  .Open
                  .Charset = strSourceCharset
                  .WriteText strText
                  .Position = 0
                  .Charset = strDestCharset
                  strConvert = .ReadText
                  End With

                  Set objStream = Nothing
                  End Function
                  '================================================= ============================
                  2.2 Create userparameter:
                  UserParameter=uDiffPrograms, cscript.exe /nologo "C:\Program Files\Zabbix Agent\uDiffPrograms.vbs"

                  2.3 Create item uDiffPrograms and Text as type
                  2.4 Create trigger: like this one:
                  {Template_Windows_Active:uDiffPrograms.str(0x0)}=0

                  As final I get email alert like this


                  Time:20:06:36
                  Date:2009.10.13
                  Host: trkbook.trk

                  Набор программ на данном компьютере был изменен.

                  New software installed:
                  1С:Предприятие 7.7 (сетевая версия)

                  That's all

                  And also, scripts are cyrilic adapted (cp1251), so there could be extra functions and stuff you might not need.


                  Added: Hm, both scripts in post got extra space in " sBaseKey = _
                  "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninsta ll\"
                  iRC = oRegistry.EnumKey(HKLM, sBaseKey, arSubKeys)"

                  , so I better just attach scripts instead.
                  Attached Files
                  Zbx 2.0.4 on Debian and MYSQL5 on Ubuntu Server 64bit 8.04,
                  200+ Win Agents, 50+ Linux Agents, 150+ Network Devices

                  Comment

                  • daniel.s
                    Junior Member
                    • Dec 2012
                    • 3

                    #24
                    Originally posted by Hotzenwalder
                    Does anyone have detailed info on the settings for the item to use the uLastWinUpdate.vbs script? I keep getting a ZBX_NOTSUPPORTED.

                    Thanks in advance!
                    I know this is answering a really old question, but I spent hours today trying to figure out why I was getting ZBX_NOTSUPPORTED with a similar VBScript.

                    I'm running Zabbix 2.0.3 on CentOS 6, and the x64 client on Windows Server 2008 R2.

                    I was experiencing the problem because the Timeout value in zabbix_agentd.conf was being hit. I extended the value from the default of 3 (unset) to 15. That fixed it for me.

                    Comment

                    • qix
                      Senior Member
                      Zabbix Certified SpecialistZabbix Certified Professional
                      • Oct 2006
                      • 423

                      #25
                      LLD for Windows Services

                      Small crosspost because I think it could be relevant for the people following this thread

                      I've created an LLD script that will help monitor Windows services:
                      With kind regards,

                      Raymond

                      Comment

                      Working...