0

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
  <Schedule>
    Every   1 sec
    Exec exec("/usr/bin/last", "-f", "/var/run/utmp");
  </Schedule>
</Input>

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

<Route processwtmp>
    Path      sample_umtp_linux => out_debug
</Route>

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.)

0

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
</Input>

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

#!/bin/sh
while true
do
    /usr/bin/last -f /var/run/utmp
    sleep 1
done

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.