Skip to content

Commit

Permalink
add service config files for Linux and Solaris
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens Elkner committed Jan 25, 2022
1 parent 9104419 commit 753ae36
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 0 deletions.
18 changes: 18 additions & 0 deletions etc/ipmimex.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# file: /etc/default/ipmimex

# Any options to pass verbatim to the exporter. See 'ipmimex -h'.
ARGS="-c "

# For buggy DELLs:
#ARGS="-c D"

# For SUN ILOMs:
#ARGS="-c N"

# Compact as possible. Readings, only:
#ARGS="-c PoDNUT"

# Just Power now and overall scrapetime:
#ARGS='-c -n version,ipmi,process -PS'

# Check operational state e.g. via http://localhost:9290/metrics
103 changes: 103 additions & 0 deletions etc/ipmimex.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
file: /lib/svc/manifest/system/ipmimex.xml
Run 'svcadm restart manifest-import' to activate if you copied the file
to this location manually (i.e. not installed as part of a package).
Copyright 2022 Jens Elkner.
-->

<service_bundle type='manifest' name='LNFipmimex'>

<service name='system/ipmimex' type='service' version='1'>

<create_default_instance enabled="false" />

<single_instance />

<!-- Wait for network interfaces to be initialized so we can bind. -->
<dependency name='network' grouping='require_all' restart_on='refresh'
type='service'>
<service_fmri value='svc:/milestone/network:default'/>
</dependency>

<!-- Wait for all local filesystems to be mounted. -->
<dependency name='filesystem-local' grouping='require_all' restart_on='none'
type='service'>
<service_fmri value='svc:/system/filesystem/local:default'/>
</dependency>

<!-- Start ipmimex before vmagent -->
<dependent name='vmagent' grouping='optional_all' restart_on='none'>
<service_fmri value='svc:/application/database/vmagent'/>
</dependent>

<exec_method type='method' name='start'
exec='/usr/sbin/ipmimex %{config/start_args} -d -l %{config/logfile} -p %{config/port}'
timeout_seconds='10'>
<method_context>
<!-- Who knows, why one needs sysconfig privs to be able to
query dcmi states. Someone had probably a bad day ....
user='webservd' group='webservd' should be ok, too.
-->
<method_credential user='daemon' group='daemon'
privileges='basic,sys_config,!proc_session,!proc_info,!file_link_any,{zone}:/var/log/ipmimex.log' />
</method_context>
</exec_method>

<exec_method timeout_seconds='5' type='method' name='stop'
exec=':kill -TERM' />

<property_group name='config' type='application'>
<stability value='Evolving' />
<!-- Check operational state e.g. via http://localhost:9290/metrics -->
<propval name='port' type='integer' value='9290' />
<propval name='logfile' type='astring' value='/var/log/ipmimex.log' />
<!-- Any options to pass verbatim to the agent. E.g. just power reading
and overall scrapetime use '-c -n version,ipmi,process -PS' or for
compact as possible, readings, only: '-c PoDNUT'
-->
<property name="start_args" type="astring">
<astring_list>
<value_node value='-c' />
<value_node value='-N' /><!-- fix for SUN ILOMs -->
</astring_list>
</property>
</property_group>

<property_group name='startd' type='framework'>
<!-- service mode is contract -->
<propval name='duration' type='astring' value='contract' />
<!-- sub-process core dumps shouldn't restart session -->
<propval name='ignore_error' type='astring' value='core,signal' />
</property_group>

<!--
Add all users, which should be able to manage this service
into /etc/user_attr . E.g.:
echo 'jdoe::::auths=solaris.smf.manage.ipmimex' >>/etc/user_attr
-->
<property_group name='general' type='framework'>
<propval name='action_authorization' type='astring'
value='solaris.smf.manage.ipmimex' />
<propval name='value_authorization' type='astring'
value='solaris.smf.manage.ipmimex' />
</property_group>

<stability value='Evolving' />

<template>
<common_name>
<loctext xml:lang='C'>
ipmiex - a metrics exporter for IPMI driven BMCs.
</loctext>
</common_name>
<documentation>
<manpage title='ipmimex' section='8' manpath='/usr/share/man' />
<doc_link name='github' uri='https://github.com/jelmd/ipmimex' />
</documentation>
</template>
</service>

</service_bundle>
35 changes: 35 additions & 0 deletions etc/ipmimex.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# file: /lib/systemd/system/ipmimex.service

[Unit]
Description=Metrics exporter for IPMI driven BMCs
Documentation=man:ipmimex(8)
After=network.target auditd.service
Before=vmagent.service

[Service]
Type=forking
User=daemon
Group=daemon
# The 'control-group' mode is absolutely unreliable at least on ubuntu 20.04.
# So e.g. on start timeout spawned threads would not be killed and restart
# would fail because the address/port is already in use.
KillMode=mixed

EnvironmentFile=-/etc/default/ipmimex
LogsDirectory=ipmimex

Restart=always
RestartSec=1
RestartPreventExitStatus=1 95 96 97 98 99 100 101 102
# This allows us to run ipmimex as unprivileged service. One could accomplish
# the same thing using a propper udev rule.
ExecStartPre=+-/bin/chown daemon /dev/ipmi0
ExecStart=/usr/sbin/ipmimex -l %L/ipmimex/out.log -d $ARGS
ExecStop=/bin/kill -s SIGTERM $MAINPID
TimeoutSec=10

MemoryLow=2M
MemoryMin=1M

[Install]
WantedBy=multi-user.target

0 comments on commit 753ae36

Please sign in to comment.