Closed radiaz22 closed 3 years ago
You are doing this the hard way, you should instead let the database do the work:
mysql -uroot -hlocalhost -s -e "SELECT COUNT(*) FROM radacct WHERE accstoptime IS NULL" radius
Otherwise, the script is good.
BTW, there is no question.
Thanks for the answer, well yes, the question is, why I can't graph with those 2 numbers in cacti, I get Nan but as I can see the script is located and with the right permissions
Well, first use spine. Then, once you have spine compiled, note the id of the host and then run spine like this:
./spine -R -S -V 3 -f id -l id
Replacing id with the number. You should get what the script is returning. Post that.
Thanks for the quick reply, here is the output of the command:
[root@freeradius bin]# ./spine -R -S -V 3 -f 10 -l 10 SPINE: Using spine config file [../etc/spine.conf] SPINE: Version 1.0.1 starting NOTE: Spine will support multithread device polling. DEBUG: In Poller, About to Start Polling of Device for Device ID 10 Device[10] TH[1] Device has no information for recache. Device[10] TH[1] NOTE: There are '18' Polling Items for this Device Device[10] TH[1] DS[118] SS[0] SERVER: /usr/share/cacti/scripts/ss_poller.php ss_poller, output: Time:59.5004 Method:spine Processes:1 Threads:1 Hosts:6 HostsPerProcess:6 DataSources:78 RRDsProcessed:0 Device[10] TH[1] DS[119] SS[0] SERVER: /usr/share/cacti/scripts/ss_poller.php ss_boost, output: Time:0 RRDUpdates:0 Device[10] TH[1] DS[120] SS[0] SERVER: /usr/share/cacti/scripts/ss_poller.php ss_poller_items, output: snmp:25 script:9 script_server:44 Device[10] TH[1] DS[121] SS[0] SERVER: /usr/share/cacti/scripts/ss_poller.php ss_recache, output: Poller:1 RecacheTime:0.0 DevicesRecached:0 Device[10] TH[1] DS[122] SS[0] SERVER: /usr/share/cacti/scripts/ss_poller.php ss_boost_mem, output: 0 Device[10] DEBUG: The NIFTY POPEN returned the following File Descriptor 8 Device[10] TH[1] DS[123] SCRIPT: /usr/bin/php -q /usr/share/cacti/scripts/cacti_user_stats.php, output: valid:0 invalid:0 active:0 sleeping:0 garbage:0 uactive:0 usleeping:0 Device[10] TH[1] DS[124] SS[0] SERVER: /usr/share/cacti/scripts/ss_poller.php ss_export, output: ExportDuration:0 TotalGraphsExported:0 Device[10] TH[1] DS[125] SS[0] SERVER: /usr/share/cacti/scripts/ss_poller.php ss_export, output: ExportDuration:0 TotalGraphsExported:0 Device[10] TH[1] DS[126] SS[0] SERVER: /usr/share/cacti/scripts/ss_poller.php ss_syslog_stats, output: deletes:0 incoming:0 removes:0 xfers:0 alerts:0 alarms:0 reports:0 Device[10] TH[1] DS[127] SS[0] SERVER: /usr/share/cacti/scripts/ss_poller.php ss_syslog_time, output: 0 Device[10] TH[1] DS[128] SS[0] SERVER: /usr/share/cacti/scripts/ss_poller.php ss_syslog_stats, output: deletes:0 incoming:0 removes:0 xfers:0 alerts:0 alarms:0 reports:0 Device[10] TH[1] DS[129] SS[0] SERVER: /usr/share/cacti/scripts/ss_poller.php ss_thold_time, output: 0 Device[10] TH[1] DS[130] SS[0] SERVER: /usr/share/cacti/scripts/ss_poller.php ss_boost_avg_size, output: 0 Device[10] TH[1] DS[131] SS[0] SERVER: /usr/share/cacti/scripts/ss_poller.php ss_boost_records, output: 0 Device[10] TH[1] DS[132] SS[0] SERVER: /usr/share/cacti/scripts/ss_poller.php ss_boost_table, output: 16384 Device[10] TH[1] DS[133] SS[0] SERVER: /usr/share/cacti/scripts/ss_poller.php ss_boost_timing, output: get_records:0 results_cycle:0 rrd_filename_and_template:0 rrd_lastupdate:0 rrdupdate:0 delete:0 Device[10] DEBUG: The NIFTY POPEN returned the following File Descriptor 8 Device[10] TH[1] DS[134] SCRIPT: /usr/bin/bash /usr/share/cacti/scripts/online_users.sh, output: Online:1 Total:9 Device[10] DEBUG: The NIFTY POPEN returned the following File Descriptor 8 Device[10] TH[1] DS[135] SCRIPT: /bin/sh /usr/share/cacti/scripts/online_users.sh, output: Online:1 Total:9 Device[10] TH[1] Total Time: 0.21 Seconds Device[10] TH[1] DEBUG: HOST COMPLETE: About to Exit Device Polling Thread Function DEBUG: The Value of Active Threads is 0 for Device ID 10 Time: 0.3743 s, Threads: 1, Devices: 1 [root@freeradius bin]#
So, it's collecting the data correctly right?
Device[10] TH[1] DS[134] SCRIPT: /usr/bin/bash /usr/share/cacti/scripts/online_users.sh, output: Online:1 Total:9
Device[10] DEBUG: The NIFTY POPEN returned the following File Descriptor 8
Device[10] TH[1] DS[135] SCRIPT: /bin/sh /usr/share/cacti/scripts/online_users.sh, output: Online:1 Total:9
Device[10] TH[1] Total Time: 0.21 Seconds
Looks like you have two of them though. You should post a screen shot of your Data Input Method and the Data Template. I don't think this is a bug, more of a training issue though.
Of course, here they are. I have attached them.
Yes I have 2 numbers. 1 for online users, and the second for the total users. My goal is to graph these numbers as they change while connecting. Some sort of real time graph.
An update fellows, I will now use one number to graph, only online users, so your suggestion for a script is very welcome. I will try to make it to appear one number. The problem here is that even though I'm using the command rrdtool update online-users_chillispot_online_135.rrd -t chillispot_online:chillispot_total N:1:1 to manually create a number it does not appears as I want. It appears just as a Line and somehow it drops to 0 in between time, I wish it keeps the track of the online users and never drops 0, unless there is no one connected. I have attached a graphic, and I will be very gratefull if someone points me out in a direction where I can change this. What I really want is that some how appears like this. Sorry for the paint edit. Hope anyone can help me. Thanks. In the previous graph there is online users connected and that is why the graphic is all green, but in the hour 15:20 no one, was online, so that's why is zero. then it appears 7 users. (Can the numbers be all round up?) Thanks once again for your help.
The thing I notice is you have the data source items set to COUNTER when they should be GAUGE.
Thanks I will change that feature. I have to create a new data input, to start from zero.
I have made this new data input method With this data template Also this is the debug from data source Still not getting to graph the number, even though rrdtool says it is ok I am still manually putting values with this command "_rrdtool update online-users_online155.rrd -t Online N:1" Right now I'm just playing around with settings in data source and Templates / graph settings to see if something changes. Thanks.
You max value is 20, but the last value is 52, which means your RRDfile is clipping the data:
rrdtool tune file.rrd -a Online:U
Thanks, I have run the command, but I don't get one thing, if you can explain it to me. The last value in that expample was 52. but I only created 4 values (1,2,3,4) why was 52 the last value created? Perhaps I am making the settings all wrong. What I want is to graph the result number of the script, in this case the round number, 2, 3, 4, and so on, that's all. So I don't know why a last number was 52 if none of the previous commands were major than 10. Thanks in advance. By the way I still don't graph.
Well I have change the script to only count the total users, which should be esier but I have the same results, no graphic, I know I am making some errors while creating the Data Input and Data Sources, but where? Here are the debug from the graphic Debug from graph of total users Debug from Data source of total users
Also I have checked the logs, and cacti says that the script value is 0. Thats weird. Because if I run manually the same script as in the picture, it says another value.
Sounds like the cron user is missing some permissions to get good data or something. I'm going to close this for now, at these appear to be more environment and training issues.
Hello people, this is more a question than a problem. I install a cacti software in a VM with CentOS 7, also I have hotspot software (Chillispot). My goal is to graph how many users are logged in through the hotspot. So, I have create a bash script that counts the null collums in mysql database table radacct. I have achive this part and when I made the data input process as describe in the user guide it can't graph at all. Al the parameters are default, but I dont know if I have to change something in the configuration. the SO is Centos 7.8 Cacti version 1.2.11 Freeradius 3.0.13 Mysql (mariadb) 5.5 I have attached the simple script. If you can help I would really appreciate online_users.txt