parent
ca5ff418f9
commit
dc9365eba4
|
@ -1,4 +1,4 @@
|
||||||
FROM debian:12 as prepare
|
FROM debian:12
|
||||||
RUN apt-get update && apt-get upgrade -y
|
RUN apt-get update && apt-get upgrade -y
|
||||||
RUN apt-get install -y php-dev php-cli php-pear php-mbstring php-curl git build-essential libmosquitto-dev libmosquitto-dev php-sqlite3
|
RUN apt-get install -y php-dev php-cli php-pear php-mbstring php-curl git build-essential libmosquitto-dev libmosquitto-dev php-sqlite3
|
||||||
WORKDIR /tmp
|
WORKDIR /tmp
|
||||||
|
@ -11,12 +11,4 @@ RUN make install
|
||||||
RUN echo "extension=mosquitto.so" > /etc/php/8.2/cli/php.ini
|
RUN echo "extension=mosquitto.so" > /etc/php/8.2/cli/php.ini
|
||||||
ADD run /usr/local/bin/entrypoint
|
ADD run /usr/local/bin/entrypoint
|
||||||
RUN chmod +x /usr/local/bin/entrypoint
|
RUN chmod +x /usr/local/bin/entrypoint
|
||||||
FROM prepare as make_git_id
|
|
||||||
WORKDIR /tmp/repo
|
|
||||||
ADD .git /tmp/repo/.git
|
|
||||||
RUN git rev-parse HEAD > /tmp/git_id
|
|
||||||
FROM prepare as runner
|
|
||||||
ENV GIT_ID=unknown
|
|
||||||
COPY --from=make_git_id /tmp/git_id /var/lib/git_id
|
|
||||||
|
|
||||||
CMD ["/usr/local/bin/entrypoint"]
|
CMD ["/usr/local/bin/entrypoint"]
|
||||||
|
|
|
@ -14,16 +14,13 @@ pcntl_signal(SIGTERM, "endit");
|
||||||
pcntl_signal(SIGHUP, "endit");
|
pcntl_signal(SIGHUP, "endit");
|
||||||
|
|
||||||
$mqttPort = getEnvWithDefaultInt("MQTT_PORT", 1883);
|
$mqttPort = getEnvWithDefaultInt("MQTT_PORT", 1883);
|
||||||
|
|
||||||
$mqttUser = getEnvWithDefaultStr("MQTT_USER", "");
|
$mqttUser = getEnvWithDefaultStr("MQTT_USER", "");
|
||||||
$mqttPass = getEnvWithDefaultStr("MQTT_PASS", "");
|
$mqttPass = getEnvWithDefaultStr("MQTT_PASS", "");
|
||||||
$mqttClientId = getEnvWithDefaultStr("MQTT_CLIENT_ID", "mqtt2prometheus");
|
$mqttClientId = getEnvWithDefaultStr("MQTT_CLIENT_ID", "mqtt2prometheus");
|
||||||
$mqttTopic = getEnvWithDefaultStr("MQTT_TOPIC", "prometheus");
|
$mqttTopic = getEnvWithDefaultStr("MQTT_TOPIC", "prometheus");
|
||||||
$qos = getEnvWithDefaultInt("MQTT_QOS", 2);
|
$qos = getEnvWithDefaultInt("MQTT_QOS", 2);
|
||||||
$ignoreRetained = getEnvWithDefaultInt("IGNORE_RETAINED", 1) ? 1 : 0;
|
$ignoreRetained = getEnvWithDefaultInt("IGNORE_RETAINED", 1) ? 1 : 0;
|
||||||
$gitId="Unknown";
|
|
||||||
if (is_file("/var/lib/git_id")) {
|
|
||||||
$gitId = trim(file_get_contents("/var/lib/git_id"));
|
|
||||||
}
|
|
||||||
|
|
||||||
$mqtt = new Mosquitto\Client($mqttClientId);
|
$mqtt = new Mosquitto\Client($mqttClientId);
|
||||||
|
|
||||||
|
@ -188,11 +185,10 @@ function precheck(Message $message): bool
|
||||||
function output(): void
|
function output(): void
|
||||||
{
|
{
|
||||||
filter();
|
filter();
|
||||||
global $data, $stats, $globalCounter,$gitId;
|
global $data, $stats, $globalCounter;
|
||||||
$t = time();
|
$t = time();
|
||||||
|
|
||||||
$prom = "";
|
$prom = "";
|
||||||
$prom .= "# from git-id : $gitId\n";
|
|
||||||
$prom .=
|
$prom .=
|
||||||
"# service started at : " .
|
"# service started at : " .
|
||||||
STARTED .
|
STARTED .
|
||||||
|
|
Loading…
Reference in New Issue