Adventures In Tech

Icon

A technology blog by Ross Macduff

Include a time stamp with pings

It might be useful to include an absolute time stamp when pinging multiple hosts so as to be able to make a correspondance later on.  This is what I put together in a hurry that does the trick.

while test 0; do  DATE=$( date | tr -d '\n' ); \
PING=$( ping -c 1 192.168.1.100 | grep from ); \
( echo $DATE $PING; sleep 1 ) | tee -a /path/to/log ; done

Got a better way to do this? Post a comment.

Filed under: network , , ,

Problem downloading src rpms from RHN

I mentioed in a previous post how cool it was that you can download src rpms with yumdownloader.   I didn’t realize until a couple of days ago that it is not able to grab src rpms from the Redhat Network – at least the way my RHEL 5.3 yum config is setup.

Following the suggestion here I added a repo config file specifying the location to grab the src rpms, but that was unsuccessful.

I decided to take a look at the code behind the tool (/usr/bin/yumdownloader) and this is what I found:

# Ok, we have src and bin repos. What we want to do here is:
#
# 1. _enable_ source repos for which the bin repos are enabled.
# 2. _disable_ the _other_ src repos.

(this is from the version of yumdownloader that comes with yum-utils-1.1.16-13.el5.noarch)

So only source repos must be paired up with “bin” repos. That explains why the previous attempt to solve this problem didn’t work as it was a standalone repository.

So why not add a source repo section to the config for the Redhat Network repo? Well, the Redhat Network repo settings come as a part of a plugin (rhnplugin) that does not have repo config files that you would see in /etc/yum.repos.d. From inspecting the /usr/lib/yum-plugins/rhnplugin.py I also didn’t see anything related to src rpms (though I did only a cursory inspection).

The solution I put in place was to setup a dummy (empty) yum repository to pair up with the src repo. This just requires running ‘createrepo .’ in an empty web accessible directory. With that in place the following config worked:

[rheld]
name=Red Hat Dummy
baseurl=http://your.domain.com/yum/dummy/
failovermethod=priority
enabled=1
gpgcheck=0

[rheld-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/SRPMS/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

Filed under: Sysadmin , , , ,