Skip to content

Instantly share code, notes, and snippets.

Avatar

Mooli Tayer moolitayer

View GitHub Profile
View alert_buffer.json
{"generationID":"4cf35435-6833-487d-bc64-f2bd171999b3","messages":[{"index":97,"timestamp":"2017-09-13T17:39:31.040232406Z","data":{"alerts":[{"annotations":{"message":"Huge node detected","miqTarget":"ContainerNode","severity":"HIGH","url":"https://www.example.com/fixing_instructions"},"endsAt":"0001-01-01T00:00:00Z","generatorURL":"http://prometheus-2278364511-lb8zw:9090/graph?g0.expr=container_spec_memory_limit_bytes+%3E+1e%2B10\u0026g0.tab=0","labels":{"alertname":"BigMemNode","beta_kubernetes_io_arch":"amd64","beta_kubernetes_io_instance_type":"m4.xlarge","beta_kubernetes_io_os":"linux","failure_domain_beta_kubernetes_io_region":"us-west-2","failure_domain_beta_kubernetes_io_zone":"us-west-2c","hostname":"certtest-node-compute-b5ad6","id":"/","instance":"ip-172-31-63-23.us-west-2.compute.internal","job":"kubernetes-nodes","kubernetes_io_hostname":"ip-172-31-63-23.us-west-2.compute.internal","logging_infra_fluentd":"true","ops_node":"old","region":"us-west-2","type":"compute"},"startsAt":"2017-08-31T17:10
View check_time
timedatectl
chkconfig --list ntpd
ntpq -p # run NTP query
View appliance_debug.sh
#Logs at: /var/www/miq/vmdb/log
# DB Access:
sudo su - postgres -c "psql vmdb_production"
# Rails Console:
cd /var/www/miq/vmdb/
source /etc/default/evm
bin/rails c
View miq-create-alerts.rb
#!/usr/bin/env ruby
require File.join(Dir.pwd, 'config/environment')
ALERT_UUID="17ac4258-cd1e-11e6-914b-024234304b62"
MiqAlert.where(:guid => ALERT_UUID).destroy_all # will destroy statuses and action(?) too
ma = MiqAlert.create!(guid: ALERT_UUID, description: "All hawkular", options: {:notifications=>{:delay_next_evaluation=>600, :evm_event=>{}, :automate=>{:event_name=>"Oh no, an alert"}}}, db: "ContainerNode", expression: {:eval_method=>"hwk_generic", :mode=>"internal", :options=>{}})
# create new MAS based on the existing ones
ExtManagementSystem.where(:type => "ManageIQ::Providers::Openshift::ContainerManager").each do |ext|
mas = MiqAlertStatus.create!(
View verify_empty_container_status
$ cat /tmp/container-status.json
{
"name": "registry",
"state": {},
"lastState": {
"terminated": {
"exitCode": 137,
"reason": "Error",
"startedAt": "2017-02-08T11:31:45Z",
View miq_api_alert_queries.log
[----] I, [2017-03-14T08:10:36.359525 #773:2115e84] INFO -- : Started GET "/api/alerts?expand=resources" for 127.0.0.1 at 2017-03-14 08:10:36 +0200
[----] I, [2017-03-14T08:10:36.388548 #773:2115e84] INFO -- : Processing by Api::AlertsController#index as JSON
[----] I, [2017-03-14T08:10:36.388645 #773:2115e84] INFO -- : Parameters: {"expand"=>"resources"}
[----] D, [2017-03-14T08:10:36.390332 #773:2115e84] DEBUG -- : PostgreSQLAdapter#log_after_checkout, connection_pool: size: 8, connections: 3, in use: 3, waiting_in_queue: 0
[----] D, [2017-03-14T08:10:36.391437 #773:2115e84] DEBUG -- : User Load (0.7ms) SELECT "users".* FROM "users" WHERE ("users"."id" BETWEEN $1 AND $2) AND "users"."userid" = $3 LIMIT $4 [["id", 1000000000000], ["id", 1999999999999], ["userid", "admin"], ["LIMIT", 1]]
[----] D, [2017-03-14T08:10:36.391800 #773:2115e84] DEBUG -- : User Inst Including Associations (0.1ms - 1rows)
[----] D, [2017-03-14T08:10:36.416046 #722:d27120] DEBUG -- :  (
View change_dataware_polling_intereval
# From ManageIQ root:
printf ":workers:\n :worker_base:\n :event_catcher:\n :event_catcher_hawkular_datawarehouse:\n :poll: 10.seconds\n">> config/settings.local.yml
View provider's alerts test
# TODO: This test can be used after https://github.com/ManageIQ/manageiq/pull/13233 merges
context "alerts subcollection" do
let(:infra_provider) { FactoryGirl.create(:ems_infra) }
let(:vm) { FactoryGirl.create(:vm) }
before(:each) {
api_basic_authorize collection_action_identifier(:providers, :read, :get)
}
it "get all alertss for a provider" do
alert_status2
View hawkular trigger definition
[
{
"eventType": "ALERT",
"tenantId": "_system",
"id": "auto-resolving-trigger-1482169701624-7fafcc1e-c7e6-4b2c-ba98-8fe43829833b",
"ctime": 1482169701624,
"dataSource": "_none_",
"dataId": "auto-resolving-trigger",
"category": "ALERT",
"text": "Auto resolving trigger example",