Christian Dunkel wrote: > On Friday 05 September 2008 10:55, J. Bakshi wrote: > >> Andreas Ericsson wrote: >> >>> Patch nrpe to allow dns name lookups in the "allowed_hosts" field and use >>> that instead of ip addresses. >>> >> Thanks a lot Andreas for your suggestion. >> But my local PC has no domain. >> Thanks a lot for the solution instead >> > > Hi List, hi Joydeep, > > maybe something like this might help you, as i'm in need to access my > homeserver from "outside" and also don't want to rely on dyn-dns services i > did somthing like this: > 1) setup user on homeserver and server on the net > 2) on the net this user has a little script in his ~/bin/ that greps the > remote ip from the env var: > CURRENT_IP=$(env|grep "SSH_CLIENT"|cut -d"=" -f2|cut -d" " -f1); > 3) on the homeserver setup a cronjob for that user that connects to the > other server and runs that script > 4) here comes the untested part;-) > setup this user in sudoers so he'd be able to restart nrpe > 5) use a script like this: > #!/bin/bash > OLD_IP=$(grep "^allowed_hosts" /usr/local/nagios/etc/nrpe.cfg| cut -d"," -f2); > CURRENT_IP=$(env|grep "SSH_CLIENT"|cut -d"=" -f2|cut -d" " -f1); > if [ $OLD_IP = $CURRENT_IP ]; > then exit 0; > else sed -i 's/${OLD_IP}/${CURRENT_IP}/g' /usr/local/nagios/etc/nrpe.cfg; > /etc/init.d/nagios-nrpe-server reload; > exit 0; > fi; > > regards, > Christian > >
Hi Christian, I honor your script power. Yes shell script rescue us from very difficult situation. Here my scenario is just opposite. My remote server has static IP but my local nagios PC has dynamic IP. So I need to tweak the script to fit to my requirement. Your script will also help others who have this same problem. Have a great time with best regards, -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Joydeep Bakshi, Linux System Admin Kolkatainfoservices Pvt Ltd, 23A Royd Street, Kolkata 700016, India Work Phone 91 033 40014784 http://infoservices.in/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Nagios-users mailing list Nagios-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nagios-users ::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. ::: Messages without supporting info will risk being sent to /dev/null