No activity today, make something!
cdent-rhat SnmpWithCeilometer

20150130185118 cdent  

I was curious, so I set about figuring out how to set up metering of arbitrary hosts using SNMP and having the results stored by Ceilometer. I've been aware of ceilometer/hardware/inspector/snmp.py for a while but not used it.

The developer docs make it pretty clear that data via snmpd is possible, but I couldn't find any information there about configuration. Nor in the admin or install guide.

Searching the web at large led to some examples that were, for me at least, incomplete but pointed me in the right direction.

My setup: machine A is a current devstack with ceilometer running, machine B is a random box. Both Fedora 21.

On B we need snmpd running and configured to allow remote access from at least A.

Setup B

  • Install snmpd and snmpwalk
    • sudo yum install net-snmp net-snmp-libs net-snmp-utils
  • Configure snmpd for network access. I'm on a private network with these machine so not too concerned about access handling, so it is wide open as long as the proper key is provided.
    • Add lines like this to /etc/snmp/snmpd.conf:
com2sec   mynetwork     192.168.2.0/24      hizzouse
group     MyROGroup      any        mynetwork
view      all    included      .1                               80
access    MyROGroup     ""      any       noauth    0      all    none   none
  • Open up a firewall if you've got one (restrict this as you require):
sudo iptables -I INPUT -p udp -m udp --dport 161 -j ACCEPT
sudo iptables -I INPUT -p udp -m udp --dport 162 -j ACCEPT
  • Confirm it works locally
    • snmpwalk -v2c -c hizzouse 192.168.2.3 UCD-SNMP-MIB::systemStats

Setup A

  • If you've installed ceilometer from devstack some snmp tools are probably already there, but to check things from the command line install snmpwalk:
    • yum install net-snmp-utils
  • And test:
  • snmpwalk -v2c -c hizzouse 192.168.2.3 UCD-SNMP-MIB::systemStats
  • Configure the ceilometer pipeline in /etc/ceilometer/pipeline.yaml. In the sources section add another source (note the short interval so we don't have to wait ten whole minutes to get some samples, also note the hizzouse used as a username in the snmp url, this is the "key" defined in snmpd.conf above):
    - name: meter_snmp
      interval: 60
      resources:
          - snmp://hizzouse@192.168.2.3
      meters:
        - "hardware.cpu*"
        - "hardware.memory*"
        - "hardware.disk*"
        - "hardware.network*"
      sinks:
        - meter_sink
  • Restart the ceilometer-agent-central (how this is done will vary by whether you've got a devstack or are using a more long term install).
  • Auth yourself in your devstack if you aren't already: . src/devstack/openrc admin admin.
  • Wait a bit and then check to see if there are hardware meters: ceilometer meter-list. Should see various things including hardware.memory.total.
  • Get samples for one of those meters:
$ ceilometer sample-list -m hardware.memory.total -l 5
+-------------+-----------------------+-------+------------+------+---------------------+
| Resource ID | Name                  | Type  | Volume     | Unit | Timestamp           |
+-------------+-----------------------+-------+------------+------+---------------------+
| 192.168.2.3 | hardware.memory.total | gauge | 32855084.0 | B    | 2015-01-30T18:48:25 |
| 192.168.2.3 | hardware.memory.total | gauge | 32855084.0 | B    | 2015-01-30T18:47:25 |
| 192.168.2.3 | hardware.memory.total | gauge | 32855084.0 | B    | 2015-01-30T18:46:25 |
| 192.168.2.3 | hardware.memory.total | gauge | 32855084.0 | B    | 2015-01-30T18:43:57 |
| 192.168.2.3 | hardware.memory.total | gauge | 32855084.0 | B    | 2015-01-30T18:42:57 |
+-------------+-----------------------+-------+------------+------+---------------------+