Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Jun 7, 2020

FreeBSD doesn't use /proc/ to store system information, so multiple functions needed to be modified to support FreeBSD,

Modified Os.php to include new Class FreeBSD added check for when FreeBSD is the OS.

Created FreeBSD.php based on DefaultOS.php

Functions modified from DefaultOS.php

  • Added constructor to use phpIni
  • getMemory - use sysctl - mirror logic from SystemStatistics.php
  • getCPUName - use sysctl -n hw.model
  • getUptime - return kern.bootime subtracted from current time
  • getTimeServers - remove /etc/systemd/timesyncd.conf as does not exist in FreeBSD
  • getNetworkInfo - add gateway using netstat
  • getNetworkInterfaces - modified to use ifconfig instead of /sys/class/net/*
  • readContent - removed as now unused

FreeBSD doesn't use /proc/ to store system information.
Functions modified from DefaultOS.php
Added constructer to use phpIni
getMemory - use sysctl - mirror logic from SystemStatistics.php
getCPUName - use sysctl -n hw.model
getUptime - return kern.bootime subtracted from current time
getTimeServers - remove /etc/systemd/timesyncd.conf as does not exist in FreeBSD
getNetworkInfo - add gateway using netstat
getNetworkInterfaces - modified to use ifconfig instead of /sys/class/net/*
readContent - removed as now unused
is_function_enabled -  copied from SystemStatistics.php to verify exec()

Signed-off-by: Matthew Wener <[email protected]>
Copy link
Collaborator

@kesselb kesselb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 👍

Matthew Wener and others added 5 commits June 16, 2020 21:39
@ghost ghost requested a review from kesselb June 18, 2020 18:00
@ghost ghost marked this pull request as draft June 18, 2020 22:23
@ghost ghost marked this pull request as ready for review June 19, 2020 01:39
Copy link
Author

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small change to get all ipv6 addresses in the loopback address

@ghost ghost requested a review from kesselb June 19, 2020 14:57
Copy link
Collaborator

@kesselb kesselb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Did not test it.

@kesselb
Copy link
Collaborator

kesselb commented Jun 19, 2020

Mind to share some of the command outputs here (like https://github.com/nextcloud/serverinfo/tree/master/tests/data)? I can add some tests later with it. Just post it as comments here. No need to add it as files yet ;) Thanks 👍

Co-authored-by: kesselb <[email protected]>
Signed-off-by: Matthew Wener <[email protected]>
@ghost
Copy link
Author

ghost commented Jun 19, 2020

Sample Outputs

  1. /usr/sbin/swapinfo
Device          1K-blocks     Used    Avail Capacity
/dev/ada0p3       3744300        0  3744300     0%
  1. /sbin/sysctl -n hw.physmem hw.pagesize vm.stats.vm.v_inactive_count vm.stats.vm.v_cache_count vm.stats.vm.v_free_count
68569628672
4096
3294292
0
565419
  1. /sbin/sysctl -n hw.model
    Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz

  2. /sbin/sysctl -n kern.smp.cpus
    12

  3. date
    Fri Jun 19 12:46:52 EDT 2020

  4. /sbin/sysctl -n kern.boottime
    { sec = 1592397417, usec = 706110 } Wed Jun 17 08:36:57 2020

  5. date +%s
    1592585502

@ghost ghost closed this Jun 19, 2020
@ghost
Copy link
Author

ghost commented Jun 19, 2020

  1. cat /etc/ntp.conf 2>/dev/null
#
# $FreeBSD: releng/12.1/usr.sbin/ntp/ntpd/ntp.conf 337649 2018-08-11 17:42:42Z brd $
#
# Default NTP servers for the FreeBSD operating system.
#
# Don't forget to enable ntpd in /etc/rc.conf with:
# ntpd_enable="YES"
#
# The driftfile is by default /var/db/ntpd.drift, check
# /etc/defaults/rc.conf on how to change the location.
#

#
# Set the target and limit for adding servers configured via pool statements
# or discovered dynamically via mechanisms such as broadcast and manycast.
# Ntpd automatically adds maxclock-1 servers from configured pools, and may
# add as many as maxclock*2 if necessary to ensure that at least minclock
# servers are providing good consistant time.
#
tos minclock 3 maxclock 6

#
# The following pool statement will give you a random set of NTP servers
# geographically close to you.  A single pool statement adds multiple
# servers from the pool, according to the tos minclock/maxclock targets.
# See http://www.pool.ntp.org/ for details.  Note, pool.ntp.org encourages
# users with a static IP and good upstream NTP servers to add a server
# to the pool. See http://www.pool.ntp.org/join.html if you are interested.
#
# The option `iburst' is used for faster initial synchronization.
#
pool 0.freebsd.pool.ntp.org iburst

#
# If you want to pick yourself which country's public NTP server
# you want to sync against, comment out the above pool, uncomment
# the next one, and replace CC with the country's abbreviation.
# Make sure that the hostname resolves to a proper IP address!
#
# pool 0.CC.pool.ntp.org iburst

#
# To configure a specific server, such as an organization-wide local
# server, add lines similar to the following.  One or more specific
# servers can be configured in addition to, or instead of, any server
# pools specified above.  When both are configured, ntpd first adds all
# the specific servers, then adds servers from the pool until the tos
# minclock/maxclock targets are met.
#
#server time.my-internal.org iburst

server 0.north-america.pool.ntp.org
server 1.north-america.pool.ntp.org
server 2.north-america.pool.ntp.org
server 3.north-america.pool.ntp.org

driftfile /var/db/ntp.drift

#
# Security:
#
# By default, only allow time queries and block all other requests
# from unauthenticated clients.
#
# The "restrict source" line allows peers to be mobilized when added by
# ntpd from a pool, but does not enable mobilizing a new peer association
# by other dynamic means (broadcast, manycast, ntpq commands, etc).
#
# See http://support.ntp.org/bin/view/Support/AccessRestrictions
# for more information.
#
restrict default limited kod nomodify notrap noquery nopeer
restrict source  limited kod nomodify notrap noquery

#
# Alternatively, the following rules would block all unauthorized access.
#
#restrict default ignore
#
# In this case, all remote NTP time servers also need to be explicitly
# allowed or they would not be able to exchange time information with
# this server.
#
# Please note that this example doesn't work for the servers in
# the pool.ntp.org domain since they return multiple A records.
#
#restrict 0.pool.ntp.org nomodify nopeer noquery notrap
#restrict 1.pool.ntp.org nomodify nopeer noquery notrap
#restrict 2.pool.ntp.org nomodify nopeer noquery notrap
#
# The following settings allow unrestricted access from the localhost
restrict 127.0.0.1
restrict ::1

#
# If a server loses sync with all upstream servers, NTP clients
# no longer follow that server. The local clock can be configured
# to provide a time source when this happens, but it should usually
# be configured on just one server on a network. For more details see
# http://support.ntp.org/bin/view/Support/UndisciplinedLocalClock
# The use of Orphan Mode may be preferable.
#
#server 127.127.1.0
#fudge 127.127.1.0 stratum 10

# See http://support.ntp.org/bin/view/Support/ConfiguringNTP#Section_6.14.
# for documentation regarding leapfile. Updates to the file can be obtained
# from ftp://time.nist.gov/pub/ or ftp://tycho.usno.navy.mil/pub/ntp/.
# Use either leapfile in /etc/ntp or periodically updated leapfile in /var/db.
#leapfile "/etc/ntp/leap-seconds"
leapfile "/var/db/ntpd.leap-seconds.list"

@ghost
Copy link
Author

ghost commented Jun 19, 2020

  1. cat /etc/resolv.conf 2>/dev/null
# Generated by resolvconf
nameserver 10.0.0.1
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844

@kesselb
Copy link
Collaborator

kesselb commented Jun 19, 2020

Thanks and don't forget to reopen the pr and merge :)

@ghost
Copy link
Author

ghost commented Jun 19, 2020

  1. netstat -rn
Routing tables

Internet:
Destination        Gateway            Flags     Netif Expire
default            10.0.0.1           UGS     epair0b
10.0.0.0/24        link#2             U       epair0b
10.0.0.185         link#2             UHS         lo0
127.0.0.1          link#1             UH          lo0

@ghost ghost reopened this Jun 19, 2020
@ghost
Copy link
Author

ghost commented Jun 19, 2020

  1. /sbin/ifconfig -a
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
        inet6 ::1 prefixlen 128
        inet6 0000::1%lo0 prefixlen 64 scopeid 0x1
        inet 127.0.0.1 netmask 0xff000000
        groups: lo
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
epair0b: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=8<VLAN_MTU>
        ether 00:00:00:00:00:00
        hwaddr 00:00:00:00:00:00
        inet 10.0.0.2 netmask 0xffffff00 broadcast 10.0.0.255
        inet6 0000::00:0000:0000:0000%epair0b prefixlen 64 scopeid 0x2
        groups: epair
        media: Ethernet 10Gbase-T (10Gbase-T <full-duplex>)
        status: active
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
  1. /sbin/ifconfig epair0b
epair0b: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=8<VLAN_MTU>
        ether 00:00:00:00:00:00
        hwaddr 00:00:00:00:00:00
        inet 10.0.0.2 netmask 0xffffff00 broadcast 10.0.0.255
        inet6 0000::00:0000:0000:0000%epair0b prefixlen 64 scopeid 0x2
        groups: epair
        media: Ethernet 10Gbase-T (10Gbase-T <full-duplex>)
        status: active
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
  1. df -TPk
Filesystem                         Type 1024-blocks    Used     Avail Capacity  Mounted on
tank3/iocage/jails/nextcloud/root  zfs    340658208 5655696 335002512     2%    /

@ghost
Copy link
Author

ghost commented Jun 19, 2020

Thanks and don't forget to reopen the pr and merge :)

Oops closed by accident. I cannot merge it myself.

@ghost
Copy link
Author

ghost commented Jun 19, 2020

#172 #203 Should resolve both

@kesselb kesselb merged commit 481df19 into nextcloud:master Jun 19, 2020
@kesselb
Copy link
Collaborator

kesselb commented Jun 19, 2020

Thanks 👍

@VVD
Copy link

VVD commented Jun 19, 2020

  1. "df -TP" use 512 bytes blocks size - correct command is "df -TPk".
  2. No MTU - check 1st line:
ixl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 9198
        options=e507bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,LRO,VLAN_HWFILTER,VLAN_HWTSO,RXCSUM_IPV6,TXCSUM_IPV6>
   
     ether XX:XX:XX:XX:XX:XX
        media: Ethernet autoselect (10Gbase-T <full-duplex>)
        status: active
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
  1. No CPU cores count: "sysctl -n kern.smp.cpus".
  2. Total RAM is hw.realmem, but not hw.physmem.

@ghost
Copy link
Author

ghost commented Jun 19, 2020

Issues 1, 3 and 4 are resolved in #215
Adding mtu is an enhancement and needs to be added to the default OS and the template first. I have no interest in adding mtu so I suggest you create a pull yourself @VVD

@ghost
Copy link
Author

ghost commented Jun 19, 2020

For the record the change is simple for FreeBSD.php

preg_match("/(?<=mtu ).*/m", $intface, $mtu);
$iface['mtu'] = $mtu[0];

