Changes between Version 22 and Version 23 of Nmm2022/Agenda/oxidize
- Timestamp:
- Jul 15, 2022, 7:03:00 AM (2 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Nmm2022/Agenda/oxidize
v22 v23 2 2 == '''Network Device Configuration Management - Oxidized ''' == 3 3 4 In this lab, you will install and configure Oxidized and integrate it with LibreNMS.''' When you are changing users, always start from root.''' When you are coping the commands, copy and execute line by line. Otherwise, you may get errors and worst case have to start from the beginning.4 In this lab, you will install and configure Oxidized and integrate it with LibreNMS.''' When you are changing users, always start from root.''' You may use '''exit''' to logout current user. When you are coping the commands, copy and execute line by line. Otherwise, you may get errors and worst case have to start from the beginning. 5 5 6 6 '''Requirements:''' … … 140 140 }}} 141 141 142 Create oxidized-report-git-commits file. 143 144 {{{ 145 nano .config/oxidized/oxidized-report-git-commits 146 }}} 147 148 Copy the following content to the file and save it. 149 150 {{{ 151 #!/bin/sh 152 trap '/bin/rm -f "$tmpfile"' EXIT 153 154 tmpfile=$(mktemp) || exit 1 155 156 subject="Oxidized updates for ${OX_NODE_NAME}" 157 scriptname=`basename $0` 158 159 usage() 160 { 161 echo "Usage: ${scriptname} [-f] [ -s email_subject ] [ -r email_recipient ]" 162 exit 1 163 } 164 165 email_on_gitfail=1 166 while getopts "fs:r:" opt; do 167 case $opt in 168 s) 169 subject=$OPTARG 170 ;; 171 r) 172 recipient=$OPTARG 173 ;; 174 f) 175 email_on_gitfail=0 176 ;; 177 *) 178 usage 179 ;; 180 esac 181 done 182 183 184 if [ "${OX_EVENT}" = "node_fail" ]; then 185 echo "${scriptname}: ${OX_NODE_NAME}": 'Job failed' 186 exit 64 187 fi 188 189 if [ -z "${OX_REPO_COMMITREF}" ]; then 190 echo "${scriptname}: "'$OX_REPO_COMMITREF not set' 191 exit 64 192 fi 193 194 if [ -z "${OX_REPO_NAME}" ]; then 195 echo "${scriptname}: "'$OX_REPO_NAME not set' 196 exit 64 197 fi 198 199 cat > ${tmpfile} <<EOF 200 Node name: ${OX_NODE_NAME} 201 Group name: ${OX_NODE_GROUP} 202 Job status: ${OX_JOB_STATUS} 203 Job time: ${OX_JOB_TIME} 204 Git repo: ${OX_REPO_NAME} 205 Git commit ID: ${OX_REPO_COMMITREF} 206 207 EOF 208 209 # test if commit exists 210 git --bare --git-dir="${OX_REPO_NAME}" rev-parse --quiet --verify "${OX_REPO_COMMITREF}" > /dev/null 2>&1 211 gitret=$? 212 213 if [ ${gitret} -eq 0 ]; then 214 git --bare --git-dir="${OX_REPO_NAME}" show --pretty='' --no-color "${OX_REPO_COMMITREF}" >> ${tmpfile} 2>&1 215 else 216 echo "${scriptname}: commit ${OX_REPO_COMMITREF} does not exist" >> ${tmpfile} 217 fi 218 219 if [ ! -z "${recipient}" -a \( ${gitret} -eq 0 -o ${email_on_gitfail} -eq 1 \) ]; then 220 cat ${tmpfile} | mail -s "${subject}" "${recipient}" 221 else 222 cat ${tmpfile} 223 fi 224 }}} 225 226 Give execution privileges. 227 228 {{{ 229 chmod +x .config/oxidized/oxidized-report-git-commits 230 }}} 231 142 232 '''Setup Oxidized Service''' 143 233 … … 179 269 You can view ''Show version'' and ''Show diff'' buttons '''if there are configuration changes/ changing history, after Oxidized has connected with the devices.''' Try to get that screen by changing a configuration and '''saving''' that of a connected device. All device passwords are ''123''. You may refer this [https://ws.learn.ac.lk/wiki/Cnbp2022/Agenda/NetworkSetup] 180 270 271 The default output will be ''Show version''. 272 273 [[Image(history.png, 1200px)]][[BR]] 274 181 275 Click '''Show diff'''. Below '''Hide line numbers''' a minus (-) mark in front of the command says that particular command is reverted ('''red'''). And a plus (+) mark in front of the command says the reverted command is replaced by it ('''green'''). 182 276 183 [[Image( history.png, 1200px)]][[BR]]277 [[Image(diff.png, 1300px)]][[BR]] 184 278 185 279 '''Postfix Installation'''