Category: Fedora

journalctl command to see kernel messages

Sometimes, there are just too many messages in journalctl output and it becomes a mystery game to search for the messages you are looking for. But luckily you do not need to use grep to find the right message. Here is example of what I had to do when I was looking for kernel messages.

journalctl _TRANSPORT=kernel
# To see all the fields, you can use the verbose mode
journalctl _TRANSPORT=kernel -o verbose

# And the filter on priority if needed to get the messages you need
journalctl _TRANSPORT=kernel PRIORITY=4

# and follow
journalctl _TRANSPORT=kernel PRIORITY=4 -f -l

ansible with docker dynamic inventory

So, I have a few dockers. Every now and then I want to run some command on all of them. Doing ‘docker exec’ is tiresome. I found this neat solution with ansible that I thought I should share with you.

To get started, you need to have the “docker.py” script. This script will be used as python script inventory for ansible. So, use the following command and get the script:

curl 'https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/docker.py' -o docker.p

Once done, check that all is well, with :

python docker.py

You should not get any errors or warnings and see a list of dockers running on your host. If you get error for docker-py then you can install the same with :

pip install docker-py

And now is the good time to open the docker.py script to check the documentation. It adds all the docker hosts as entry in itself. But cool  thing I liked is the fact that it creates a group for all running dockers – which is very very useful.

 

Now, if I want to set the Timezone (TZ) on all the running dockers in one go, I can do this:

ansible -i docker.py -m shell -a 'rm -f /etc/localtime; ln -s /usr/share/zoneinfo/Asia/Kolkata /etc/localtime' running

And just in case, the above does not work for you and you have a common username/password on all the machines, then another thing you would love is following:

# Export the docker host. If that is localhost, then you do not need this.
export DOCKER_HOST=tcp://192.168.122.1:4243
# This is GOOD to set option. This is the default IP address for docker
# and setting this to first IP address of the docker network is good idea
# that would ensure that ansible can login to each docker.
# And note - you need to have ssh running on all the dockers for the commands to work
export DOCKER_DEFAULT_IP=192.168.122.1
ansible -i docker.py -m setup -u root  -a 'filter=ansible_eth[0-2]'  all

power saving on laptop

One of the easiest way to make sure that you can have a decent battery life is

sudo yum install tlp smartmontools
sudo systemctl enable tlp
sudo systemctl start tlp

And after this you can check the status like this:

sudo tlp stat
— TLP 0.9 ——————————————–

+++ Configured Settings: /etc/default/tlp
TLP_ENABLE=1
TLP_DEFAULT_MODE=AC
DISK_IDLE_SECS_ON_AC=0
DISK_IDLE_SECS_ON_BAT=2
MAX_LOST_WORK_SECS_ON_AC=15
MAX_LOST_WORK_SECS_ON_BAT=60
SCHED_POWERSAVE_ON_AC=0
SCHED_POWERSAVE_ON_BAT=1
NMI_WATCHDOG=0
ENERGY_PERF_POLICY_ON_AC=performance
ENERGY_PERF_POLICY_ON_BAT=powersave
DISK_DEVICES=”sda sdb”
DISK_APM_LEVEL_ON_AC=”254 254″
DISK_APM_LEVEL_ON_BAT=”128 128″
SATA_LINKPWR_ON_AC=max_performance
SATA_LINKPWR_ON_BAT=min_power
AHCI_RUNTIME_PM_TIMEOUT=15
PCIE_ASPM_ON_AC=performance
PCIE_ASPM_ON_BAT=powersave
RADEON_POWER_PROFILE_ON_AC=high
RADEON_POWER_PROFILE_ON_BAT=low
RADEON_DPM_STATE_ON_AC=performance
RADEON_DPM_STATE_ON_BAT=battery
RADEON_DPM_PERF_LEVEL_ON_AC=auto
RADEON_DPM_PERF_LEVEL_ON_BAT=auto
WIFI_PWR_ON_AC=off
WIFI_PWR_ON_BAT=on
WOL_DISABLE=Y
SOUND_POWER_SAVE_ON_AC=0
SOUND_POWER_SAVE_ON_BAT=1
SOUND_POWER_SAVE_CONTROLLER=Y
BAY_POWEROFF_ON_BAT=0
BAY_DEVICE=”sr0″
RUNTIME_PM_ON_AC=on
RUNTIME_PM_ON_BAT=auto
RUNTIME_PM_ALL=1
RUNTIME_PM_DRIVER_BLACKLIST=”radeon nouveau”
USB_AUTOSUSPEND=1
USB_BLACKLIST_WWAN=1
RESTORE_DEVICE_STATE_ON_STARTUP=0

+++ System Info
System         = LENOVO Lenovo Y50-70 20378
BIOS           = 9ECN26WW(V1.09)
Release        = “Fedora release 25 (Twenty Five)”
Kernel         = 4.8.0-0.rc5.git1.1.fc25.x86_64 #1 SMP Tue Sep 6 15:52:10 UTC 2016 x86_64
/proc/cmdline  = BOOT_IMAGE=/vmlinuz-4.8.0-0.rc5.git1.1.fc25.x86_64 root=/dev/mapper/fedora_balp–fed–amitag-root ro nomodeset rd.lvm.lv=fedora_balp-fed-amitag/root vconsole.font=latarcyrheb-sun16 rd.lvm.lv=fedora_balp-fed-amitag/swap rhgb quiet resume=/dev/dm-1 LANG=en_US.UTF-8
Init system    = systemd
Boot mode      = UEFI

+++ TLP Status
State          = enabled
Last run       = 12:16:55 PM,    556 sec(s) ago
Mode           = AC
Power source   = AC

Notice: systemd-rfkill@.service is not masked — invoke “systemctl mask systemd-rfkill@.service” to correct this!
Notice: systemd-rfkill.service is not masked — invoke “systemctl mask systemd-rfkill.service” to correct this!

+++ Processor
CPU model      = —————————————————–

/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver    = intel_pstate
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor  = powersave
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq  =   800000 [kHz]