Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    • Register
    • Login
    Introducing Netgate Nexus: Multi-Instance Management at Your Fingertips.

    Need help building Dashboard widget that displays Log file

    Scheduled Pinned Locked Moved webGUI
    4 Posts 2 Posters 2.0k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      Kruzekova
      last edited by

      I need a widget that displays the last 5 lines of a text logfile that is made from a bash script. The output of this script to the logfile is quite simple:

      Tue Jan  1 04:29:43 MST 2013 4.2.2.2 Ping FAILED
      Tue Jan  1 04:29:56 MST 2013 8.8.8.8 Ping FAILED
      Tue Jan  1 04:30:09 MST 2013 8.8.4.4 Ping FAILED
      Tue Jan  1 04:30:11 MST 2013 ALL PINGS FAILED
      Tue Jan  1 04:30:11 MST 2013 REQUESTING REBOOT…
      Tue Jan  1 04:30:11 MST 2013 DSL MODEM REBOOTING!

      I can get this in a shell with  tail -5 /var/logfile.log  but I'm not sure how to do this in a widget format.

      Thank you

      1 Reply Last reply
      Reply Quote 0
      • jimpJ
        jimp Rebel Alliance Developer Netgate
        last edited by

        There are several widgets that display logs, some more complex than others. Have a look at the snort widget (in packages), havp widget (also in packages), and firewall logs widget.

        What you're after would be easier than those, they do a bit of parsing before displaying, but you could perhaps use them as a basis for what you're trying to accomplish.

        Or at least to see how widgets work in general.

        Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

        Need help fast? Netgate Global Support!

        Do not Chat/PM for help!

        1 Reply Last reply
        Reply Quote 0
        • K
          Kruzekova
          last edited by

          Thank you. I looked at the code for those widgets and learned how to make my own. It is quite simple:

          
          $file = "/var/log/DSLModemUptimeMonitor.log";
          $contents = file($file);
          $string = array_slice($contents,-6);
          $string1 = array_reverse($string);
          
          ?>
          
          | 
                                  # havp version
                        echo implode("
          ", $string1);
                    ?>
                   |
          
          
          1 Reply Last reply
          Reply Quote 0
          • jimpJ
            jimp Rebel Alliance Developer Netgate
            last edited by

            Very good, nice and simple :-)

            Eventually we'll probably have a general-purpose log widget that lets someone choose any of the files in /var/log to show in a widget. Shouldn't be too hard to do, but it's one of those things that nobody has thought to take the time for yet.

            Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

            Need help fast? Netgate Global Support!

            Do not Chat/PM for help!

            1 Reply Last reply
            Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post
            Copyright 2026 Rubicon Communications LLC (Netgate). All rights reserved.
            Privacy Policy · Cookie Policy