January 28, 20179 yr Awesome script! Thank you. Curious if anyone else is having the same issues that I am...That being, I'm only getting data for two drives. No matter what order I put them in the array, I only get temp data for sda & sdb. edit: Want to add that SMART is enabled on all drives and when I run the command manually, I get data back. root@Hollywood:~# smartctl -A /dev/sde Temperature_Celsius 0x0022 020 040 000 Old_age Always - 20 (0 14 0 0 0) root@Hollywood:~# smartctl -A /dev/sda 194 Temperature_Celsius 0x0022 128 119 000 Old_age Always - 22 Hey dude, I had similar issues with another script, so managed to find why, I've quoted the important sections for you... What's happening is that the script is looking for exactly two digits at the end of the temperature line, but seeing "0)", and this causes it to fail .. I tested and had a similar issue here; All of my non-WD drives report similarly. If I was running just WD, it looks like it'd be fine. output from bash script parity 40 disk1 40 disk2 40 disk3 39 disk4 41 disk5 39 disk6 40 disk7 38 cache 40 output from php script 39 /dev/sdc /dev/sdd /dev/sde /dev/sdg 40 /dev/sdh /dev/sdi /dev/sdj /dev/sdb 39 /dev/sdf Unfortunately I don't know enough PHP to say how to actually fix it, although it does look like a regex issue.. maybe Viaduct can assist .. For myself, I actually used RAINMAN's HDTemp script which can be found in this same thread, it uses a different method of parsing the smartctl output, so doesn't suffer the same issue .. -Kharn
January 30, 20179 yr had a play while I was at work today ... if you wish to still use this script, change the line: preg_match("/Temperature.+(\d\d)$/im", $output, $match); to preg_match("/Temperature_Celsius.+-.+?(\d{2})/im", $output, $match); This should make it work Let me know how you get on ..
February 2, 20179 yr Latest one .. This works on Cisco series 800 routers, and should work on others as well.. Things that are monitored include: Interface Traffic, in/out & errors CPU Usage Memory Usage Uptime as a string Uptime in seconds And much, much more* Configuration is the same as the rest of my scripts. Just put in the necessary details at the top, and then run the script with cron Pretty picture: and the script: ### MIBS # ifDesc .1.3.6.1.2.1.2.2.1.2.x # ifOperStatus .1.3.6.1.2.1.2.2.1.8.x (interface up/down) # ifInOctets .1.3.6.1.2.1.2.2.1.10.x # ifOutOctets .1.3.6.1.2.1.2.2.1.16.x # ifInErrors .1.3.6.1.2.1.2.2.1.14.x # ifOutErrors .1.3.6.1.2.1.2.2.1.20.x # Uptime .1.3.6.1.2.1.1.3.0 # Processor Used Mem 1.3.6.1.4.1.9.9.48.1.1.1.5.1 # I/O Used Mem 1.3.6.1.4.1.9.9.48.1.1.1.5.2 # Processor Free Mem 1.3.6.1.4.1.9.9.48.1.1.1.6.1 # I/O Free Mem 1.3.6.1.4.1.9.9.48.1.1.1.6.2 # CPU 5m .1.3.6.1.4.1.9.9.109.1.1.1.1.8 # CPU 1m .1.3.6.1.4.1.9.9.109.1.1.1.1.7 # CPU 5s .1.3.6.1.4.1.9.9.109.1.1.1.1.6 ### DB Details DBURL=http://localhost:8086 DBNAME=test DEVICE="test" ### SNMP Details VERSION=2c # 1, v2c COMMUNITY=public #Community String SNMPURL=test #Hostname or IP ### Time periods in seconds SECONDS=316512321252 SECYEAR=31536000 SECMONTH=2592000 SECWEEK=604800 SECDAY=86400 SECHOUR=3600 SECMIN=60 ## Main program ### Interface stats INTERFACES=( `snmpwalk -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov .1.3.6.1.2.1.2.2.1.2 | awk '{printf $2 " "}'` ) arrayLength=${#INTERFACES[@]} for (( i = 1; i <= ${arrayLength}; i++)) do snmpget -v 2c -c public firewall -Ov .1.3.6.1.2.1.2.2.1.2.$i | awk '{print $2}' | while read INTER do snmpget -v 2c -c public firewall -Ov .1.3.6.1.2.1.2.2.1.10.$i | awk '{print $2}' |sed 's/[^0-9]*//g' | while read INOCT do snmpget -v 2c -c public firewall -Ov .1.3.6.1.2.1.2.2.1.16.$i | awk '{print $2}' | sed 's/[^0-9]*//g' | while read OUTOCT do snmpget -v 2c -c public firewall -Ov .1.3.6.1.2.1.2.2.1.14.$i | awk '{print $2}' | sed 's/[^0-9]*//g' | while read INERROR do snmpget -v 2c -c public firewall -Ov .1.3.6.1.2.1.2.2.1.20.$i | awk '{print $2}' | sed 's/[^0-9]*//g' | while read OUTERROR do if [[ $INOCT == '' ]]; then INOCT=0 fi if [[ $OUTOCT == '' ]]; then OUTOCT=0 fi if [[ $INERROR == '' ]]; then INERROR=0 fi if [[ $OUTERROR == '' ]]; then OUTERROR=0 fi curl -is -XPOST "$DBURL/write?db=$DBNAME" --data-binary "${DEVICE}_Stats,Type=Traffic,Interface=${INTER} Data_In=${INOCT},Data_Out=${OUTOCT},Errors_in=${INERROR},Errors_Out=${OUTERROR}" >/dev/null 2>&1 done done done done done done ###Device Uptime snmpget -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov .1.3.6.1.2.1.1.3.0 | awk '{ print $2 }' | sed 's/[()]//g' | while read UPTIMENUM do UPTIME=$(($UPTIMENUM / 100)) # convert timeticks to seconds curl -is -XPOST "$DBURL/write?db=$DBNAME" --data-binary "${DEVICE}_Stats,Type=UptimeSeconds Uptime_Seconds=${UPTIME}" >/dev/null 2>&1 done ### Get Device Uptime as a string snmpget -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov .1.3.6.1.2.1.1.3.0 | awk '{ print $2 }' | sed 's/[()]//g' | while read UPTIMENUM do UPTIME=$(($UPTIMENUM / 100)) # convert timeticks to seconds #Convert seconds in to days/months/years etc.. STRINGTIME=$(printf "\"%d Years, %d Months, %d Weeks, %d Days, %d Hours, %d Minutes, and %d Seconds\"" \ $(( ${UPTIME} / ${SECYEAR} )) \ $(( ${UPTIME} % ${SECYEAR} / ${SECMONTH} )) \ $(( ${UPTIME} % ${SECYEAR} % ${SECMONTH} / ${SECWEEK} )) \ $(( ${UPTIME} % ${SECYEAR} % ${SECMONTH} % ${SECWEEK} / ${SECDAY} )) \ $(( ${UPTIME} % ${SECYEAR} % ${SECMONTH} % ${SECWEEK} % ${SECDAY} / ${SECHOUR} )) \ $(( ${UPTIME} % ${SECYEAR} % ${SECMONTH} % ${SECWEEK} % ${SECDAY} % ${SECHOUR} / ${SECMIN} )) \ $(( ${UPTIME} % ${SECYEAR} % ${SECMONTH} % ${SECWEEK} % ${SECDAY} % ${SECHOUR} % ${SECMIN} % 60 ))) curl -is -XPOST "$DBURL/write?db=$DBNAME" --data-binary "${DEVICE}_Stats,Type=UptimeString Uptime_String=${STRINGTIME}" >/dev/null 2>&1 done ### Get CPU usage percentage snmpget -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov .1.3.6.1.4.1.9.9.109.1.1.1.1.6.1 | awk '{ print $2 }' | while read FIVESEC do snmpget -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov .1.3.6.1.4.1.9.9.109.1.1.1.1.7.1 | awk '{ print $2 }' | while read ONEMIN do snmpget -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov .1.3.6.1.4.1.9.9.109.1.1.1.1.8.1 | awk '{ print $2 }' | while read FIVEMIN do curl -is -XPOST "$DBURL/write?db=$DBNAME" --data-binary "${DEVICE}_Stats,Type=CPU 5Sec_Average=${FIVESEC},1Min_Average=${ONEMIN},5Min_Average=${FIVEMIN}" >/dev/null 2>&1 done done done ### Get Memory usage PROCUSED=( `snmpget -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov 1.3.6.1.4.1.9.9.48.1.1.1.5.1 | awk '{printf $2}'` ) PROCFREE=( `snmpget -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov 1.3.6.1.4.1.9.9.48.1.1.1.6.1 | awk '{printf $2}'` ) IOUSED=( `snmpget -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov 1.3.6.1.4.1.9.9.48.1.1.1.5.2 | awk '{printf $2}'` ) IOFREE=( `snmpget -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov 1.3.6.1.4.1.9.9.48.1.1.1.6.2 | awk '{printf $2}'` ) curl -is -XPOST "$DBURL/write?db=$DBNAME" --data-binary "${DEVICE}_Stats,Type=Memory Processor_Used=${PROCUSED},Processor_Free=${PROCFREE},IO_Used=${IOUSED},IO_Free=${IOFREE}" >/dev/null 2>&1 Enjoy *There isn't actually any more.
February 9, 20179 yr Ran into an odd problem. I've had to rebuild my Grafana server and since I built it on Ubuntu 16.04, I followed the guidance and install the Grafana 3.0 beta and the latest version of InfluxDB. I updated the Unraid script for the new DB. Something is unhappy with the setup though and I suspect it has to do with how the scripts are writing data to InfluxDB. All of the Unraid metrics are doing the same thing. They will not display by default. I have to change them to points instead of lines. Then, they only work for 5 metrics at a time. If I add a 6th metric, such as for drive temps, it won't display it unless I hide one of the others. This is the case for any of the Unraid reported stats using these scripts. Telegraf gathered stats work fine and don't behave in the same way. Anyone run into this and know a fix? Is this a problem with how the scripts write to InfluxDB?
February 10, 20179 yr As soon as I posted this, I figured it out. Change the "Fill" from null to none. Working well now.
February 18, 20179 yr Does anyone have any suggestions for monitoring VM CPU/memory usage similar to dockers? I'd like to break down how much each VM uses.
February 19, 20179 yr Does anyone have any suggestions for monitoring VM CPU/memory usage similar to dockers? I'd like to break down how much each VM uses. Is it something that is viewable externally via a command? if so it's easy .. if not, you could probably do it via SNMP, or have the script run on the VM itself that pushes to the DB ..
February 19, 20179 yr Hey all, I was having some trouble with RAINMAN's cpu script, for an hour each day, I was noticing that I was getting no stats ... A bit of digging found that it was the first hour each day from when I booted the server.. I don't know if it's because I have a weird processor or not, but if anyone else is having similar issues, my (very slightly) edited version of RAINMAN's script may help you out. DBURL=http://localhost:8086 DBNAME=test DEVICE="test" CURDATE=`date +%s` # Had to increase to 10 samples because I was getting a spike each time I read it. This seems to smooth it out more top -b -n 10 -d.2 | grep "Cpu" | tail -n 1 | awk '{print $2,$4,$6,$8,$10,$12,$14,$16}' | while read CPUusr CPUsys CPUnic CPUidle CPUio CPUirq CPUsirq CPUst do top -bn1 | head -3 | sed -e 's/.*load//g' | awk '/average/ {print $2" " $3" " $4}' | sed -e 's/,//g'| while read LAVG1 LAVG5 LAVG15 do curl -is -XPOST "$DBURL/write?db=$DBNAME" --data-binary "cpuStats,Device=${DEVICE} CPUusr=${CPUusr},CPUsys=${CPUsys},CPUnic=${CPUnic},CPUidle=${CPUidle},CPUio=${CPUio},CPUirq=${CPUirq},CPUsirq=${CPUsirq},CPUst=${CPUst},CPULoadAvg1m=${LAVG1},CPULoadAvg5m=${LAVG5},CPULoadAvg15m=${LAVG15} ${CURDATE}000000000" >/dev/null 2>&1 done done I was having the same problem, and your edit seems to have fixed the problem. Thanks!
February 19, 20179 yr You can access the docker stats using: docker stats --no-stream Right now this outputs the dockers container IDs. There is a --format option that was implemented until version 1.8 of docker and i have 1.10 as part of unraid 6.2.4. With --format you can specify to use name instead which would probably be easier long term as the ID changes when you rebuild or change it. However, I dont see this option as existing for some reason. Not sure. Add formatting options to docker ps with --format https://github.com/docker/docker/blob/master/CHANGELOG.md#180-2015-08-11 What you can do is then run docker ps | grep ContainerID to and grab the container name from there. Something like that. I havent put together a script but its on my list so if someone else gets one going please share
February 19, 20179 yr Haha, ok so it perked my interest. Here you go. Its almost done. Just need to parse it into a script. docker stats --no-stream $(docker ps --format={{.Names}}) Edit: Even better docker stats --no-stream $(docker ps --format={{.Names}}) | sed 's/%//g' | grep -v "CONTAINER" | awk '{print $1,$2,$3}' Just throw that into a while read and send to influx. Table: Name CPU Memory
February 19, 20179 yr Haha, ok so it perked my interest. Here you go. Its almost done. Just need to parse it into a script. docker stats --no-stream $(docker ps --format={{.Names}}) Edit: Even better docker stats --no-stream $(docker ps --format={{.Names}}) | sed 's/%//g' | grep -v "CONTAINER" | awk '{print $1,$2,$3}' Just throw that into a while read and send to influx. Table: Name CPU Memory Was this for me? Thanks if so but I'm looking for VM stats (I already have docker setup with telegraf).
February 21, 20179 yr On 19/02/2017 at 6:48 PM, AllanMar said: Was this for me? Thanks if so but I'm looking for VM stats (I already have docker setup with telegraf). Opps, it was but I miss-read. For virtual machines you are a bit more limited. You can try: virsh domstats CPU usage is measured in ticks or ns so you would have to do some math on the calculation. Looks a bit complicated. I think memory just records what is available for the VM not actually used but I could be wrong. I measure the stats within each of my VMs (actually just 1 at the moment). But it would be nice to get the total usage of the entire CPU from outside the container. Edited February 21, 20179 yr by RAINMAN
May 26, 20179 yr On 11/2/2016 at 2:29 PM, RAINMAN said: If anyone wants the grafana json just let me know I can post it as well. I would absolutely love that! I've spent a good chunk of the day getting something not near as pretty made.
June 2, 20179 yr Hi! First of all, a huge thanks Viaduct for your scripts! It motivated to start scripting again in php (i made a script to control my case fans depending on the drive, mobo and CPU temps, with various thresholds) and the result in grafana looks awesome. I recently bought a WD Red 8tb drive. Unfortunately it always reports "active/idle" (even though the unraid GUI indicates the drive is spun down) with "hdparm -C", which renders the spinup script useless to identify whether the drive is spun up or down: Quote root@Tower:~# hdparm -C /dev/sdf /dev/sdf: drive state is: active/idle I've been looking for other means to get the spin status, but didn't find anything useful. Any ideas? In attachement, a preview of a part of my grafana dashboard. It doesn't illustrate my problem, i just post it as eye candy. EDIT: Ok, i figured that the problem is that my drive is actually never spinning down, even when unRAID tells it to. When i give the command (via Putty hdparm -y or via unraid web ui), it spins down, and about 5 seconds later, it spins back up. I tried setting hdparm -B 127 /dev/sdXXX (https://wiki.archlinux.org/index.php/Hdparm), as well as hdparm -S 180 /dev/sdXXX, but it didn't help. As it is the parity drive, and i have cache drives (with mover), I don't understand what happens. It seems to me that it has something to do with the drives power management, but i can't figure out what. EDIT2: I posted in the Storage device forum about that: Edited June 3, 20179 yr by Lynxphp
June 5, 20179 yr I looked in to this a while back, seems that there's an issue between hdparm/wd drives ... Here's one guy's solution ... http://withblue.ink/2016/07/15/what-i-learnt-from-using-wd-red-disks-to-build-a-home-nas.html About half way down the page, uses a program called "HD Idle" .. but it's not really what you're after .. On 6/2/2017 at 9:02 PM, Lynxphp said: I recently bought a WD Red 8tb drive. Unfortunately it always reports "active/idle" (even though the unraid GUI indicates the drive is spun down) with "hdparm -C", which renders the spinup script useless to identify whether the drive is spun up or down: I've been looking for other means to get the spin status, but didn't find anything useful. Any ideas? EDIT: Ok, i figured that the problem is that my drive is actually never spinning down, even when unRAID tells it to. When i give the command (via Putty hdparm -y or via unraid web ui), it spins down, and about 5 seconds later, it spins back up. I tried setting hdparm -B 127 /dev/sdXXX (https://wiki.archlinux.org/index.php/Hdparm), as well as hdparm -S 180 /dev/sdXXX, but it didn't help. As it is the parity drive, and i have cache drives (with mover), I don't understand what happens. It seems to me that it has something to do with the drives power management, but i can't figure out what. EDIT2: I posted in the Storage device forum about that:
November 3, 20178 yr On 02/06/2017 at 3:02 PM, Lynxphp said: n attachement, a preview of a part of my grafana dashboard. It doesn't illustrate my problem, i just post it as eye candy. How do you get the disk spin state to plot like this? Seems like you have three Y-axis? I'm trying to plot a thermostat like this where temp/humidity are Y1 and Y2, but I want the on/off state of heater to be plotted like your spin state here
November 4, 20178 yr Hi, I think that what you are looking for is the "staircase" display type combined with "line fill" (see attached screenshots). I have it in the series override, because I only wanted the HDD spin to be displayed like this, but you can also specify it in the draw options -> Staircase checkbox & FIll. I hope that helps! Edited November 4, 20178 yr by Lynxphp
November 6, 20178 yr But that means you have it on Y-axis 1, how does that work when its using temperature? Spin seems to be "30" when its spinning, did you just multiply it to make it look like this?
April 22, 20188 yr On 2/1/2017 at 9:00 PM, kharntiitar said: Latest one .. This works on Cisco series 800 routers, and should work on others as well.. Things that are monitored include: Interface Traffic, in/out & errors CPU Usage Memory Usage Uptime as a string Uptime in seconds And much, much more* Configuration is the same as the rest of my scripts. Just put in the necessary details at the top, and then run the script with cron Hey kharntiitar, thanks for the scripts! I'm trying to run this latest one through user.scripts and I keep getting the response: Unknown host (firewall) (Device or resource busy) However, when I run "snmpwalk -v 2c -c public 192.168.1.1" from unRAID CLI I get the feedback I'm expecting. Any idea what the problem might be?
April 23, 20188 yr 1 hour ago, zandrsn said: Hey kharntiitar, thanks for the scripts! I'm trying to run this latest one through user.scripts and I keep getting the response: Unknown host (firewall) (Device or resource busy) However, when I run "snmpwalk -v 2c -c public 192.168.1.1" from unRAID CLI I get the feedback I'm expecting. Any idea what the problem might be? Yup, firewall was my testing hostname .. hostname and I didn't sanitize my script, try this: ### MIBS # ifDesc .1.3.6.1.2.1.2.2.1.2.x # ifOperStatus .1.3.6.1.2.1.2.2.1.8.x (interface up/down) # ifInOctets .1.3.6.1.2.1.2.2.1.10.x # ifOutOctets .1.3.6.1.2.1.2.2.1.16.x # ifInErrors .1.3.6.1.2.1.2.2.1.14.x # ifOutErrors .1.3.6.1.2.1.2.2.1.20.x # Uptime .1.3.6.1.2.1.1.3.0 # Processor Used Mem 1.3.6.1.4.1.9.9.48.1.1.1.5.1 # I/O Used Mem 1.3.6.1.4.1.9.9.48.1.1.1.5.2 # Processor Free Mem 1.3.6.1.4.1.9.9.48.1.1.1.6.1 # I/O Free Mem 1.3.6.1.4.1.9.9.48.1.1.1.6.2 # CPU 5m .1.3.6.1.4.1.9.9.109.1.1.1.1.8 # CPU 1m .1.3.6.1.4.1.9.9.109.1.1.1.1.7 # CPU 5s .1.3.6.1.4.1.9.9.109.1.1.1.1.6 ### DB Details DBURL=http://localhost:8086 DBNAME=test DEVICE="test" ### SNMP Details VERSION=2c # 1, v2c COMMUNITY=public #Community String SNMPURL=test #Hostname or IP ### Time periods in seconds SECONDS=316512321252 SECYEAR=31536000 SECMONTH=2592000 SECWEEK=604800 SECDAY=86400 SECHOUR=3600 SECMIN=60 ## Main program ### Interface stats INTERFACES=( `snmpwalk -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov .1.3.6.1.2.1.2.2.1.2 | awk '{printf $2 " "}'` ) arrayLength=${#INTERFACES[@]} for (( i = 1; i <= ${arrayLength}; i++)) do snmpget -v 2c -c public ${SNMPURL} -Ov .1.3.6.1.2.1.2.2.1.2.$i | awk '{print $2}' | while read INTER do snmpget -v 2c -c public ${SNMPURL} -Ov .1.3.6.1.2.1.2.2.1.10.$i | awk '{print $2}' |sed 's/[^0-9]*//g' | while read INOCT do snmpget -v 2c -c public ${SNMPURL} -Ov .1.3.6.1.2.1.2.2.1.16.$i | awk '{print $2}' | sed 's/[^0-9]*//g' | while read OUTOCT do snmpget -v 2c -c public ${SNMPURL} -Ov .1.3.6.1.2.1.2.2.1.14.$i | awk '{print $2}' | sed 's/[^0-9]*//g' | while read INERROR do snmpget -v 2c -c public ${SNMPURL} -Ov .1.3.6.1.2.1.2.2.1.20.$i | awk '{print $2}' | sed 's/[^0-9]*//g' | while read OUTERROR do if [[ $INOCT == '' ]]; then INOCT=0 fi if [[ $OUTOCT == '' ]]; then OUTOCT=0 fi if [[ $INERROR == '' ]]; then INERROR=0 fi if [[ $OUTERROR == '' ]]; then OUTERROR=0 fi curl -is -XPOST "$DBURL/write?db=$DBNAME" --data-binary "${DEVICE}_Stats,Type=Traffic,Interface=${INTER} Data_In=${INOCT},Data_Out=${OUTOCT},Errors_in=${INERROR},Errors_Out=${OUTERROR}" >/dev/null 2>&1 done done done done done done ###Device Uptime snmpget -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov .1.3.6.1.2.1.1.3.0 | awk '{ print $2 }' | sed 's/[()]//g' | while read UPTIMENUM do UPTIME=$(($UPTIMENUM / 100)) # convert timeticks to seconds curl -is -XPOST "$DBURL/write?db=$DBNAME" --data-binary "${DEVICE}_Stats,Type=UptimeSeconds Uptime_Seconds=${UPTIME}" >/dev/null 2>&1 done ### Get Device Uptime as a string snmpget -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov .1.3.6.1.2.1.1.3.0 | awk '{ print $2 }' | sed 's/[()]//g' | while read UPTIMENUM do UPTIME=$(($UPTIMENUM / 100)) # convert timeticks to seconds #Convert seconds in to days/months/years etc.. STRINGTIME=$(printf "\"%d Years, %d Months, %d Weeks, %d Days, %d Hours, %d Minutes, and %d Seconds\"" \ $(( ${UPTIME} / ${SECYEAR} )) \ $(( ${UPTIME} % ${SECYEAR} / ${SECMONTH} )) \ $(( ${UPTIME} % ${SECYEAR} % ${SECMONTH} / ${SECWEEK} )) \ $(( ${UPTIME} % ${SECYEAR} % ${SECMONTH} % ${SECWEEK} / ${SECDAY} )) \ $(( ${UPTIME} % ${SECYEAR} % ${SECMONTH} % ${SECWEEK} % ${SECDAY} / ${SECHOUR} )) \ $(( ${UPTIME} % ${SECYEAR} % ${SECMONTH} % ${SECWEEK} % ${SECDAY} % ${SECHOUR} / ${SECMIN} )) \ $(( ${UPTIME} % ${SECYEAR} % ${SECMONTH} % ${SECWEEK} % ${SECDAY} % ${SECHOUR} % ${SECMIN} % 60 ))) curl -is -XPOST "$DBURL/write?db=$DBNAME" --data-binary "${DEVICE}_Stats,Type=UptimeString Uptime_String=${STRINGTIME}" >/dev/null 2>&1 done ### Get CPU usage percentage snmpget -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov .1.3.6.1.4.1.9.9.109.1.1.1.1.6.1 | awk '{ print $2 }' | while read FIVESEC do snmpget -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov .1.3.6.1.4.1.9.9.109.1.1.1.1.7.1 | awk '{ print $2 }' | while read ONEMIN do snmpget -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov .1.3.6.1.4.1.9.9.109.1.1.1.1.8.1 | awk '{ print $2 }' | while read FIVEMIN do curl -is -XPOST "$DBURL/write?db=$DBNAME" --data-binary "${DEVICE}_Stats,Type=CPU 5Sec_Average=${FIVESEC},1Min_Average=${ONEMIN},5Min_Average=${FIVEMIN}" >/dev/null 2>&1 done done done ### Get Memory usage PROCUSED=( `snmpget -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov 1.3.6.1.4.1.9.9.48.1.1.1.5.1 | awk '{printf $2}'` ) PROCFREE=( `snmpget -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov 1.3.6.1.4.1.9.9.48.1.1.1.6.1 | awk '{printf $2}'` ) IOUSED=( `snmpget -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov 1.3.6.1.4.1.9.9.48.1.1.1.5.2 | awk '{printf $2}'` ) IOFREE=( `snmpget -v ${VERSION} -c ${COMMUNITY} ${SNMPURL} -Ov 1.3.6.1.4.1.9.9.48.1.1.1.6.2 | awk '{printf $2}'` ) curl -is -XPOST "$DBURL/write?db=$DBNAME" --data-binary "${DEVICE}_Stats,Type=Memory Processor_Used=${PROCUSED},Processor_Free=${PROCFREE},IO_Used=${IOUSED},IO_Free=${IOFREE}" >/dev/null 2>&1 If you look at the start of the main program, there is "snmpget -v 2c -c public firewall..." that was looking for a host named "firewall" .. now it will look for whatever you put in the SNMP URL ... sorry about that let me know if that fixes the issue..
April 23, 20188 yr 13 hours ago, kharntiitar said: If you look at the start of the main program, there is "snmpget -v 2c -c public firewall..." that was looking for a host named "firewall" .. now it will look for whatever you put in the SNMP URL ... sorry about that let me know if that fixes the issue.. Thanks a lot! Runs without an error now. For some reason I'm still not getting any information written to my influxdb though. I tried both a new database within my existing influxdb container (@ SERVERIP:8086/write?db=router) and creating a new influxdb container (@ http://SERVERIP:8087/write?db=router) and neither worked... Any idea what I've done wrong? This is the only part of the script I changed: ### DB Details DBURL=http://192.168.1.107:8086 DBNAME=router DEVICE="asuswrt" ### SNMP Details VERSION=2c # 1, v2c COMMUNITY=public #Community String SNMPURL=192.168.1.1 #Hostname or IP
April 23, 20188 yr 39 minutes ago, zandrsn said: Thanks a lot! Runs without an error now. For some reason I'm still not getting any information written to my influxdb though. I tried both a new database within my existing influxdb container (@ SERVERIP:8086/write?db=router) and creating a new influxdb container (@ http://SERVERIP:8087/write?db=router) and neither worked... Any idea what I've done wrong? This is the only part of the script I changed: ### DB Details DBURL=http://192.168.1.107:8086 DBNAME=router DEVICE="asuswrt" ### SNMP Details VERSION=2c # 1, v2c COMMUNITY=public #Community String SNMPURL=192.168.1.1 #Hostname or IP That should be all you need to change .. what happens if you try something like: curl -i -XPOST http://192.168.1.107:8087/write?db=test --data-binary "TESTING,test1=test1,test2=test2"test3=test3,test4=test4" from the same machine that you're running my script on... You'll need to create a db called 'test' first ..
April 23, 20188 yr 6 hours ago, kharntiitar said: That should be all you need to change .. what happens if you try something like: curl -i -XPOST http://192.168.1.107:8087/write?db=test --data-binary "TESTING,test1=test1,test2=test2"test3=test3,test4=test4" from the same machine that you're running my script on... You'll need to create a db called 'test' first . Ugh, sorry - I'm sure this is some problem on my end. I appreciate your help. When I try: "curl -i -XPOST http://192.168.1.107:8087/write?db=test --data-binary "TESTING,test1=test1,test2=test2"test3=test3,test4=test4" or (since the two instances are different versions of influxdb) "curl -i -XPOST http://192.168.1.107:8086/write?db=test --data-binary "TESTING,test1=test1,test2=test2"test3=test3,test4=test4" I get nothing in either test database and just get one of these > in my terminal. Edited April 23, 20188 yr by zandrsn
April 23, 20188 yr 3 hours ago, zandrsn said: "curl -i -XPOST http://192.168.1.107:8087/write?db=test --data-binary "TESTING,test1=test1,test2=test2"test3=test3,test4=test4" or (since the two instances are different versions of influxdb) "curl -i -XPOST http://192.168.1.107:8086/write?db=test --data-binary "TESTING,test1=test1,test2=test2"test3=test3,test4=test4" I get nothing in either test database and just get one of these > in my terminal. Ok, so there's something going on with your influx, both of those should have errored out, as there was an extra quote in the middle there ... kharn@ts1:~$ curl -i -XPOST http://192.168.1.1:8086/write?db=test --data-binary "TESTING,test1=test1,test2=test2"test3=test3,test4=test4 HTTP/1.1 400 Bad Request Content-Type: application/json Request-Id: 77dfb6b1-4747-11e8-9a98-000000000000 X-Influxdb-Build: OSS X-Influxdb-Error: unable to parse 'TESTING,test1=test1,test2=test2test3=test3,test4=test4': invalid tag format X-Influxdb-Version: 1.5.2 X-Request-Id: 77dfb6b1-4747-11e8-9a98-000000000000 Date: Mon, 23 Apr 2018 22:41:31 GMT Content-Length: 105 I then used the example out of the manual http://docs.influxdata.com/influxdb/v0.9/guides/writing_data/ kharn@ts1:~$ curl -i -XPOST 'http://192.168.1.1:8086/write?db=mydb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000' HTTP/1.1 404 Not Found Content-Type: application/json Request-Id: b6c3f421-4747-11e8-9ab8-000000000000 X-Influxdb-Build: OSS X-Influxdb-Error: database not found: "mydb" X-Influxdb-Version: 1.5.2 X-Request-Id: b6c3f421-4747-11e8-9ab8-000000000000 Date: Mon, 23 Apr 2018 22:43:16 GMT Content-Length: 41 {"error":"database not found: \"mydb\""} basically, it should be spitting some sort of error back at you .. Using the example on the website: kharn@ts1:~$ curl -i -XPOST 'http://192.168.1.1:8086/write?db=mydb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000' HTTP/1.1 204 No Content Content-Type: application/json Request-Id: c49e30df-474a-11e8-9cdb-000000000000 X-Influxdb-Build: OSS X-Influxdb-Version: 1.5.2 X-Request-Id: c49e30df-474a-11e8-9cdb-000000000000 Date: Mon, 23 Apr 2018 23:05:08 GMT -------- influx db commands --------- > create database mydb **********I ran the curl command here************** > use mydb Using database mydb > show measurements name: measurements name ---- cpu_load_short > select * from "cpu_load_short" name: cpu_load_short time host region value ---- ---- ------ ----- 1434055562000000000 server01 us-west 0.64 Hopefully this can shed some light, as you can see what you should/shouldn't be seeing ..
April 23, 20188 yr 13 minutes ago, kharntiitar said: Hopefully this can shed some light, as you can see what you should/shouldn't be seeing .. Strangely enough all of a sudden your script seems to be working for me... And the examples from the manual work as they did for you. I didn't change anything else in the script, so I'm not sure what was going on, but I appreciate the help!
Archived
This topic is now archived and is closed to further replies.