Nagios kann einige Programme nicht ausführen

G

Gast123

Hallo Leute,

ich würde Nagios gerne via
Code:
/bin/systemctl status <service>
die Status einiger Systemdienste überwachen lassen. Leider spuckt Nagios folgende Fehlermeldung ins Log:
Code:
Warning: Return code of 126 for check of service 'Minecraft Server' on host 'hpsrv' was out of bounds.Make sure the plugin you're trying to run is executable.
Wenn ich in der entsprechenden Konfigurationsdatei
Code:
/bin/systemctl status minecraft.service
durch
Code:
/bin/echo helloworld
ersetzte, funktionierts.
Die Dateirechte der beiden Programme sind ebenfalls identisch:
Code:
[root@hpsrv bin]# ls -alF | grep systemctl
-rwxr-xr-x.  1 root root  165632 20. Jun 10:10 systemctl*
[root@hpsrv bin]# ls -alF | grep echo
-rwxr-xr-x.  1 root root   26180  8. Feb 12:46 echo*
[root@hpsrv bin]#
Wenn ich den Nagios user das Programm manuell ausführen lasse klappt es auch:
Code:
[root@hpsrv bin]# su - nagios -c "/bin/systemctl status minecraft.service" -s /bin/bash
minecraft.service - Minecraft Server
	  Loaded: loaded (/etc/systemd/system/minecraft.service)
	  Active: active (exited) since Thu, 07 Jul 2011 15:00:25 +0200; 34min ago
	 Process: 6403 ExecStart=/home/minecraft/bin/minecraftd (code=exited, status=0/SUCCESS)
	  CGroup: name=systemd:/system/minecraft.service
		  ├  6405 /bin/bash /home/minecraft/bin/mineparsed
		  ├  6407 /usr/bin/SCREEN -S minecraft -d -m /usr/bin/java -Xincgc -Xmx1G -jar craftbukkit-0.0.1-SNAPSHOT.jar
		  ├  6409 /usr/bin/java -Xincgc -Xmx1G -jar craftbukkit-0.0.1-SNAPSHOT.jar
		  └ 15654 sleep 0.5
[root@hpsrv bin]#

Also wie bekomme ich nagios dazu, /bin/systemctl auszuführen.

Danke Euch

MfG
Schard
 
Nagios erwartet bestimmte Exit-Codes von seinen Checks (0 = OK, 1 = Warning, 2 = CRITICAL, 3 = UNKNOWN). Wenn das Programm nicht diese Exit-Codes liefert, wirst du es wohl in einem Skript aufrufen müssen, das dann die Exit-Codes des Programms verarbeitet und je nach Exit-Code einen für Nagios verständlichen Exit-Code zurückgibt.
 
Hey,

der Exit Code ist korrekt:
Code:
[root@hpsrv bin]# su - nagios -c "/bin/systemctl status minecraft.service; echo $?" -s /bin/bash
minecraft.service - Minecraft Server
	  Loaded: loaded (/etc/systemd/system/minecraft.service)
	  Active: active (exited) since Thu, 07 Jul 2011 16:00:26 +0200; 4min 41s ago
	 Process: 21648 ExecStart=/home/minecraft/bin/minecraftd (code=exited, status=0/SUCCESS)
	  CGroup: name=systemd:/system/minecraft.service
		  ├ 21650 /bin/bash /home/minecraft/bin/mineparsed
		  ├ 21652 /usr/bin/SCREEN -S minecraft -d -m /usr/bin/java -Xincgc -Xmx1G -jar craftbukkit-0.0.1-SNAPSHOT.jar
		  ├ 21654 /usr/bin/java -Xincgc -Xmx1G -jar craftbukkit-0.0.1-SNAPSHOT.jar
		  └ 22887 sleep 0.5
0
[root@hpsrv bin]#
 
Code:
[b]Return code of 126[/b] for check of service 'Minecraft Server' on host 'hpsrv' was out of bounds.

Sieht mir aber nicht danach aus.
 
Hi Schard!

Zeige mal bitte den dazugehörigen Bereich in deiner commands.cfg und services.cfg.
 
Hallo Remidemi,

hier der Ausschnitt aus meiner commands.cfg:
Code:
#
# Custom Commands
#

# Check status of system service
define command{
	command_name	check-system-service
	command_line	/bin/systemctl status minecraft.service 
	#command_line	/bin/echo helloworld
	}

und meine localhost.cfg:
Code:
# Define a service to check the Minecraft server on the local machine.
# Disable notifications for this service by default.

define service{
        use                             local-service         ; Name of service template to use
        host_name                       hpsrv
        service_description             Minecraft Server
	#check_command			check-system-service!"minecraft.service"
	check_command			check-system-service
	notifications_enabled		0
        }

Ich frage mich wirklich, warum Nagios behauptet einen anderen exit code zu bekommen, wenn es als daemon läuft, als wenn ich es per su ausführe. Das macht doch keinen Sinn.

MfG
 
Hi,

ich nehme an, du hast SELinux im Enforcing Mode am Laufen; prüf doch mal das Logfile "/var/log/audit/audit.log", oder versuch, ob der Check läuft, wenn du auf Permissive Mode umschaltest ("setenforce 0"). Sieht für mich so aus, als ob der Daemon in einem anderen SELinux-Context läuft als die interaktive (su-) Shell.

Gruss, A.
 
Hallo floyd62

Wenn ich setenforce auf 0 setzte funktionierts.
Liegt wohl echt an SELinux. So ein Mist.
Also wieder mal eine Policy basteln.

MfG
 

Ähnliche Themen

Apache HTTP Server startet nicht

Autostart von X mit google-chrome durch systemd

CentOS 7 keine Netzwerkgeräte verfügbar

Kein Internet mehr

Fedora: selinux Berichtungsproblem mit Apache

Zurück
Oben