mirror of
				https://github.com/Icinga/icinga2.git
				synced 2025-10-31 11:14:10 +01:00 
			
		
		
		
	
						commit
						fa0e1e66a2
					
				| @ -7,6 +7,7 @@ | ||||
| #cmakedefine HAVE_VFORK | ||||
| 
 | ||||
| #define ICINGA_PREFIX "${CMAKE_INSTALL_PREFIX}" | ||||
| #define ICINGA_SYSCONFDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}" | ||||
| #define ICINGA_LOCALSTATEDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}" | ||||
| #define ICINGA_PKGDATADIR "${CMAKE_INSTALL_FULL_DATADIR}/icinga2" | ||||
| 
 | ||||
|  | ||||
| @ -1,10 +1,11 @@ | ||||
| ## <a id="global-variables"> Global Variables | ||||
| ## <a id="global-variables"></a> Global Variables | ||||
| 
 | ||||
| Icinga 2 provides a number of special global variables: | ||||
| 
 | ||||
| Variable                  |Description | ||||
| --------------------------|------------------- | ||||
| IcingaPrefixDir           |**Read-only.** Contains the installation prefix that was specified with cmake -DCMAKE_INSTALL_PREFIX. Defaults to /usr/local | ||||
| IcingaSysconfDir          |**Read-only.** Contains the path of the sysconf directory. Defaults to IcingaPrefixDir + "/etc". | ||||
| IcingaLocalStateDir       |**Read-only.** Contains the path of the local state directory. Defaults to IcingaPrefixDir + "/var". | ||||
| IcingaPkgDataDir          |**Read-only.** Contains the path of the package data directory. Defaults to IcingaPrefixDir + "/share/icinga2". | ||||
| IcingaStatePath           |**Read-write.** Contains the path of the Icinga 2 state file. Defaults to IcingaLocalStateDir + "/lib/icinga2/icinga2.state". | ||||
|  | ||||
| @ -41,6 +41,7 @@ install_if_not_exists(icinga2/features-available/notification.conf ${CMAKE_INSTA | ||||
| install_if_not_exists(icinga2/features-available/perfdata.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) | ||||
| install_if_not_exists(icinga2/features-available/statusdata.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) | ||||
| install_if_not_exists(icinga2/features-available/syslog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available) | ||||
| install_if_not_exists(icinga2/scripts/mail-notification.sh ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/scripts) | ||||
| 
 | ||||
| install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled\")") | ||||
| install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/checker.conf \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled/checker.conf\")") | ||||
|  | ||||
| @ -22,27 +22,21 @@ template Notification "mail-notification" { | ||||
| } | ||||
| 
 | ||||
