Results 1 to 3 of 3
Hi,
I am using system() call in c program as a plugin for nagios, to get details from weblogic server MBean as follows
system"(java snmpwlk -v v1 public@medrec 127.0.0.1 .1.3.6.4.1.730.625 ...
- 03-13-2008 #1Just Joined!
- Join Date
- Feb 2008
- Posts
- 8
problem regarding system() call using c in Nagios
Hi,
I am using system() call in c program as a plugin for nagios, to get details from weblogic server MBean as follows
system"(java snmpwlk -v v1 public@medrec 127.0.0.1 .1.3.6.4.1.730.625 > /usr/local/nagios/libexec/output")
It executed and created output file.But output file have no data.
please guide me..
- 03-13-2008 #2Just Joined!
- Join Date
- Feb 2008
- Posts
- 50
Try with this, it will redirect all...
system"(java snmpwlk -v v1 public@medrec 127.0.0.1 .1.3.6.4.1.730.625 &> /usr/local/nagios/libexec/output")
- 03-14-2008 #3Just Joined!
- Join Date
- Feb 2008
- Posts
- 8
Hi,
Thanks for ur reply. I tried that using &> symbols in the java snmpwalk command.
I used the putenv() function to set the environment variables. After that I call the java snmpwalk utility as follows:
system("java snmpget -v v1 -c public@medrec -p 161 127.0.0.1 .1.3.6.1.4.1.140.625.730.1.45.32.99.98.97.57.53.49 .97.52.57.98.101.101.97.51.97.102.99.99.48.48.101. 100.97.56.101.97.101.49.97.102.101.56 &> /usr/local/nagios/libexec/output");
As for reference I have attatched my code here:
#include "stdio.h"
int main()
{
FILE * fin;
char * temp,*ptr,c;
char value[1000];
int i=0;
putenv("CLASSPATH=/root/bea9.0/patch_weblogic901/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/root/bea9.0/jrockit90_150_03/lib/tools.jar:/root/bea9.0/weblogic90/server/lib/weblogic_sp.jar:/root/bea9.0/weblogic90/server/lib/weblogic.jar");
putenv("PATH=/root/bea9.0/weblogic90/server/bin:/root/bea9.0/jrockit90_150_03/jre/bin:/root/bea9.0/jrockit90_150_03/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin");
putenv("export PATH CLASSPATH");
system("java snmpget -v v1 -c public@medrec -p 161 127.0.0.1 .1.3.6.1.4.1.140.625.730.1.45.32.99.98.97.57.53.49 .97.52.57.98.101.101.97.51.97.102.99.99.48.48.101. 100.97.56.101.97.101.49.97.102.101.56 &> /usr/local/nagios/libexec/output");
fin=fopen("/usr/local/nagios/libexec/output.txt","r");
value[i]=fgetc(fin);
while(value[i]!=EOF)
{
// printf("%c",value[i]);
i++;
value[i]=fgetc(fin);
}
close(fin);
i=0;
printf("welcome");
while(i<9)
{
printf("%c",value[i]);
i++;
}
system("rm output --force");
return(1);
}
WHile I'm running it independently it returns the desired results. But after adding it to nagios, it doesn't return the results. It just creates a "output" file as empty file. That file doen't have any data. I give the executable permission for that file to nagios. I'm also defined in commands.cfg and services..cfg.
While starting Nagios, It creates a empty file in the name "output". The nagios doesn't write any value to that file. Please help us to return the results to the "output" file through Nagios.


Reply With Quote