Hello,
I am trying to use an external script like below:
vim script.sh
echo "35";
cat test-wan.conf | grep "OUTCOMMENT" | wc -l;
echo "1";
echo "1";
which returns:
35
14
1
1
Then
I am trying to use the customised value in my label:
NODE test
LABEL {node:this:bandwidth_in}{node:this:bandwidth_out}
TARGET !/usr/share/cacti/site/plugins/weathermap/configs/script.sh
It returns 35 and 0
I would like to have 35 and 14
Can you help me?
Thanks
Also Thanks for php weathermap, this tool is just crazy
LABEL and External Script
Moderators: Developers, Moderators
- Howie
- Cacti Guru User
- Posts: 5508
- Joined: Thu Sep 16, 2004 5:53 am
- Location: United Kingdom
- Contact:
Re: LABEL and External Script
First step - run with DEBUG logging and look for the ReadData log lines. You should see exactly what Weathermap gets bac from the script.
My guess is that you need to specify full paths for at least the file you are grepping, and probably for cat, grep and wc, too.
My guess is that you need to specify full paths for at least the file you are grepping, and probably for cat, grep and wc, too.
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: LABEL and External Script
As you said, That was the path.
I had to put:
cat /usr/share/cacti/site/plugins/weathermap/configs/test-wan.conf | grep "OUTCOMMENT" | wc -l;
in my file.
Thanks so much!!
You are the best!
I had to put:
cat /usr/share/cacti/site/plugins/weathermap/configs/test-wan.conf | grep "OUTCOMMENT" | wc -l;
in my file.
Thanks so much!!
You are the best!
Re: LABEL and External Script
Sorry Boss but i have another problem
I have this script:
/bin/rm /usr/share/cacti/site/plugins/weathermap/configs/output16.txt;
sshpass -ppassowrd ssh -o StrictHostKeyChecking=no testuser@router "sh ip ospf database | i 192.168.0.0" >> /usr/share/cacti/site/plugins/weathermap/configs/output16.txt;
test=$(/bin/cat /usr/share/cacti/site/plugins/weathermap/configs/output16.txt | /usr/bin/wc -l);
b=-3; let c=test+b; echo $c ;
echo 1;
echo 0;
echo 0;
I get
125
1
0
0
Here is the node declared in the conf file:
NODE routes-1
LABEL Routes from X: {node:this:bandwidth_in}
TARGET !/usr/share/cacti/site/plugins/weathermap/configs/genial2.sh
I get 0 in my map, I hoped I would get 125
I have activated the debug mode:
03:13:59 PM - WEATHERMAP: Poller[0] DEBUG: [ReadConfig@Weathermap.class.php:2492] [Map 16] wan.conf: TARGET: !/usr/share/cacti/site/plugins/weathermap/configs/genial2.sh
03:13:59 PM - WEATHERMAP: Poller[0] DEBUG: [ProcessTargets@Weathermap.class.php:779] [Map 16] wan.conf: ProcessTargets: New Target: !/usr/share/cacti/site/plugins/weathermap/configs/genial2.sh
03:13:59 PM - WEATHERMAP: Poller[0] DEBUG: [ProcessString@Weathermap.class.php:517] [Map 16] wan.conf: Trace: ProcessString(!/usr/share/cacti/site/plugins/weathermap/configs/genial2.sh, node:routes-1)
03:14:01 PM - WEATHERMAP: Poller[0] DEBUG: [ReadData@Weathermap.class.php:901] [Map 16] wan.conf: ReadData: New Target: !/usr/share/cacti/site/plugins/weathermap/configs/genial2.sh
03:14:01 PM - WEATHERMAP: Poller[0] DEBUG: [ProcessString@Weathermap.class.php:517] [Map 16] wan.conf: Trace: ProcessString(!/usr/share/cacti/site/plugins/weathermap/configs/genial2.sh, node:routes-1)
03:14:01 PM - WEATHERMAP: Poller[0] DEBUG: [ReadData@WeatherMapDataSource_external.php:45] [Map 16] wan.conf: ExternalScript ReadData: Running /usr/share/cacti/site/plugins/weathermap/configs/genial2.sh
I have found the "problem", i changed the script to this and this is working:
I don't know why this was not working under phpweathermap with my previous script.
/bin/rm /usr/share/cacti/site/plugins/weathermap/configs/output16.txt;
sshpass -ppassword ssh -o StrictHostKeyChecking=no testuser@router "sh ip ospf database | i 192.168.0.0" >> /usr/share/cacti/site/plugins/weathermap/configs/output16.txt;
test=$(/bin/cat /usr/share/cacti/site/plugins/weathermap/configs/output16.txt | /usr/bin/wc -l);
echo $(( test - 3));
echo 1;
echo 0;
echo 0;
I have this script:
/bin/rm /usr/share/cacti/site/plugins/weathermap/configs/output16.txt;
sshpass -ppassowrd ssh -o StrictHostKeyChecking=no testuser@router "sh ip ospf database | i 192.168.0.0" >> /usr/share/cacti/site/plugins/weathermap/configs/output16.txt;
test=$(/bin/cat /usr/share/cacti/site/plugins/weathermap/configs/output16.txt | /usr/bin/wc -l);
b=-3; let c=test+b; echo $c ;
echo 1;
echo 0;
echo 0;
I get
125
1
0
0
Here is the node declared in the conf file:
NODE routes-1
LABEL Routes from X: {node:this:bandwidth_in}
TARGET !/usr/share/cacti/site/plugins/weathermap/configs/genial2.sh
I get 0 in my map, I hoped I would get 125
I have activated the debug mode:
03:13:59 PM - WEATHERMAP: Poller[0] DEBUG: [ReadConfig@Weathermap.class.php:2492] [Map 16] wan.conf: TARGET: !/usr/share/cacti/site/plugins/weathermap/configs/genial2.sh
03:13:59 PM - WEATHERMAP: Poller[0] DEBUG: [ProcessTargets@Weathermap.class.php:779] [Map 16] wan.conf: ProcessTargets: New Target: !/usr/share/cacti/site/plugins/weathermap/configs/genial2.sh
03:13:59 PM - WEATHERMAP: Poller[0] DEBUG: [ProcessString@Weathermap.class.php:517] [Map 16] wan.conf: Trace: ProcessString(!/usr/share/cacti/site/plugins/weathermap/configs/genial2.sh, node:routes-1)
03:14:01 PM - WEATHERMAP: Poller[0] DEBUG: [ReadData@Weathermap.class.php:901] [Map 16] wan.conf: ReadData: New Target: !/usr/share/cacti/site/plugins/weathermap/configs/genial2.sh
03:14:01 PM - WEATHERMAP: Poller[0] DEBUG: [ProcessString@Weathermap.class.php:517] [Map 16] wan.conf: Trace: ProcessString(!/usr/share/cacti/site/plugins/weathermap/configs/genial2.sh, node:routes-1)
03:14:01 PM - WEATHERMAP: Poller[0] DEBUG: [ReadData@WeatherMapDataSource_external.php:45] [Map 16] wan.conf: ExternalScript ReadData: Running /usr/share/cacti/site/plugins/weathermap/configs/genial2.sh
I have found the "problem", i changed the script to this and this is working:
I don't know why this was not working under phpweathermap with my previous script.
/bin/rm /usr/share/cacti/site/plugins/weathermap/configs/output16.txt;
sshpass -ppassword ssh -o StrictHostKeyChecking=no testuser@router "sh ip ospf database | i 192.168.0.0" >> /usr/share/cacti/site/plugins/weathermap/configs/output16.txt;
test=$(/bin/cat /usr/share/cacti/site/plugins/weathermap/configs/output16.txt | /usr/bin/wc -l);
echo $(( test - 3));
echo 1;
echo 0;
echo 0;
Who is online
Users browsing this forum: No registered users and 6 guests