Forum Discussion

Keimond's avatar
Keimond
Icon for Neophyte rankNeophyte
8 months ago

Linux services and autodiscovery

Hey guys, I just wanted to let you know that I took LogicMonitor's default datasource, "Linux_SSH_ServiceStatus", and added auto discovery to it.

The only thing that is needed at the resource or group level is that the following three properties are set:

  • ssh.user
  • ssh.pass
  • linux.ssh.services.regex   ( default: "sshd\.service" )

I published the datasource under 93Y4PC (currently under security review as of this post)

  • The discovery script gets the output of
    systemctl list-units --all --type=service --plain --state=loaded | egrep service
  • Loop through each line of the output and see if it matches the regex from the property, "linux.ssh.services.regex"

 

A person could even set the regex to be ".*" which would grab all of the services.. then turn around and create a filter to exclude certain things. For example if I wanted everything but services with the name ssh in them, I could create a filter that says ##WILDVALUE## not contain ssh.

4 Replies

  • Anonymousapparently I forgot :D I pushed my files up today so you could check them out. I was including/excluding regex properties from within my AD script... although I like how you had them in the datasource filters so I moved them there. The only thing I didn't remove was the include regex. I wanted that to also be in the AD.groovy script so that I could say if the property didn't exist, only show sshd.service by default... when I add 40 random machines and give LM the SSH credentials to them, I don't want them to all just start monitoring every single systemd service.

  • Update: the DS filters weren't working quite as intended, I've moved them back in to the AD script.

    For example, I have a server with a bunch of services prefixed with proxy-
    My include regex is "(sshd|snmpd|proxy-.*)\.service"
    but then I don't want a few of the proxy names 
    My exclude regex is "proxy-(ae|nu).*"

    The script written with the ==~ match works great, but if I try to add them to the DS filters, everything just gets filtered out.