Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    How to run a Bashtop or top after system rebooting, right after general menu (in Console) ?

    Scheduled Pinned Locked Moved General pfSense Questions
    11 Posts 3 Posters 414 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.
    • Sergei_ShablovskyS
      Sergei_Shablovsky
      last edited by Sergei_Shablovsky

      Hi, pfSense Gurus!

      How to run a bashtop / top after system rebooting, right after general menu (in Console).

      I mean like You logging locally on Console Port or via Rack Terminal (Keyboard + Monitor) locally attached, and after successfully booting press "8" to loading Shell, and after loading "bashtop" or "top".

      And additional question are "How to add extra one item (for example "Top") to general menu (in Console) for quickly launching "bashtop" or "top"?

      May be solution are editing /etc/rc.initial ?

      Thank You for help and suggestions! Have a nice sunny day!

      —
      CLOSE SKY FOR UKRAINE https://youtu.be/_tU1i8VAdCo !
      Help Ukraine to resist, save civilians people’s lives !
      (Take an active part in public protests, push on Your country’s politics, congressmans, mass media, leaders of opinion.)

      1 Reply Last reply Reply Quote 0
      • Sergei_ShablovskyS
        Sergei_Shablovsky
        last edited by

        Or using shellcmd option (described in https://docs.netgate.com/pfsense/en/latest/development/boot-commands.html#shellcmd-option) to start top?

        —
        CLOSE SKY FOR UKRAINE https://youtu.be/_tU1i8VAdCo !
        Help Ukraine to resist, save civilians people’s lives !
        (Take an active part in public protests, push on Your country’s politics, congressmans, mass media, leaders of opinion.)

        1 Reply Last reply Reply Quote 0
        • GertjanG
          Gertjan
          last edited by Gertjan

          Hi,

          When you login, you're in front of the screen, right ?
          As SSH access needs a cert password to be typed in, what's against an extra 8 + enter + top + enter ?

          @Sergei_Shablovsky said in How to run a top after system rebooting, right after general menu (in Console) ?:

          Or using shellcmd option

          You tried it ?
          top would start, find out it wasn't started using an interactive shell, so it quiet ... or refreshing the list it can't show, only eating system resources in the back ground.

          No "help me" PM's please. Use the forum, the community will thank you.
          Edit : and where are the logs ??

          Sergei_ShablovskyS 1 Reply Last reply Reply Quote 0
          • stephenw10S
            stephenw10 Netgate Administrator
            last edited by stephenw10

            You could just patch rc.initial. Can be a hidden option, like 101 say:

            101)
            	/usr/bin/top -aSH
            	;;
            
            *** Welcome to pfSense 2.4.5-RELEASE-p1 (amd64) on 244dev ***
            
             WAN (wan)       -> vtnet0     -> v4/DHCP4: 172.21.16.180/24
             LAN (lan)       -> vtnet1     -> v4: 192.168.180.1/24
             OPT1 (opt1)     -> vtnet2     -> v4: 192.168.56.1/24
            
             0) Logout (SSH only)                  9) pfTop
             1) Assign Interfaces                 10) Filter Logs
             2) Set interface(s) IP address       11) Restart webConfigurator
             3) Reset webConfigurator password    12) PHP shell + pfSense tools
             4) Reset to factory defaults         13) Update from console
             5) Reboot system                     14) Disable Secure Shell (sshd)
             6) Halt system                       15) Restore recent configuration
             7) Ping host                         16) Restart PHP-FPM
             8) Shell
            
            Enter an option: 101
            
            
            last pid: 73892;  load averages:  0.09,  0.14,  0.12    up 0+00:56:00  15:57:36
            168 processes: 2 running, 140 sleeping, 26 waiting
            CPU:  0.0% user,  0.0% nice,  0.0% system,  0.0% interrupt,  100% idle
            Mem: 65M Active, 75M Inact, 192M Wired, 38M Buf, 1608M Free
            Swap: 512M Total, 512M Free
            
              PID USERNAME   PRI NICE   SIZE    RES STATE    TIME    WCPU COMMAND
               11 root       155 ki31     0K    16K RUN     54:42  99.79% [idle]
               12 root       -60    -     0K   416K WAIT     0:03   0.06% [intr{swi4: clock
            73892 root        22    0  7824K  4124K RUN      0:00   0.04% /usr/bin/top -aSH
               12 root       -92    -     0K   416K WAIT     0:01   0.01% [intr{irq261: vir
            31602 dhcpd       20    0 16464K 10120K select   0:00   0.01% /usr/local/sbin/d
                7 root       -16    -     0K    16K -        0:00   0.01% [rand_harvestq]
                6 root       -16    -     0K    16K pftm     0:00   0.01% [pf purge]
            83336 root        20    0  6908K  2316K nanslp   0:00   0.01% /usr/local/bin/dp
            83047 root        20    0  6908K  2316K nanslp   0:00   0.01% /usr/local/bin/dp
            68769 root        20    0 12968K  7792K select   0:00   0.01% sshd: admin@pts/0
            83336 root        20    0  6908K  2316K sbwait   0:00   0.00% /usr/local/bin/dp
              337 root        20    0 94900K 25260K kqread   0:00   0.00% php-fpm: master p
            25259 root        20    0 10420K  5680K select   0:00   0.00% /usr/local/sbin/n
            83047 root        20    0  6908K  2316K sbwait   0:00   0.00% /usr/local/bin/dp
            53271 root        20    0  6968K  2692K bpf      0:00   0.00% /usr/local/sbin/f
               22 root        20    -     0K    32K sdflus   0:00   0.00% [bufdaemon{/ work
            

            It would get overwritten so you'd probably want to use an actual patch applied via the patches package.

            Steve

            Sergei_ShablovskyS 1 Reply Last reply Reply Quote 0
            • Sergei_ShablovskyS
              Sergei_Shablovsky @Gertjan
              last edited by

              @Gertjan said in How to run a bashtop or top after system rebooting, right after general menu (in Console) ?:

              Hi,

              When you login, you're in front of the screen, right ?
              As SSH access needs a cert password to be typed in, what's against an extra 8 + enter + top + enter ?

              @Sergei_Shablovsky said in How to run a top after system rebooting, right after general menu (in Console) ?:

              Or using shellcmd option

              You tried it ?
              top would start, find out it wasn't started using an interactive shell, so it quiet ... or refreshing the list it can't show, only eating system resources in the back ground.

              Thank You for suggesting!

              I am not sure that I clearly understanding You.

              I just need after hardware “cool restart” (watchdog in UEFI, or in separate Hardware Monitoring pcb, or after power failure and reestablish) and bsd/pfSense start, AUTOMATICALLY going to console menu and start Bashtop item.
              Just like this happened now, but AUTOMATICALLY go to certain menu item (in my case Bash).

              —
              CLOSE SKY FOR UKRAINE https://youtu.be/_tU1i8VAdCo !
              Help Ukraine to resist, save civilians people’s lives !
              (Take an active part in public protests, push on Your country’s politics, congressmans, mass media, leaders of opinion.)

              1 Reply Last reply Reply Quote 0
              • Sergei_ShablovskyS
                Sergei_Shablovsky @stephenw10
                last edited by

                @stephenw10 said in How to run a bashtop or top after system rebooting, right after general menu (in Console) ?:

                You could just patch rc.initial. Can be a hidden option, like 101 say:

                101)
                	/usr/bin/top -aSH
                	;;
                

                It would get overwritten so you'd probably want to use an actual patch applied via the patches package.

                Thank You for help!

                Now I have 2 questions:

                Why I need “hidden” option instead to creat normal menu item by editing original rc.initial file?

                Please point me on User Manual that describe how to make the “patches package”. And how to make applying my custom “patches package(s)” each time after pfSense update (no matter what way from webgui or console)?

                —
                CLOSE SKY FOR UKRAINE https://youtu.be/_tU1i8VAdCo !
                Help Ukraine to resist, save civilians people’s lives !
                (Take an active part in public protests, push on Your country’s politics, congressmans, mass media, leaders of opinion.)

                1 Reply Last reply Reply Quote 0
                • stephenw10S
                  stephenw10 Netgate Administrator
                  last edited by

                  It doesn't have to be hidden you just have that option.

                  You need to create a diff file and then you can import that as a patch into the patches package.

                  I would create that by forking it on github and editing it. That will create the diff for you and give you a convenient commit url to import.
                  For example:
                  https://github.com/stephenw10/pfsense/commit/e66cd5949ee8a0c4d0c7c8d7c3bbfe1ed550da64

                  Steve

                  Sergei_ShablovskyS 1 Reply Last reply Reply Quote 0
                  • Sergei_ShablovskyS
                    Sergei_Shablovsky @stephenw10
                    last edited by Sergei_Shablovsky

                    @stephenw10 said in How to run a bashtop or top after system rebooting, right after general menu (in Console) ?:

                    It doesn't have to be hidden you just have that option.

                    You need to create a diff file and then you can import that as a patch into the patches package.

                    I would create that by forking it on github and editing it. That will create the diff for you and give you a convenient commit url to import.
                    For example:
                    https://github.com/stephenw10/pfsense/commit/e66cd5949ee8a0c4d0c7c8d7c3bbfe1ed550da64

                    Steve

                    Ok, I understand how to create a patch from diff.

                    What a You suggest about how to automatically apply this “my patch” after each pfSense update ?

                    And back to topic, how to automatically start Bashtop/top/whatever from menu after pfSense loading? (Like local operator choose menu item in VGA console)

                    —
                    CLOSE SKY FOR UKRAINE https://youtu.be/_tU1i8VAdCo !
                    Help Ukraine to resist, save civilians people’s lives !
                    (Take an active part in public protests, push on Your country’s politics, congressmans, mass media, leaders of opinion.)

                    1 Reply Last reply Reply Quote 0
                    • stephenw10S
                      stephenw10 Netgate Administrator
                      last edited by

                      The patches packages has an option to 'auto apply' patches.

                      Adding those options to the rc.initial menu starts them from there. Just enter the menu number like any of the other entries.

                      Steve

                      Sergei_ShablovskyS 1 Reply Last reply Reply Quote 0
                      • Sergei_ShablovskyS
                        Sergei_Shablovsky @stephenw10
                        last edited by

                        @stephenw10 said in How to run a bashtop or top after system rebooting, right after general menu (in Console) ?:

                        The patches packages has an option to 'auto apply' patches.

                        Thank You, Steve!

                        Adding those options to the rc.initial menu starts them from there. Just enter the menu number like any of the other entries.

                        Sorry my stupidness today, where in code I must insert to automatically start certain menu item ? (And I hope after Ctrl+C/Q/Esc, back to main rc.initial menu. Like, I start, let’s to say, “Ping host” and then back to rc.initial menu after exit from rc.initial.ping)

                        —
                        CLOSE SKY FOR UKRAINE https://youtu.be/_tU1i8VAdCo !
                        Help Ukraine to resist, save civilians people’s lives !
                        (Take an active part in public protests, push on Your country’s politics, congressmans, mass media, leaders of opinion.)

                        1 Reply Last reply Reply Quote 0
                        • stephenw10S
                          stephenw10 Netgate Administrator
                          last edited by

                          Ah, I haven't tried starting one of the options by default, without selecting something. I'm not sure how that would work if there wasn't actually a console attached.
                          But it's just a shell script, you can have it do whatever you can code it to.

                          Steve

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.