-2

i have written a bash script. If I run this script manually on same server then its output is

CRITICAL:Something really bad is happening on server.CPU load of Process id: 11109
for user: root with command: java is 76.5

Then I configured its alert on nagios, and nagios is reading its output like

CRITICAL:Something really bad is happening on server.CPU load of Process id:
for user: with command: is

Means values are missing driven from file.

jww
  • 97,681
  • 90
  • 411
  • 885
  • 4
    Please show your code. Since Stack Overflow hides the Close reason from you: *Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve).* – jww Jan 11 '18 at 13:41

1 Answers1

0

That's most likely happening because generally Nagios uses a user "nagios" or "nrpe" to execute the script plugins and that user is not able to view all processes like root does or does not have the permission to read the file you are asking it to read. You should give the nrpe user permission to read via "sudo" to solve your issue. Please note that in order to run sudo with a user that does not log in(as the Nagios user), you also nees to commebt out the Require tty parameter from /etc/sudoers file.

AnythingIsFine
  • 1,777
  • 13
  • 11
  • I am already running it with root user from nagios. Also another point, I am also getting response code as '(No output returned from plugin) ' . I hope it can help us. – Virender Punia Jan 12 '18 at 05:23
  • Let me re-iterate, on your central Nagios server you can issue the command as root, but on the nagios monitored node server on which the command will be executed via NRPE with the user you have set up in your "/etc/nagos/nrpe.cfg" (default path) config file. That user most likely does not have permissions. Please share you nrpe.cfg config file. – AnythingIsFine Jan 12 '18 at 10:26
  • Sir, Can we have discussion over mail or call plz ? – Virender Punia Jan 14 '18 at 11:58
  • Sorry, i can.t do that. The simplest thing that comes to mind is to add the folowing line in your sudoers file " ALL=(ALL) NOPASSWD: /cmd/from/nagios/script/path" and comment out the "Require tty" entry from sudoers as well. Then, edit the nagios script you wrote and add "sudo" to the command you entered above in sudoers, that should do it. – AnythingIsFine Jan 14 '18 at 14:26
  • I have tried same also , but getting same error. Any other case we can do – Virender Punia Jan 17 '18 at 07:53
  • Please share your sudoers, nrpe.cfg from the server you wish to run it on and the script you wrote, then I can tell you precisely what needs to be done. – AnythingIsFine Jan 17 '18 at 08:05