Enabling prometheus on k8s is pretty simple now. Helm has a complete stable chart of it, simply install it on k8s and it will work. To collect all slave nodes’ CPU usage: sum (rate (container_cpu_usage_seconds_total{kubernetes_io_hostname !~"k8s-master.*"}[10m])) / sum (machine_cpu_cores) * 100 To collect all slave nodes’ RAM usage: sum (container_memory_working_set_bytes{kubernetes_io_hostname!~"k8s-master.*"}) / sum (machine_memory_bytes{kubernetes_io_hostname!~"k8s-master.*"}) * 100 To collect data from prometheus API: curl -g '[]=container_cpu_usage_seconds_total{kubernetes_io_hostname!~"k8s-master.*"}' is my prometheus server IP. needs to elimiate space for URL.

Continue reading

ELK & Grafana

ELK Refer to my github, modified from official github. https://github.com/chz8494/k8s-ELK by default, ubuntu doens’t have enough vm.max_map_count which causes docker failure when bootstrap elasticsearch. max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] To fix this, add vm.max_map_count = 262144 in /etc/sysctl.conf. Then restart sysctl process: sudo sysctl --system A better solution of collecting docker container data is to use filebeat, there’s a helm chart for it.

Continue reading

#!/usr/bin/python -- coding: utf-8 -- "”” Zabbix SMTP Alert script for gmail. "”” import sys import smtplib from email.MIMEText import MIMEText from email.Header import Header from email.Utils import formatdate Mail Account MAIL_ACCOUNT = ‘[email protected]’ MAIL_PASSWORD = ‘your mail password’ Sender Name SENDER_NAME = u’Zabbix Alert’ Mail Server SMTP_SERVER = ‘smtp.gmail.com’ SMTP_PORT = 587 TLS SMTP_TLS = True def send_mail(recipient, subject, body, encoding='utf-8’): session = None msg = MIMEText(body, ‘plain’, encoding) msg[‘Subject’] = Header(subject, encoding) msg[‘From’] = Header(SENDER_NAME, encoding) msg[‘To’] = recipient msg[‘Date’] = formatdate() try: session = smtplib.

Continue reading

Author's picture


Love coding and new technologies

Cloud Solution Consultant