I'm trying to read the output of the last command in Nxlog. I would like to run last on the utmp file on regular intervals. In other words I want to schedule a shell command to run with a time interval and pipe the output as a log event. In yet other words I would like to have <Schedule> clauses in a im_exec module but it seems that this is not possible so I'm trying something else (the example is for linux):

<Input sample_umtp_linux>
  Module im_null
    Every   1 sec
    Exec exec("/usr/bin/last", "-f", "/var/run/utmp");

<Output out_debug>
    Module    om_file
    File      '<mydir>/debug.log'

<Route processwtmp>
    Path      sample_umtp_linux => out_debug

I don't get any error messages, but I don't get any output either. Is there some way to catch the output and feed it into the Nxlog routing?

(Additional limitation: I'm going to deploy the solution to Hp Ux, so my options are a bit limited in terms of available system tools. I'd like to depend as little as possible on things outside Nxlog itself.)


I found a working solution for Linux that should've been rather obvious:

<Input sample_umtp_linux>
  Module im_exec
  Command <my_script_dir>/run_last_forever.sh

And with a script, run_last_forever.sh, like this:

while true
    /usr/bin/last -f /var/run/utmp
    sleep 1

However, it seems that Nxlog might not be buildable for HP-UX after all. But that's a separate issue.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.