<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<title>Re: [Nagiosplug-devel] loading environment variables to nagios</title>
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:8.5in 11.0in;
        margin:70.85pt 70.85pt 56.7pt 70.85pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Hi,<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>The user nagios loads the environment variable automatically
from /etc/profile . <o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>The plugin is executed on the nagios server and it connects to
the oracle directly on port 1512<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Can you give me example on how to execute the command if I add
the /.bashrc file in nagios home dir.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<div>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Viele Grüße,<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>ServiceDesk_TDN<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Ovidiu Marcu<o:p></o:p></span></p>

</div>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Matthew Litwin
[mailto:mlitwin@stubhub.com] <br>
<b>Sent:</b> Monday, March 02, 2009 8:08 PM<br>
<b>To:</b> Nagios Plugin Development Mailing List<br>
<b>Subject:</b> Re: [Nagiosplug-devel] loading environment variables to nagios<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:11.0pt;
font-family:"Calibri","sans-serif"'>The easiest solution would be to have your
nagios user load the profile of your Oracle user. On my system, both the oracle
and nagios user have bash for their shell, so I copy oracle’s .bashrc to
nagios’ home dir. If you are executing your commands via nrpe, you need
to precede each of your oracle plugin commands with . ~nagios/.bashrc; in order
for all those Oracle related environment variables to be properly set.<br>
<br>
Also, you might need to add the nagios user to whatever group your oracle user
account is in in order for the nagios user to be able to read Oracle’s
logs and files.<br>
<br>
<br>
On 3/2/09 3:31 AM, "Ovidiu Marcu" <<a href="Ovidiu.Marcu@tdn.de">Ovidiu.Marcu@tdn.de</a>>
wrote:</span><o:p></o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:11.0pt;
font-family:"Calibri","sans-serif"'>Hello,<br>
 <br>
Is there a way to load environment variables to nagios?<br>
 <br>
I have set up check_oracle_health in my nagios but it does not work:<br>
Nagios gives me the following message:<br>
CRITICAL - cannot connect to nagios. ORA-12154: TNS:could not resolve the
connect identifier specified (DBD ERROR: OCIServerAttach)<br>
Which means that nagios cannot find the environment variable TNS_ADMIN which I
have defined in /etc/profiles<br>
 <br>
If I try manually as user nagios I get:<br>
[nagios@nagios root]$ /usr/local/nagios/plugins/check_oracle_health
--connect=nagios --user=nagios --password=pass --mode=tnsping<br>
OK - connection established to nagios.<br>
 <br>
The TNS_ADMIN env seems to be ok:<br>
[nagios@nagios root]$ echo $TNS_ADMIN<br>
/usr/lib/oracle/11.1/client64/bin/network/admin<br>
<span style='color:#1F497D'><br>
</span><br>
Viele Grüße,<br>
 <br>
ServiceDesk_TDN<br>
Ovidiu Marcu<br>
 <o:p></o:p></span></p>

<div class=MsoNormal align=center style='text-align:center'><span
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>

<hr size=3 width="95%" align=center>

</span></div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>------------------------------------------------------------------------------<br>
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA<br>
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise<br>
-Strategies to boost innovation and cut costs with open source participation<br>
-Receive a $600 discount off the registration fee with the source code: SFAD<br>
<a href="http://p.sf.net/sfu/XcvMzF8H">http://p.sf.net/sfu/XcvMzF8H</a><o:p></o:p></span></p>

<div class=MsoNormal align=center style='text-align:center'><span
style='font-size:10.0pt;font-family:Consolas'>

<hr size=3 width="95%" align=center>

</span></div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>_______________________________________________________<br>
Nagios Plugin Development Mailing List <a
href="Nagiosplug-devel@lists.sourceforge.net">Nagiosplug-devel@lists.sourceforge.net</a><br>
Unsubscribe at <a
href="https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel">https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel</a><br>
::: Please include plugins version (-v) and OS when reporting any issue. <br>
::: Messages without supporting info will risk being sent to /dev/null</span><o:p></o:p></p>

</div>

</body>

</html>