Hello Team,
Need to set a room temperature alert for my server room, I don't know which plugin needs to be installed, I am using the following devices Ubibot GS1-AETH1RS + TH30S-B Ethernet Thermometer Hygrometer, WiFi Temperature Humidity Sensor, Digital Temperature Data Logger.
It is a cloud-based device, so we don’t have an IP address to query. You will need to use the URL to find something that can read the results of an API call.
Can you please help me out?
Do I need to make changes in the command file also?
Note-We won't be having IP address only the link we will be having
Room temperature alert
Re: Room temperature alert
Hello @mandar18,
It sounds like you're looking for a custom plugin that will query your URL and read the response. Is this correct?
I would suggest creating a script that uses Python, Bash or some other language compatible with your Nagios Core instance that will query the desired URL and based on the response, give the appropriate output.
Here are some resources to help you get started:
Nagios Plugins - Developer Guidelines
Nagios Plugins - Developer Guidelines - Plugin Outputs
It sounds like you're looking for a custom plugin that will query your URL and read the response. Is this correct?
I would suggest creating a script that uses Python, Bash or some other language compatible with your Nagios Core instance that will query the desired URL and based on the response, give the appropriate output.
Here are some resources to help you get started:
Nagios Plugins - Developer Guidelines
Nagios Plugins - Developer Guidelines - Plugin Outputs
Actively advancing awesome answers with ardent alliteration, aptly addressing all ambiguities. Amplify your acumen and avail our amicable assistance. Eagerly awaiting your astute assessments of our advice.
Re: Room temperature alert
But by URL, can we monitor the room's temperature using the plugin?
Also can we fetch results from API?
I want to monitor the "https://webapi.ubibot.com/channels/8933 ... b547f13f39" this link.
Also can we fetch results from API?
I want to monitor the "https://webapi.ubibot.com/channels/8933 ... b547f13f39" this link.
Re: Room temperature alert
Ask yourself how you would pull this info from the shell. Then do it. Then create a small script that does it and returns text and a return value.
Of course someone else has possibly done the same thing so check out the exchange.
Of course someone else has possibly done the same thing so check out the exchange.
Re: Room temperature alert
@Bbahn can you please help on this?
I am not getting the exact path what you are saying.
I am not getting the exact path what you are saying.
Re: Room temperature alert
Hello @mandar18,
I threw together a quick python script to get you started:
Now you just need to take this data, handle the intervals and output status. You can reference other Nagios python plugins as reference as well as use the documentation I mentioned before.
I threw together a quick python script to get you started:
Code: Select all
import requests
import json
def get_data():
url = "https://webapi.ubibot.com/channels/89336?account_key=7bc1cdc6599832d23e4214b547f13f39"
response = requests.get(url)
data = response.json()
return data
data = get_data()
# "field1": "Temperature",
# "field2": "Humidity",
# "field3": "Voltage",
# "field4": "WIFI RSSI",
# "field5": "GSM RSSI",
# "field6": "Light",
# "field7": "RS485 Temperature",
# "field8": "RS485 Humidity",
# "field9": "RS485 Soil Temperature",
# "field10": "RS485 Soil Moisture",
# "field11": "External Light",
# "field12": "PT100 Temperature",
# "field13": "Wind Speed",
# "field14": "Carbon Dioxide",
# "field15": "RS485 Atmospheric Pressure",
def parse_data(data):
last_values = data["channel"]['last_values']
last_values = json.loads(last_values)
field1 = last_values['field1']['value']
field2 = last_values['field2']['value']
field3 = last_values['field3']['value']
field6 = last_values['field6']['value']
return field1, field2, field3, field6
field1, field2, field3, field6 = parse_data(data)
print("Temperature: ", field1)
print("Humidity: ", field2)
print("Voltage: ", field3)
print("Light: ", field6)
print()
Actively advancing awesome answers with ardent alliteration, aptly addressing all ambiguities. Amplify your acumen and avail our amicable assistance. Eagerly awaiting your astute assessments of our advice.
Re: Room temperature alert
Thank you Bbahan,
I need to add the host first to get data, but like I said before, I only have an API link where I can get the data.
what needs to be done now to add the same as a host in Nagios core?
For example, I am using the below stuff to add a host
define host{
use generic-host
host_name XXXX
alias XXX
address 192.168.XX.XX
check_command check-host-alive
max_check_attempts 5
notification_interval 60
notification_period 24x7
notification_options d,u,r
contact_groups admins
}
To Add the API If I don't have an IP Address then how do I add that API to the host?
I need to add the host first to get data, but like I said before, I only have an API link where I can get the data.
what needs to be done now to add the same as a host in Nagios core?
For example, I am using the below stuff to add a host
define host{
use generic-host
host_name XXXX
alias XXX
address 192.168.XX.XX
check_command check-host-alive
max_check_attempts 5
notification_interval 60
notification_period 24x7
notification_options d,u,r
contact_groups admins
}
To Add the API If I don't have an IP Address then how do I add that API to the host?
Re: Room temperature alert
@Bbahan,
Can you please help me ?
Can you please help me ?
Re: Room temperature alert
You will want command and host or service definitions to be something like the following:
Where check_temperature is the name of your plugin located in /user/local/nagios/libexec
You can find out more about Nagios Core definitions here: Nagios Core Documentation - Object Definitions
Code: Select all
define command{
name check_temperature
command_name check_temperature
command_line $USER1$/check_temperature -I $HOSTADDRESS$ $ARG1$
}
Code: Select all
define service{
use generic-service ; Inherit default values from a template
host_name Ubibot GS1-AETH1RS
service_description Temperature
check_command check_temperature
}
You can find out more about Nagios Core definitions here: Nagios Core Documentation - Object Definitions
Actively advancing awesome answers with ardent alliteration, aptly addressing all ambiguities. Amplify your acumen and avail our amicable assistance. Eagerly awaiting your astute assessments of our advice.