Install phosphor-fan-monitor app and service

Resolves openbmc/openbmc#1346

Change-Id: I9abac19b18b02158ff4fdae6e94406b64957cefb
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/common/recipes-phosphor/fans/phosphor-fan.bb b/common/recipes-phosphor/fans/phosphor-fan.bb
index 736149c..19eb4db 100644
--- a/common/recipes-phosphor/fans/phosphor-fan.bb
+++ b/common/recipes-phosphor/fans/phosphor-fan.bb
@@ -22,11 +22,12 @@
 FAN_PACKAGES = " \
         ${PN}-presence-tach \
         ${PN}-control \
+        ${PN}-monitor \
         phosphor-chassis-cooling-type \
 "
 PACKAGES_remove = "${PN}"
 PACKAGES += "${FAN_PACKAGES}"
-PACKAGECONFIG ??= "presence control cooling-type"
+PACKAGECONFIG ??= "presence control cooling-type monitor"
 SYSTEMD_PACKAGES = "${FAN_PACKAGES}"
 RDEPENDS_${PN}-dev = "${FAN_PACKAGES}"
 RDEPENDS_${PN}-staticdev = "${FAN_PACKAGES}"
@@ -79,3 +80,23 @@
 PACKAGECONFIG[cooling-type] = "--enable-cooling-type,--disable-cooling-type,libevdev,"
 RDEPENDS_phosphor-chassis-cooling-type += "libevdev"
 FILES_phosphor-chassis-cooling-type = "${sbindir}/phosphor-cooling-type"
+
+# --------------------------------------
+# ${PN}-monitor specific configuration
+PACKAGECONFIG[monitor] = "--enable-monitor \
+     FAN_MONITOR_YAML_FILE=${STAGING_DIR_NATIVE}${monitor_datadir}/monitor.yaml \
+     FAN_MONITOR_OUTPUT_DIR=${S}/monitor, \
+    --disable-monitor, \
+    phosphor-fan-monitor-config-native \
+    , \
+"
+
+RDEPENDS_${PN}-monitor += "sdbusplus"
+
+TMPL_MONITOR = "phosphor-fan-monitor@.service"
+INSTFMT_MONITOR = "phosphor-fan-monitor@{0}.service"
+FMT_MONITOR = "../${TMPL_MONITOR}:${TGTFMT}.requires/${INSTFMT_MONITOR}"
+
+FILES_${PN}-monitor = "${sbindir}/phosphor-fan-monitor"
+SYSTEMD_SERVICE_${PN}-monitor += "${TMPL_MONITOR}"
+SYSTEMD_LINK_${PN}-monitor += "${@compose_list(d, 'FMT_MONITOR', 'OBMC_CHASSIS_INSTANCES')}"
diff --git a/common/recipes-phosphor/fans/phosphor-fan.inc b/common/recipes-phosphor/fans/phosphor-fan.inc
index 7a583ab..193aab7 100644
--- a/common/recipes-phosphor/fans/phosphor-fan.inc
+++ b/common/recipes-phosphor/fans/phosphor-fan.inc
@@ -2,4 +2,4 @@
 LICENSE = "Apache-2.0"
 LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"
 SRC_URI += "git://github.com/openbmc/phosphor-fan-presence"
-SRCREV = "77d32d1b0b780b9ac773bc49a6c74c19508ff8e8"
+SRCREV = "e824f985e7e32923d9f76e3ad5baf4909880739f"
diff --git a/common/recipes-phosphor/fans/phosphor-fan/phosphor-fan-monitor@.service b/common/recipes-phosphor/fans/phosphor-fan/phosphor-fan-monitor@.service
new file mode 100644
index 0000000..57b01c7
--- /dev/null
+++ b/common/recipes-phosphor/fans/phosphor-fan/phosphor-fan-monitor@.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Phosphor Fan Monitor Daemon
+Wants=obmc-power-on@%i.target
+After=obmc-power-on@%i.target
+Conflicts=obmc-chassis-poweroff@%i.target
+
+[Service]
+Restart=on-failure
+ExecStart={sbindir}/phosphor-fan-monitor
+
+[Install]
+RequiredBy=obmc-chassis-poweron@%i.target
diff --git a/common/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bb b/common/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bb
index 1bdb0f4..c1f531f 100644
--- a/common/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bb
+++ b/common/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bb
@@ -53,6 +53,7 @@
 SUMMARY_${PN}-fan-control = "Fan control"
 RDEPENDS_${PN}-fan-control = " \
         ${VIRTUAL-RUNTIME_obmc-fan-control} \
+        phosphor-fan-monitor \
         "
 
 SUMMARY_${PN}-host-state-mgmt = "Host state management"