Tag Archives: bash - Page 2

How to check if zabbix agent insstalled at all infrastructure hosts

We use LXC containers at PH hosts.
containers named like:
rolename$RoleVersion-$InstanceNumber

For example
at host sXX2
appserver1-1
db1-1
db1-2
zabbix3-1

We need to check, if zabbix agents are installed at all infrastructure. One way – user fabric, Luke, as all 80 level DevOps do, or use ssh as all 40 level DevOps do.
Sorry for a little bit 🙂 “hindi” code 🙂 no review was done 🙂
Read more »

How to mount disk to LXC container

It`s rather simple.
just mount disk via fstab to host system:

root@sfa2 ~ # cat /etc/fstab | grep sdc1
/dev/sdc1       /mnt/sdc1   ext4     noatime,nodiratime      0 0

and add mount with bind to your LXC fstab, usually located at

root@sfa2 ~ # cat /var/lib/lxc/dbslave1-1/config | grep fstab
lxc.mount
.entry
= /var/lib/lxc/dbslave1-1/fstab

Now restart container and enjoy.

root@sfa2 ~ # cat /var/lib/lxc/dbslave1-1/fstab
proc            proc         proc    nodev,noexec,nosuid 0 0
sysfs           sys          sysfs defaults  0 0
/mnt/sdc1       /var/lib/lxc/dbslave1-1/rootfs/sdc1  none bind     0 0

BTW: Your cannot see remained space via df -h. I don`t know how to solve this issue 🙁 🙁 🙁

How to remove backdore at inittab, left by ISP

Suddenly I found backdore at our servers, leaved by our dedicated server provider, I will not say it`s name, because we already talk to them, get a big discount and solve this issue.
If their engineer press Alt+ArrowUp he obtain a root console, without login record displayed by lastlog.
dump-utmp help 🙂

r: ~ #aptitude install acct
  r: ~ # dump-utmp /var/log/wtmp

And here is a backdore:

r: ~ # cat /etc/inittab | grep kbre                                                                                                                
  #kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work."                                                                          
  kb::kbrequest:/sbin/getty -n -l /bin/bash tty12 115200                                                                                                    
  r: ~ #

How to remove it.

 #!/bin/sh
 
  for v in ` mkipsec -l |  awk '{print $1}' | sed s/:/\ / | tr -d '\n' | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"`;
  do
    s=`echo $v|sed 's/.*\.//'` ;
    printf "$s :\n";
    ssh -q -t  $s "sed -i s/kb\:\:/\#kb\:\:/ /etc/inittab" ;
  done