TARGET !scriptname
Moderators: Developers, Moderators
TARGET !scriptname
Hello
Can Weather map display the value of a script other then a numeric value like text?
I have a script that produces the current running artist/song on my MPD server and thought it would be cool to display on my weather map.
I tried a few things with TARGET !/cacti/scripts/getsong.sh but I believe its looking for a numeric value.
Thanks
Nick
Can Weather map display the value of a script other then a numeric value like text?
I have a script that produces the current running artist/song on my MPD server and thought it would be cool to display on my weather map.
I tried a few things with TARGET !/cacti/scripts/getsong.sh but I believe its looking for a numeric value.
Thanks
Nick
- Howie
- Cacti Guru User
- Posts: 5508
- Joined: Thu Sep 16, 2004 5:53 am
- Location: United Kingdom
- Contact:
Re: TARGET !scriptname
From the manual: http://network-weathermap.com/manual/0. ... tml#script
It looks to me as if you can have your script output:
and then use {node:blah:external_line3} and {node:blah:external_line4} to use them. I haven't actually tested that particular plugin in a very long time, though!
It looks to me as if you can have your script output:
Code: Select all
0
0
Artist
Title
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
Re: TARGET !scriptname
Very cool Howie it works!
I have one strange problem though. There's a character on my map looks like a backtick but not sure what it is. I turned on debug but nothing shows up in the logs.
Any idea where that character is coming from at the end of the song title? I tried various things in my script that are commented out but they all show that character.
If I have the script produce no output that character still shows up.
My conf
NODE node01535
LABEL {node:this:external_line4}
LABELOUTLINECOLOR none
LABELBGCOLOR none
LABELFONTCOLOR 255 255 255
TARGET !/var/lib/cacti/scripts/getsong.sh
USESCALE none in percent
POSITION 425 210
My script
#!/bin/sh
#artist="`mpc -h 192.168.5.10 current -f %artist%`"
#song="`mpc -h 192.168.5.10 current `"
#title="'mpc -h 192.168.5.10 current -f %title'"
title="`mpc -h 192.168.5.10 --format \"[[%artist% - ]%title%]\" | head -n 1`"
echo 1
echo 2
echo 3
echo $title
Thanks,
Nick
I have one strange problem though. There's a character on my map looks like a backtick but not sure what it is. I turned on debug but nothing shows up in the logs.
Any idea where that character is coming from at the end of the song title? I tried various things in my script that are commented out but they all show that character.
If I have the script produce no output that character still shows up.
My conf
NODE node01535
LABEL {node:this:external_line4}
LABELOUTLINECOLOR none
LABELBGCOLOR none
LABELFONTCOLOR 255 255 255
TARGET !/var/lib/cacti/scripts/getsong.sh
USESCALE none in percent
POSITION 425 210
My script
#!/bin/sh
#artist="`mpc -h 192.168.5.10 current -f %artist%`"
#song="`mpc -h 192.168.5.10 current `"
#title="'mpc -h 192.168.5.10 current -f %title'"
title="`mpc -h 192.168.5.10 --format \"[[%artist% - ]%title%]\" | head -n 1`"
echo 1
echo 2
echo 3
echo $title
Thanks,
Nick
- Attachments
-
- screenshot-area-2015-02-18-141654.png (4.51 KiB) Viewed 3133 times
Re: TARGET !scriptname
Hello Howie,
I am having the same issue with the backtick being displayed at the end of the string. Looks like there's a return being added too, please see the attached image. I'm using version 0.97c. Is there a solution to fix this?
Cheers,
Rob
I am having the same issue with the backtick being displayed at the end of the string. Looks like there's a return being added too, please see the attached image. I'm using version 0.97c. Is there a solution to fix this?
Cheers,
Rob
Code: Select all
#!/bin/bash
echo 1
echo 2
echo test
echo extern-test
Code: Select all
NODE dd-wrt-front
LABEL {node:this:external_line4}
INFOURL /device/device=11/
NOTES dd-wrt-front
OVERLIBGRAPH /graph.php?height=100&width=512&device=11&type=device_bits&legend=no
ICON images/wireless_1_sm.png
TARGET !/opt/observium/html/weathermap/devicestates/test.sh
LABELOFFSET 0 62
POSITION 928 500
- Attachments
-
- extern_test.png (27.62 KiB) Viewed 2841 times
- Howie
- Cacti Guru User
- Posts: 5508
- Joined: Thu Sep 16, 2004 5:53 am
- Location: United Kingdom
- Contact:
Re: TARGET !scriptname
Could you run with DEBUG, and check the logs, just to see what weathermap thinks is happening? Look for the ReadData lines.
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
Re: TARGET !scriptname
Howie,
Here are the wm_debug ReadData outputs:
ExternalScript ReadData: Returning (1,2,1432958162)
ExternalScript ReadData: Running ../../html/weathermap/devicestates/test.sh
I took a look at the WeatherMapDataSource_external.php script and dumped the arrays to a text file. I wanted to see how the PHP code was interpreting the test.sh shell script. The arrays, $lines and $data, look correct and don't contain a backtick.
Debug code I added to WeatherMapDataSource_external.php:
Ouput of added code:
Thoughts of what could be the problem?
Rob
Here are the wm_debug ReadData outputs:
ExternalScript ReadData: Returning (1,2,1432958162)
ExternalScript ReadData: Running ../../html/weathermap/devicestates/test.sh
I took a look at the WeatherMapDataSource_external.php script and dumped the arrays to a text file. I wanted to see how the PHP code was interpreting the test.sh shell script. The arrays, $lines and $data, look correct and don't contain a backtick.
Debug code I added to WeatherMapDataSource_external.php:
Code: Select all
ob_start();
var_dump($lines);
$linesDump=ob_get_contents();
ob_end_clean();
ob_start();
var_dump($data);
$dataDump=ob_get_contents();
ob_end_clean();
$externFile = "./WeatherMapDataSource_external_lines.txt";
$fh = fopen($externFile, 'w') or die("fopen can not write to file");
fwrite($fh, $command . "\r\n");
fwrite($fh, $linesDump);
fwrite($fh, $dataDump);
fclose($fh);
Code: Select all
array(5) {
[0]=>
string(2) "1
"
[1]=>
string(2) "2
"
[2]=>
string(5) "test
"
[3]=>
string(12) "extern-test
"
[4]=>
bool(false)
}
array(2) {
[0]=>
float(1)
[1]=>
float(2)
}
Rob
- Howie
- Cacti Guru User
- Posts: 5508
- Joined: Thu Sep 16, 2004 5:53 am
- Location: United Kingdom
- Contact:
Re: TARGET !scriptname
fgets() gets lines, but leaves the whitespace on them.
should become
I guess some recent change in gd has made it so \n actually renders, because it was tested OK back when it was written!
Code: Select all
$lines[$i++] = fgets($pipe,1024);
Code: Select all
$lines[$i++] = rtrim(fgets($pipe,1024));
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
Re: TARGET !scriptname
Nice work Howie. I can think of a hundred uses for it.
- Howie
- Cacti Guru User
- Posts: 5508
- Joined: Thu Sep 16, 2004 5:53 am
- Location: United Kingdom
- Contact:
Re: TARGET !scriptname
Nice
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
Who is online
Users browsing this forum: No registered users and 0 guests