help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cf_lastseen.db [was: List of monitored files?]


From: Chip Seraphine
Subject: Re: cf_lastseen.db [was: List of monitored files?]
Date: Tue, 19 Oct 2004 11:09:20 -0500
User-agent: Mozilla Thunderbird 0.8 (X11/20040916)

Brendan Strejcek wrote:

Oh, and it would be nice if there was an option to make the
FriendStatus() alerts function do name resolution. Because getting an
email with a list of IP addresses requires me to manually resolve all
of them and then ignore most of the warnings (that is a dhcp address so
I don't care, that is a machine that got rebuilt yesterday so I don't
care, that is a machine that is not supposed to be running cfengine
because someone else is testing some new software on it, etc, etc).
Seeing the host names in the alert would make that more obvious.
Please excuse me omitting most of the above message; I just ran into the same problem Brendan did and ended up using a perl snippet on the emails to help me out. I'm posting it for benefit of anyone out there that isn't very scripting-inclined but is tired of running 'nslookup' a dozen times every morning :-).

#!/usr/bin/perl
#
# Derefs output of a showfriends() message with lines like:
#   sausage: Host 10.10.1.108 (hailed us) last at Mon Oct 18 08:10:52 2004
#
use Socket;
while (<>)
{
   $_ =~ /^\w+:\sHost\s([\d\.]+)\s\(hailed/;
   length($1) or next;
   $addy= inet_aton ($1);
$name= (gethostbyaddr( $addy, AF_INET ))[0];
   exists ($t{$name}) or print "$name\n";
   $t{$name}= 1;
}

--

Chip Seraphine
Unix Administrator
TradeLink, LLC
312-264-2048
address@hidden





reply via email to

[Prev in Thread] Current Thread [Next in Thread]