Modify an OmniOS service parameters
376 words, 2 minutes
I was today years old when I needed to change some of the parameters of my Prometheus service on OmniOS. It runs via pkgsrc and the provided SMF. And modifying the running parameters is not as simple as editing an rc.d file.
I first read the svcs - report service status man page but this was of no help for my need. Then I went for the svcadm - manipulate service instances man page and still didn’t know how to do the modifications. I finally found the svccfg - import, export and modify service configurations and started to saw the light.
I’m not very skilled with this OS and I didn’t understand the properties part. At least, how I was supposed to modify them. But I know how to use vi and can read/write XML files. So I mimicked Example 1 and 2: export the Service Description, modify the XML file and import the Service Description back.
# svcs -a | grep prometheus
online 23:36:23 svc:/pkgsrc/prometheus:default
# svccfg export -a pkgsrc/prometheus > /tmp/prometheus.xml
# sed -i -e 's|<method_credential group='nobody' user='nobody'/>|<method_credential group='prometheus' user='prometheus'/>|' /tmp/prometheus.xml
# svccfg import /tmp/prometheus.xml
Thanks to Joshua M. Clulow, I learned a smarter way of modifying the SMF
properties: using svccfg -s FMRI editprop
.
It will open a text editor with a bunch of commented out stuff which represents the current state of the service or service instance (FMRI of blah or blah:default). You can uncomment what you want, save and exit, and it will run the commands. Then you can “svcadm refresh” the service to get a new snapshot and restart it. You can also use svccfg as a captive shell to manipulate properties and such.
To modify the user and group used to run the service, I simply went:
# svccfg -s pkgsrc/prometheus editprop
select svc:/pkgsrc/prometheus
(...)
setprop method_context/group = astring: prometheus
setprop method_context/user = astring: prometheus
(...)
# svcadm refresh pkgsrc/prometheus
# svcadm restart pkgsrc/prometheus
# svcs -p prometheus
STATE STIME FMRI
online 23:52:29 svc:/pkgsrc/prometheus:default
23:52:29 23053 prometheus
When it comes to prometheus, this is also handy if you want to change
the --storage.tsdb.retention.time
or --storage.tsdb.retention.size
parameters as they are passed as a command argument. Look for and modify
the start/exec
property.
And that’s all for now. Another lesson learned.