source: src-sh/warden/scripts/backend/details.sh @ 22842a8

9.1-release9.2-releasereleng/10.0releng/10.0.1
Last change on this file since 22842a8 was 22842a8, checked in by Kris Moore <kris@…>, 12 months ago

Fix bugs checking for updates to a jail and showing MB usage on disk

  • Property mode set to 100755
File size: 2.3 KB
Line 
1#!/bin/sh
2# Script to check a jail status
3# Args $1 = JAILNAME
4######################################################################
5
6# Source our functions
7PROGDIR="/usr/local/share/warden"
8
9# Source our variables
10. ${PROGDIR}/scripts/backend/functions.sh
11
12JAILNAME="$1"
13
14if [ -z "${JAILNAME}" ]
15then
16  echo "ERROR: You must specify a jail to check"
17  exit 5
18fi
19
20if [ -z "${JDIR}" ]
21then
22  echo "ERROR: JDIR is unset!!!!"
23  exit 5
24fi
25
26JAILDIR="${JDIR}/${JAILNAME}"
27
28if [ ! -d "${JAILDIR}" ]
29then
30  echo "ERROR: No jail located at ${JAILDIR}"
31  exit 5
32fi
33
34set_warden_metadir
35
36IP4="`cat ${JMETADIR}/ipv4 2>/dev/null`"
37if [ -n "${IP4}" ] ; then
38  get_ip_and_netmask "${IP4}"
39  IP4="${JIP}"
40  MASK4="${JMASK}"
41fi
42
43IP6="`cat ${JMETADIR}/ipv6 2>/dev/null`"
44if [ -n "${IP6}" ] ; then
45  get_ip_and_netmask "${IP6}"
46  IP6="${JIP}"
47  MASK6="${JMASK}"
48fi
49
50# Display details about this jail now
51#####################################################################
52echo "Details for jail: ${JAILNAME}"
53isDirZFS "${JAILDIR}" "1"
54if [ $? -eq 0 ] ; then
55   tank=`getZFSDataset "${JAILDIR}"`
56   diskUsage=`df -m | grep -w "^${tank} " | awk '{print $3}'`
57else
58   diskUsage=`du -c -x -m ${JAILDIR} 2>/dev/null | grep total | tail -n 1 | awk '{print $1}'`
59fi
60
61portList4=
62activeCon4=
63if [ -n "${IP4}" ] ; then
64   sockstat | grep "${IP4}" | grep '*.*' | awk '{print $6}' | sed "s|${IP4}:||g" | sort -g | uniq >/tmp/.socklist4.$$
65   while read line
66   do
67     if [ -z "$portList4" ] ; then
68       portList4="${line}" 
69     else
70       portList4="${portList4},$line" 
71     fi
72   done < /tmp/.socklist4.$$
73   rm /tmp/.socklist4.$$
74   activeCon4=`sockstat | grep "${IP4}" | grep -v '*.*' | wc -l | awk '{print $1}'`
75fi
76
77portList6=
78activeCon6=
79if [ -n "${IP6}" ] ; then
80   sockstat | grep "${IP6}" | grep '*.*' | awk '{print $6}' | sed "s|${IP6}:||g" | sort -g | uniq >/tmp/.socklist6.$$
81   while read line
82   do
83     if [ -z "$portList6" ] ; then
84       portList6="${line}" 
85     else
86       portList6="${portList6},$line" 
87     fi
88   done < /tmp/.socklist6.$$
89   rm /tmp/.socklist6.$$
90   activeCon6=`sockstat | grep "${IP6}" | grep -v '*.*' | wc -l | awk '{print $1}'`
91fi
92
93echo "Disk Usage: ${diskUsage}MB"
94
95echo "Active IPv4 Ports: ${portList4}"
96echo "Current IPv4 Connections: ${activeCon4}"
97
98echo "Active IPv6 Ports: ${portList6}"
99echo "Current IPv6 Connections: ${activeCon6}"
Note: See TracBrowser for help on using the repository browser.