From 8081a5520a441b43a8a7a73f3a90c7aacfaa8e10 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sun, 24 Feb 2019 21:05:27 +0100 Subject: Move everything one level up --- .../tasks/snmp_agent_uptime/howtos/en/index.html | 319 --------------------- 1 file changed, 319 deletions(-) delete mode 100644 kpov_judge/tasks/snmp_agent_uptime/howtos/en/index.html (limited to 'kpov_judge/tasks/snmp_agent_uptime/howtos/en') diff --git a/kpov_judge/tasks/snmp_agent_uptime/howtos/en/index.html b/kpov_judge/tasks/snmp_agent_uptime/howtos/en/index.html deleted file mode 100644 index bef6792..0000000 --- a/kpov_judge/tasks/snmp_agent_uptime/howtos/en/index.html +++ /dev/null @@ -1,319 +0,0 @@ - - - - snmp_agent_uptime - - -

snmp_agent_uptime

-

Quick instructions

-

- Set up three virtual computers, SimpleArbiter with the disk image - simpleArbiterDhcp, SNMPServer and SNMPClient. Write a program - called upminutes. This program should output the uptime of the - computer in minutes. Set it up on SNMPClient in the home directory - of the user test with the password test. -

-

- Make sure that the SNMP server reports it's uptime in seconds - over SNMP under NET-SNMP-EXTEND-MIB::nsExtendOutput2Table. -

-

- Write a script called beri.sh that reads the value from the - OID 1.3.6.1.4.1.8072.1.3.2.4.1.2 on SNMPServer. Set it up on - SNMPClient in the home directory of the user test. -

-

Instructions

-

Set up of VM VirtualBox

-
    -
  1. - Download the following virtual images (*.vid) from the directory - with images of virtual computers: -
      -
    1. - simpleArbiterDhcp.vdi -
    2. -
    3. - some-bash-console.vdi – twice, one for SNMPServer - and second for SNMPClient -
    4. -
    -
  2. -
  3. - VM VirtualBox WARNING! If you want to use one same virtual image - (some-bash-console.vdi) for two virtual computers - (SNMPServer and SNMPClient), you must change UUID - of one image. -
      -
    1. - Use this command - vboxmanage internalcommands sethduuid name-of-disk.vdi - to change UUID (hint). -
    2. -
    -
  4. -
  5. - Final view of sets VM VirtualBox machines.
    - VM VirtualBox machines -
  6. -
- -

Set up of SNMPServer machine

-
    -
  1. - setup network as “Bridged Adapter” -> Machine-> Settings ->Network - - Install snmpd and snmp packages and tools for inspecting the - data available over SNMP. -
      -
    1. - command apt-get install snmpd snmp snmp-mibs-downloader -
    2. -
    -
  2. - RECOMMENDATION! Before doing any changes to your /etc/snmp/snmpd.conf - file take a copy of original file. -
      -
    1. - command cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig -
    2. -
    -
  3. -
  4. - Set up the snmp server to allow all other computers to access it = edit - snmpd.conf file. -
      -
    1. - command nano /etc/snmp/snmpd.conf - (you can use different editor) -
    2. -
    3. - Check this 4 rows and make sure they look like this:
      - # Listen for connections from the local system only
      - # agentAddress udp:127.0.0.1:161
      - # Listen for connections on all interfaces (both IPv4 *and* IPv6)
      - agentAddress udp:161,udp6:[::1]:161
      -
    4. -
    -
  5. -
  6. - Add a group (community) of computers we deem to be worthy of - accessing all data. This group will be called students = again edit - snmpd.conf file. -
      -
    1. - rocommunity students 0.0.0.0/0 -
    2. -
    3. - change 0.0.0.0./0 into correct address ifconfig -a -
    4. -
    -
  7. -
  8. - OPTIONAL CONFIGURATION. Lower in the same file you can set the - location of the computer snmpd is running on and the name - of the administrator. -
      -
    1. - find under # SYSTEM INFORMATION -
    2. -
    -
  9. -
  10. - Make sure that the SNMP server reports it's uptime in seconds - over SNMP under NET-SNMP-EXTEND-MIB::nsExtendOutput2Table. -
      -
    1. - create script upseconds containing this and save it where - you want:
      - #!/bin/bash
      - uptime=$(</proc/uptime)
      - seconds=${uptime%%.*}
      - echo "Uptime in seconds:" $seconds
      - exit 0
      -
    2. -
    3. - don't forget to make the script runnable:
      - command chmod +x /your_path_to_script/upseconds -
    4. -
    5. - Then edit file snmpd.conf and under # EXTENDING THE AGENT - comment all three tests and add your line of your code - with upsecond script. It will look like this:
      - # extend test1 /bin/echo Hello, world!
      - # extend-sh test2 echo Hello, world! ; echo Hi there ; exit 35
      - # extend-sh test3 /bin/sh /tmp/shtest
      - extend-sh "your_name" "your_path_to_script_upseconds" -
      -
    6. -
    -
  11. -
  12. - You need to restart the snmp services. -
      -
    1. - command /etc/init.d/snmpd restart -
    2. -
    -
  13. -
  14. - You can test your configuration through localhost. -
      -
    1. - command snmpwalk localhost -c public -v1 -
    2. -
    -
  15. -
  16. - Also test the correct return of server's uptime in seconds SNMP under - NET-SNMP-EXTEND-MIB::nsExtendOutput2Table. -
      -
    1. - command snmpwalk -c students -v1 IPaddressOfServer - 1.3.6.1.4.1.8072.1.3.2.4.1.2 -
    2. -
    3. - you should get string: "Uptime in seconds: xyz" -
    4. -
    -
  17. -
