SNMP RPi2
SNMP RPi2
SNMP RPi2
Há apenas 6 arquivos envolvidos por isso é bastante fácil de ver como ele
funciona e modificar como quiser - digo para adicionar algo que você gostaria
de monitorar em seu Raspi.
Eu entrei na Raspi do meu laptop e usado Geany um pouco para criar alguma atividade nas parcelas.
Note que o contador na parte inferior (a exibir "..." aqui) é uma contagem decrescente (em segundos)
para a próxima vez que este monitor vai fazer um pedido para a Raspi para o próximo conjunto de
contagens. Em seguida, o contador (em geral) mostra "..." enquanto ele está esperando até que as
contagens foram devolvidos. Portanto, se esse contador ou é a contagem regressiva ou mostrar "..." por
períodos curtos (ver o tempo "geral" de resposta em seu enredo "Tempo de Resposta"), então as coisas
estão provavelmente funcionando normalmente.
Eu me pergunto por que a temperatura subiu um pouco à direita. Um mistério.
Setup
Para configurar o Raspi, eu instalei primeiro SNMP e snmpd sobre ele como se
segue. Eu achei que eu precisava usar --fixmissing no snmpd instalar:
sudo apt-get update
sudo apt-get install snmpd --fixmissing
sudo apt-get install snmp
/etc/init.d/snmpd restart
Man-O-War Cay, 9 Jan 2015
Dale escreve para dizer que ele precisava também instalarl “snmp-mibs-downloader” para evitar
mensagens de erro durante a instalação. Graças Dale.
Se você deseja instalar os MIBs mais amigáveis para usar com SNMP, esta
nota foi útil. Para os meus propósitos, porém, a lista de OIDs encontrado nesta
nota e especialmente este onewere muito útil. Há também referência
impressionante da Cisco.
My code
My code is still something of "a work in progress"...
Here is my current version: raspi-mon-28Sep2013.zip.
Here are the components - either in that zip file or compiled from them:
What Named Where they go on the RasPi
1. The web page that calls the CGI on the mikesmon.html /var/www/mikesmon.html
RasPi and presents the results to the user mikesmon-favicon.png /var/www/mikesmon-favicon.png
2. The CGI that calls a C program to
mikesmon.cgi /usr/lib/cgi-bin/mikesmon.cgi
collect the counts
3. The source code for the C program that mikesmon.c
You can put these anywhere, let's say in a folder called mon in
collects the counts from SNMP and myutils.h
your home directory on the RasPi
command-line programs OIDs.h
4. The executable from compiling the
source code in #3 ("gcc -o mikesmon mikesmon /usr/bin/mikesmon
mikesmon.c")
jquery.min.js /var/www/flot/jquery.min.js
5. The chart-drawing libraries
jquery.flot.min.js /var/www/flot/jquery.flot.min.js
1.Copy the files from the zip file to their locations on the RasPi as
indicated above. Set the permissions as necessary, e.g.
sudo chmod +x /usr/lib/cgi-bin/mikesmon.cgi
Dale writes, making the point that if you are using (and want to monitor) an Ethernet network
(I was using a WiFi network), you should change the OIDs referencing the network counters in
the C code to have .2 as the last character, instead of .3 . So, that's:
"1.3.6.1.2.1.2.2.1.10.2" in place of "1.3.6.1.2.1.2.2.1.10.3"
"1.3.6.1.2.1.2.2.1.14.2" in place of "1.3.6.1.2.1.2.2.1.14.3"
"1.3.6.1.2.1.2.2.1.16.2" in place of "1.3.6.1.2.1.2.2.1.16.3"
"1.3.6.1.2.1.2.2.1.20.2" in place of "1.3.6.1.2.1.2.2.1.20.3"
Try
snmpwalk -v 1 -c public localhost 1.3.6.1.2.1.31.1.1.1
on your RasPi console to see your network interfaces and check the last character to use on the
network counters you are interested in. On my RasPi (in Sep, 2013), the RasPi's response was:
IF-MIB::ifName.1 = STRING: lo
IF-MIB::ifName.2 = STRING: eth0
IF-MIB::ifName.3 = STRING: wlan0
lo stands for loopback - ie. the RasPi, eth0 is the Ethernet network, and wlan0 is the WiFi network.
Your results may vary depending on your network configuration (say, you have other network
adapters plugged in). Thanks Dale.
Again, you should see something like the following, now in your browser
window:
H,raspberrypi,T,44388,CRU,6268,CRN,0,CRS,4118,CRI,1009417,TRF,377276,SP,80,NIO3,
412078,NOO3,384715,NIE3,0,NOE3,0,RT,5747,
You should see something like the screen shot shown above. If not, look
at the RasPi's web server logs in /var/log/apache2/.
To do
1.Make the HTTP request to the server asynchronous. Right now, the UI
locks up while the Javascript code is making the request to the RasPi for
the next sample. So, it is not able to respond to user input for several
seconds every sample interval - if the user clicks on the Start/Pause
button or tries to change the "Sample interval" from the drop-down list.
There is an asynchronous way of making the request.. I just need to
implement it.
2.Shrink the size of the HTML file. Probably can be done be redoing the
switch statements.
-- FIN --