#!/bin/sh
# Writing procmeter fifo programs can be simple. Here's one that
# just displays how many users are logged in.
#
# Copyright GPL Joey Hess & Andrew Bishop 1997
#
# This program is rather inefficient since it uses shell script
# Procmeter will only read the output when needed, so deselecting
# it in procmeter will stop it from running.
#

# You need to start this program using the start-procmeter.sh script.
# For example use start-procmeter.sh users.sh

defn=$1.def
fifo=$1.dat

# Set up the definition file and the fifo.

echo "users users 1" > $defn
mkfifo $fifo 2>/dev/null

# Get the information and write it to the file

while (true) do

    # Replace this line with any command that outputs a line with 
    # a single number on it.

    data=`who | wc -l`

    # Send the data to the fifo.

    echo $data > $fifo

    # Don't use
    #   who | wc -l > $fifo
    # because it will leave extra processes around when it is killed.

done
