xymon

Check-in [002a03e592]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:r7356 from 4.3: Solaris client: Fix memory report when no swap configured, and fix reporting for hosts using zones. From Andy Smith http://lists.xymon.com/archive/2014-January/038845.html git-svn-id: http://svn.code.sf.net/p/xymon/code/trunk@7402 44351d6e-118b-4698-b696-ce33095ecaa4
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | master
Files: files | file ages | folders
SHA3-256: 002a03e592d7a1bf6145b5e270ec567b40e070c64ec9ad1e59cce27cddb117ad
User & Date: storner@users.sf.net 2014-02-09 11:04:00
Context
2014-02-09
11:04
r7359,7360,7380 from 4.3: xymond_alert: Fix bug where alerts that were initially suppressed due to TIME restrictions are delayed until REPEAT interval expires. http://lists.xymon.com/archive/2014-January/038863.html git-svn-id: http://svn.code.sf.net/p/xymon/code/trunk@7403 44351d6e-118b-4698-b696-ce33095ecaa4 check-in: ce2e6dcfca user: storner@users.sf.net tags: trunk, master
11:04
r7356 from 4.3: Solaris client: Fix memory report when no swap configured, and fix reporting for hosts using zones. From Andy Smith http://lists.xymon.com/archive/2014-January/038845.html git-svn-id: http://svn.code.sf.net/p/xymon/code/trunk@7402 44351d6e-118b-4698-b696-ce33095ecaa4 check-in: 002a03e592 user: storner@users.sf.net tags: trunk, master
11:03
r7355 from 4.3: alerts: Fix crash when stripping <cr> from message data git-svn-id: http://svn.code.sf.net/p/xymon/code/trunk@7401 44351d6e-118b-4698-b696-ce33095ecaa4 check-in: 577de5ee88 user: storner@users.sf.net tags: trunk, master
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to client/xymonclient-sunos.sh.

7
8
9
10
11
12
13







14
15
16
17
18
19
20
..
22
23
24
25
26
27
28


29






30
31



32
33





34
35
36
37
38
39
40
..
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
# This program is released under the GNU General Public License (GPL),       #
# version 2. See the file "COPYING" for details.                             #
#                                                                            #
#----------------------------------------------------------------------------#
#
# $Id$








echo "[date]"
date
echo "[uname]"
uname -a
echo "[uptime]"
uptime
echo "[who]"
................................................................................

echo "[df]"
# Bothersome, because Solaris df cannot show multiple fs-types, or exclude certain fs types.
# Print the root filesystem first, with the header, and those fs's that have the same type.
ROOTFSTYPE=`/bin/df -n / | awk '{print $3}'`
/bin/df -F $ROOTFSTYPE -k
# Then see what fs types are in use, and weed out those we dont want.


FSTYPES=`/bin/df -n -l|cut -d: -f2 | awk '{print $1}'|egrep -v "^${ROOTFSTYPE}|^proc|^fd|^mntfs|^ctfs|^devfs|^objfs|^nfs|^lofs"|sort|uniq`






set $FSTYPES
while test "$1" != ""; do



  /bin/df -F $1 -k | grep -v " /var/run" | tail +2
  shift





done

# This only works for ufs filesystems
echo "[inode]"
(if test -x /usr/ucb/df
then
   /usr/ucb/df -i
................................................................................
fi) | awk '
NR<2{printf "%-20s %10s %10s %10s %10s %s\n", $1, "itotal", $2, $3, $4, $5}
NR>=2{printf "%-20s %10d %10d %10d %10s %s\n", $1, $2+$3, $2, $3, $4, $5}'

echo "[mount]"
mount
echo "[prtconf]"


/usr/sbin/prtconf







echo "[memory]"


vmstat 1 2 | tail -1

























echo "[swap]"
/usr/sbin/swap -s




echo "[swaplist]"
/usr/sbin/swap -l


echo "[ifconfig]"
ifconfig -a
echo "[route]"
netstat -rn
echo "[netstat]"
netstat -s
echo "[ports]"
netstat -na -f inet -P tcp | tail +3
netstat -na -f inet6 -P tcp | tail +5
echo "[ifstat]"
# Leave out the wrmsd and mac interfaces. See http://www.xymon.com/archive/2009/06/msg00204.html