@VVD
Copy link

VVD commented Jun 20, 2020

  1. swapinfo need -k same as df: "/usr/sbin/swapinfo -k".

@constrict, I wrote patch 2 months ago: #203.

@ghost
Copy link
Author

ghost commented Jun 20, 2020

Does not seem to be an issue on my box but I have added -k to swapinfo, so that it is always shown in 1k-blocks.

@ghost
Copy link
Author

ghost commented Jun 20, 2020

Does not seem to be an issue on my box but I have added -k to swapinfo, so that it is always shown in 1k-blocks.

Issue is actually in SystemStatistics.php. The swap return is unused in FreeBSD.php.

@EliranHayun
Copy link

Hi all,

I have FreeNAS (FreeBSD) system running Nextcloud 18.0.6
Is there anything I can help with?

Thanks,
Eliran

@Schueni1
Copy link

I'm still getting an 'Internal Server Error' when I try to access settings/admin/serverinfo on FreeBSD 12.1 with NC20.
Shouldn't this already work?

@ghost
Copy link
Author

ghost commented Oct 11, 2020

I'm still getting an 'Internal Server Error' when I try to access settings/admin/serverinfo on FreeBSD 12.1 with NC20.
Shouldn't this already work?

See #245 and #251

@PaulArgoud
Copy link

I'm still getting an 'Internal Server Error' when I try to access settings/admin/serverinfo on FreeBSD 12.1 with NC20.
Shouldn't this already work?

See #245 and #251

Same problem for me, with FreeBSD 12 and NC20...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants