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
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
|
#! /bin/sh
#
# Copyright (c) 1997-2003 Silicon Graphics, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# Install the cisco PMDA and/or PMNS
#
. $PCP_DIR/etc/pcp.env
. $PCP_SHARE_DIR/lib/pmdaproc.sh
iam=cisco
pmda_interface=2
forced_restart=false
# Do it
#
pmdaSetup
check_delay=20
pollrate=120 # poll each Cisco interface once every 120 seconds
# -- change this if desired
# special cisco PMDA args
if $do_pmda
then
args="-r$pollrate"
default="wanptg"
while true
do
no_host=true
while $no_host
do
echo
$PCP_ECHO_PROG $PCP_ECHO_N "Cisco hostname or IP address? [return to quit Cisco selection] ""$PCP_ECHO_C"
read host
[ "X$host" = X ] && break
echo '
A username and/or user-level password may be required for the Cisco
"show interface" command.
If you are unsure, try the command
$ telnet '$host'
and if the prompt "Username:" appears, then a username is required,
and if the prompt "Password:" appears, a user-level password is required,
otherwise respond with an empty line for the next two questions.
Once logged in, we need to know the termination string for the command
line prompt (one or more unique characters at the end of the prompt) -
the default is ">", but if this is not correct, enter the prompt
termination string also.
'
$PCP_ECHO_PROG $PCP_ECHO_N "Cisco username? ""$PCP_ECHO_C"
read username
userarg=""
[ "X$username" != X ] && userarg="-U$username"
$PCP_ECHO_PROG $PCP_ECHO_N "User-level Cisco password? ""$PCP_ECHO_C"
read passwd
passarg=""
[ "X$passwd" != X ] && passarg="-P$passwd"
$PCP_ECHO_PROG $PCP_ECHO_N "Cisco command line prompt termination? [>] ""$PCP_ECHO_C"
read prompt
promptarg=""
[ "X$prompt" != X ] && promptarg="-s'$prompt'"
echo "Probing Cisco for list of interfaces ..."
for try in 1 2 3
do
intf=`eval ./probe $userarg $passarg $promptarg $host 2>$tmp/err`
[ ! -z "$intf" ] && break
sleep 2
done
if [ -z "$intf" ]
then
echo '
There appears to be a problem ... after three attempts could not get
interfaces. Output at the last attempt was:'
sed -e 's/^/ /' <$tmp/err
echo '
You may wish to try the following commands to identify the configured
interfaces for this Cisco.
$ telnet '$host'
....> terminal length 0
....> show interface
....> quit
'
else
no_host=false
fi
done
[ "X$host" = X ] && break
if [ -z "$username" ]
then
login=""
else
login="@$username"
fi
[ ! -z "$passwd" ] && login="$login?$passwd"
[ ! -z "$prompt" ] && login="$login!$prompt"
echo '
Enter interfaces to monitor, one per line in the format tX where "t" is
a type and one of "e" (Ethernet), "E" (FastEthernet), "f" (Fddi), "s"
(Serial), "a" (ATM), "B" (ISDN BRI) or "h" (HSSC) and "X" is an
interface identifier which is either an integer (e.g. 4000 Series
routers) or two integers separated by a slash (e.g. 7000 Series
routers).'
while true
do
echo
echo 'The currently unselected interfaces for the Cisco "'$host'" are:'
echo "$intf" | fmt | sed -e 's/^/ /'
echo 'Enter "*" to select all, "quit" to terminate selections for this Cisco.'
first=`echo "$intf" | sed -e 's/ .*//'`
[ -z "$first" ] && first=quit
$PCP_ECHO_PROG $PCP_ECHO_N "Interface? [$first] ""$PCP_ECHO_C"
read ans
[ "X$ans" = Xquit ] && break
if [ "X$ans" = "X*" ]
then
# do them all
for ans in `echo "$intf"`
do
args="$args $host:$ans$login"
login=''
done
break
fi
[ -z "$ans" ] && ans="$first"
if echo " $intf" | grep " $ans" >/dev/null
then
sed_ans=`echo $ans | sed -e 's;/;\\\\/;g'`
intf=`echo " $intf" | sed -e "s/ $sed_ans//" -e 's/^ //'`
else
echo "Warning: $ans is not in the list, I hope you know what you're doing"
fi
args="$args $host:$ans$login"
login=''
[ -z "$intf" ] && break
done
done
fi
pmdaInstall
exit 0
|