- -

Set up of SNMPClient machine

-
    -
  1. - Install snmpd and snmp packages. -
      -
    1. - command apt-get install snmpd snmp -
    2. -
    -
  2. - RECOMMENDATION! Before doing any changes to your /etc/snmp/snmpd.conf - file take a copy of original file. -
      -
    1. - command cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig -
    2. -
    -
  3. -
  4. - Set up the snmp client to allow all other computers to access it = edit - snmpd.conf file. -
      -
    1. - command nano /etc/snmp/snmpd.conf - (you can use different editor) -
    2. -
    3. - (un)comment these four lines as below:
      - # Listen for connections from the local system only
      - # agentAddress udp:127.0.0.1:161
      - # Listen for connections on all interfaces (both IPv4 *and* IPv6)
      - agentAddress udp:161,udp6:[::1]:161
      -
    4. -
    -
  5. -
  6. - Add a group (community) of computers we deem to be worthy of - accessing all data. This group will be called students = again edit - snmpd.conf file. -
      -
    1. - rocommunity students 0.0.0.0/0 -
    2. -
    3. - write correct network address = command ifconfig -a -
    4. -
    -
  7. -
  8. - OPTIONAL CONFIGURATION. Lower in the same file you can set the - location of the computer snmpd is running on and the name - of the administrator. -
      -
    1. - find under # SYSTEM INFORMATION -
    2. -
    -
  9. - -
  10. - You need to restart the snmp services. -
      -
    1. - command /etc/init.d/snmpd restart -
    2. -
    -
  11. -
  12. - You can test your configuration through localhost. -
      -
    1. - command snmpwalk localhost -c public -v1 -
    2. -
    -
  13. -
  14. Create the user test with password test -
      -
    1. - command adduser test -
    2. -
    -
  15. -
  16. Login as user test and create program upminutes - in the home directory. This program should output the uptime of the - computer in minutes. -
      -
    1. - command nano upminutes (you can use different editor) -
    2. -
    3. - add the source code:
      - #!/bin/bash
      - uptime=$(</proc/uptime)
      - uptime=${uptime%%.*}
      - minutes=$(( uptime / 60 ))
      - echo $minutes
      - exit 0
      -
    4. -
    5. - don't forget to make the program runnable:
      - command chmod +x /home/test/upminutes -
    6. -
    7. - test the program (it should output the uptime of the - computer in minutes)
      - command /home/test/upminutes -
    8. -
    -
  17. -
  18. As user test and create next script called - beri.sh that reads the value from the OID - 1.3.6.1.4.1.8072.1.3.2.4.1.2. on SNMPServer. Set it up on SNMPClient - in the home directory of the user test. -
      -
    1. - command nano beri.sh (you can use different editor) -
    2. -
    3. - add the source code:
      - #!/bin/bash
      - snmpwalk -c students -v1 IPServerAddress 1.3.6.1.4.1.8072.1.3.2.4.1.2
      - exit 0
      -
    4. -
    5. - don't forget to make the program runnable:
      - command chmod +x /home/test/upminutes - you can test it with ./beri.sh -
    6. -
    -
  19. -
- -

Setting SimpleArbiter

- User: tester - Password: test - - apt-get install libsnmp-python - - -- cgit v1.2.1