#!/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;
}
Tuesday, 26 May 2015
Disk Usage - What's eating my disk space Perl script
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=100Create 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=noCreate 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=noEdit 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
Tuesday, 28 April 2015
Add http/https access to iptables - CentOS 6
Edit iptables:
vi /etc/sysconfig/iptablesAdd the following lines:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPTRestart iptables:
service iptables restart
Tuesday, 10 March 2015
Installing Hyper-V Daemons on CentOS 7
[root@its-webmon ~]# yum search hyperv
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.coreix.net
* epel: mirror.vorboss.net
* extras: mirror.ox.ac.uk
* updates: mirror.ox.ac.uk
============================= N/S matched: hyperv ==============================
hyperv-daemons.x86_64 : HyperV daemons suite
hyperv-daemons-license.noarch : License of the HyperV daemons suite
hypervkvpd.x86_64 : HyperV key value pair (KVP) daemon
hypervvssd.x86_64 : HyperV VSS daemon
perl-Sys-Virt.x86_64 : Represent and manage a libvirt hypervisor connection
Name and summary matches only, use "search all" for everything.
[root@its-webmon ~]# yum install hyperv-daemons
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.coreix.net
* epel: mirror.vorboss.net
* extras: mirrors.coreix.net
* updates: mirror.sov.uk.goscomb.net
Resolving Dependencies
--> Running transaction check
---> Package hyperv-daemons.x86_64 0:0-0.24.20130826git.el7 will be installed
--> Processing Dependency: hypervvssd = 0-0.24.20130826git.el7 for package: hyperv-daemons-0-0.24.20130826git.el7.x86_64
--> Processing Dependency: hypervkvpd = 0-0.24.20130826git.el7 for package: hyperv-daemons-0-0.24.20130826git.el7.x86_64
--> Running transaction check
---> Package hypervkvpd.x86_64 0:0-0.24.20130826git.el7 will be installed
--> Processing Dependency: hyperv-daemons-license = 0-0.24.20130826git.el7 for package: hypervkvpd-0-0.24.20130826git.el7.x86_64
---> Package hypervvssd.x86_64 0:0-0.24.20130826git.el7 will be installed
--> Running transaction check
---> Package hyperv-daemons-license.noarch 0:0-0.24.20130826git.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository
Size
================================================================================
Installing:
hyperv-daemons x86_64 0-0.24.20130826git.el7 base 3.7 k
Installing for dependencies:
hyperv-daemons-license noarch 0-0.24.20130826git.el7 base 11 k
hypervkvpd x86_64 0-0.24.20130826git.el7 base 18 k
hypervvssd x86_64 0-0.24.20130826git.el7 base 9.9 k
Transaction Summary
================================================================================
Install 1 Package (+3 Dependent packages)
Total download size: 43 k
Installed size: 60 k
Is this ok [y/d/N]: y
Downloading packages:
(1/4): hyperv-daemons-0-0.24.20130826git.el7.x86_64.rpm | 3.7 kB 00:00
(2/4): hyperv-daemons-license-0-0.24.20130826git.el7.noarc | 11 kB 00:00
(3/4): hypervvssd-0-0.24.20130826git.el7.x86_64.rpm | 9.9 kB 00:00
(4/4): hypervkvpd-0-0.24.20130826git.el7.x86_64.rpm | 18 kB 00:00
--------------------------------------------------------------------------------
Total 103 kB/s | 43 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : hyperv-daemons-license-0-0.24.20130826git.el7.noarch 1/4
Installing : hypervkvpd-0-0.24.20130826git.el7.x86_64 2/4
Installing : hypervvssd-0-0.24.20130826git.el7.x86_64 3/4
Installing : hyperv-daemons-0-0.24.20130826git.el7.x86_64 4/4
Verifying : hyperv-daemons-license-0-0.24.20130826git.el7.noarch 1/4
Verifying : hyperv-daemons-0-0.24.20130826git.el7.x86_64 2/4
Verifying : hypervkvpd-0-0.24.20130826git.el7.x86_64 3/4
Verifying : hypervvssd-0-0.24.20130826git.el7.x86_64 4/4
Installed:
hyperv-daemons.x86_64 0:0-0.24.20130826git.el7
Dependency Installed:
hyperv-daemons-license.noarch 0:0-0.24.20130826git.el7
hypervkvpd.x86_64 0:0-0.24.20130826git.el7
hypervvssd.x86_64 0:0-0.24.20130826git.el7
Complete!
[root@its-webmon init.d]# service hypervkvpd start
Redirecting to /bin/systemctl start hypervkvpd.service
[root@its-webmon init.d]# service hypervvssd start
Redirecting to /bin/systemctl start hypervvssd.service
[root@its-webmon init.d]# systemctl|grep hyper
hypervkvpd.service loaded active running Hyper-V KVP daemon
hypervvssd.service loaded active running Hyper-V VSS daemon
Friday, 6 March 2015
Registering networker ports
echo "Registering networker ports 7937-7999 with backup server" /usr/bin/nsrports -s backupserver.domain.com -S 7937-7999 /usr/bin/nsrports -S 7937-7999 /usr/bin/nsrports -s backupserver.domain.com -C 10001-30000 /usr/bin/nsrports -C 10001-30000
Subscribe to:
Posts (Atom)