/usr/bin/kstat -p -s '[or]bytes64' | egrep -v 'wrsmd|mac' | sort







echo "[ps]"


ps -A -o pid,ppid,user,stime,s,pri,pcpu,time,pmem,rss,vsz,args









# If TOP is defined, then use it. If not, fall back to the Solaris prstat command.
echo "[top]"
if test "$TOP" != "" -a -x "$TOP"
then
	"$TOP" -b 20
else







>
>
>
>
>
>
>







 







>
>
|
>
>
>
>
>
>
|
<
>
>
>
|
<
>
>
>
>
>







 







>
>
|
>
>
>
>
>
>
>

>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


>
>
>
>
|
|
>
>











>
>
|
>
>
>
>
>
>
>

>
>
|
>
>
>
>
>
>
>
>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
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
..
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# This program is released under the GNU General Public License (GPL),       #
# version 2. See the file "COPYING" for details.                             #
#                                                                            #
#----------------------------------------------------------------------------#
#
# $Id$

# Work out what type of environment we are on 
#
# this will return the zone name on any non-global solaris zone
# or the word "Global" on any global solaris zone
# or the word "global" on any standalone solaris platform, including LDOMS
(/usr/sbin/zoneadm list 2>/dev/null || echo 1) | wc -l | grep '\<1\>' > /dev/null 2>&1 && ZTYPE=`/bin/zonename 2>/dev/null || echo global` || ZTYPE='Global'

echo "[date]"
date
echo "[uname]"
uname -a
echo "[uptime]"
uptime
echo "[who]"
................................................................................

echo "[df]"
# Bothersome, because Solaris df cannot show multiple fs-types, or exclude certain fs types.
# Print the root filesystem first, with the header, and those fs's that have the same type.
ROOTFSTYPE=`/bin/df -n / | awk '{print $3}'`
/bin/df -F $ROOTFSTYPE -k
# Then see what fs types are in use, and weed out those we dont want.
case $ZTYPE in
global|Global)
   FSTYPES=`/bin/df -n -l|cut -d: -f2 | awk '{print $1}'|egrep -v "^${ROOTFSTYPE}|^proc|^fd|^mntfs|^ctfs|^devfs|^objfs|^nfs|^lofs|^tmpfs|^sharefs"|sort|uniq`
   ;;
*)
   # zones are frequently type lofs so deal with them specially
   FSTYPES=`/bin/df -n -l|cut -d: -f2 | awk '{print $1}'|egrep -v "^${ROOTFSTYPE}|^proc|^fd|^mntfs|^ctfs|^devfs|^objfs|^nfs|^tmpfs|^sharefs"|sort|uniq`
   ;;
esac
# $FSTYPES may be empty

for fst in $FSTYPES; do
  case $ZTYPE in
    global|Global)
      /bin/df -F $fst -k | grep -v " /var/run" | tail +2

      ;;
    *)
      /bin/df -F $fst -k | egrep -v "( /var/run|^(/dev|/platform/))" | tail +2
      ;;
  esac
done

# This only works for ufs filesystems
echo "[inode]"
(if test -x /usr/ucb/df
then
   /usr/ucb/df -i
................................................................................
fi) | awk '
NR<2{printf "%-20s %10s %10s %10s %10s %s\n", $1, "itotal", $2, $3, $4, $5}
NR>=2{printf "%-20s %10d %10d %10d %10s %s\n", $1, $2+$3, $2, $3, $4, $5}'

echo "[mount]"
mount
echo "[prtconf]"
case $ZTYPE in
global|Global)
   /usr/sbin/prtconf 2>&1
   ;;
*)
   # provided  by the firmware (PROM) since devinfo facility not available
   # in a zone
   /usr/sbin/prtconf -p 2>&1
   ;;
esac
echo "[memory]"
case $ZTYPE in
global|Global)
   vmstat 1 2 | tail -1
   ;;
