-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathenv.Rmd
118 lines (99 loc) · 3.9 KB
/
env.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Cloud environment
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Basic Info
```{r message=FALSE, warning=FALSE, echo=FALSE}
pacman::p_load(RMySQL)
pacman::p_load(configr)
conf_raw <- read.config('../conf/config.json')
#conf <- conf_raw$mysql
#conn <- dbConnect(MySQL(), dbname = conf$database, username=conf$username,
# password=conf$password, host=conf$host, port=conf$port)
#raw <- dbReadTable(conn, "users")
json <- system('cd ../conf/baidu; sh fetch.sh pv', intern = TRUE)
json <- configr::str2config(paste0(json, '\n'))
json <- as.data.frame(json$body$data$result$items[[1]][2])
total_pv <- suppressWarnings(sum(as.numeric(json[,1]), na.rm = T))
total_visitor <- suppressWarnings(sum(as.numeric(json[,2]), na.rm = T))
Term <- c('Hiplot Version', "Total (PV)", "Total (UV)", 'Update Date')
Value <- c(conf_raw$version, total_pv, total_visitor, as.character( Sys.time()))
dat <- data.frame(Term, Value)
x <- write.config(as.list(dat), "/app/hiplot/dist/docs/pv.json", write.type = "json")
knitr::kable(dat, row.names = F)
```
## System Info
```{r message=FALSE, warning=FALSE, echo=FALSE}
dat <- as.data.frame(data.table::fread("cat /proc/cpuinfo", fill=T, sep = '\t'))
dat <- dat[,c(1,3)]
dat[,2] <- stringr::str_replace(dat[,2], ' :|:', '')
dat <- dat[!duplicated(dat[,1]),]
colnames(dat) <- c('Term', 'Info')
total_logical_num <- system("cat /proc/cpuinfo| grep 'processor'| wc -l", intern = TRUE)
physical_num <- system("cat /proc/cpuinfo| grep 'physical id'| sort| uniq| wc -l", intern = TRUE)
core_num_per <- system("cat /proc/cpuinfo| grep 'cpu cores'| uniq | sed 's/.* //'", intern = TRUE)
loadavg <- data.table::fread("cat /proc/loadavg", data.table = FALSE)
tmp <- data.frame(Term=c("Linux Kernel", "Total Logical Cores", "Physical CPU", "Cores Per CPU", "Load Avg"),
Info=c(system('uname -s -r', intern = TRUE), total_logical_num, physical_num, core_num_per, loadavg[1, 4]))
dat <- rbind(tmp, dat)
dat_cpu <- dat[dat[,2] != '',]
Tag <- rep('cpu', nrow(dat_cpu))
Tag[1] <- 'linux'
dat_cpu <- cbind(dat_cpu, Tag)
dat <- as.data.frame(data.table::fread('cat /proc/meminfo', fill = TRUE))
dat <- dat[,1:2]
use_kb <- dat[,2] < 1024
use_mb <- dat[,2] >= 1024
use_gb <- dat[,2] >= 1024 * 1024
use_tb <- dat[,2] >= 1024 * 1024 * 1024
use_pb <- dat[,2] >= 1024 * 1024 * 1024 * 1024
dat$Size <- NA
if (sum(use_kb) > 0) {
dat[use_kb,3] <- paste0(dat[use_kb,2], ' KB')
}
if (sum(use_mb) > 0) {
dat[use_mb,3] <- paste0(round(dat[use_mb,2] / 1024, 2), ' MB')
}
if (sum(use_gb) > 0) {
dat[use_gb,3] <- paste0(round(dat[use_gb,2] / (1024 * 1024), 2), ' GB')
}
if (sum(use_tb) > 0) {
dat[use_tb,3] <- paste0(round(dat[use_tb,2] / (1024 * 1024 * 1024), 2), ' TB')
}
if (sum(use_pb) > 0) {
dat[use_pb,3] <- paste0(round(dat[use_pb,2] / (1024 * 1024 * 1024 * 1024), 2), ' PB')
}
dat <- dat[,-2]
colnames(dat) <- c('Term', "Info")
Tag <- rep('mem', nrow(dat))
dat_mem <- cbind(dat, Tag)
dat <- data.table::fread("df -h /| sed 's/ */\t/g' | cut -f 2,3,4,5")
dat_disk <- as.data.frame(t(dat))
dat_disk <- cbind(row.names(dat_disk), dat_disk)
dat_disk[,1] <- paste0('DISK ', dat_disk[,1])
dat_disk$Tag <- "disk"
colnames(dat_disk)[1:2] <- c('Term', "Info")
dat <- rbind(dat_cpu, dat_mem, dat_disk)
dat[,1] <- Hmisc::capitalize(dat[,1])
x <- write.config(as.list(dat), "/app/hiplot/dist/docs/hardware.json", write.type = "json")
knitr::kable(dat, row.names = F)
```
## Installed RPM packages
```{r message=FALSE, warning=FALSE, echo=FALSE}
dat <- read.csv('data/yum_installed_pkgs.txt', sep = '\t')
knitr::kable(dat, row.names = F)
```
## Installed R Packages
```{r message=FALSE, warning=FALSE, echo=FALSE}
dat <- installed.packages()[,c(1,3, 10, 16)]
knitr::kable(dat, row.names = F)
```
## Installed Python packages
```{r message=FALSE, warning=FALSE, echo=FALSE}
dat <- BioInstaller::conda.list()
knitr::kable(dat, row.names = F)
```
## Sessioninfo
```{r message=FALSE, warning=FALSE, echo=FALSE}
sessioninfo::session_info()
```