Skip to content

Instantly share code, notes, and snippets.

Basic googling usually shows articles with alerts via exec. That makes configuration overcomplicated as you have to duplicate it for an alert and for a real action. However you can setup your sendmail to do the slack messaging.

Monit

      - name: put monit config
        copy:
            dest: /etc/monit.d/foo.conf
            content: |
              set alert slack.monit@localhost but not on { instance }
2017-11-06 14:36:27,289 [DEBUG] - Configured chocolatey.infrastructure.logging.log4net.config.xml from assembly choco, Version=0.10.3.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb
2017-11-06 14:36:27,289 [DEBUG] - Configured chocolatey.infrastructure.logging.log4net.config.xml from assembly choco, Version=0.10.3.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb
2017-11-06 14:36:27,304 [DEBUG] - XmlConfiguration is now operational
2017-11-06 14:36:27,429 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\config\chocolatey.config.update".
2017-11-06 14:36:27,445 [INFO ] - ============================================================
2017-11-06 14:36:27,445 [INFO ] - Chocolatey v0.10.3
2017-11-06 14:36:27,445 [DEBUG] - Chocolatey is running on Windows v 6.1.7601.65536
2017-11-06 14:36:27,445 [DEBUG] - Attempting to delete file "C:/ProgramData/chocolatey/choco.exe.old".
2017-11-06 14:36:27,445 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\choco.exe.old".
2017-11-06 14:36:27,460
- name: read serverid
shell: head -10 /etc/go/cruise-config.xml|sed -rn 's/.*serverId="([^"]+)".*/\1/p'
changed_when: no
register: serverid
- name: read xml
set_fact: xmlconf={{ lookup('file', 'files/cruise-config.xml')|
regex_replace('(serverId=)"[^"]+', '\\1"' + serverid.stdout)|
replace('\n','\\n')|
regex_replace('<security>.*</security>','')|
[Adblock Plus 2.0]
! Last modified: 12 Aug 2019 21:12 UTC
! Version: 201908122112
! Checksum: UsUJJ29xVUmq5NVbdbkbRg
! Title: hryamzik's list
! Expires: 1 days (update frequency)
! Homepage: localhost
! Licence: BSD
livejournal.com##div.b-discoverytimes
#!/bin/bash
read line
role=$(echo "$line"|/usr/local/bin/sed -E 's/^\s*-\s*\{?\s*(role:\s)?([a-zA-Z0-9_+-\/]+)($|,.*)/\2/')
testpath="$TM_DIRECTORY"
function testPath {
if test -d "$1/$role"
then
echo "$1/$role"
elif test -d "$1/roles/$role"
@hryamzik
hryamzik / localhost.yml
Created September 1, 2016 19:51
ansible 2.1.1.0 issue
localhost ansible_connection=local
localhost2 ansible_connection=local
2016/04/26 22:11:56 (map[string]*io_prometheus_client.MetricFamily)map[some_metric:<*>name:"some_metric" type:COUNTER metric:<label:<name:"label" value:"val1" > counter:<value:35 > > ]
([]*io_prometheus_client.MetricFamily)[<*>name:"some_metric" metric:<label:<name:"instance" value:"localhost:9100" > label:<name:"job" value:"some_job" > label:<name:"label" value:"val1" > counter:<value:35 > >  <*>name:"some_metric2" type:GAUGE metric:<label:<name:"instance" value:"localhost:9100" > label:<name:"job" value:"some_job" > label:<name:"label" value:"val1" > gauge:<value:28 > > metric:<label:<name:"instance" value:"localhost:9100" > label:<name:"job" value:"some_job" > label:<name:"label" value:"val1" > label:<name:"lable2" value:"val2" > gauge:<value:3 > > ]
(storage.GroupingKeyToMetricGroup)map[6988295756644506254:{Labels:(map[string]string)map[job:some_job instance:localhost:9100] Metrics:(storage.NameToTimestampedMetricFamilyMap)map[some_metric:{Timestamp:(time.Time)2016-04-26 20:28:56.704136597 +0300 MSK M
{
"receiver": "admins-critical",
"status": "resolved",
"alerts": [
{
"status": "resolved",
"labels": {
"alertname": "node_down",
"env": "prod",
"instance": "testhost.local:9100",
// http://stackoverflow.com/questions/14766951/convert-digits-into-words-with-javascript
var a = ['','one ','two ','three ','four ', 'five ','six ','seven ','eight ','nine ','ten ','eleven ','twelve ','thirteen ','fourteen ','fifteen ','sixteen ','seventeen ','eighteen ','nineteen '];
var b = ['', '', 'twenty','thirty','forty','fifty', 'sixty','seventy','eighty','ninety'];
function inWords (num) {
// if ((num = num.toString()).length > 9) return 'overflow';
n = ('000000000' + num).substr(-9).match(/^(\d{2})(\d{2})(\d{2})(\d{1})(\d{2})$/);
if (!n) return; var str = '';
str += (n[1] != 0) ? (a[Number(n[1])] || b[n[1][0]] + ' ' + a[n[1][1]]) + 'crore ' : '';
str += (n[2] != 0) ? (a[Number(n[2])] || b[n[2][0]] + ' ' + a[n[2][1]]) + 'lakh ' : '';
#!/bin/bash
read line
role=$(echo "$line"|/usr/local/bin/sed -E 's/^\s*-\s*\{?\s*(role:\s)?([a-zA-Z0-9_+-\/]+)($|,.*)/\2/')
testpath="$TM_DIRECTORY"
function testPath {
if test -d "$1/$role"
then
echo "$1/$role"
elif test -d "$1/roles/$role"