• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    [Feedback Requested] Adding kernel info to FOG Reporting

    Scheduled Pinned Locked Moved
    General
    2
    11
    802
    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.
    • Wayne WorkmanW
      Wayne Workman
      last edited by

      I’ve opened two PRs for this.
      https://github.com/FOGProject/fogproject/pull/469
      https://github.com/FOGProject/fogproject/pull/468

      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
      Daily Clean Installation Results:
      https://fogtesting.fogproject.us/
      FOG Reporting:
      https://fog-external-reporting-results.fogproject.us/

      1 Reply Last reply Reply Quote 0
      • S
        Sebastian Roth Moderator
        last edited by

        @Wayne-Workman Great stuff, thanks for this. Pretty busy at the moment but I will reply in more detail over the weekend.

        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

        1 Reply Last reply Reply Quote 0
        • S
          Sebastian Roth Moderator
          last edited by Sebastian Roth

          @wayne-workman said in [Feedback Requested] Adding kernel info to FOG Reporting:

          A single fog server can have many kernels.

          On the one hand side it would be great to see more than just the active kernel binary (global settings) but on the other hand we can’t tell if people really use all those kernels or just have those sitting there unused. From my point of view it would get us the most clear picture about kernels in use if we check the database for global kernel filename (64 & 32 bit) and possibly also kernels assigned in host settings (just another simple query to the hosts table. Open for discussion. What do you all think?

          I decided to purposely not include the kernel file name, as this may contain some sort of identifiable information. Also I purposely chopped some of the file command output, to get only version information and nothing else.

          While I can see that filenames might be a particular name chosen by the admin I don’t think this would reveal too much valuable information. I just say this because I was looking for a way to distinguish between bzImage (64 bit) and bzImage32 (32 bit) using Linux commands but have not been able to yet. Using filenames would help. On the other hand the script could just check the filename and add 32, 64 bit or ARM64 information according to the filename.

          If we really use the information from the database we don’t need to think about this part too much.

          grub & memdisk kernels are really old. 2005 and 2010. What’s involved with updating these?

          I don’t really know where those binaries came from in the first place. Those were added before I joined. Keeping things up tp date is usually a good thing but it can break stuff as well. Some people have complained about us updating rEFInd a couple of times and I am not sure if we should touch these (grub & memdisk). As well I am not sure if newer versions exist. As far as I know this is a grub4dos binary - no update since 2009. Probably similar with memdisk?!?

          Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

          Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

          Wayne WorkmanW 1 Reply Last reply Reply Quote 0
          • Wayne WorkmanW
            Wayne Workman @Sebastian Roth
            last edited by

            @sebastian-roth Good points. Let me refine this a little with the DB query stuff.

            Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
            Daily Clean Installation Results:
            https://fogtesting.fogproject.us/
            FOG Reporting:
            https://fog-external-reporting-results.fogproject.us/

            1 Reply Last reply Reply Quote 1
            • Wayne WorkmanW
              Wayne Workman
              last edited by Wayne Workman

              New Script

              #!/bin/bash
              
              # Get the OS Information.
              read -r os_name os_version <<< $(lsb_release -ir | cut -d':' -f2 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr '\n' ' ')
              
              # Get the FOG Version.
              source /opt/fog/.fogsettings
              system_class_php=${docroot}/${webroot}/lib/fog/system.class.php
              fog_version=$(cat ${system_class_php} | grep FOG_VERSION | cut -d',' -f2 | cut -d"'" -f2)
              
              # Construct correct mysql options.
              options="-sN"
              if [[ $snmysqlhost != "" ]]; then
                      options="$options -h$snmysqlhost"
              fi
              if [[ $snmysqluser != "" ]]; then
                      options="$options -u$snmysqluser"
              fi
              if [[ $snmysqlpass != "" ]]; then
                      options="$options -p$snmysqlpass"
              fi
              options="$options -D $mysqldbname -e"
              
              # Construct sql statements.
              FOG_TFTP_PXE_KERNEL_32_select='select settingValue from globalSettings WHERE settingKey = "FOG_TFTP_PXE_KERNEL_32";'
              FOG_TFTP_PXE_KERNEL_select='select settingValue from globalSettings WHERE settingKey = "FOG_TFTP_PXE_KERNEL";'
              FOG_TFTP_PXE_KERNEL_DIR_select='select settingValue from globalSettings WHERE settingKey = "FOG_TFTP_PXE_KERNEL_DIR";'
              FOG_HOSTS_KERNELS_select='SELECT UNIQUE hostKernel FROM hosts;'
              
              # Execute sql statements, get values.
              FOG_TFTP_PXE_KERNEL_32=$(mysql $options "$FOG_TFTP_PXE_KERNEL_32_select")
              FOG_TFTP_PXE_KERNEL=$(mysql $options "$FOG_TFTP_PXE_KERNEL_select")
              FOG_TFTP_PXE_KERNEL_DIR=$(mysql $options "$FOG_TFTP_PXE_KERNEL_DIR_select")
              FOG_HOST_KERNELS=$(mysql $options "$FOG_HOSTS_KERNELS_select")
              
              # Get kernel information.
              ## Begin building the JSON array to send.
              kernel_versions_info='['
              
              # Begin processing global 32 bit kernel.
              # Check if 32 bit global kernel file exists.
              if [[ -f ${FOG_TFTP_PXE_KERNEL_DIR}${FOG_TFTP_PXE_KERNEL_32} ]]; then
                  # Get file information.
                  file_information=$(file --no-pad --brief ${FOG_TFTP_PXE_KERNEL_DIR}${FOG_TFTP_PXE_KERNEL_32})
                  # Check if this is a linux kernel or not.
                  if [[ "${file_information}" == *"Linux kernel"* ]]; then
                      # Here, we are pretty sure the current file we're looking at is a Linux kernel. Parse the version information.
                      version=$(echo ${file_information} | cut -d, -f2 | sed 's/version*//' | xargs)
                      # If there are any double quotes in this version information, add a backslash in front of them for JSON escaping.
                      version=$(echo $version | sed 's/"/\\"/g')
              	# Prepend the filename to the version.
              	version="${FOG_TFTP_PXE_KERNEL_32} ${version}"
              	# Wrap the version in double quotes for JSON syntax.
                      version="\"${version}\""
                      # Check if the last character in the kernel_versions_info variable is a double quote. If so, add a leading comma.
                      if [[ "${kernel_versions_info: -1}" == '"' ]]; then
                          version=",${version}"
                      fi
                      # Append version to kernel_versions_info JSON list.
                      kernel_versions_info="${kernel_versions_info}${version}"
                  fi
              fi
              
              # Begin processing 64 bit global kernel.
              # Check if global kernel file exists.
              if [[ -f ${FOG_TFTP_PXE_KERNEL_DIR}${FOG_TFTP_PXE_KERNEL} ]]; then
                  # Get file information.
                  file_information=$(file --no-pad --brief ${FOG_TFTP_PXE_KERNEL_DIR}${FOG_TFTP_PXE_KERNEL})
                  # Check if this is a linux kernel or not.
                  if [[ "${file_information}" == *"Linux kernel"* ]]; then
                      # Here, we are pretty sure the current file we're looking at is a Linux kernel. Parse the version information.
                      version=$(echo ${file_information} | cut -d, -f2 | sed 's/version*//' | xargs)
                      # If there are any double quotes in this version information, add a backslash in front of them for JSON escaping.
                      version=$(echo $version | sed 's/"/\\"/g')
                      # Prepend the filename to the version.
                      version="${FOG_TFTP_PXE_KERNEL} ${version}"
                      # Wrap the version in double quotes for JSON syntax.
                      version="\"${version}\""
                      # Check if the last character in the kernel_versions_info variable is a double quote. If so, add a leading comma.
                      if [[ "${kernel_versions_info: -1}" == '"' ]]; then
                          version=",${version}"
                      fi
                      # Append version to kernel_versions_info JSON list.
                      kernel_versions_info="${kernel_versions_info}${version}"
                  fi
              fi
              
              # Begin processing each unique host kernel that is not a global kernel.
              for host_kernel in $FOG_HOST_KERNELS; do
                  # Check if this is the name of the 32 or 64 bit global kernel. If so, skip it.
                  if [[ "${host_kernel}" != "${FOG_TFTP_PXE_KERNEL}" && "${host_kernel}" != "${FOG_TFTP_PXE_KERNEL_32}" ]]; then
                      if [[ -f ${FOG_TFTP_PXE_KERNEL_DIR}${host_kernel} ]]; then
                          # Get file information.
                          file_information=$(file --no-pad --brief ${FOG_TFTP_PXE_KERNEL_DIR}${host_kernel})
                          # Check if this is a linux kernel or not.
                          if [[ "${file_information}" == *"Linux kernel"* ]]; then
                              # Here, we are pretty sure the current file we're looking at is a Linux kernel. Parse the version information.
                              version=$(echo ${file_information} | cut -d, -f2 | sed 's/version*//' | xargs)
                              # If there are any double quotes in this version information, add a backslash in front of them for JSON escaping.
                              version=$(echo $version | sed 's/"/\\"/g')
                              # Prepend the filename to the version.
                              version="${host_kernel} ${version}"
                              # Wrap the version in double quotes for JSON syntax.
                              version="\"${version}\""
                              # Check if the last character in the kernel_versions_info variable is a double quote. If so, add a leading comma.
                              if [[ "${kernel_versions_info: -1}" == '"' ]]; then
                                  version=",${version}"
                              fi
                              # Append version to kernel_versions_info JSON list.
                              kernel_versions_info="${kernel_versions_info}${version}"
                          fi
                      fi
                  fi    
              done
              
              # Finish JSON list formatting.
              kernel_versions_info="${kernel_versions_info}]"
              
              # Format payload.
              payload='{"fog_version":"'${fog_version}'","os_name":"'${os_name}'","os_version":"'${os_version}'","kernel_versions_info":'${kernel_versions_info}'}'
              
              #echo "os_name=${os_name}"
              #echo "os_version=${os_version}"
              #echo "fog_version=${fog_version}"
              #echo "kernel_versions_info=${kernel_versions_info}"
              #echo "payload=${payload}"
              
              # Send to reporting endpoint.
              curl -s -X POST -H "Content-Type: application/json" -d "${payload}" https://fog-external-reporting-entries.theworkmans.us:/api/records
              

              New Payload

              {
                "fog_version": "1.5.9.139",
                "os_name": "Debian",
                "os_version": "11",
                "kernel_versions_info": [
                  "bzImage32 5.15.19 (buildkite-agent@Tollana) #1 SMP Thu Feb 3 15:05:47 CST 2022",
                  "bzImage 5.15.19 (buildkite-agent@Tollana) #1 SMP Thu Feb 3 15:10:05 CST 2022",
                  "arm_Image_test little-endian",
                  "another_test_kernel 4.19.145 (sebastian@Tollana) #1 SMP Sun Sep 13 05:43:10 CDT 2020"
                ]
              }
              

              Notes

              The script got lengthy, I think it’s fine though. I prepended the filename to the version information. I noticed the FOG ARM kernels lack version information - even when not parsed. This is it unparsed:

              Linux kernel ARM64 boot executable Image, little-endian, 4K pages
              

              If version information is added to future ARM kernels, the script should pick it up. I did add three hosts to my test fog system. Two of them I assigned valid kernel files to, and the third one I assigned a bogus file name. The script checks to make sure all the kernels actually exist, and are actually linux kernels before adding them to the payload.

              Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
              Daily Clean Installation Results:
              https://fogtesting.fogproject.us/
              FOG Reporting:
              https://fog-external-reporting-results.fogproject.us/

              1 Reply Last reply Reply Quote 0
              • S
                Sebastian Roth Moderator
                last edited by

                @Wayne-Workman Awesome! Tested on a test VM with Ubuntu as well. Works like a charm.

                If version information is added to future ARM kernels, the script should pick it up. I did add three hosts to my test fog system. Two of them I assigned valid kernel files to, and the third one I assigned a bogus file name. The script checks to make sure all the kernels actually exist, and are actually linux kernels before adding them to the payload.

                👍

                Would you mind opening pull requests for dev-branch and working-1.6 again?

                Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                Wayne WorkmanW 1 Reply Last reply Reply Quote 0
                • Wayne WorkmanW
                  Wayne Workman @Sebastian Roth
                  last edited by

                  @sebastian-roth

                  https://github.com/FOGProject/fogproject/pull/471
                  https://github.com/FOGProject/fogproject/pull/470

                  Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
                  Daily Clean Installation Results:
                  https://fogtesting.fogproject.us/
                  FOG Reporting:
                  https://fog-external-reporting-results.fogproject.us/

                  1 Reply Last reply Reply Quote 0
                  • Wayne WorkmanW
                    Wayne Workman
                    last edited by

                    @Sebastian-Roth thanks for merging.

                    I’ve got the information storing pieces worked out in the server side via this PR. Next is to get the graphs created.

                    Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
                    Daily Clean Installation Results:
                    https://fogtesting.fogproject.us/
                    FOG Reporting:
                    https://fog-external-reporting-results.fogproject.us/

                    1 Reply Last reply Reply Quote 1
                    • Wayne WorkmanW
                      Wayne Workman
                      last edited by

                      @Sebastian-Roth I’ve added the graphing. Below is a graph generated with just 4 test entries in the DB. I’ve changed all the graphs to display 30 instead of 20, and made the images a bit bigger.

                      kernels_out_there.png

                      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
                      Daily Clean Installation Results:
                      https://fogtesting.fogproject.us/
                      FOG Reporting:
                      https://fog-external-reporting-results.fogproject.us/

                      1 Reply Last reply Reply Quote 1
                      • Wayne WorkmanW
                        Wayne Workman @Wayne Workman
                        last edited by

                        Putting a bow-tie on this thread: This feature is complete. Link to the external reporting is in my signature, the kernels in use are beginning to show up, these figures will increase and show a bigger picture over time.

                        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
                        Daily Clean Installation Results:
                        https://fogtesting.fogproject.us/
                        FOG Reporting:
                        https://fog-external-reporting-results.fogproject.us/

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post

                        154

                        Online

                        12.0k

                        Users

                        17.3k

                        Topics

                        155.2k

                        Posts
                        Copyright © 2012-2024 FOG Project