File: sysinfo

package info (click to toggle)
konversation 1.3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 17,080 kB
  • ctags: 4,900
  • sloc: cpp: 45,134; perl: 475; python: 397; sh: 211; makefile: 9
file content (81 lines) | stat: -rwxr-xr-x 1,723 bytes parent folder | download | duplicates (2)
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
#!/bin/sh
#
# Licensed under GPL v2 or later at your option
# Copyright 2004 by Michiel de Boer <infobash@rebelhomicide.demon.nl>
# Copyright 2006 by Emil Obermayr <nobs@tigress.com>
#
# this version is stripped down to no-color
#
# get full original version at http://rebelhomicide.demon.nl/scripts/

SERVER=$1;
TARGET=$2;

export LC_ALL="C"

HN="$(hostname)"
OSKERN="$(uname -s) $(uname -r)"
if [ "$KDE_FULL_SESSION" = "true" ]; then
	if [ "$KDE_SESSION_VERSION" = 4 ];  then
		KDE="$(kde4-config --version | sed -n '2p' | sed 's/://;s/ *$//')"
	else
		KDE="$(kde-config --version | sed -n '2p' | sed 's/://;s/ *$//')"
	fi
fi

CPU=$(awk -F':' '/model name/{name=$2}
 /cpu MHz/{mhz=int($2)}
 /bogomips/ {bogo=int($2) 
}
END{
 gsub (/ *\(tm\) */, " ", name);
 gsub (/ *\(TM\) */, " ", name);
 gsub (/ *Processor */, " ", name);
 gsub (/ *$/, "", name);
 gsub (/^ */, "", name);
 printf "CPU: %s at %d MHz (%d bogomips)", name, mhz, bogo;
}
' /proc/cpuinfo )
  
HDD=$(df -lP| awk '($1~/\/dev/){
  use+=$3/1024^2;
  tot+=$2/1024^2;
 }
 END{print "HD: " int(use) "/" int(tot) "GB"}')

MEM=$(awk '($1=="MemTotal:"){tot=int($2/1024)}
 ($1=="MemFree:"){free=int($2/1024)}
 END{
use=tot-free
print "RAM: " use "/" tot "MB"}
' /proc/meminfo)

PROC="$(($(ps aux | wc -l)-1))"

UPT=$(awk '{u="s";
n=$1;
if (n>60){
 n2=n%60;
 n/=60;
 u="min";
 if (n>60){
  n2=n%60;
  n/=60;
  u="h";
  if (n>24){
   n2=n%24;
   n/=24;
   u="d"; 
   }
  }
 }
printf ("%d.%d%s up",n, n2, u);
}' /proc/uptime )

out="Sysinfo for '$HN': $OSKERN running $KDE, $CPU, $HDD, $MEM, $PROC proc's, ${UPT}" 

if [ "x$TARGET" = "x" ] ; then
    qdbus org.kde.konversation /irc error "$out"
else
    qdbus org.kde.konversation /irc say $SERVER "$TARGET" "$out"
fi