| object NotificationCommand "mail-service-notification" inherits "plugin-notification-command" { | ||||
|   command = [ | ||||
|     "/usr/bin/printf", | ||||
|     "\"%b\"", | ||||
|     {{{\"***** Icinga  ***** | ||||
|   command = [ (IcingaSysconfDir + "/icinga2/scripts/mail-notification.sh") ], | ||||
| 
 | ||||
|     Notification Type: $NOTIFICATIONTYPE$ | ||||
| 
 | ||||
|     Service: $SERVICEDESC$ | ||||
|     Host: $HOSTALIAS$ | ||||
|     Address: $HOSTADDRESS$ | ||||
|     State: $SERVICESTATE$ | ||||
| 
 | ||||
|     Date/Time: $LONGDATETIME$ | ||||
| 
 | ||||
|     Additional Info: $SERVICEOUTPUT$ | ||||
| 
 | ||||
|     Comment: [$NOTIFICATIONAUTHORNAME$] $NOTIFICATIONCOMMENT$\"}}}, | ||||
|     "/bin/mail", | ||||
|     "-s", | ||||
|     "\"$NOTIFICATIONTYPE$ - $HOSTDISPLAYNAME$ - $SERVICEDISPLAYNAME$ is $SERVICESTATE$\"", | ||||
|     "$USEREMAIL$" | ||||
|   export_macros = [ | ||||
|     "NOTIFICATIONTYPE", | ||||
|     "SERVICEDESC", | ||||
|     "HOSTALIAS", | ||||
|     "HOSTADDRESS", | ||||
|     "SERVICESTATE", | ||||
|     "LONGDATETIME", | ||||
|     "SERVICEOUTPUT", | ||||
|     "NOTIFICATIONAUTHORNAME", | ||||
|     "NOTIFICATIONCOMMENT", | ||||
|     "HOSTDISPLAYNAME", | ||||
|     "SERVICEDISPLAYNAME", | ||||
|     "USEREMAIL" | ||||
|   ] | ||||
| } | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										20
									
								
								etc/icinga2/scripts/mail-notification.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										20
									
								
								etc/icinga2/scripts/mail-notification.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,20 @@ | ||||
| #!/usr/bin/env bash | ||||
| template=$(cat <<TEMPLATE | ||||
| ***** Icinga  ***** | ||||
| 
 | ||||
| Notification Type: $NOTIFICATIONTYPE | ||||
| 
 | ||||
| Service: $SERVICEDESC | ||||
| Host: $HOSTALIAS | ||||
| Address: $HOSTADDRESS | ||||
| State: $SERVICESTATE | ||||
| 
 | ||||
| Date/Time: $LONGDATETIME | ||||
| 
 | ||||
| Additional Info: $SERVICEOUTPUT | ||||
| 
 | ||||
| Comment: [$NOTIFICATIONAUTHORNAME] $NOTIFICATIONCOMMENT | ||||
| TEMPLATE) | ||||
| 
 | ||||
| /usr/bin/printf "%b" $template | mail -s "$NOTIFICATIONTYPE - $HOSTDISPLAYNAME - $SERVICEDISPLAYNAME is $SERVICESTATE" $USEREMAIL | ||||
| 
 | ||||
| @ -198,6 +198,7 @@ int main(int argc, char **argv) | ||||
| 	Application::InstallExceptionHandlers(); | ||||
| 
 | ||||
| 	Application::DeclarePrefixDir(ICINGA_PREFIX); | ||||
| 	Application::DeclareSysconfDir(ICINGA_SYSCONFDIR); | ||||
| 	Application::DeclareLocalStateDir(ICINGA_LOCALSTATEDIR); | ||||
| 	Application::DeclarePkgDataDir(ICINGA_PKGDATADIR); | ||||
| 
 | ||||
|  | ||||
| @ -315,10 +315,12 @@ exit 0 | ||||
| %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d | ||||
| %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available | ||||
| %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled | ||||
| %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/scripts | ||||
| %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf | ||||
| %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf | ||||
| %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf | ||||
| %config(noreplace) %{_sysconfdir}/%{name}/features-enabled/*.conf | ||||
| %config(noreplace) %{_sysconfdir}/%{name}/scripts/* | ||||
| %{_sbindir}/%{name} | ||||
| %{_bindir}/%{name}-migrate-config | ||||
| %{_bindir}/%{name}-build-ca | ||||
|  | ||||
| @ -609,6 +609,26 @@ void Application::DeclarePrefixDir(const String& path) | ||||
| 	ScriptVariable::Declare("IcingaPrefixDir", path); | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|  * Retrives the path of the sysconf dir. | ||||
|  * | ||||
|  * @returns The path. | ||||
|  */ | ||||
| String Application::GetSysconfDir(void) | ||||
| { | ||||
| 	return ScriptVariable::Get("IcingaSysconfDir"); | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|  * Sets the path of the sysconf dir. | ||||
|  * | ||||
|  * @param path The new path. | ||||
|  */ | ||||
| void Application::DeclareSysconfDir(const String& path) | ||||
| { | ||||
| 	ScriptVariable::Declare("IcingaSysconfDir", path); | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|  * Retrieves the path for the local state dir. | ||||
|  * | ||||
|  | ||||
| @ -73,6 +73,9 @@ public: | ||||
| 	static String GetPrefixDir(void); | ||||
| 	static void DeclarePrefixDir(const String& path); | ||||
| 
 | ||||
| 	static String GetSysconfDir(void); | ||||
| 	static void DeclareSysconfDir(const String& path); | ||||
| 
 | ||||
| 	static String GetLocalStateDir(void); | ||||
| 	static void DeclareLocalStateDir(const String& path); | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user