Skip to content
Snippets Groups Projects
Select Git revision
  • 6ac7e97fae55a1dae938984f535580ae117c2cc9
  • experimental
  • master
  • v2021.1.2-ffs
  • v2021.1.1-ffs
  • nrb/gluon-master-cpe510
  • v2021.1-ffs
  • v2020.2.3-ffs
  • nrbffs/fastd-remove-delay
  • v2020.2.2-ffs
  • v2020.2.1-ffs
  • v2020.2-ffs
  • v2020.2.x
  • v2020.1.3-ffs
  • v2020.1.1-ffs
  • v2020.1-ffs
  • v2019.1.2-ffs
  • v2019.1.1-ffs
  • nrb/test-radv-filter
  • v2019.1-ffs
  • nrbffs/netgear-ex6120
  • v2021.1.2-ffs0.2
  • v2021.1.2-ffs0.1
  • v2021.1.1-ffs0.4
  • v2021.1.1-ffs0.3
  • v2021.1.1-ffs0.2
  • v2021.1.1-ffs0.1
  • v2021.1-ffs0.1
  • v2020.2.3-ffs0.3
  • v2020.2.3-ffs0.2
  • v2020.2.3-ffs0.1
  • v2020.2.2-ffs0.1
  • v2020.2.1-ffs0.1
  • v2020.2-ffs0.1
  • v2020.2
  • v2020.2.x-ffs0.1
  • v2020.1.3-ffs0.1
  • v2020.1.1-ffs0.1
  • v2020.1-ffs0.1
  • v2019.1.2-ffs0.1
  • v2019.1.1-ffs0.1
41 results

respondd.c

Blame
  • Forked from firmware / FFS Gluon
    Source project has a limited visibility.
    • lemoer's avatar
      6ac7e97f
      gluon-respondd: add information from /proc/stat to "statistics" · 6ac7e97f
      lemoer authored
      This commit adds information about:
      - how cpu time is spent since boot in jiffies (1/100*sek) (cpu)
          - the value is summed for all cores, so in 10 seconds the
            summed values will increase by 4000, if the cpu has
            4 cores
      - context switches since boot (ctxt)
      - interrupt counters since boot (intr, softirq)
      - forks since boot (processes)
      
          { "stat": {
             "cpu": {
               "user": 219403,
               "nice": 1714,
               "system": 75159,
               "idle": 2727739,
               "iowait": 2943,
               "irq": 0,
               "softirq": 571
             },
             "intr": 8426340,
             "ctxt": 50992590,
             "processes": 10549,
             "softirq": 5161884
          } }
      6ac7e97f
      History
      gluon-respondd: add information from /proc/stat to "statistics"
      lemoer authored
      This commit adds information about:
      - how cpu time is spent since boot in jiffies (1/100*sek) (cpu)
          - the value is summed for all cores, so in 10 seconds the
            summed values will increase by 4000, if the cpu has
            4 cores
      - context switches since boot (ctxt)
      - interrupt counters since boot (intr, softirq)
      - forks since boot (processes)
      
          { "stat": {
             "cpu": {
               "user": 219403,
               "nice": 1714,
               "system": 75159,
               "idle": 2727739,
               "iowait": 2943,
               "irq": 0,
               "softirq": 571
             },
             "intr": 8426340,
             "ctxt": 50992590,
             "processes": 10549,
             "softirq": 5161884
          } }
    gluon-switch-domain 1.66 KiB
    #!/usr/bin/lua
    
    local uci = require('simple-uci').cursor()
    local unistd = require 'posix.unistd'
    local util = require 'gluon.util'
    local site = require 'gluon.site'
    
    -- Returns true if node was offline long enough to perform domain switch
    local function switch_after_min_reached()
    	if not unistd.access("/tmp/gluon_offline") then
    		return false
    	end
    
    	local switch_after_sec = site.domain_switch.switch_after_offline_mins() * 60
    
    	local current_uptime = util.get_uptime()
    	if current_uptime == nil then
    		return false
    	end
    
    	local f = util.readfile("/tmp/gluon_offline")
    	if f == nil then
    		return false
    	end
    	local offline_since = tonumber(f)
    
    	local offline_time_sec = current_uptime - offline_since
    
    	if offline_time_sec > switch_after_sec then
    		return true
    	end
    	return false
    end
    
    -- Returns true in case switch time has passed
    local function switch_time_passed()
    	local current_time = os.time()
    	local switch_time = site.domain_switch.switch_time()
    
    	return switch_time < current_time
    end
    
    if site.domain_switch() == nil then
    	-- Switch not applicable for current domain
    	print("No domain switch defined for the current domain.")
    	os.exit(0)
    end
    
    local current_domain = uci:get("gluon", "core", "domain")
    local target_domain = site.domain_switch.target_domain()
    
    if target_domain == current_domain then
    	-- Current and target domain are equal
    	print("Domain '" .. target_domain .. "' equals current domain.")
    	os.exit(1)
    end
    
    if not switch_after_min_reached() and not switch_time_passed() then
    	-- Neither switch-time passed nor switch_after_min reached
    	os.exit(0)
    end
    
    uci:set("gluon", "core", "domain", target_domain)
    uci:commit("gluon")
    
    os.execute("gluon-reconfigure")
    os.execute("reboot")