<br><div class="gmail_extra"><div class="gmail_quote">On Sat, Apr 28, 2012 at 2:38 AM, Morty <span dir="ltr"><<a href="mailto:morty+nagios@frakir.org" target="_blank">morty+nagios@frakir.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Is there a way for an NRPE script to know the remote server's IP? I'm<br>
not seeing anything in the environment for NRPE 2.12. getpeername on<br>
STDIN doesn't seem to help; presumably nrpe doesn't connect the script<br>
directly to the sockets.<br>
<br>
Detailed scenario:<br>
<br>
I have two nagios servers running in an active/active cluster. So<br>
each nagios instance is checking all servers. Some services utilize<br>
NRPE. One service check is a script that wants to see change in a<br>
certain system parameter since last time. It then saves the value in<br>
a statefile, so it can check the next time.<br>
<br>
Problem: race condition. If the two nagios servers both check at<br>
around the same time, one of them will set the state file. Then the<br>
other one sees the recent statefile and sees no change in the system<br>
parameter, and the service check goes critical.<br>
<br>
A lockfile won't solve the problem, because the problem isn't when the<br>
two are running at the same time, it's when the two run shortly after<br>
one another.<br>
<br>
One fix would be to have the script use a statefile that includes the<br>
nagios server IP. So it would use a different statefile depending on<br>
which nagios server queries, and there would be no conflict. The<br>
problem is, I can't see a way to supply the server IP to the script.<br>
No such variable appears in the NRPE environment. getpeername isn't<br>
working, at least on STDIN.<br>
<br>
I could try to do something with a nagios macro, but NRPE scripts are<br>
supposed to have fixed options unless I turn on dont_blame_nrpe=1,<br>
which I don't want to do.<br>
<br>
- Morty<br></blockquote><div><br><font face="courier new,monospace"><br></font>dont_blame_nrpe isnt that big a security issue if you trust your Nagios servers security and restrict whos allowed to run nrpe commands.<br>You could then pass in a custom macro from Nagios.<br>
<br>The only other way I could think would be to run a different client side check / service for each Nagios server. <br><br>if you use the _exact_ same config on each Nagios server you can probably use a custom macro in the service's command definition.<br>
<br>I have not tried it my self but i dont see why it wont work.<br><br>service {<br>name statefile<br>command $USER1$/statefile_$USER5$.pl<br>}<br><br>where $USER5$ is set to the Nagios servers host name and just define two nrpe commands on the client's.<br>
<br><br>HTH<br>Ritchie,<br clear="all">--<br><--Time flies like an arrow; fruit flies like a banana. --><br>
<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
------------------------------------------------------------------------------<br>
Live Security Virtual Conference<br>
Exclusive live event will cover all the ways today's security and<br>
threat landscape has changed and how IT managers can respond. Discussions<br>
will include endpoint security, mobile security and the latest in malware<br>
threats. <a href="http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/" target="_blank">http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/</a><br>
_______________________________________________<br>
Nagios-users mailing list<br>
<a href="mailto:Nagios-users@lists.sourceforge.net">Nagios-users@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/nagios-users" target="_blank">https://lists.sourceforge.net/lists/listinfo/nagios-users</a><br>
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.<br>
::: Messages without supporting info will risk being sent to /dev/null<br>
</blockquote></div><br></div>