About bentech4u

Aug.30

Transmission settings.json Reverting to Defaults

The transmission-daemon package from EPEL makes it easy to setup a command line bittorrent client on RHEL  or CentOS . However, I have encountered situations where modified settings in/var/lib/transmission/.config/transmission/settings.json revert back to their defaults upon starting the transmission-daemon service.

In particular, the rpc-authentication-required parameter will always revert back to false if set to true when using a default transmission-daemon install. This occurs because of certain switches being passed by the transmission-daemon init script found at /etc/init.d/transmission-daemon.

The particular line in /etc/init.d/transmission-daemon that is overriding certain parameters in /var/lib/transmission/.config/transmission/settings.json is the following:

 

DAEMON_ARGS="-T --blocklist -g $TRANSMISSION_HOME/.config/transmission"

The -T switch causes transmission-daemon to never require authentication, and the –blocklist switch enables peer blocklists. If you would rather your settings only be defined in /var/lib/transmission/.config/transmission/settings.json, remove those switches. I would suggest copying this line, commenting it out, pasting a new line, and removing the switches from the new line in case you ever want to revert to the default settings. The new DAEMON_ARGS line would then look like the following:

 

DAEMON_ARGS="-g $TRANSMISSION_HOME/.config/transmission"

Now, all settings will only be defined in /var/lib/transmission/.config/transmission/settings.json.

Take note, in order to change any settings in /var/lib/transmission/.config/transmission/settings.json, the transmission-daemon service must be stopped. Changes made while the service is running will be ignored and set back to their previous settings upon restart.

Solaris Script:- Generate sar CPU & MEMORY of current month

HI

This is to generate comma separated values of CPU and Memory usage of current month. later we can export to .csv file for plotting graph in excel.

 

#!/usr/bin/bash
#Wrote on 18-08-2016 by Ben George
##################################
# Generate sar CPU & MEMORY of current month
##################################
PATH=/usr/xpg4/bin:$PATH
IFS=$’\n’ read -d ” -ra date < <(ls -l /var/adm/sa/ | grep `date +%b` | awk ‘{print $6″ “$7}’)
IFS=$’\n’ read -d ” -ra file < <(ls -l /var/adm/sa/ | grep `date +%b` | awk ‘{print $9}’)
printf “\n\n##— CPU AVERAGE —## \n\n”
echo $(sar -u -f /var/adm/sa/sa01 | awk ‘NR==4{print “Date,”$2″,”$3″,”$4”,”$5}’)
for i in “${!date[@]}”
do
cpuvalues=$(sar -u -f /var/adm/sa/”${file[$i]}” | grep -i average | awk ‘{print $2″,”$3″,”$4″,”$5}’)
echo “${date[$i]},$cpuvalues”
done
printf “\n\n##— MEMORY AVERAGE —## \n\n”
echo $(sar -r -f /var/adm/sa/sa01 | awk ‘NR==4{print “Date,”$2”,”$3}’)
for j in “${!date[@]}”
do
memoryvalues=$(sar -r -f /var/adm/sa/”${file[$j]}” | grep -i average |awk ‘{print $2″,”$3}’)
echo “${date[$j]},$memoryvalues”
done

 

NOTE: please request if you have difficulty in copy/paste. i will send you script through mail

Solaris script to generate average Disk I/O based on sar

HI

 

this is a simple script to generate average diskI /O based on sar reports. the output is given as comma separated and you can easily generate graphs by Excel or LibreOffice

 

#!/usr/bin/env bash
#Wrote on 15-08-2016 by Ben George
##################################
# Generate sar Disk IO of current month
##################################

PATH=/usr/xpg4/bin:$PATH

