Skip to content

Instantly share code, notes, and snippets.

import java.net.URL;
import java.io.InputStream;
public class Test {
public static void main(String args[]) throws Exception {
URL url = new URL("https://www.baidu.com");
InputStream in =url.openStream();
}
}
from ceilometer.publisher import utils
import datetime
msg = {
'source': 'openstack',
'counter_name': 'cpu_util',
'counter_type': 'gauge',
'counter_unit': '%',
'counter_volume': '99',
'user_id': 'adf08413e7ee4926b3b2496be649c8b1',
An old farmer lived on a farm in the mountains with his young grandson. Each morning Grandpa was up early sitting at the kitchen table reading his book. One day the grandson asked, "Grandpa! I try to read the book just like you but I don't understand it, and what I do understand I forget as soon
as I close the book. What good does reading the book do?"
The grandfather quietly turned from putting coal in the stove and replied, "Take this coal basket down to the river and bring me back a basket of water."
The boy did as he was told, but all the water leaked out before he got back to the house. The grandfather laughed and said, "You'll have to move a little faster next time," and sent him back to the river with the basket to try again. This time the boy ran faster, but again the basket was empty before he returned home. Out of breath, he told his grandfather that it was impossible to carry water in a basket, and he went to get a bucket instead. The old man said, "I don't want a bucket of water; I want a bask
@zqfan
zqfan / local.conf
Last active October 16, 2015 17:20
OpenStack DevStack local.conf
# Sample ``local.conf`` for user-configurable variables in ``stack.sh``
# NOTE: Copy this file to the root ``devstack`` directory for it to
# work properly.
# ``local.conf`` is a user-maintained setings file that is sourced from ``stackrc``.
# This gives it the ability to override any variables set in ``stackrc``.
# Also, most of the settings in ``stack.sh`` are written to only be set if no
# value has already been set; this lets ``local.conf`` effectively override the
# default values.

resource-list timestamp cannot use eq

# curl -i -X GET -H 'X-Auth-Token: eaaa9e1b69bf4cb0859651410bc25742' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'User-Agent: python-ceilometerclient' 'http://160.132.0.17:8777/v2/resources?q.op=eq&q.value=2014-03-12T00%3A00%3A00&q.field=timestamp'
{"error_message": {"debuginfo": null, "faultcode": "Client", "faultstring": "Invalid input for field/attribute op. Value: 'eq'. unimplemented operator for timestamp"}}

meter-list metadata works now

# ceilometer meter-list -q "resource=c576e2a0-be24-43db-bb37-2747481612e0;metadata.size=1"
+-------------+-------+--------+--------------------------------------+----------------------------------+----------------------------------+
| Name        | Type  | Unit   | Resource ID                          | User ID                          | Project ID                       |
Sun Mar 30 04:40:59.860 [initandlisten] MongoDB starting : pid=17840 port=27017 dbpath=/var/lib/mongodb 64-bit host=n00259e3563af
Sun Mar 30 04:40:59.861 [initandlisten] db version v2.4.3
Sun Mar 30 04:40:59.861 [initandlisten] git version: nogitversion
Sun Mar 30 04:40:59.861 [initandlisten] build info: Linux cloud115 3.11.6-4-default #1 SMP Wed Oct 30 18:04:56 UTC 2013 (e6d4a27) x86_64 BOOST_LIB_VERSION=1_49
Sun Mar 30 04:40:59.861 [initandlisten] allocator: tcmalloc
Sun Mar 30 04:40:59.861 [initandlisten] options: { auth: "true", bind_ip: "172.30.102.105", config: "/etc/mongodb.conf", dbpath: "/var/lib/mongodb", fork: "true", logappend: "true", logpath: "/var/log/mongodb/mongodb.log", nohttpinterface: "true", port: 27017, quiet: true }
Sun Mar 30 04:40:59.861 [initandlisten]
Sun Mar 30 04:40:59.861 [initandlisten] ** WARNING: Readahead for /var/lib/mongodb is set to 512KB
Sun Mar 30 04:40:59.861 [initandlisten] ** We suggest setting it to 256KB (512 sectors) or less
Sun Mar 30 04:40:59.861 [initan
http://www.gromacs.org/Developer_Zone/Git/Gerrit#error.3a_server_certificate_verification_failed._CAfile...
problem:
error: server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none while accessing https://review.openstack.org/openstack/
fix:
# git config --global --add http.sslVerify false
$ . accrc/admin/admin
$ ceilometer alarm-threshold-create -m instance --threshold 1 --name required-alarm
$ ceilometer alarm-list
+--------------------------------------+--------------------+-------------------+---------+------------+-----------------------------------------------------------------+
| Alarm ID | Name | State | Enabled | Continuous | Alarm condition |
+--------------------------------------+--------------------+-------------------+---------+------------+-----------------------------------------------------------------+
| 5a563160-8fcb-4ef0-a7a0-937b5624ea2a | need-another-alarm | insufficient data | True | False | combinated states (AND) of 865a812b-24b7-4698-b890-65656d4552ce |
| 865a812b-24b7-4698-b890-65656d4552ce | required-alarm | insufficient data | True | False | instance == 1.0 during 1 x 60s |
| bfa5d625-019c-4f34-b31c-d4cfba3bae1f
Copyright (c) 2014, Huawei Technologies Co., Ltd
All rights reserved

Ceilometer可靠性分析

异常场景

  1. mongodb服务不可用导致ceilometer-collector服务不可用。在ceilometer-collector服务启动时如果mongodb服务不可用,则会抛出异常,此时进程不会自然终止。当mongodb恢复为可用时,ceilometer-collector无法自动连接数据库,造成进程虽然存在但实际上功能不可用。
  2. keystone服务不可用导致ceilometer-agent-central服务不可用。当ceilometer-agent-central在指定的周期采集数据时,如果keystone服务中断,则会抛出异常但ceilometer-agent-central进程不会终止,且当keystone服务恢复后,ceilometer-agent-central服务不会自动恢复可用