Monday, December 6, 2010

Howto - Find broken symbolic links

2 cool ways to find broken symbolic links on your system:
Bash:
for i in `find /`; do if (test -h $i); then file $i|grep broken; fi; done

Output:
./bar_link: broken symbolic link to `/etc/foo'



Any Shell:
find / -type l ! -exec test -r {} \; -print

Output:
./bar_link

When measuring the results with "time" command - the 2nd command wins, so if performance is critical in your case, use the 2nd one :)

Tuesday, September 14, 2010

Change ILO settings via CLI from Linux

ILO - aka "Integrated Lights Out" is an advanced console technology that HP has implemented in most of their servers, it includes dozens of cool features and allows total remote control on the server in all kinds of aspects. ILO includes lot's of advanced configurations such as IP configuration, DNS, SNMP, LDAP integration, Users, Permissions and many more.

The "traditional" way to change these settings is via server downtime and booting it to ILO BIOS (usually by pressing F8 at boot time) and changing it there.

But what if we have hundreds of servers that require immediate change, going the first way would be a huge waste of time, therefore HP introduced a cool scripting tool (for both Linux & Windows) called  - "hponcfg". In this short tutorial we will understand how to use it - read on:


To use "hpconfg" we first have to make sure a service called "hprsm" is installed properly & running and that the needed modules are loaded into kernel:

linux01 #rpm -q hprsm hponcfg
hprsm-7.9.0-108.sles10
hponcfg-1.6.0-1

linux01 #/etc/init.d/hprsm start

The service is running and we are ready to configure our ILO settings, to see the current settings we can generate an XML template with our current settings, to achieve this execute:

linux01 #hponcfg -w /tmp/ilo_cfg_`uname -n`.xml
Firmware Revision = 1.81 Device type = iLO 2 Driver name = cpqci
RILOE II/iLO configuration successfully written to file "/tmp/ilo_config_linux01.xml"


Now, we can see our current ILO configuration represented in the XML template we saved to /tmp, let's see what it contains:

linux01 #cat /tmp/ilo_config_linux01.xml



















Ok, now you can edit whatever parameter you like and upload the updated XML template to ILO via "hpocnfg tool".

To upload the XML template, execute:
linux01 #hponcfg -f /tmp/ilo_config_`uname -n`.xml

Please note that  restart of ILO is needed for changes to take effect.

Sunday, August 29, 2010

Check Hyper Threading - Linux

When you need to know whether hyper-threading is enabled without rebooting your system (and checking BIOS/UEFI), you can simply look at the output of /proc/cpuinfo and compare the siblings with the cpu cores fields.
Even though /proc/cpuinfo shows you all the logical CPUs (processor field) in the system, the siblings field holds the number of logical CPUs for the physical CPU this entry belongs to (including both the cores and the hyper-threaded LCPUs).

For example, if you see:
processor : 7
physical id : 9
siblings : 4
cpu cores : 2

That means that LCPU #7 (the eight logical CPU in your system) is one of the 4 logical CPUs on the physical CPU that has 2 cores. So - hyper-threading is enabled.

Thursday, June 17, 2010

Change MTU size in Linux

Maximum Transmission Unit(MTU), the largest physical packet size, measured in bytes, that a network can transmit. Any messages larger than the MTU are divided into smaller packets before being sent .
By optimizing the MTU setting you can gain substantial network performance.
In IPv4 the values range between 576 and 1500 bytes being the max size.

The general syntax is: ifconfig "interface" mtu "size"

For example:ifconfig eth0 mtu 1420


Will change MTU to 1420 bytes.

For permanent change, you can add the MTU parameter into your interface configuration file,
For example in Debian the configuration will look like this:



iface eth0 inet static
address 192.168.0.100
network 192.168.0.0
gateway 192.168.0.254
netmask 255.255.255.0
mtu 1420

Friday, February 19, 2010

Generate hosts file with Perl

A sweet way to add couple of servers to your hosts file/NIS map using a tiny perl script:

#!/usr/bin/perl -w

use strict;
use warnings;
print `clear`;
my $j=10;

open (HOSTS ,">>/etc/hosts.txt") or die $!;
for (my $num=0;$num <= 10; $num++) {
printf(HOSTS "server$j \t server$j.domain.org \t 192.168.0.$num\n");
$j++;
}
close (HOSTS) or die $! ;

#END


The output will be:

server10 server10.domain.org 192.168.0.0

server11 server11.domain.org 192.168.0.1
server12 server12.domain.org 192.168.0.2
server13 server13.domain.org 192.168.0.3
server14 server14.domain.org 192.168.0.4
server15 server15.domain.org 192.168.0.5
server16 server16.domain.org 192.168.0.6
server17 server17.domain.org 192.168.0.7
server18 server18.domain.org 192.168.0.8
server19 server19.domain.org 192.168.0.9
server20 server20.domain.org 192.168.0.10

Monday, January 11, 2010

Howto change NIC order in Linux (SUSE 10)

I recently had an issue with a mother board that was replaced on some server, after renaming the configuration file to the correct MAC address (ifcfg-eth-id-00:1a:64:7a:d0:be), the new NIC was recognized as eth4, (and not eth0 as previously),after digging abit in the depths of the OS I have found a solution:

/etc/udev/rules.d/30-net_persistent_names.rules

Through this file you can configure the NIC order by MAC address.
For example:

SUBSYSTEM=="net", ACTION=="add", SYSFS{address}=="00:1a:64:7a:d0:be", IMPORT="/lib/udev/rename_netiface %k eth0"

To change take place you will probably need to reboot the machine so udev will re-read it's configurations(restarting networking service is not enough).