send data from rpi - SparkGrads2016/envmonitorSpark GitHub Wiki
Splunk
Code Edits
Go to the location of the main.py file and edit it.
sudo nano main.py
Edit the location of the envMonitorSettings.ini to the correct place. The location can be checked by navigating to the directory of the envMonitor.ini file and typing "pwd" in the command line.
parser.read('location of envMonitor.ini file')
e.g. - parser.read('/home/pi/Desktop/envmonitor/sensors/envMonitorSettings.ini)
Check that the main file runs correctly.
sudo python main.py
Splunk Edits
Copy all the sensor code into the /opt/splunkforwarder/bin/scripts directory.
sudo cp sensor_ code_directory/* /opt/splunkforwarder/bin/scripts
e.g. - sudo cp /home/pi/Desktop/envmonitor/sensors/* /opt/splunkforwarder/bin/scripts
Navigate to the inputs.conf file and edit it.
sudo nano /opt/splunkforwarder/etc/system/local/inputs.conf
Add the location of the executable files along with other details including the time interval to send the data.
e.g. -
[script:///opt/splunkforwarder/bin/scripts/internalStats.sh]
index = main
interval = 60
source = cpu_details
sourcetype = pi_system_scripts
Telegraf
Code Edits
Go to the location of the main.py file and edit it.
sudo nano main.py
Edit the location of the envMonitorSettings.ini to the correct place. The location can be checked by navigating to the directory of the envMonitor.ini file and typing "pwd" in the command line.
parser.read('location of envMonitor.ini file')
e.g. - parser.read('/home/pi/Desktop/envmonitor/sensors/envMonitorSettings.ini)
Check that the main file runs correctly.
sudo python main.py
As Telegraf does not run python scripts, the main file needs to be executed through a shell script. Go to the location of the envData.sh file and edit it.
sudo nano envData.sh
Edit the location of the main.py file to the correct place The location can be checked by navigating to the directory of the main.py file and typing "pwd" in the command line.
python "location of the main.py file"
e.g. - python "/home/pi/Desktop/envmonitor/sensors/main.py"
Check the script runs correctly. It should output the exact same information as the main.py file previously executed.
sudo ./envData.sh
Telegraf Config File Edit
Navigate to and edit the the telegraf.conf file.
sudo nano /etc/telegraf/telegraf.conf
Add the shell scripts to execute under [inputs.exec]. Add the location of the scripts into the commands array.
commands = ["shell script 1","shell script 2"]
e.g. - commands = ["/home/pi/Desktop/envmonitor/sensors/envData.sh","/home/pi/Desktop/envmonitor/sensors/internalStats.sh"]