aims-collect-support-data 3.05 KB
Newer Older
Jonathan Carter's avatar
Jonathan Carter committed
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
#!/bin/bash

mkdir -p ~/.aims
LOGFILE=~/.aims/$HOSTNAME
WELCOME="This script will post system information on a public pastebin for support purposes. You will have a chance to review the data before the information is posted. Afterwards, you will receive a link that you can submit to your support department containing the support data."

if [ "$1" = "gui" ]; then
    zenity --title "AIMS Desktop Support" --info --text "$WELCOME" --icon-name="aims-starburst" --width=480
fi
if [ "$1" = "menu" ]; then
    whiptail --title "AIMS Desktop Support" --msgbox \
             "$WELCOME Use the arrow buttons to navigate and ENTER to select." 12 70
fi

echo " * Writing data to $LOGFILE..."

(
    echo -e "== Basic System Information ==\n"
    echo    " * System Time: $(date)"
    echo    " * Hostname: $HOSTNAME"
    echo    " * Username: $USER"
    echo    " * Kernel Version: $(uname -r)"
) > $LOGFILE

echo -e "\n== Memory Information ==\n" >> $LOGFILE
free -h >> $LOGFILE

echo -e "\n== Top Memory Using Processes ==\n" >> $LOGFILE
echo '%Mem Process' >> $LOGFILE
ps ax -o %mem -o comm | tail -n+2 | sort -nr | head >> $LOGFILE

echo -e "\n== Disk Space Usage==\n" >> $LOGFILE
df -h >> $LOGFILE

echo -e "\n== PCI Devices ==\n" >> $LOGFILE
lspci >> $LOGFILE

echo -e "\n== Attached USB Devices ==\n" >> $LOGFILE
lsusb >> $LOGFILE

echo -e "\n== Network Configuration ==\n" >> $LOGFILE
echo "Routing:" >> $LOGFILE
/sbin/route >> $LOGFILE
echo -e "\nInterfaces:" >> $LOGFILE
/sbin/ifconfig >> $LOGFILE

echo -e "\n== APT Status ==\n" >> $LOGFILE
echo -e "Contents of /etc/apt/sources.list.d/:" >> $LOGFILE
ls -1 /etc/apt/sources.list.d >> $LOGFILE

echo -e "\n== CPU Information ==\n" >> $LOGFILE
cat /proc/cpuinfo >> $LOGFILE

if [ "$1" = "menu" ]; then
    whiptail --scrolltext --title "AIMS Desktop Support" --textbox $LOGFILE 23 78
    whiptail --title "AIMS Desktop Support" --yesno "    Submit data to pastebin?" 7 38
    if [ "$?" = "1" ]; then
        ACTION="abort"
    fi
fi
if [ "$1" = "gui" ]; then
    zenity --title "AIMS Desktop Support" --text-info --filename=$LOGFILE --ok-label="Submit to Pastebin" --width=480 --height=600
    if [ "$?" = "1" ]; then
        ACTION="abort"
    fi
fi

if [ "$ACTION" = "abort" ]; then
    ABORT_TEXT="Support request aborted."
    if [ "$1" = "menu" ]; then
        whiptail --title "AIMS Desktop Support" --msgbox "$ABORT_TEXT." 10 48 
    fi
    if [ "$1" = "gui" ]; then
        zenity --title "AIMS Desktop Support" --info --text "$ABORT_TEXT" --icon-name="aims-starburst"
    fi
    exit 1
fi

echo " * Sending information to pastebin..."
pastebinurl=$(pastebinit $LOGFILE)
INFOTEXT="Information has been posted to $pastebinurl. Share that URL with your IT centre for further assistance."

if [ "$1" = "menu" ]; then
    whiptail --title "AIMS Desktop Support" --msgbox "$INFOTEXT" 10 48
fi
if [ "$1" = "gui" ]; then
    zenity --title "AIMS Desktop Support" --info --text "Information has been posted to $pastebinurl. Share that URL with your IT centre for further assistance." --icon-name="aims-starburst" --width=480
fi

echo " * Pastebin URL is $pastebinurl"