rancher / os

Tiny Linux distro that runs the entire OS as Docker containers
https://rancher.com/docs/os/v1.x/en/
Apache License 2.0
6.44k stars 659 forks source link

SNMP support #2712

Open guy-new opened 5 years ago

guy-new commented 5 years ago

RancherOS Version: (ros os version)

rancher/os:v1.5.1 local latest running

Where are you running RancherOS? (docker-machine, AWS, GCE, baremetal, etc.)

Proxmox VM image booting via iPXE

RancherOS needs to have SNMPD service built in, deploying in an enterprise world it's necessary to monitor and manage the underlaying systems. The defacto standard way to do this is via SNMP.

kingsd041 commented 5 years ago

When I have time, I will support this feature.

guy-new commented 5 years ago

Great, thanks.. Others have also tried to do this, however their SNMP containers are very big. 800Mb+.. I believe that this should really be micro sized..in the order of 10Mb.

mainiak commented 5 years ago

How about Docker Alpine image + net-snmp ? That should be under 10MBs

guy-new commented 5 years ago

Yes I was thinking the same, Alpine should make this very small. Would it be possible to take configuration from cloud-config as well? it would be helpful at the least to specify the IP address of the SNMP polling server and access string. I guess you might be able to include the snmpd.conf into the cloud-config file

kingsd041 commented 5 years ago

@guy-menlo You can try this way:

#cloud-config
write_files:
  - path: /etc/rc.local
    permissions: "0755"
    owner: root
    content: |
      #!/bin/bash

      container_name=snmpd
      docker ps -a --format "{{.Names}}" | grep -w $container_name

      if [[ $? != 0 ]]; then
          docker run -d -v /proc:/host_proc \
            --privileged \
            --read-only \
            -p 161:161/udp \
            --name $container_name \
            really/snmpd
      else
          docker start $container_name
      fi
guy-new commented 5 years ago

I spent a little time this weekend playing with really/snmpd which is close to what I wanted. I ended up cloning. I was then able to include my own snmpd.conf file. I also removed "Python2" after building is complete.. This brought it down to 35Mb in size.

I finally added the following lines to my cloud-config.yml file to have the service install and start:

  services:
    snmpd:
      labels:
        io.rancher.os.scope: "system"
        io.rancher.os.after: "network"
        io.rancher.os.detach: "true"
      image: gitlab.local:5005/snmpd
      name: snmpd
      restart: always
      privileged: true
      network_mode: "host"
      ready-only: true
      pid: host
      ipc: host
      net: host
      uts: host
      ports:
        - "161:161/udp"
ToeiRei commented 5 years ago

nevertheless I would prefer to get that stuff directly from the host to see how that box is doing.