Skip to content

Instantly share code, notes, and snippets.

@pcuzner
pcuzner / gist:049cc8fef1f49c533e0dac47fb66976e
Created June 22, 2017 07:09
selinux problem with write_graphite plugin
In collectd log
Jun 21 12:42:52 magna123 collectd[1415]: write_graphite plugin: Connecting to magna010.ceph.redhat.com:2003 via tcp failed. The last error was: failed to connect to remote host: Permission denied
Jun 21 12:44:22 magna123 collectd[1415]: write_graphite plugin: Connecting to magna010.ceph.redhat.com:2003 via tcp failed. The last error was: failed to connect to remote host: Permission denied
Jun 21 12:47:12 magna123 collectd[1415]: write_graphite plugin: Connecting to magna010.ceph.redhat.com:2003 via tcp failed. The last error was: failed to connect to remote host: Permission denied
Jun 21 12:52:42 magna123 collectd[1415]: write_graphite plugin: Connecting to magna010.ceph.redhat.com:2003 via tcp failed. The last error was: failed to connect to remote host: Permission denied
In audit log
type=AVC msg=audit(1498115272.402:51160): avc: denied { name_connect } for pid=1481 comm="writer#1" dest=2003 scontext=system_u:system_r:collectd_t:s0 tcontext=system_u:object_r:lmtp_port_t:s0 tclass=tcp_soc
@pcuzner
pcuzner / rbdperf.py
Created May 9, 2018 17:11
example code using librbd stats
#!/usr/bin/env python2
import json
import glob
import os
import sys
import time
import argparse
@pcuzner
pcuzner / fetch_disks.py
Created May 8, 2019 01:56
redfish example getting host and low level disk information from a server (tested on iDRAC9)
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
import os
import sys
import json
import time
import humanize
import progressbar
# turn off insecure warnings since BMC is self signed
@pcuzner
pcuzner / monitoring.py
Last active November 27, 2019 22:54
deploying ceph monitoring components. This is just test code to identify the processing flow that would need to be added to the ceph-daemon script
import yaml
import threading
import logging
import json
import os
import subprocess
import socket
import sys
import fcntl
import select
@pcuzner
pcuzner / daemonls.py
Last active September 1, 2020 06:05
POC code which demonstrates a faster approach to the cephadm daemon_list function
#!/usr/bin/env python3
import os
import fcntl
import subprocess
import logging
import time
import select
import json
import datetime
from urllib.request import urlopen
@pcuzner
pcuzner / cephadm payload
Created September 10, 2020 22:47
Output example from a proposed web service for cephadm
{
"health": {
"host_facts": "active",
"list_daemons": "active",
"ceph_volume": "active",
"http_server": "active"
},
"host": {
"scrape_timestamp": 1599777626.2632258,
"scrape_duration_secs": 0.01775193214416504,
@pcuzner
pcuzner / Peek 2020-09-11 16-40.gif
Last active September 11, 2020 05:19
cephadm daemon demo
Peek 2020-09-11 16-40.gif
@pcuzner
pcuzner / cephadmremoto.py
Last active September 29, 2020 22:36
test script to understand the elapsed time of a remoto (ssh) call for a basic cephadm -h command
import datetime
import os
import json
# 1. ensure your host has python3-remoto installed
import remoto
# 2. Pick the location of the cephadm 'binary' to ship to the target
# cephadm_path = '/home/paul/git/ceph/src/cephadm/cephadm'
# cephadm_path = '/usr/sbin/cephadm'
@pcuzner
pcuzner / CephContainerAnalysis.json
Created July 19, 2021 21:36
Grafana Dashboard to visualise Ceph container resource utilisation from cadvisor metrics
{
"annotations": {
"list": [
{
"$$hashKey": "object:140",
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
@pcuzner
pcuzner / cherrypie.py
Created August 9, 2021 22:22
cherrypy example
#!/usr/bin/env python3
import cherrypy
# Test:
# curl -H "Content-Type: application/json" http://localhost:8000/data --data '{"data":30}' -X POST
class Root:
def __init__(self):