Compare commits

...

15 commits

Author SHA1 Message Date
Muhammad Herdiansyah
56545944d3 Merge branch 'master' into hp-ux 2017-11-09 18:53:29 +07:00
Muhammad Herdiansyah
5d63097994 Memory [HP-UX]: Complete support 2017-07-05 16:50:05 +07:00
Muhammad Herdiansyah
b8c902e65f Uptime [HP-UX]: Remove leading zeroes
Variables with a leading 0 are treated as base-8, so it halts HP-UX
detection because of the error.
2017-07-05 02:19:52 +07:00
Muhammad Herdiansyah
01bbad7c79 Install Date [HP-UX]: Add initial support 2017-07-04 20:13:25 +07:00
Muhammad Herdiansyah
7dac8843f1 Disk [HP-UX]: Add initial support 2017-07-04 19:51:28 +07:00
Muhammad Herdiansyah
9b51f9f528 Memory [HP-UX]: Add partial support 2017-07-04 19:36:29 +07:00
Muhammad Herdiansyah
d233e5bb2e CPU [HP-UX]: Add partial support 2017-07-04 19:29:51 +07:00
Muhammad Herdiansyah
5cb04eccce Distro: Fix typo 2017-07-04 19:14:20 +07:00
Muhammad Herdiansyah
7141db1046 Misc: Shellcheck fix 2017-07-04 19:08:57 +07:00
Muhammad Herdiansyah
af6358fe47 Distro [HP-UX/IRIX]: Make use of the kernel_shorthand feature 2017-07-04 19:06:55 +07:00
Muhammad Herdiansyah
53148c1ffe Merge master branch into hp-ux 2017-07-04 18:54:17 +07:00
Dylan Araps
c3901fbc2a Packages: Add support for HP-UX 2017-01-19 14:12:07 +11:00
Dylan Araps
68630a125e Uptime: Add support for HP-UX 2017-01-19 14:08:57 +11:00
Dylan Araps
e8bd2975e0 Model: Add support for HP-UX 2017-01-19 14:04:59 +11:00
Dylan Araps
9a7b4c3871 OS: Add initial support for HP-UX 2017-01-19 13:59:20 +11:00

View file