*)
   # need to modify vmstat output in a non-global zone
   VMSTAT=`vmstat 1 2 | tail -1`
   # cut out the useable parts
   VMFR=`echo $VMSTAT | cut -d " " -f1,2,3`
   VMBK=`echo $VMSTAT | cut -d " " -f6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22`
   # get the total memory for the platform
   TMEM=`/usr/sbin/prtconf 2>&1 | grep Memory | cut -d" " -f3`
   TMEM=`expr $TMEM "*" 1024`
   # get the total allocated and reserved swap
   SUSED=`swap -s | cut -d "=" -f2 | cut -d "," -f1 | cut -d " " -f2 | cut -d "k" -f1`
   # work out the RSS for this zone
   TUSED=`prstat -Z -n 1,1 1 1 | \
     nawk ' NR == 4 {
       do {
         if ($4 ~ /G$/) { sub(/G$/,"",$4); print $4*1024*1024; break; }
         if ($4 ~ /M$/) { sub(/M$/,"",$4); print $4*1024; break; }
         if ($4 ~ /K$/) { sub(/K$/,"",$4); print $4; break; }
         print "unknown"
       } while (0)}'`
   TUSED=`expr $TMEM "-" $TUSED`
   echo "$VMFR $SUSED $TUSED $VMBK"
   ;;
esac
echo "[swap]"
/usr/sbin/swap -s
# dont report the swaplist in a non-global zone because it will cause the
# server client module to miscalculate memory
case $ZTYPE in
global|Global)
   echo "[swaplist]"
   /usr/sbin/swap -l 2>/dev/null
   ;;
esac
echo "[ifconfig]"
ifconfig -a
echo "[route]"
netstat -rn
echo "[netstat]"
netstat -s
echo "[ports]"
netstat -na -f inet -P tcp | tail +3
netstat -na -f inet6 -P tcp | tail +5
echo "[ifstat]"
# Leave out the wrmsd and mac interfaces. See http://www.xymon.com/archive/2009/06/msg00204.html
case $ZTYPE in
global|Global)
   /usr/bin/kstat -p -s '[or]bytes64' | egrep -v 'wrsmd|mac' | sort
   ;;
*)
   # find out which nics are configured into this zone
   MYNICS=`netstat -i |cut -f1 -d" " | egrep -i -v "Name|lo|^$"  |paste -s -d"|" - `
   /usr/bin/kstat -p -s '[or]bytes64' | egrep "$MYNICS"| sort
   ;;
esac
echo "[ps]"
case $ZTYPE in
global)
    /bin/ps -A -o pid,ppid,user,stime,s,pri,pcpu,time,pmem,rss,vsz,args
   ;;
Global)
    /bin/ps -A -o zone,pid,ppid,user,stime,class,s,pri,pcpu,time,pmem,rss,vsz,args | sort
   ;;
*)
    /bin/ps -A -o pid,ppid,user,stime,class,s,pri,pcpu,time,pmem,rss,vsz,args
   ;;
esac

# If TOP is defined, then use it. If not, fall back to the Solaris prstat command.
echo "[top]"
if test "$TOP" != "" -a -x "$TOP"
then
	"$TOP" -b 20
else

Changes to xymond/client/solaris.c.

124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
					bol = nl+1;
				}
				else {
					bol = NULL;
				}
			}

			if ((blktotal > 0) && (blkfree > 0)) {
				/* Values from swap -l are numbers of 512-byte blocks. Convert to MB = N*512/(1024*1024) = N/2048 */
				memswapused = (blktotal - blkfree) / 2048;
				memswapfree = blkfree / 2048;
			}
		}

		if ((memphystotal>=0) && (memphysfree>=0) && (memswapused>=0) && (memswapfree>=0)) {







|







124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
					bol = nl+1;
				}
				else {
					bol = NULL;
				}
			}

			if ((blktotal >= 0) && (blkfree >= 0)) {
				/* Values from swap -l are numbers of 512-byte blocks. Convert to MB = N*512/(1024*1024) = N/2048 */
				memswapused = (blktotal - blkfree) / 2048;
				memswapfree = blkfree / 2048;
			}
		}

		if ((memphystotal>=0) && (memphysfree>=0) && (memswapused>=0) && (memswapfree>=0)) {