Closed abhin123 closed 7 years ago
make sure the widget id is the same as the one you send on send_event
Thanks for responding. Yes, its the same. While replacing the send_event line in .rb file with the folowing send_event('polarion', { value: rand(100) }) its getting dispalyed correctly but i want the content in /dashing/abhi/sample.txt which is a number to be displayed in the dashboard.
var.to_i
maybe? it expects a number
Thanks for the suggestion. Even after the changes, the value is not been displayed on the dashboard. I have modifed the .rb file to
SCHEDULER.every '30s' do var = File.open("/dashing/abhi/sample.txt", "r") var.each_line do |line| puts line send_event('polarion', { value: var.to_i }) end end
But still no luck. Any help in this is highly appreciated. I am a beginner, setting the dashboard for the first time.
send_event('polarion', { value: line.to_i })
Applied the changes, still the result is the same. The ouput of the file /dashing/abhi/sample.txt is a number just one line.
I am getting the value with this.
var = File.open("/dashing/abhi/sample.txt", "r") SCHEDULER.every '30s' do send_event('polarion', { current: var.gets.to_i }) end
But the value goes after refreshing looks like the value is not appearing once the scheduler runs. It takes the value for the first time and when the scheduler runs value turns to zero.
because the first time you read the value, the file cursor stays a the end of the file and there is nothing more to read. You need to open/read the file every time or put the cursor back at the beginning of the file every time.
Hi, Can you please suggest a method so that the value in the file gets displayed?
Finnaly got it working. Thanks a lot for your help
np, glad you figured this out :)
I want to push numeric data from a file to my dashboard.
I am using the following .rb file as job for pushing the data
SCHEDULER.every '30s' do var = File.open("/dashing/abhi/sample.txt", "r") var.each_line do |line| puts line send_event('polarion', { value: var }) end end
But the data is not being displayed in dashboard.