Changes between Version 22 and Version 23 of Nmm2022/Agenda/oxidize


Ignore:
Timestamp:
Jul 15, 2022, 7:03:00 AM (2 years ago)
Author:
dushmantha
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Nmm2022/Agenda/oxidize

    v22 v23  
    22== '''Network Device Configuration Management - Oxidized ''' ==
    33
    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.
     4In 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.
    55
    66'''Requirements:'''
     
    140140}}}
    141141
     142Create oxidized-report-git-commits file.
     143
     144{{{
     145nano .config/oxidized/oxidized-report-git-commits
     146}}}
     147
     148Copy the following content to the file and save it.
     149
     150{{{
     151#!/bin/sh
     152trap '/bin/rm -f "$tmpfile"' EXIT
     153
     154tmpfile=$(mktemp) || exit 1
     155
     156subject="Oxidized updates for ${OX_NODE_NAME}"
     157scriptname=`basename $0`
     158
     159usage()
     160{
     161    echo "Usage: ${scriptname} [-f] [ -s email_subject ] [ -r email_recipient ]"
     162    exit 1
     163}
     164
     165email_on_gitfail=1
     166while 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
     181done
     182
     183
     184if [ "${OX_EVENT}" = "node_fail" ]; then
     185    echo "${scriptname}: ${OX_NODE_NAME}": 'Job failed'
     186    exit 64
     187fi
     188
     189if [ -z "${OX_REPO_COMMITREF}" ]; then
     190        echo "${scriptname}: "'$OX_REPO_COMMITREF not set'
     191        exit 64
     192fi
     193
     194if [ -z "${OX_REPO_NAME}" ]; then
     195        echo "${scriptname}: "'$OX_REPO_NAME not set'
     196        exit 64
     197fi
     198
     199cat > ${tmpfile} <<EOF
     200Node name: ${OX_NODE_NAME}
     201Group name: ${OX_NODE_GROUP}
     202Job status: ${OX_JOB_STATUS}
     203Job time: ${OX_JOB_TIME}
     204Git repo: ${OX_REPO_NAME}
     205Git commit ID: ${OX_REPO_COMMITREF}
     206
     207EOF
     208
     209# test if commit exists
     210git --bare --git-dir="${OX_REPO_NAME}" rev-parse --quiet --verify "${OX_REPO_COMMITREF}" > /dev/null 2>&1
     211gitret=$?
     212
     213if [ ${gitret} -eq 0 ]; then
     214    git --bare --git-dir="${OX_REPO_NAME}" show --pretty='' --no-color "${OX_REPO_COMMITREF}" >> ${tmpfile} 2>&1
     215else
     216    echo "${scriptname}: commit ${OX_REPO_COMMITREF} does not exist" >> ${tmpfile}
     217fi
     218
     219if [ ! -z "${recipient}" -a \( ${gitret} -eq 0 -o ${email_on_gitfail} -eq 1 \) ]; then
     220    cat ${tmpfile} | mail -s "${subject}" "${recipient}"
     221else
     222    cat ${tmpfile}
     223fi
     224}}}
     225
     226Give execution privileges.
     227
     228{{{
     229chmod +x .config/oxidized/oxidized-report-git-commits
     230}}}
     231
    142232'''Setup Oxidized Service'''
    143233
     
    179269You 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]
    180270
     271The default output will be ''Show version''.
     272
     273[[Image(history.png, 1200px)]][[BR]]
     274
    181275Click '''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''').
    182276
    183 [[Image(history.png, 1200px)]][[BR]]
     277[[Image(diff.png, 1300px)]][[BR]]
    184278
    185279'''Postfix Installation'''