Friday, 19 June 2015

When a process shows uid number instead of user name

When a process appears with the uid number instead of the username, it is because the username is more than 8 characters long:
[root@ pe-activemq]# ps -ef|grep active
497       2578     1  0 12:44 ?        00:00:27 /opt/puppet/lib/jvm/pe-java/jre/bin/java -Xms512m -Xmx512m -Djava.util.logging.config.file=logging.properties -Dhawtio.realm=activemq -Dhawtio.role=admins -Dhawtio.rolePrincipalClasses=org.apache.activemq.jaas.GroupPrincipal -Djava.security.auth.login.config=/etc/puppetlabs/activemq/login.config -Dcom.sun.management.jmxremote -Djava.awt.headless=true -Djava.io.tmpdir=/opt/puppet/share/activemq/tmp -Dactivemq.classpath=/etc/puppetlabs/activemq; -Dactivemq.home=/opt/puppet/share/activemq -Dactivemq.base=/opt/puppet/share/activemq -Dactivemq.conf=/etc/puppetlabs/activemq -Dactivemq.data=/opt/puppet/share/activemq/data -jar /opt/puppet/share/activemq/bin/activemq.jar start
root     16591  7586  0 13:30 pts/0    00:00:00 grep active
Use the command option -o to shown fullname:
[root@ pe-activemq]# ps -e -o "user:16,pid,ppid,c,stime,tty,time,command"|grep active
pe-activemq       2578     1  0 12:44 ?        00:00:28 /opt/puppet/lib/jvm/pe-java/jre/bin/java -Xms512m -Xmx512m -Djava.util.logging.config.file=logging.properties -Dhawtio.realm=activemq -Dhawtio.role=admins -Dhawtio.rolePrincipalClasses=org.apache.activemq.jaas.GroupPrincipal -Djava.security.auth.login.config=/etc/puppetlabs/activemq/login.config -Dcom.sun.management.jmxremote -Djava.awt.headless=true -Djava.io.tmpdir=/opt/puppet/share/activemq/tmp -Dactivemq.classpath=/etc/puppetlabs/activemq; -Dactivemq.home=/opt/puppet/share/activemq -Dactivemq.base=/opt/puppet/share/activemq -Dactivemq.conf=/etc/puppetlabs/activemq -Dactivemq.data=/opt/puppet/share/activemq/data -jar /opt/puppet/share/activemq/bin/activemq.jar start
root             17623  7586  0 13:37 pts/0    00:00:00 grep active
root             17391 grep active

Tuesday, 9 June 2015

Add CDROM as local yum repo - CentOS 7

Mount the CD/DVD ROM on the any directory of your wish, for testing mount it on /cdrom.
# mkdir /cdrom
# mount /dev/cdrom /cdrom
Configuration file: Create the new repo file called cdrom.repo under /etc/yum.repos.d directory. # vi /etc/yum.repos.d/local.repo Add the following details.
[LocalRepo]
name=Local Repository
baseurl=file:///cdrom
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Thursday, 28 May 2015

Regenerate authorized_keys file in GitLab

sudo gitlab-rake gitlab:shell:setup
To check your GitLab for issues:
sudo gitlab-rake gitlab:check RAILS_ENV=production

Tuesday, 26 May 2015

Disk Usage - What's eating my disk space Perl script

#!/usr/bin/perl
use strict;
use IO::File;

my $size;
my $inode;
my $sum = 0;
my @entries;
my $e;
my $percent = 0;
my $remsum = 0;
my $counter = 0;
my $nofiles = 0;

my $du = new IO::File;

if (@ARGV) {
    chdir "$ARGV[0]" or die "cannot change to [ $ARGV[0] ]\n";
}

my $path =  $ARGV[0] . "/";
print "$path\n";
START:

$du->open("du -sk *|") or
    die "cannot open du program and pipe";

while (<$du>) {
    ($size, $inode)=split;
    $inode .= "/" if (-d $inode);
    $sum += $size;
    push @entries, { size => $size, inode => $inode };
}

@entries = sort { $b->{size} <=> $a->{size} } @entries;

$du->close;

foreach $e (@entries) {
    $percent = $e->{size}/$sum*100;

    if ($counter < 10) {
        printf(
            "%30s | %5d | %5.2f%%\n",
            $e->{inode},
            $e->{size},
            $percent);
    }
    else {
        $nofiles++;
        $remsum += $e->{size};
    }
    $counter++;
}

if ($remsum > 0) {
    printf(
        "%30s | %5d | %5.2f%%\n",
        "files",
        $remsum,
        $remsum/$sum*100);
}


if (@entries[0]->{inode} =~ /(.*\/$)/)
{
    $path .= $1;
    chdir $path;
    print "$path\n";
    undef @entries;
    $counter=0; $nofiles=0;
    goto START;
}
else
{
    print "No more!";
    exit;
}

Wednesday, 20 May 2015

Port Bonding and VLAN - CentOS 6

Create the file /etc/modprobe.d/bonding.conf, add the following lines:
alias bond0 bonding
options bond0 mode=1 miimon=100
Create the bond file /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
BONDING_OPTS="miimon=100 mode=1"
TYPE=Unknown
IPV6INIT=no
Create the VLAN bond file /etc/sysconfig/network-scripts/ifcfg-bond0.35
DEVICE=bond0.35
BOOTPROTO=none
TYPE=Ethernet
ONBOOT=yes
VLAN=yes
NM_CONTROLLED=no
IPADDR=x.x.35.13
PREFIX=24
GATEWAY=x.x.35.250
NM_CONTOLLED=no
USERCTL=no
Edit the interface files ifcfg-em1 and ifcfg-em2:
DEVICE="em1"
BOOTPROTO="none"
HWADDR="xx:xx:xx:xx:xx:7A"
IPV6INIT="yes"
MTU="1500"
NM_CONTROLLED="no"
ONBOOT="yes"
TYPE="Ethernet"
UUID="90e968f4-xxxx-xxxx-xxxx-0a188c6cc9e8"
MASTER=bond0
SLAVE=yes
USERCTL=no
--------------------------------------------------------------------------
DEVICE=em2
HWADDR=xx:xx:xx:xx:xx:7C
TYPE=Ethernet
UUID=4bc7043a-xxxx-xxxx-xxxx-cd5f6f04e0f7
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
USERCTL=no

Thursday, 30 April 2015

Foreman-Proxy SSL Error

Oops, we're sorry but something went wrong
 
×
Warning!

ERF12-5356 [ProxyAPI::ProxyException]: Unable to get PuppetCA certificates ([OpenSSL::SSL::SSLError]: SSL_connect returned=1 errno=0 state=SSLv3 read server session ticket A: tlsv1 alert un...) for proxy https://foreman.domain.net:8443/puppet/ca
If you feel this is an error with Foreman itself, please open a new issue with Foreman ticketing system, You would probably need to attach the Full trace and relevant log entries.

Back

Reset Foreman Admin Login Password

As super-user, on the command line, run:
foreman-rake permissions:reset