Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
distro_info
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
korinf
distro_info
Commits
373a89ea
Commit
373a89ea
authored
Oct 10, 2020
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
distro_info: add -c: print number of available CPU cores
parent
e7a4eeda
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
distro_info
bin/distro_info
+31
-0
No files found.
bin/distro_info
View file @
373a89ea
...
@@ -454,6 +454,32 @@ print_name_version()
...
@@ -454,6 +454,32 @@ print_name_version()
[
-n
"
$DISTRIB_RELEASE
"
]
&&
echo
$DISTRIB_ID
/
$DISTRIB_RELEASE
||
echo
$DISTRIB_ID
[
-n
"
$DISTRIB_RELEASE
"
]
&&
echo
$DISTRIB_ID
/
$DISTRIB_RELEASE
||
echo
$DISTRIB_ID
}
}
get_core_count
()
{
local
detected
=
""
local
DIST_OS
=
"
$(
get_base_os_name
)
"
case
"
$DIST_OS
"
in
macos|freebsd
)
detected
=
$(
sysctl hw.ncpu |
awk
'{print $2}'
)
;;
linux
)
detected
=
$(
grep
-c
"^processor"
/proc/cpuinfo
)
;;
solaris
)
detected
=
$(
prtconf |
grep
-c
'cpu[^s]'
)
;;
aix
)
detected
=
$(
lsdev
-Cc
processor
-S
A |
wc
-l
)
;;
# *)
# fatal "Unsupported OS $DIST_OS"
esac
[
-n
"
$detected
"
]
||
detected
=
0
echo
$detected
}
get_virt
()
get_virt
()
{
{
local
VIRT
local
VIRT
...
@@ -505,6 +531,7 @@ Pretty distro name (--pretty): $(print_pretty_name)
...
@@ -505,6 +531,7 @@ Pretty distro name (--pretty): $(print_pretty_name)
Packaging system (-p):
$(
pkgtype
)
Packaging system (-p):
$(
pkgtype
)
Running service manager (-y):
$(
get_service_manager
)
Running service manager (-y):
$(
get_service_manager
)
Virtualization (-i):
$(
get_virt
)
Virtualization (-i):
$(
get_virt
)
CPU Cores (-c):
$(
get_core_count
)
CPU Architecture (-a):
$(
get_arch
)
CPU Architecture (-a):
$(
get_arch
)
CPU norm register size (-b):
$(
get_bit_size
)
CPU norm register size (-b):
$(
get_bit_size
)
System memory size (MB) (-m):
$(
get_memory_size
)
System memory size (MB) (-m):
$(
get_memory_size
)
...
@@ -522,6 +549,7 @@ case $1 in
...
@@ -522,6 +549,7 @@ case $1 in
echo
"Options:"
echo
"Options:"
echo
" -a - print hardware architecture"
echo
" -a - print hardware architecture"
echo
" -b - print size of arch bit (32/64)"
echo
" -b - print size of arch bit (32/64)"
echo
" -c - print number of CPU cores"
echo
" -d - print distro name"
echo
" -d - print distro name"
echo
" -e - print full name of distro with version"
echo
" -e - print full name of distro with version"
echo
" -i - print virtualization type"
echo
" -i - print virtualization type"
...
@@ -556,6 +584,9 @@ case $1 in
...
@@ -556,6 +584,9 @@ case $1 in
-b
)
-b
)
get_bit_size
get_bit_size
;;
;;
-c
)
get_core_count
;;
-i
)
-i
)
get_virt
get_virt
;;
;;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment