logs filesystem type on startup (#5558)

Signed-off-by: Lee Gaines <leetgaines@gmail.com>
This commit is contained in:
Lee Gaines 2019-05-17 02:16:16 -07:00 committed by Brian Brazil
parent 04f22700b7
commit f4486815c1
5 changed files with 263 additions and 0 deletions

View File

@ -657,6 +657,7 @@ func main() {
if err != nil {
return errors.Wrapf(err, "opening storage failed")
}
level.Info(logger).Log("fs_type", prom_runtime.Statfs(cfg.localStoragePath))
level.Info(logger).Log("msg", "TSDB started")
level.Debug(logger).Log("msg", "TSDB options",
"MinBlockDuration", cfg.tsdb.MinBlockDuration,

22
pkg/runtime/statfs.go Normal file
View File

@ -0,0 +1,22 @@
// Copyright 2017 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build openbsd windows netbsd
package runtime
// Statfs returns the file system type (Unix only)
// syscall.Statfs_t isn't available on openbsd
func Statfs(path string) string {
return "unknown"
}

View File

@ -0,0 +1,83 @@
// Copyright 2017 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build !windows,!openbsd,!netbsd
// +build !386
package runtime
import (
"strconv"
"syscall"
)
// Statfs returns the file system type (Unix only)
func Statfs(path string) string {
// Types of file systems that may be returned by `statfs`
fsTypes := map[int64]string{
0xadf5: "ADFS_SUPER_MAGIC",
0xADFF: "AFFS_SUPER_MAGIC",
0x42465331: "BEFS_SUPER_MAGIC",
0x1BADFACE: "BFS_MAGIC",
0xFF534D42: "CIFS_MAGIC_NUMBER",
0x73757245: "CODA_SUPER_MAGIC",
0x012FF7B7: "COH_SUPER_MAGIC",
0x28cd3d45: "CRAMFS_MAGIC",
0x1373: "DEVFS_SUPER_MAGIC",
0x00414A53: "EFS_SUPER_MAGIC",
0x137D: "EXT_SUPER_MAGIC",
0xEF51: "EXT2_OLD_SUPER_MAGIC",
0xEF53: "EXT4_SUPER_MAGIC",
0x4244: "HFS_SUPER_MAGIC",
0xF995E849: "HPFS_SUPER_MAGIC",
0x958458f6: "HUGETLBFS_MAGIC",
0x9660: "ISOFS_SUPER_MAGIC",
0x72b6: "JFFS2_SUPER_MAGIC",
0x3153464a: "JFS_SUPER_MAGIC",
0x137F: "MINIX_SUPER_MAGIC",
0x138F: "MINIX_SUPER_MAGIC2",
0x2468: "MINIX2_SUPER_MAGIC",
0x2478: "MINIX2_SUPER_MAGIC2",
0x4d44: "MSDOS_SUPER_MAGIC",
0x564c: "NCP_SUPER_MAGIC",
0x6969: "NFS_SUPER_MAGIC",
0x5346544e: "NTFS_SB_MAGIC",
0x9fa1: "OPENPROM_SUPER_MAGIC",
0x9fa0: "PROC_SUPER_MAGIC",
0x002f: "QNX4_SUPER_MAGIC",
0x52654973: "REISERFS_SUPER_MAGIC",
0x7275: "ROMFS_MAGIC",
0x517B: "SMB_SUPER_MAGIC",
0x012FF7B6: "SYSV2_SUPER_MAGIC",
0x012FF7B5: "SYSV4_SUPER_MAGIC",
0x01021994: "TMPFS_MAGIC",
0x15013346: "UDF_SUPER_MAGIC",
0x00011954: "UFS_MAGIC",
0x9fa2: "USBDEVICE_SUPER_MAGIC",
0xa501FCF5: "VXFS_SUPER_MAGIC",
0x012FF7B4: "XENIX_SUPER_MAGIC",
0x58465342: "XFS_SUPER_MAGIC",
0x012FD16D: "_XIAFS_SUPER_MAGIC",
}
var fs syscall.Statfs_t
err := syscall.Statfs(path, &fs)
if err != nil {
return strconv.FormatInt(int64(fs.Type), 16)
}
if fsType, ok := fsTypes[int64(fs.Type)]; ok {
return fsType
}
return strconv.FormatInt(int64(fs.Type), 16)
}

View File

@ -0,0 +1,79 @@
// Copyright 2017 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build !windows !openbsd !darwin !freebsd !netbsd
// +build linux,386
package runtime
import (
"strconv"
"syscall"
)
// Statfs returns the file system type (Unix only)
func Statfs(path string) string {
// Types of file systems that may be returned by `statfs`
fsTypes := map[int32]string{
0xadf5: "ADFS_SUPER_MAGIC",
0xADFF: "AFFS_SUPER_MAGIC",
0x42465331: "BEFS_SUPER_MAGIC",
0x1BADFACE: "BFS_MAGIC",
0x73757245: "CODA_SUPER_MAGIC",
0x012FF7B7: "COH_SUPER_MAGIC",
0x28cd3d45: "CRAMFS_MAGIC",
0x1373: "DEVFS_SUPER_MAGIC",
0x00414A53: "EFS_SUPER_MAGIC",
0x137D: "EXT_SUPER_MAGIC",
0xEF51: "EXT2_OLD_SUPER_MAGIC",
0xEF53: "EXT4_SUPER_MAGIC",
0x4244: "HFS_SUPER_MAGIC",
0x9660: "ISOFS_SUPER_MAGIC",
0x72b6: "JFFS2_SUPER_MAGIC",
0x3153464a: "JFS_SUPER_MAGIC",
0x137F: "MINIX_SUPER_MAGIC",
0x138F: "MINIX_SUPER_MAGIC2",
0x2468: "MINIX2_SUPER_MAGIC",
0x2478: "MINIX2_SUPER_MAGIC2",
0x4d44: "MSDOS_SUPER_MAGIC",
0x564c: "NCP_SUPER_MAGIC",
0x6969: "NFS_SUPER_MAGIC",
0x5346544e: "NTFS_SB_MAGIC",
0x9fa1: "OPENPROM_SUPER_MAGIC",
0x9fa0: "PROC_SUPER_MAGIC",
0x002f: "QNX4_SUPER_MAGIC",
0x52654973: "REISERFS_SUPER_MAGIC",
0x7275: "ROMFS_MAGIC",
0x517B: "SMB_SUPER_MAGIC",
0x012FF7B6: "SYSV2_SUPER_MAGIC",
0x012FF7B5: "SYSV4_SUPER_MAGIC",
0x01021994: "TMPFS_MAGIC",
0x15013346: "UDF_SUPER_MAGIC",
0x00011954: "UFS_MAGIC",
0x9fa2: "USBDEVICE_SUPER_MAGIC",
0x012FF7B4: "XENIX_SUPER_MAGIC",
0x58465342: "XFS_SUPER_MAGIC",
0x012FD16D: "_XIAFS_SUPER_MAGIC",
}
var fs syscall.Statfs_t
err := syscall.Statfs(path, &fs)
if err != nil {
return strconv.Itoa(int(fs.Type))
}
if fsType, ok := fsTypes[fs.Type]; ok {
return fsType
}
return strconv.Itoa(int(fs.Type))
}

View File

@ -0,0 +1,78 @@
// Copyright 2017 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build 386,darwin 386,freebsd
package runtime
import (
"strconv"
"syscall"
)
// Statfs returns the file system type (Unix only)
func Statfs(path string) string {
// Types of file systems that may be returned by `statfs`
fsTypes := map[uint32]string{
0xadf5: "ADFS_SUPER_MAGIC",
0xADFF: "AFFS_SUPER_MAGIC",
0x42465331: "BEFS_SUPER_MAGIC",
0x1BADFACE: "BFS_MAGIC",
0x73757245: "CODA_SUPER_MAGIC",
0x012FF7B7: "COH_SUPER_MAGIC",
0x28cd3d45: "CRAMFS_MAGIC",
0x1373: "DEVFS_SUPER_MAGIC",
0x00414A53: "EFS_SUPER_MAGIC",
0x137D: "EXT_SUPER_MAGIC",
0xEF51: "EXT2_OLD_SUPER_MAGIC",
0xEF53: "EXT4_SUPER_MAGIC",
0x4244: "HFS_SUPER_MAGIC",
0x9660: "ISOFS_SUPER_MAGIC",
0x72b6: "JFFS2_SUPER_MAGIC",
0x3153464a: "JFS_SUPER_MAGIC",
0x137F: "MINIX_SUPER_MAGIC",
0x138F: "MINIX_SUPER_MAGIC2",
0x2468: "MINIX2_SUPER_MAGIC",
0x2478: "MINIX2_SUPER_MAGIC2",
0x4d44: "MSDOS_SUPER_MAGIC",
0x564c: "NCP_SUPER_MAGIC",
0x6969: "NFS_SUPER_MAGIC",
0x5346544e: "NTFS_SB_MAGIC",
0x9fa1: "OPENPROM_SUPER_MAGIC",
0x9fa0: "PROC_SUPER_MAGIC",
0x002f: "QNX4_SUPER_MAGIC",
0x52654973: "REISERFS_SUPER_MAGIC",
0x7275: "ROMFS_MAGIC",
0x517B: "SMB_SUPER_MAGIC",
0x012FF7B6: "SYSV2_SUPER_MAGIC",
0x012FF7B5: "SYSV4_SUPER_MAGIC",
0x01021994: "TMPFS_MAGIC",
0x15013346: "UDF_SUPER_MAGIC",
0x00011954: "UFS_MAGIC",
0x9fa2: "USBDEVICE_SUPER_MAGIC",
0x012FF7B4: "XENIX_SUPER_MAGIC",
0x58465342: "XFS_SUPER_MAGIC",
0x012FD16D: "_XIAFS_SUPER_MAGIC",
}
var fs syscall.Statfs_t
err := syscall.Statfs(path, &fs)
if err != nil {
return strconv.Itoa(int(fs.Type))
}
if fsType, ok := fsTypes[fs.Type]; ok {
return fsType
}
return strconv.Itoa(int(fs.Type))
}