DATEROW=$(read -r date month < <(date ‘+%d %b’); days=(); for (( i = 1; i <= 10#$date; ++i )); do days+=(“$month$i”); done; printf ‘%s,’ “${days[@]}”)
echo “Device,”$DATEROW

lastfile=/var/adm/sa/sa$(date +%d)

for file in /var/adm/sa/sa[0-9][0-9]; do
[[ $file > $lastfile ]] && break
sar -d -f “$file”
done | awk -v RS= -F’\n’ ‘
$1 ~ /Average/ {
for (i = 1; i<=NF; ++i) {
if ($i !~ /vdc/)
continue;
split($i, row, ” “);
a[row[1]]=a[row[1]]”,”row[4] }
}
END {
for (disk in a)
print disk a[disk] }’

 

NOTE: if anyone is getting difficulty reading the script, please mail me i will send the script

Mar.23

Network Issue on VMWare Workstation – CentOS 7 & above

I was facing this issue with centos 7.2 release and device was not showing in my nmcli.

I tried many times adding/removing cards the reason is that the v7 3.10 kernel no longer supports the Ethernet Controller device And the solution is..

I added the following line to your  .vmx file and reboot system.

ethernet0.virtualDev = “e1000”

*replace ethernet0 with your card specific number

Script to Detect un-used/not mounted Storages

simple script to alert unused storage space. This will also tell you active storage path mount points

#!/usr/bin/bash
#created by Ben.T.George
LunId=( `luxadm probe |grep -v “Type:Tape” |grep -v “Node WWN:” | awk -F\/ ‘NR>3{print $4}’|sed ‘s/..$//g’` )
zonelist=( `zoneadm list` )
echo “__________________________________________________________________________________”
zoneadm list -cv
echo “__________________________________________________________________________________”
for luns in “${!LunId[@]}”;do
(echo -e “\x1B[31m ${LunId[$luns]} \x1B[0m”
echo “”
result=$(echo | format “${LunId[$luns]}” 2>&1 |egrep -c ‘(mounted|zpool)’)
if [ $result -gt 0 ]; then
echo -e “\x1B[01;96m ${LunId[$luns]} mounted on: $(mount | grep ${LunId[$luns]} | awk ‘{print $1}’)\x1B[0m”
else
echo -e “\x1B[01;31m ${LunId[$luns]} not mounted \x1B[0m”
fi)&
done

One Line Script to list all LUNS on Solaris 10

Hi All,

 

Here is one line script to list all LUN’s(only external Storage) on solaris 10.

 

root@benvin.net# luxadm probe | grep -v “Node WWN:” | awk -F\/ ‘NR>3{print $4}’|sed ‘s/..$//g’
c3t600D0231000BE73D1C9ED0B453F185C2d0
c3t600D0231000BE73D4A2C042D18A2E641d0
c3t600D0231000BE73D6D42C80D77B8DDF0d0
c3t600D0231000BE73D194D85CA4D102795d0
c3t600D0231000BE73D435D27657C919F6Ed0
c3t600D0231000BE73D5482A3BE75F412FCd0
c3t600D0231000BE73D5619FDD6500CF273d0
c3t600D0231000BE73D37672E311947B18Cd0

Good luck

Copy RSA keys to all Solaris zones & restart ssh service

This is a simple script to copy SSH RSA keys to all standard zones and restarting ssh services on all .

i am not going to explain how to create public RSA keys. Also assume that RSA key is copied to global zone.

usage : create file with script, give exicute permission & run example.sh <ip>

#!/bin/bash
ipaddress=$1
IFS=$’\n’ read -d ” -ra name < <(ssh “$ipaddress” zoneadm list -cv | awk ‘NR > 2{print $4}’ )
IFS=$’\n’ read -d ” -ra state < <(ssh “$ipaddress” zoneadm list | awk ‘NR > 1’ )

for i in “${!name[@]}”;do
ssh $ipaddress mkdir -p “${name[$i]}”/root/.ssh
ssh $ipaddress chmod 700 “${name[$i]}”/root/.ssh
echo “copying RSA keys on : ${state[$i]}”
echo “ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4T+N21GzKnYgCh9sC72qhOYKjbjHRyp5GqWPDGSfUkhmk8iJRAS2hhcP5lZ1x6fc/cNzqETQ98sjdKm59PB7MSJQ12WMHTc7wtuBdh7+wE0ZlWsjGfEvzCaWIXNUhh2hK2ZUq7XMZ5QR2E+j2uWTJKsZmQyf4
A5z8nLTAtL2CKQamxZskABttpXkxx7gm+yc8coJB8nhOr6Q4KsyDcEmjGAFwbjiBKyefUIiMroP0PtZPI/8EYtwtP/Cm79BFzhJtOl/VGqTvlab+1IQeO54/ztL0gg7C0zTwNTKODTrCNh+nIj6Fk6/CjyX0Qg9xWd7BRr1oUbI5yMvg3wLD66tEw== root@kwtprgateone01
” | ssh $ipaddress “cat >> “${name[$i]}”/root/.ssh/authorized_keys”
ssh $ipaddress chmod 600 “${name[$i]}”/root/.ssh/authorized_keys
echo “changing ssh configuration files on: ${state[$i]}”
ssh $ipaddress “cat ${name[$i]}/root/etc/ssh/sshd_config | sed ‘s/PermitRootLogin no/PermitRootLogin yes/g’ > ${name[$i]}/root/tmp/sshd_config ; cp ${name[$i]}/root/tmp/sshd_config ${name[$i]}/root/e
tc/ssh/sshd_config”
echo “Restarting ssh service on : ${state[$i]}”
ssh $ipaddress “zlogin ${state[$i]} svcadm restart ssh”
done