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

    ALIX 2c3 and pfsense (LEDs)

    Scheduled Pinned Locked Moved General pfSense Questions
    51 Posts 8 Posters 36.3k 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.
    • X
      xbipin
      last edited by

      i was waiting for this since the day i bought the alix, is it possible to configure the led to blink even faster or lets say a way to configure the on and off period, i want it to blick link the leds on  a switch or a router, which is faster.

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

        @xbipin:

        i was waiting for this since the day i bought the alix, is it possible to configure the led to blink even faster or lets say a way to configure the on and off period, i want it to blick link the leds on  a switch or a router, which is faster.

        You would have to look at the source of the blinkled program for that, which I didn't write. I don't think it can be used as a realtime indicator like a real switch port. It only polls periodically and flashes if it sees activity within a specific timeframe, if I recall correctly.

        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
        • X
          xbipin
          last edited by

          how about if it was used for the correct purpose of the LED being in the alix in the first place, think of it as a computer, LED1 could be power which it already is, LED2 as processor indicator and LED3 as HDD or CF read/write as the LEDs on the network adapters are enough of LEDs already blinking as for me they face the wall and there not being any way to turn them off as its directly plugged to the network card chip

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

            It being a customizable device, there is no real "correct purpose" for the LEDs, they can be whatever someone programs them to be. Personally, I like LED1 to be power and alerts, and LED2/3 to be network activity.

            If someone wants to come along and write a program that will flash the LEDs based on other types of activity, it would be more than welcome.

            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
            • dotdashD
              dotdash
              last edited by

              Here is an old thread with some additional ideas on using the LEDs. http://forum.pfsense.org/index.php/topic,327.0.html

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

                @dotdash:

                Here is an old thread with some additional ideas on using the LEDs. http://forum.pfsense.org/index.php/topic,327.0.html

                In 2.0 I have an LED library that makes it easy to do some handy things, but I don't think it's going to make it into 1.2.x. For example, I have it blink "sos" in morse code on LED1 when there is an alert. That part may make it into 1.2.3 if I get some time to work out a patch (should be easy I just need to take the time to reflash my alix as 1.2.3 and test it first)

                If something is going to use the LEDs on 1.2.3, it will need to be something that can be made into a package, like I'm working on with blinkled.

                The problem is that the system itself can't be told to trigger the LEDs on, for example, disk activity. Some program will have to be constantly running and polling for disk activity and then flash the LED when it is seen.

                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
                • G
                  GoldServe
                  last edited by

                  Anyone do anything cool with the LEDs?

                  1 Reply Last reply Reply Quote 0
                  • N
                    nuno0351
                    last edited by

                    Not with PFSense, but with a WAN Emulator I have the second LED turn on when emulation is on.  Just a visual reminder.
                    Maybe PFSense could have it turn on if certain events are true like if OpenVPN connection is established, if a certain firewall rule is tripped or if a critical service stops running like ospfd or snort?

                    Personally I use pfsend under kvm, so I don't run it on ALIX.  I don't know if you guys keep it on your desks where you can easily look at it.

                    1 Reply Last reply Reply Quote 0
                    • W
                      woeper
                      last edited by

                      @jimp:

                      I know it's been a while but I do have some updates:

                      #1: I'm going to be adding some LED stuff to 2.0. Stuff that won't/can't make it into 1.2.3 because it will have to be in system files and not in a package.

                      #2: I did just add a blinkled package that will work on the 1.2.3-RC nanobsd images. It works for me, so give it a try. After installing the package, go to Interfaces -> Assign LEDs. Should be self-explanatory from there.

                      Is there any way to obtain de source code of blinkled ? i would like to try to adapt this code for the leds of a  firebox II panel ?

                      1 Reply Last reply Reply Quote 0
                      • dotdashD
                        dotdash
                        last edited by

                        RSW's blinkled.c:

                        /* Part of this code taken from:

                        • MiniUPnP project
                        • http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
                        • author: Ryan Wagoner and Thomas Bernard
                        • © 2006 Thomas Bernard
                        • This software is subject to the conditions detailed
                        • in the LICENCE file provided within the distribution */

                        #include <sys types.h="">#include <sys socket.h="">#include <net if.h="">#include <arpa inet.h="">#include <netinet in.h="">#if defined(FreeBSD)
                        #include <net if_var.h="">#endif
                        #include <net pfvar.h="">#include <kvm.h>#include <fcntl.h>#include <nlist.h>#include <sys queue.h="">#include <stdio.h>#include <string.h>#include <limits.h>#include <unistd.h>struct nlist list[] = {
                        {"_ifnet"},
                        {NULL}
                        };

                        struct ifdata {
                        unsigned long opackets;
                        unsigned long ipackets;
                        unsigned long obytes;
                        unsigned long ibytes;
                        unsigned long baudrate;
                        };

                        static volatile int quitting = 0;

                        void sigterm(int sig);
                        int getifstats(const char * ifname, struct ifdata * data);

                        int main(int argc, char * * argv)
                        {
                        int i, file, ledstatelen;
                        int debugflag = 0;
                        char ledstate[5];
                        struct ifdata tdata, pdata;
                        const char * iface = NULL, * led = NULL;
                        struct sigaction sa;

                        for(i=1; i <argc; i++)<br="">{
                        if(argv_[0]!='-')
                        {
                        fprintf(stderr, "Unknown option: %s\n", argv_);
                        }
                        else switch(argv_[1])
                        {
                        case 'i':
                        iface = argv[++i];
                        break;
                        case 'l':
                        led = argv[++i];
                        break;
                        case 'd':
                        debugflag = 1;
                        break;
                        default:
                        fprintf(stderr, "Unknown option: %s\n", argv_);
                        }
                        }

                        if(!iface || !led)
                        {
                        fprintf(stderr, "Usage:\n\t%s [-i ifname] [-l led] [-d]\n", argv[0]);
                        return 1;
                        }

                        if(access(led, F_OK) < 0)
                        {
                        fprintf(stderr, "Error: Unable to access %s\n", led);
                        return 1;
                        }

                        if (!debugflag)
                        {
                        if (fork() == 0)
                        {
                        int nullfd;
                        if ((nullfd = open("/dev/null", O_WRONLY, 0)) < 0)
                        {
                        fprintf(stderr, "Error: Could not open /dev/null");
                        return 1;
                        }
                        dup2(nullfd, STDIN_FILENO);
                        dup2(nullfd, STDOUT_FILENO);
                        dup2(nullfd, STDERR_FILENO);
                        close(nullfd);
                        setsid();
                        }
                        else
                        {
                        return 0;
                        }
                        }

                        memset(&sa, 0, sizeof(struct sigaction));
                        sa.sa_handler = sigterm;

                        if (sigaction(SIGTERM, &sa, NULL))
                        {
                        fprintf(stderr, "Error: Unable to set SIGTERM handler\n");
                        return 1;
                        }
                        if (sigaction(SIGINT, &sa, NULL))
                        {
                        fprintf(stderr, "Error: Unable to set SIGTERM handler\n");
                        return 1;
                        }

                        if(getifstats(iface, &tdata) < 0)
                        {
                        fprintf(stderr, "Error: getifstats: FAILED\n");
                        return 1;
                        }

                        while (!quitting)
                        {
                        sleep(1);

                        if(getifstats(iface, &pdata) < 0)
                        {
                        fprintf(stderr, "Error: getifstats: FAILED\n");
                        return 1;
                        }

                        if( (pdata.ibytes - tdata.ibytes) > 5120 || (pdata.obytes - tdata.obytes) > 5120 )
                        {
                        ledstatelen = sprintf(ledstate, "f1");
                        tdata = pdata;
                        }
                        else
                        {
                        ledstatelen = sprintf(ledstate, "0");
                        }

                        file = open(led, O_WRONLY, 0666);
                        write(file, ledstate, ledstatelen);
                        close(file);
                        }

                        ledstatelen = sprintf(ledstate, "0");
                        file = open(led, O_WRONLY, 0666);
                        write(file, ledstate, ledstatelen);
                        close(file);

                        printf("Good-bye\n");

                        return 0;
                        }

                        void sigterm(int sig)
                        {
                        signal(sig, SIG_IGN);
                        quitting = 1;
                        }

                        int getifstats(const char * ifname, struct ifdata * data)
                        {
                        #if defined(FreeBSD)
                        struct ifnethead ifh;
                        #elif defined(OpenBSD) || defined(NetBSD)
                        struct ifnet_head ifh;
                        #else
                        #error "Dont know if I should use struct ifnethead or struct ifnet_head"
                        #endif
                        struct ifnet ifc;
                        struct ifnet *ifp;
                        kvm_t *kd;
                        ssize_t n;
                        char errstr[_POSIX2_LINE_MAX];

                        kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errstr);
                        if(!kd)
                        {
                        fprintf(stderr, "Error: kvm_open(): %s\n", errstr);
                        return -1;
                        }
                        if(kvm_nlist(kd, list) < 0)
                        {
                        fprintf(stderr, "Error: kvm_nlist(): FAILED\n");
                        kvm_close(kd);
                        return -1;
                        }
                        if(!list[0].n_value)
                        {
                        fprintf(stderr, "Error: n_value(): FAILED\n");
                        kvm_close(kd);
                        return -1;
                        }
                        n = kvm_read(kd, list[0].n_value, &ifh, sizeof(ifh));
                        if(n<0)
                        {
                        fprintf(stderr, "Error: kvm_read(head): %s\n", kvm_geterr(kd));
                        kvm_close(kd);
                        return -1;
                        }
                        for(ifp = TAILQ_FIRST(&ifh); ifp; ifp = TAILQ_NEXT(&ifc, if_list))
                        {
                        n = kvm_read(kd, (u_long)ifp, &ifc, sizeof(ifc));
                        if(n<0)
                        {
                        fprintf(stderr, "Error: kvm_read(element): %s\n", kvm_geterr(kd));
                        kvm_close(kd);
                        return -1;
                        }
                        if(strcmp(ifname, ifc.if_xname) == 0)
                        {
                        data->opackets = ifc.if_data.ifi_opackets;
                        data->ipackets = ifc.if_data.ifi_ipackets;
                        data->obytes = ifc.if_data.ifi_obytes;
                        data->ibytes = ifc.if_data.ifi_ibytes;
                        data->baudrate = ifc.if_data.ifi_baudrate;
                        kvm_close(kd);
                        return 0;
                        }
                        }
                        }____</argc;></unistd.h></limits.h></string.h></stdio.h></sys></nlist.h></fcntl.h></kvm.h></net></net></netinet></arpa></net></sys></sys>

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

                          It's also available in the pfSense-packages git repo.

                          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
                          • First post
                            Last post
                          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.