Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support
  3. Script / Template for windows services

Script / Template for windows services

Scheduled Pinned Locked Moved Support
3 Posts 2 Posters 30.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T
    T
    theyareseven
    wrote on last edited by
    #1

    I have been trying to make a way so that NETXMS will auto find all services (auto ect) and monitor them, the system supports this for disk space ect but can't seem to map this to services. any ideas or help?

    ty

    1 Reply Last reply
    0
    • T
      T
      twenrich
      wrote on last edited by
      #2

      I use a script for instance discovery and a filter script to remove unwanted services.
      Additional, custom attributes allow to include and exclude services per node.

      Please see the attached image for usage in the template DCI.

      Kind regards,
      Thomas

      Script windows_auto_services:

      col_startup = 4;
      array a;
      
      table = AgentReadTable($node, "System.Services");
      if (table == null)
      {
          println "ERROR: Cannot read table from agent";
          return;
      }
      
      index = 0;
      for (i=0; i<table->rowCount; i++)
          {
          startup = table->get(i, col_startup);
          if (startup == "Auto")
              {
              a[index++] = table->get(i, 0);
              println table->get(i, 0);
              }
          }
      
      // trace(1, "discover_auto_services: return 0");
      
      return a;
      

      Script filter_windows_services:

      sub filter_windows_service(svc)
      	{
      	attr = GetCustomAttribute($node, "SERVICE_EXCLUDE");
      	if (attr != null && inList(attr, ",", svc))
      		{
      		trace(1, $node->name . ": Service " . svc . " excluded by attribute SERVICE_EXCLUDE");
      		return false;
      		}
      	attr = GetCustomAttribute($node, "SERVICE_INCLUDE");
      	if (attr != null && inList(attr, ",", svc))
      		return true;
      
      	return
      		   (svc != "TBS")
      		&& (svc != "KtmRm")
      		&& (svc != "iphlpsvc")
      		&& (svc != "sppsvc")
      		&& (svc != "ShellHWDetection")
      		&& (svc != "ccmsetup")
      		&& (svc != "SysmonLog")
      		&& (!(svc ~= "^clr_optimization_.*") )
      		&& svc != "spupdsvc"
      		&& svc != "RDSessMgr"
      		&& svc != "DPS"
      		&& svc != "FontCache"
      		&& svc != "MSDTC"
      		&& svc != "WinRM"
      		&& svc != "gupdate"
      		&& svc != "wscsvc"
      		&& svc != "VSS"
      		&& svc != "wuauserv"
      		&& svc != "TrustedInstaller"
      		&& svc != "BackupExecAgentAccelerator"
      		&& svc != "CcmExec"
      		;
      	}
      

      netxms_template.PNG

      1 Reply Last reply
      0
      • T
        T
        theyareseven
        wrote on last edited by
        #3

        HI twenrich,

        Thank you!!!! 🙂 this is a great script, should be standard in the package!!!!

        The only thing I have noticed is that for some reason, when I add in extra services to 'ignore' it still shows them AdobeUpdateService and alike but am sure that is something I have done / not doing.

        ty

        1 Reply Last reply
        0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        Powered by NodeBB Contributors
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups