Tereus Scott
Tereus Scott

Reputation: 682

embedded linux startup and integrity monitor

Perhaps this is not a programming question, ie. there is a non-programming solution. I am working on a first generation product using embedded linux. I am struggling with the best solution for system startup, shutdown and integrity monitoring. Currently there is a home-brew solution which is a single convoluted piece of c-code that starts up the other processes and then monitors their health as well as several other unrelated functions. Does anyone have advice on a simple, and robust way to take care of startup, shutdown and integrity monitoring of the embedded device? The distro does not really matter, it is using busybox and I can add anything else we need. I am looking for tips/words of wisdom - or rtfm and some pointers, or point me somewhere else.

Thx.

Upvotes: 1

Views: 1574

Answers (2)

Ben
Ben

Reputation: 1359

If you're looking for a process monitor to replace your in-house version I've used PCD - Process Control Daemon with great success.

Upvotes: 1

sawdust
sawdust

Reputation: 17067

I am struggling with the best solution for system startup,

You have not provided any criteria for deciding what is "best".

... a simple, and robust way to take care of startup, shutdown and integrity monitoring of the embedded device?

If "simple" and "best" are your criteria, then what you are looking for is already integral to the Linux OS. It uses the concept of runlevels. On start up, a runlevel is established, and a set of processes can be started. Any change to another runlevel will stop a set of processes and start a set of processes. On shutdown, which is another runlevel, all processes are terminated.

I don't know what you mean by "integrity monitoring". If a system process terminates, then it can be "respawned" if it is so designated. The proc pseudo-filesystem can be used to monitor active processes. You will probably have design & implement your own concept of integrity monitoring.

BusyBox has simplified the standard (aka SysV) init process, presumably on the assumption that embedded processes run once or always after startup. Either cron or a custom daemon would have to provide process startup on events. But you argue that:

It does not have a concept of run levels.
So we are not able to use the same startup mechanisms as a full-featured OS.

Not quite. BusyBox declares:

BusyBox init doesn't support multiple runlevels. The runlevels field of the /etc/inittab file is completely ignored by BusyBox init.

Note the the word "multiple". BusyBox's init will perform process control for the runlevels equivalent to startup, shutdown and reboot. Interestingly, BusyBox even has a runlevel command! If you want more "runlevels" than BusyBox offers, then

If you want runlevels, use sysvinit.

SysV init source code is available from here. BusyBox is fully configurable, and its version of init can easily be replaced.

A mini version of SysV init is released under the GPL by Axis Communications for their Etrax SoC. The Axis /etc/inittab is:`

# The runlevels used by axis are:
#   0 - Halt
#   1 - Single user mode
#   2 - Multiuser without network
#   3 - Full multiuser mode
#   4 - Upgrade
#   5 - unused
#   6 - Reboot

id:3:initdefault:

sh:1235:respawn:/bin/cttyhack /bin/sh

tnet:35:once:/usr/sbin/telnetd

# System initialization.
si::sysinit:/etc/init.d/rc sysinit

# The initscripts.
l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6

# Add your own stuff below

The current source is in devboard-R2_20-distfiles.tar.gz, which includes version 1.3.6 of init.c and initscript packages, and requires registration at the Axis site.

Upvotes: 1

Related Questions