@ -44,6 +44,7 @@ get_os() {
"MINIX") os="MINIX" ;; "MINIX") os="MINIX" ;;
"AIX") os="AIX" ;; "AIX") os="AIX" ;;
"IRIX64") os="IRIX" ;; "IRIX64") os="IRIX" ;;
"HP-UX") os="HP-UX" ;;
*) *)
printf "%s\n" "Unknown OS detected: '$kernel_name', aborting..." >&2 printf "%s\n" "Unknown OS detected: '$kernel_name', aborting..." >&2
printf "%s\n" "Open an issue on GitHub to add support for your OS." >&2 printf "%s\n" "Open an issue on GitHub to add support for your OS." >&2
@ -226,8 +227,11 @@ get_distro() {
distro="AIX $(oslevel)" distro="AIX $(oslevel)"
;; ;;
"IRIX") "IRIX" | "HP-UX")
distro="IRIX ${kernel_version}" distro="$os ${kernel_version}"
case "$distro_shorthand" in
"on" | "tiny") distro="${distro/ ${kernel_version}}" ;;
esac
;; ;;
esac esac
@ -339,6 +343,10 @@ get_model() {
"AIX") "AIX")
model="$(/usr/bin/uname -M)" model="$(/usr/bin/uname -M)"
;; ;;
"HP-UX")
model="$(model)"
;;
esac esac
# Remove dummy OEM info. # Remove dummy OEM info.
@ -368,8 +376,8 @@ get_title() {
} }
get_kernel() { get_kernel() {
# Since these OS are integrated systems, it's better to skip this function altogether # Since AIX has no useful output in uname, it's better to skip this function altogether
[[ "$os" =~ (AIX|IRIX) ]] && return [[ "$os" == "AIX" ]] && return
case "$kernel_shorthand" in case "$kernel_shorthand" in
"on") kernel="$kernel_version" ;; "on") kernel="$kernel_version" ;;
@ -377,7 +385,7 @@ get_kernel() {
esac esac
# Hide kernel info if it's identical to the distro info. # Hide kernel info if it's identical to the distro info.
if [[ "$os" =~ (BSD|MINIX) && "$distro" == *"$kernel_name"* ]]; then if [[ "$os" =~ (BSD|MINIX|IRIX|HP-UX) && "$distro" == *"$kernel_name"* ]]; then
case "$distro_shorthand" in case "$distro_shorthand" in
"on" | "tiny") kernel="$kernel_version" ;; "on" | "tiny") kernel="$kernel_version" ;;
*) unset kernel ;; *) unset kernel ;;
@ -417,8 +425,8 @@ get_uptime() {
seconds="${seconds/.*}" seconds="${seconds/.*}"
;; ;;
"AIX" | "IRIX") "AIX" | "IRIX" | "HP-UX")
t="$(LC_ALL=POSIX ps -o etime= -p 1)" t="$(LC_ALL=POSIX UNIX95=1 ps -o etime= -p 1)"
d="0" h="0" d="0" h="0"
case "$t" in *"-"*) d="${t%%-*}"; t="${t#*-}";; esac case "$t" in *"-"*) d="${t%%-*}"; t="${t#*-}";; esac
case "$t" in *":"*":"*) h="${t%%:*}"; t="${t#*:}";; esac case "$t" in *":"*":"*) h="${t%%:*}"; t="${t#*:}";; esac
@ -599,6 +607,10 @@ get_packages() {
"IRIX") "IRIX")
packages="$(($(versions -b | wc -l)-3))" packages="$(($(versions -b | wc -l)-3))"
;; ;;
"HP-UX")
packages="$(($(swlist -l product | wc -l)-6))"
;;
esac esac
((packages == 0)) && unset packages ((packages == 0)) && unset packages
@ -1070,6 +1082,18 @@ get_cpu() {
# Get CPU cores. # Get CPU cores.
cores="$(sysconf NPROC_ONLN)" cores="$(sysconf NPROC_ONLN)"
;; ;;
"HP-UX")
# Get CPU name.
# This will be partial for now, because apparently hppa and
# IA64 has different approaches of how it should be handled.
# Get CPU speed.
# Same reasons as above.
# Get CPU cores.
cores="$(ioscan -k | grep -c "processor")"
;;
esac esac
# Remove un-needed patterns from cpu output. # Remove un-needed patterns from cpu output.
@ -1405,6 +1429,13 @@ get_memory() {
mem_free="$((mem_stat[5] / 1024))" mem_free="$((mem_stat[5] / 1024))"
mem_used="$((mem_total - mem_free))" mem_used="$((mem_total - mem_free))"
;; ;;
"HP-UX")
mem_total="$(machinfo | awk -F':' '/Memory/ {print $2}')"
mem_total="${mem_total/MB*}"
mem_free="$(($(vmstat | awk 'NR==3{printf $5}') / 1024))"
mem_used="$((mem_total - mem_free))"
;;
esac esac
memory="${mem_used}${mem_label:-MiB} / ${mem_total}${mem_label:-MiB}" memory="${mem_used}${mem_label:-MiB} / ${mem_total}${mem_label:-MiB}"
@ -2044,7 +2075,10 @@ get_disk() {
# Create an array called 'disks' where each element is a separate line from # Create an array called 'disks' where each element is a separate line from
# df's output. We then unset the first element which removes the column titles. # df's output. We then unset the first element which removes the column titles.
IFS=$'\n' IFS=$'\n'
disks=($(df "${df_flags[@]}" "${disk_show[@]:-/}")) case "$os" in
"HP-UX") disks=($(bdf "${disk_show[@]:-/}" 2>/dev/null)); df_version="bdf" ;;
*) disks=($(df "${df_flags[@]}" "${disk_show[@]:-/}" 2>/dev/null)) ;;
esac
unset 'disks[0]' unset 'disks[0]'
IFS="$old_ifs" IFS="$old_ifs"
@ -2060,9 +2094,10 @@ get_disk() {
disk_perc="${disk_info[4]/'%'}" disk_perc="${disk_info[4]/'%'}"
case "$df_version" in case "$df_version" in
*"befhikm"*) *"befhikm"*|"bdf")
disk="$((disk_info[2]/1024/1024))G / $((disk_info[1]/1024/1024))G (${disk_perc}%)" disk="$((disk_info[2]/1024/1024))G / $((disk_info[1]/1024/1024)) (${disk_perc}%)"
;; ;;
*) disk="${disk_info[2]/i} / ${disk_info[1]/i} (${disk_perc}%)" ;; *) disk="${disk_info[2]/i} / ${disk_info[1]/i} (${disk_perc}%)" ;;
esac esac
@ -2240,6 +2275,7 @@ get_install_date() {
esac esac
;; ;;
"AIX") install_file="/var/adm/ras/bosinstlog" ;; "AIX") install_file="/var/adm/ras/bosinstlog" ;;
"HP-UX") install_file="/dev/config" ;;
esac esac
ls_prog="$(ls --version 2>&1)" ls_prog="$(ls --version 2>&1)"
@ -2260,7 +2296,7 @@ get_install_date() {
install_date="$(ls -tcd --full-time "$install_file" | awk '{printf $6 " " $7}')" install_date="$(ls -tcd --full-time "$install_file" | awk '{printf $6 " " $7}')"
;; ;;
*"ACFHLNRS"* | *"RadC1xmnlog"*) # AIX ls / IRIX ls *"ACFHLNRS"* | *"RadC1xmnlog"* | *"1ARadeCx"*) # AIX ls / IRIX ls / HP-UX ls
err "Install Date doesn't work because your 'ls' doesn't support full date/time." err "Install Date doesn't work because your 'ls' doesn't support full date/time."
return return
;; ;;