mirror of https://github.com/Icinga/icinga2.git
commit
fa0e1e66a2
|
@ -7,6 +7,7 @@
|
||||||
#cmakedefine HAVE_VFORK
|
#cmakedefine HAVE_VFORK
|
||||||
|
|
||||||
#define ICINGA_PREFIX "${CMAKE_INSTALL_PREFIX}"
|
#define ICINGA_PREFIX "${CMAKE_INSTALL_PREFIX}"
|
||||||
|
#define ICINGA_SYSCONFDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}"
|
||||||
#define ICINGA_LOCALSTATEDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}"
|
#define ICINGA_LOCALSTATEDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}"
|
||||||
#define ICINGA_PKGDATADIR "${CMAKE_INSTALL_FULL_DATADIR}/icinga2"
|
#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:
|
Icinga 2 provides a number of special global variables:
|
||||||
|
|
||||||
Variable |Description
|
Variable |Description
|
||||||
--------------------------|-------------------
|
--------------------------|-------------------
|
||||||
IcingaPrefixDir |**Read-only.** Contains the installation prefix that was specified with cmake -DCMAKE_INSTALL_PREFIX. Defaults to /usr/local
|
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".
|
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".
|
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".
|
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/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/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/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 "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\")")
|
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" {
|
object NotificationCommand "mail-service-notification" inherits "plugin-notification-command" {
|
||||||
command = [
|
command = [ (IcingaSysconfDir + "/icinga2/scripts/mail-notification.sh") ],
|
||||||
"/usr/bin/printf",
|
|
||||||
"\"%b\"",
|
|
||||||
{{{\"***** Icinga *****
|
|
||||||
|
|
||||||
Notification Type: $NOTIFICATIONTYPE$
|
export_macros = [
|
||||||
|
"NOTIFICATIONTYPE",
|
||||||
Service: $SERVICEDESC$
|
"SERVICEDESC",
|
||||||
Host: $HOSTALIAS$
|
"HOSTALIAS",
|
||||||
Address: $HOSTADDRESS$
|
"HOSTADDRESS",
|
||||||
State: $SERVICESTATE$
|
"SERVICESTATE",
|
||||||
|
"LONGDATETIME",
|
||||||
Date/Time: $LONGDATETIME$
|
"SERVICEOUTPUT",
|
||||||
|
"NOTIFICATIONAUTHORNAME",
|
||||||
Additional Info: $SERVICEOUTPUT$
|
"NOTIFICATIONCOMMENT",
|
||||||
|
"HOSTDISPLAYNAME",
|
||||||
Comment: [$NOTIFICATIONAUTHORNAME$] $NOTIFICATIONCOMMENT$\"}}},
|
"SERVICEDISPLAYNAME",
|
||||||
"/bin/mail",
|
"USEREMAIL"
|
||||||
"-s",
|
|
||||||
"\"$NOTIFICATIONTYPE$ - $HOSTDISPLAYNAME$ - $SERVICEDISPLAYNAME$ is $SERVICESTATE$\"",
|
|
||||||
"$USEREMAIL$"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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::InstallExceptionHandlers();
|
||||||
|
|
||||||
Application::DeclarePrefixDir(ICINGA_PREFIX);
|
Application::DeclarePrefixDir(ICINGA_PREFIX);
|
||||||
|
Application::DeclareSysconfDir(ICINGA_SYSCONFDIR);
|
||||||
Application::DeclareLocalStateDir(ICINGA_LOCALSTATEDIR);
|
Application::DeclareLocalStateDir(ICINGA_LOCALSTATEDIR);
|
||||||
Application::DeclarePkgDataDir(ICINGA_PKGDATADIR);
|
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}/conf.d
|
||||||
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
|
%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}/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}/%{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}/conf.d/*.conf
|
||||||
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.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}/features-enabled/*.conf
|
||||||
|
%config(noreplace) %{_sysconfdir}/%{name}/scripts/*
|
||||||
%{_sbindir}/%{name}
|
%{_sbindir}/%{name}
|
||||||
%{_bindir}/%{name}-migrate-config
|
%{_bindir}/%{name}-migrate-config
|
||||||
%{_bindir}/%{name}-build-ca
|
%{_bindir}/%{name}-build-ca
|
||||||
|
|
|
@ -609,6 +609,26 @@ void Application::DeclarePrefixDir(const String& path)
|
||||||
ScriptVariable::Declare("IcingaPrefixDir", 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.
|
* Retrieves the path for the local state dir.
|
||||||
*
|
*
|
||||||
|
|
|
@ -73,6 +73,9 @@ public:
|
||||||
static String GetPrefixDir(void);
|
static String GetPrefixDir(void);
|
||||||
static void DeclarePrefixDir(const String& path);
|
static void DeclarePrefixDir(const String& path);
|
||||||
|
|
||||||
|
static String GetSysconfDir(void);
|
||||||
|
static void DeclareSysconfDir(const String& path);
|
||||||
|
|
||||||
static String GetLocalStateDir(void);
|
static String GetLocalStateDir(void);
|
||||||
static void DeclareLocalStateDir(const String& path);
|
static void DeclareLocalStateDir(const String& path);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue