First commit

This commit is contained in:
2018-03-13 08:04:28 +01:00
commit 196a7d2af6
32 changed files with 33836 additions and 0 deletions

6676
syno/_macbook-snmpwalk.txt Normal file

File diff suppressed because it is too large Load Diff

135
syno/_smartctl_hlp.txt Normal file
View File

@@ -0,0 +1,135 @@
smartctl 6.3 2014-07-26 r3976 [x86_64-apple-darwin13.3.0] (local build)
Copyright (C) 2002-14, Bruce Allen, Christian Franke, www.smartmontools.org
Usage: smartctl [options] device
============================================ SHOW INFORMATION OPTIONS =====
-h, --help, --usage
Display this help and exit
-V, --version, --copyright, --license
Print license, copyright, and version information and exit
-i, --info
Show identity information for device
--identify[=[w][nvb]]
Show words and bits from IDENTIFY DEVICE data (ATA)
-g NAME, --get=NAME
Get device setting: all, aam, apm, lookahead, security, wcache, rcache, wcreorder
-a, --all
Show all SMART information for device
-x, --xall
Show all information for device
--scan
Scan for devices
--scan-open
Scan for devices and try to open each device
================================== SMARTCTL RUN-TIME BEHAVIOR OPTIONS =====
-q TYPE, --quietmode=TYPE (ATA)
Set smartctl quiet mode to one of: errorsonly, silent, noserial
-d TYPE, --device=TYPE
Specify device type to one of: ata, scsi, sat[,auto][,N][+TYPE], usbcypress[,X], usbjmicron[,p][,x][,N], usbsunplus, auto, test
-T TYPE, --tolerance=TYPE (ATA)
Tolerance: normal, conservative, permissive, verypermissive
-b TYPE, --badsum=TYPE (ATA)
Set action on bad checksum to one of: warn, exit, ignore
-r TYPE, --report=TYPE
Report transactions (see man page)
-n MODE, --nocheck=MODE (ATA)
No check if: never, sleep, standby, idle (see man page)
============================== DEVICE FEATURE ENABLE/DISABLE COMMANDS =====
-s VALUE, --smart=VALUE
Enable/disable SMART on device (on/off)
-o VALUE, --offlineauto=VALUE (ATA)
Enable/disable automatic offline testing on device (on/off)
-S VALUE, --saveauto=VALUE (ATA)
Enable/disable Attribute autosave on device (on/off)
-s NAME[,VALUE], --set=NAME[,VALUE]
Enable/disable/change device setting: aam,[N|off], apm,[N|off],
lookahead,[on|off], security-freeze, standby,[N|off|now],
wcache,[on|off], rcache,[on|off], wcreorder,[on|off]
======================================= READ AND DISPLAY DATA OPTIONS =====
-H, --health
Show device SMART health status
-c, --capabilities (ATA)
Show device SMART capabilities
-A, --attributes
Show device SMART vendor-specific Attributes and values
-f FORMAT, --format=FORMAT (ATA)
Set output format for attributes: old, brief, hex[,id|val]
-l TYPE, --log=TYPE
Show device log. TYPE: error, selftest, selective, directory[,g|s],
xerror[,N][,error], xselftest[,N][,selftest],
background, sasphy[,reset], sataphy[,reset],
scttemp[sts,hist], scttempint,N[,p],
scterc[,N,M], devstat[,N], ssd,
gplog,N[,RANGE], smartlog,N[,RANGE]
-v N,OPTION , --vendorattribute=N,OPTION (ATA)
Set display OPTION for vendor Attribute N (see man page)
-F TYPE, --firmwarebug=TYPE (ATA)
Use firmware bug workaround:
none, nologdir, samsung, samsung2, samsung3, xerrorlba, swapid
-P TYPE, --presets=TYPE (ATA)
Drive-specific presets: use, ignore, show, showall
-B [+]FILE, --drivedb=[+]FILE (ATA)
Read and replace [add] drive database from FILE
[default is +/usr/local/etc/smart_drivedb.h
and then /usr/local/Cellar/smartmontools/6.3/share/smartmontools/drivedb.h]
============================================ DEVICE SELF-TEST OPTIONS =====
-t TEST, --test=TEST
Run test. TEST: offline, short, long, conveyance, force, vendor,N,
select,M-N, pending,N, afterselect,[on|off]
-C, --captive
Do test in captive mode (along with -t)
-X, --abort
Abort any non-captive test on device
=================================================== SMARTCTL EXAMPLES =====
smartctl -a disk0 (Prints all SMART information)
smartctl -t long /dev/disk0 (Executes extended disk self-test)
smartctl --smart=on --saveauto=on /dev/rdisk0 (Enables SMART on first disk)
smartctl --attributes --log=selftest --quietmode=errorsonly /dev/disk0
(Prints Self-Test & Attribute errors)
smartctl -a IOService:/MacRISC2PE/pci@f4000000/AppleMacRiscPCI/ata-6@D/AppleKauaiATA/ATADeviceNub@0/IOATABlockStorageDriver/IOATABlockStorageDevice
(You can use IOService: ...)
smartctl -c IODeviceTree:/pci@f4000000/ata-6@D/@0:0
(... Or IODeviceTree:)

3461
syno/_syno_snmpwalk.txt Normal file

File diff suppressed because it is too large Load Diff

20894
syno/_walk_syno.xml Normal file

File diff suppressed because it is too large Load Diff

424
syno/check_snmp_ds414.sh Executable file
View File

@@ -0,0 +1,424 @@
#!/bin/bash
SNMPCOMMUNITY="public"
SNMPVERSION="2c"
SNMPWALK=$(which snmpwalk)
SNMPGET=$(which snmpget)
HOSTNAME="192.168.0.8"
verbose="yes"
#######################
# Synology System MIB
#######################
OID_syno="1.3.6.1.4.1.6574"
OID_modelName="1.3.6.1.4.1.6574.1.5.1.0"
OID_serialNumber="1.3.6.1.4.1.6574.1.5.2.0"
OID_DSMVersion="1.3.6.1.4.1.6574.1.5.3.0"
OID_temp="1.3.6.1.4.1.6574.1.2.0"
# Normal (1) Failed (2)
OID_systemStatus="1.3.6.1.4.1.6574.1.1.0"
OID_powerStatus="1.3.6.1.4.1.6574.1.3.0"
OID_systemFanStatus="1.3.6.1.4.1.6574.1.4.1.0"
OID_CPUFanStatus="1.3.6.1.4.1.6574.1.4.2.0"
# Available(1) Unavailable(2) Connecting(3) Disconnected(4) Others(5)
OID_upgradeAvailable="1.3.6.1.4.1.6574.1.5.4.0"
#####################
# Synology Disk MIB
#####################
OID_disk=""
OID_diskID="1.3.6.1.4.1.6574.2.1.1.2"
OID_diskModel="1.3.6.1.4.1.6574.2.1.1.3"
# SATA, SSD
OID_diskType="1.3.6.1.4.1.6574.2.1.1.4"
# Normal(1) Initialized(2) NotInitialized(3) SystemPartitionFailed(4) Crashed(5)
OID_diskStatus="1.3.6.1.4.1.6574.2.1.1.5"
OID_diskTemp="1.3.6.1.4.1.6574.2.1.1.6"
#OID_diskID_0="1.3.6.1.4.1.6574.2.1.1.2.0"
#OID_diskID_3="1.3.6.1.4.1.6574.2.1.1.2.3"
#OID_diskModel_0="1.3.6.1.4.1.6574.2.1.1.3.0"
#OID_diskModel_3="1.3.6.1.4.1.6574.2.1.1.3.3"
#OID_diskStatus_0="1.3.6.1.4.1.6574.2.1.1.5.0"
#OID_diskStatus_3="1.3.6.1.4.1.6574.2.1.1.5.3"
#OID_diskTemp_0="1.3.6.1.4.1.6574.2.1.1.6.0"
#OID_diskTemp_3="1.3.6.1.4.1.6574.2.1.1.6.3"
#####################
# Synology RAID MIB
#####################
OID_RAID=""
#OID_RAIDName="1.3.6.1.4.1.6574.3.1.1.2"
#OID_RAIDStatus="1.3.6.1.4.1.6574.3.1.1.3"
OID_RAIDName="1.3.6.1.4.1.6574.3.1.1.2.0"
# Normal(1) Repairing(2) Migrating(3) Expanding(4) Deleting(5) Creating(6) RaidSyncing(7) RaidParityChecking(8) RaidAssembling(9) Canceling(10) Degrade(11) Crashed(12)
OID_RAIDStatus="1.3.6.1.4.1.6574.3.1.1.3.0"
####################
# Synology UPS MIB
####################
OID_upsDeviceModel=".1.1"
OID_upsDeviceManufacturer=".1.2"
OID_upsDeviceSerial=".1.3"
OID_upsInfoStatus=".2.1"
OID_upsInfoMfrDate=".2.6.2"
OID_upsInfoLoadValue=".2.12.1"
OID_upsBatteryChargeValue=".3.1.1"
OID_upsBatteryChargeWarning=".3.1.4"
OID_upsBatteryType=".3.12"
#$OID_upsDeviceModel $OID_upsDeviceManufacturer $OID_upsDeviceSerial $OID_upsInfoStatus $OID_upsInfoMfrDate $OID_upsInfoLoadValue $OID_upsBatteryChargeValue $OID_upsBatteryChargeWarning $OID_upsBatteryType
###########
# CPU MIB
###########
OID_ssCpuUser=".1.3.6.1.4.1.2021.11.9.0"
OID_ssCpuSystem=".1.3.6.1.4.1.2021.11.10.0"
OID_ssCpuIdle=".1.3.6.1.4.1.2021.11.11.0"
OID_laLoadInt_1=".1.3.6.1.4.1.2021.10.1.5.1"
OID_laLoadInt_2=".1.3.6.1.4.1.2021.10.1.5.2"
OID_laLoadInt_3=".1.3.6.1.4.1.2021.10.1.5.3"
#$OID_ssCpuUser $OID_ssCpuSystem $OID_ssCpuIdle $OID_laLoadInt_1 $OID_laLoadInt_2 $OID_laLoadInt_3
#############
# Memory MIB
#############
OID_memTotalSwap=".1.3.6.1.4.1.2021.4.3.0"
OID_memAvailSwap=".1.3.6.1.4.1.2021.4.4.0"
OID_memTotalReal=".1.3.6.1.4.1.2021.4.5.0"
OID_memAvailReal=".1.3.6.1.4.1.2021.4.6.0"
OID_memTotalFree=".1.3.6.1.4.1.2021.4.11.0"
OID_memShared=".1.3.6.1.4.1.2021.4.13.0"
OID_memBuffer=".1.3.6.1.4.1.2021.4.14.0"
OID_memCached=".1.3.6.1.4.1.2021.4.15.0"
#$OID_memTotalSwap $OID_memAvailSwap $OID_memTotalReal $OID_memAvailReal $OID_memTotalFree $OID_memShared $OID_memBuffer $OID_memCached
##############
# Network MIB
##############
OID_if=""
OID_ifName=".1.3.6.1.2.1.31.1.1.1.1"
OID_ifHCInOctets=".1.3.6.1.2.1.31.1.1.1.6"
OID_ifHCOutOctets=".1.3.6.1.2.1.31.1.1.1.10"
#$OID_ifName $OID_ifHCInOctets $OID_ifHCOutOctets
##############
# Disk MIB (no)
##############
OID_storage=""
OID_hrStorageDescr=".1.3.6.1.2.1.25.2.3.1.3"
OID_hrStorageAllocationUnits=".1.3.6.1.2.1.25.2.3.1.4"
OID_hrStorageSize=".1.3.6.1.2.1.25.2.3.1.5"
OID_hrStorageUsed=".1.3.6.1.2.1.25.2.3.1.6"
OID_diskIODevice=".1.3.6.1.4.1.2021.13.15.1.1.2"
OID_diskIONReadX=".1.3.6.1.4.1.2021.13.15.1.1.12"
OID_diskIONWrittenX=".1.3.6.1.4.1.2021.13.15.1.1.13"
OID_synoDisk=".1.3.6.1.4.1.6574.2"
#$OID_hrStorageDescr $OID_hrStorageAllocationUnits $OID_hrStorageSize $OID_hrStorageUsed $OID_diskIODevice $OID_diskIONReadX $OID_diskIONWrittenX $OID_synoDisk
#coldStart="1.3.6.1.6.31.1.5.1"
#warmStart="1.3.6.1.6.31.1.5.2"
#authentificationFailure="1.3.6.1.6.31.1.5.5"
nbDisk=`$SNMPWALK -OQne -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME 1.3.6.1.4.1.6574.2.1.1.2 2> /dev/null | wc -l `
nbRAID=`$SNMPWALK -OQne -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME 1.3.6.1.4.1.6574.3.1.1.2 2> /dev/null | wc -l`
for i in `seq 1 $nbDisk`;
do
OID_disk="$OID_disk $OID_diskID.$(($i-1)) $OID_diskModel.$(($i-1)) $OID_diskStatus.$(($i-1)) $OID_diskTemp.$(($i-1)) "
done
for i in `seq 1 $nbRAID`;
do
OID_RAID="$OID_RAID $OID_RAIDName.$(($i-1)) $OID_RAIDStatus.$(($i-1))"
done
# Synology System MIB
synoSystem=`$SNMPGET -OQne -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME $OID_modelName $OID_serialNumber $OID_DSMVersion $OID_temp $OID_systemStatus $OID_powerStatus $OID_systemFanStatus $OID_CPUFanStatus $OID_upgradeAvailable 2> /dev/null`
if [ "$?" != "0" ] ; then
echo "CRITICAL - Problem with SNMP request synoSystem"
#exit 2
fi
#echo $synoSystem
modelName=$(echo "$synoSystem" | grep $OID_modelName | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "Synology model: $modelName" ; fi
serialNumber=$(echo "$synoSystem" | grep $OID_serialNumber | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "Synology s/n: $serialNumber" ; fi
DSMVersion=$(echo "$synoSystem" | grep $OID_DSMVersion | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "DSMVersion: $DSMVersion" ; fi
temp=$(echo "$synoSystem" | grep $OID_temp | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "Temperature: $temp °C" ; fi
systemStatus=$(echo "$synoSystem" | grep $OID_systemStatus | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "Etat Système: $systemStatus" ; fi
powerStatus=$(echo "$synoSystem" | grep $OID_powerStatus | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "Etat alimentation: $powerStatus" ; fi
systemFanStatus=$(echo "$synoSystem" | grep $OID_systemFanStatus | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "Ventilo Système: $systemFanStatus" ; fi
CPUFanStatus=$(echo "$synoSystem" | grep $OID_CPUFanStatus | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "Ventilo CPU: $CPUFanStatus" ; fi
upgradeAvailable=$(echo "$synoSystem" | grep $OID_upgradeAvailable | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "Temperature: $upgradeAvailable" ; fi
# Synology Disk MIB
synoDisk=`$SNMPGET -OQne -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME $OID_disk $OID_RAID 2> /dev/null`
#echo $synoDisk
if [ "$?" != "0" ] ; then
echo "CRITICAL - Problem with SNMP request synoDisk"
#exit 2
fi
#echo $synoDisk
echo "Nb de disques: $nbDisk"
for i in `seq 1 $nbDisk`;
do
diskID[$i]=$(echo "$synoDisk" | grep "$OID_diskID.$(($i-1)) " | cut -d "=" -f2)
diskModel[$i]=$(echo "$synoDisk" | grep "$OID_diskModel.$(($i-1)) " | cut -d "=" -f2)
diskStatus[$i]=$(echo "$synoDisk" | grep "$OID_diskStatus.$(($i-1)) " | cut -d "=" -f2 | sed 's/^[ \t]*//;s/[ \t]*$//')
diskTemp[$i]=$(echo "$synoDisk" | grep "$OID_diskTemp.$(($i-1)) " | cut -d "=" -f2 | sed 's/^[ \t]*//;s/[ \t]*$//')
if [ "${diskStatus[$i]}" != "1" ] ; then
if [ "${diskStatus[$i]}" = "2" ] ; then diskStatus[$i]="Initialized"; fi
if [ "${diskStatus[$i]}" = "3" ] ; then diskStatus[$i]="NotInitialized"; fi
if [ "${diskStatus[$i]}" = "4" ] ; then diskStatus[$i]="SystemPartitionFailed"; fi
if [ "${diskStatus[$i]}" = "5" ] ; then diskStatus[$i]="Crashed"; fi
healthStatus=2
healthString="$healthString, problem with ${diskID[$i]} (model:${diskModel[$i]}) status:${diskStatus[$i]} temperature:${diskTemp[$i]} C "
else
diskStatus[$i]="Normal"
fi
if [ "$verbose" = "yes" ] ; then echo "${diskID[$i]} (model:${diskModel[$i]}) status:${diskStatus[$i]} temperature:${diskTemp[$i]} C" ; fi
done
echo "Nb de RAID: $nbRAID"
for i in `seq 1 $nbRAID`;
do
RAIDName[$i]=$(echo "$synoDisk" | grep $OID_RAIDName.$(($i-1)) | cut -d "=" -f2)
RAIDStatus[$i]=$(echo "$synoDisk" | grep $OID_RAIDStatus.$(($i-1)) | cut -d "=" -f2 | sed 's/^[ \t]*//;s/[ \t]*$//')
if [ "${RAIDStatus[$i]}" != "1" ] ; then
if [ "${RAIDStatus[$i]}" = "2" ] ; then RAIDStatus[$i]="Repairing"; fi
if [ "${RAIDStatus[$i]}" = "3" ] ; then RAIDStatus[$i]="Migrating"; fi
if [ "${RAIDStatus[$i]}" = "4" ] ; then RAIDStatus[$i]="Expanding"; fi
if [ "${RAIDStatus[$i]}" = "5" ] ; then RAIDStatus[$i]="Deleting"; fi
if [ "${RAIDStatus[$i]}" = "6" ] ; then RAIDStatus[$i]="Creating"; fi
if [ "${RAIDStatus[$i]}" = "7" ] ; then RAIDStatus[$i]="RaidSyncing"; fi
if [ "${RAIDStatus[$i]}" = "8" ] ; then RAIDStatus[$i]="RaidParityChecking"; fi
if [ "${RAIDStatus[$i]}" = "9" ] ; then RAIDStatus[$i]="RaidAssembling"; fi
if [ "${RAIDStatus[$i]}" = "10" ] ; then RAIDStatus[$i]="Canceling"; fi
if [ "${RAIDStatus[$i]}" = "11" ] ; then RAIDStatus[$i]="Degrade"; fi
if [ "${RAIDStatus[$i]}" = "12" ] ; then RAIDStatus[$i]="Crashed"; fi
#healthStatus=2
#healthString="$healthString, RAID status ($RAIDName ): $RAIDStatus "
else
RAIDStatus[$i]="Normal"
fi
if [ "$verbose" = "yes" ] ; then echo "${RAIDName[$i]} status:${RAIDStatus[$i]}" ; fi
done
# Synology UPS MIB
synoUPS=`$SNMPGET -OQne -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME $OID_upsDeviceModel $OID_upsDeviceManufacturer $OID_upsDeviceSerial $OID_upsInfoStatus $OID_upsInfoMfrDate $OID_upsInfoLoadValue $OID_upsBatteryChargeValue $OID_upsBatteryChargeWarning $OID_upsBatteryType 2> /dev/null`
if [ "$?" != "0" ] ; then
echo "CRITICAL - Problem with SNMP request synoUPS"
#exit 2
else
#echo $synoUPS
upsDeviceModel=$(echo "$synoUPS" | grep $OID_upsDeviceModel | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "upsDeviceModel: $upsDeviceModel" ; fi
upsDeviceManufacturer=$(echo "$synoUPS" | grep $OID_upsDeviceManufacturer | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "upsDeviceManufacturer: $upsDeviceManufacturer" ; fi
upsDeviceSerial=$(echo "$synoUPS" | grep $OID_upsDeviceSerial | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "upsDeviceSerial: $upsDeviceSerial" ; fi
upsInfoStatus=$(echo "$synoUPS" | grep $OID_upsInfoStatus | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "upsInfoStatus: $upsInfoStatus" ; fi
upsInfoMfrDate=$(echo "$synoUPS" | grep $OID_upsInfoMfrDate | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "upsInfoMfrDate: $upsInfoMfrDate" ; fi
upsInfoLoadValue=$(echo "$synoUPS" | grep $OID_upsInfoLoadValue | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "upsInfoLoadValue: $upsInfoLoadValue" ; fi
upsBatteryChargeValue=$(echo "$synoUPS" | grep $OID_upsBatteryChargeValue | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "upsBatteryChargeValue: $upsBatteryChargeValue" ; fi
upsBatteryChargeWarning=$(echo "$synoUPS" | grep $OID_upsBatteryChargeWarning | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "upsBatteryChargeWarning: $upsBatteryChargeWarning" ; fi
upsBatteryType=$(echo "$synoUPS" | grep $OID_upsBatteryType | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "upsBatteryType: $upsBatteryType" ; fi
fi
# CPU MIB
cpuMIB=`$SNMPGET -OQne -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME $OID_ssCpuUser $OID_ssCpuSystem $OID_ssCpuIdle $OID_laLoadInt_1 $OID_laLoadInt_2 $OID_laLoadInt_3 2> /dev/null`
if [ "$?" != "0" ] ; then
echo "CRITICAL - Problem with SNMP request cpuMIB"
#exit 2
fi
#echo $cpuMIB
ssCpuUser=$(echo "$cpuMIB" | grep $OID_ssCpuUser | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "ssCpuUser: $ssCpuUser" ; fi
ssCpuSystem=$(echo "$cpuMIB" | grep $OID_ssCpuSystem | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "ssCpuSystem: $ssCpuSystem" ; fi
ssCpuIdle=$(echo "$cpuMIB" | grep $OID_ssCpuIdle | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "ssCpuIdle: $ssCpuIdle" ; fi
laLoadInt_1=$(echo "$cpuMIB" | grep $OID_laLoadInt_1 | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "laLoadInt_1: $laLoadInt_1" ; fi
laLoadInt_2=$(echo "$cpuMIB" | grep $OID_laLoadInt_2 | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "laLoadInt_2: $laLoadInt_2" ; fi
laLoadInt_3=$(echo "$cpuMIB" | grep $OID_laLoadInt_3 | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "laLoadInt_3: $laLoadInt_3" ; fi
# Memory MIB
memoryMIB=`$SNMPGET -OQne -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME $OID_memTotalSwap $OID_memAvailSwap $OID_memTotalReal $OID_memAvailReal $OID_memTotalFree $OID_memShared $OID_memBuffer $OID_memCached 2> /dev/null`
if [ "$?" != "0" ] ; then
echo "CRITICAL - Problem with SNMP request memoryMIB"
#exit 2
fi
#echo $memoryMIB
memTotalSwap=$(echo "$memoryMIB" | grep $OID_memTotalSwap | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "memTotalSwap: $memTotalSwap" ; fi
memAvailSwap=$(echo "$memoryMIB" | grep $OID_memAvailSwap | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "memAvailSwap: $memAvailSwap" ; fi
memTotalReal=$(echo "$memoryMIB" | grep $OID_memTotalReal | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "memTotalReal: $memTotalReal" ; fi
memAvailReal=$(echo "$memoryMIB" | grep $OID_memAvailReal | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "memAvailReal: $memAvailReal" ; fi
memTotalFree=$(echo "$memoryMIB" | grep $OID_memTotalFree | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "memTotalFree: $memTotalFree" ; fi
memShared=$(echo "$memoryMIB" | grep $OID_memShared | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "memShared: $memShared" ; fi
memBuffer=$(echo "$memoryMIB" | grep $OID_memBuffer | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "memBuffer: $memBuffer" ; fi
memCached=$(echo "$memoryMIB" | grep $OID_memCached | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "memCached: $memCached" ; fi
# Network MIB (no)
nbIF=`$SNMPWALK -OQne -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME .1.3.6.1.2.1.31.1.1.1.1 2> /dev/null | wc -l `
#echo $nbIF
for i in `seq 1 $nbIF`;
do
echo "OID_ifName $OID_ifName.$(($i))"
echo "OID_ifHCInOctets $OID_ifHCInOctets.$(($i))"
echo "OID_ifHCOutOctets $OID_ifHCOutOctets.$(($i))"
OID_if="$OID_if $OID_ifName.$(($i)) $OID_ifHCInOctets.$(($i)) $OID_ifHCOutOctets.$(($i)) "
done
echo "tableau"
echo ${OID_if[0]}
networkMIB=`$SNMPGET -OQne -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME $OID_if 2> /dev/null`
echo $networkMIB
if [ "$?" != "0" ] ; then
echo "CRITICAL - Problem with SNMP request networkMIB"
#exit 2
fi
for i in `seq 1 $nbIF`;
do
ifName[$i]=$(echo "$networkMIB" | grep "$OID_ifName.$(($i)) " | cut -d "=" -f2)
ifHCInOctets[$i]=$(echo "$networkMIB" | grep "$OID_ifHCInOctets.$(($i)) " | cut -d "=" -f2)
ifHCOutOctets[$i]=$(echo "$networkMIB" | grep "$OID_ifHCOutOctets.$(($i)) " | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "${ifName[$i]} In:${ifHCInOctets[$i]} Out:${ifHCOutOctets[$i]}" ; fi
done
# Disk MIB (no)
OID_hrStorageIndex=".1.3.6.1.2.1.25.2.3.1.1"
nbStorage=`$SNMPWALK -OQne -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME .1.3.6.1.2.1.25.2.3.1.3 2> /dev/null | wc -l`
for i in `seq 1 $nbStorage`;
do
echo "OID_hrStorageIndex $OID_hrStorageIndex.$(($i))"
#OID_hrStorageIndex .1.3.6.1.2.1.25.2.3.1.1.1 -> get 1
#OID_hrStorageIndex .1.3.6.1.2.1.25.2.3.1.1.2
#OID_hrStorageIndex .1.3.6.1.2.1.25.2.3.1.1.3
#diskIndex=`$SNMPGET -OQne -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME
echo "OID_hrStorageDescr $OID_hrStorageDescr.$(($i))"
echo "OID_ifHCInOctets $OID_ifHCInOctets.$(($i))"
echo "OID_hrStorageAllocationUnits $OID_hrStorageAllocationUnits.$(($i))"
OID_if="$OID_if $OID_hrStorageDescr.$(($i)) $OID_hrStorageAllocationUnits.$(($i)) $OID_hrStorageSize.$(($i)) "
done
diksMIB=`$SNMPGET -OQne -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME $OID_hrStorageDescr $OID_hrStorageAllocationUnits $OID_hrStorageSize $OID_hrStorageUsed $OID_diskIODevice $OID_diskIONReadX $OID_diskIONWrittenX $OID_synoDisk 2> /dev/null`
#OID_hrStorageIndex=".1.3.6.1.2.1.25.2.3.1.1"
#OID_hrStorageType=".1.3.6.1.2.1.25.2.3.1.2"
#OID_hrStorageDescr=".1.3.6.1.2.1.25.2.3.1.3"
#OID_hrStorageAllocationUnits=".1.3.6.1.2.1.25.2.3.1.4"
#OID_hrStorageSize=".1.3.6.1.2.1.25.2.3.1.5"
#OID_hrStorageUsed=".1.3.6.1.2.1.25.2.3.1.6"
#OID_diskIODevice=".1.3.6.1.4.1.2021.13.15.1.1.2"
#OID_diskIONReadX=".1.3.6.1.4.1.2021.13.15.1.1.12"
#OID_diskIONWrittenX=".1.3.6.1.4.1.2021.13.15.1.1.13"
#OID_synoDisk=".1.3.6.1.4.1.6574.2"
if [ "$?" != "0" ] ; then
echo "CRITICAL - Problem with SNMP request diksMIB"
#exit 2
fi
#echo $diksMIB
OID_hrStorageDescr=$(echo "$diksMIB" | grep $OID_hrStorageDescr | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "OID_hrStorageDescr: $OID_hrStorageDescr" ; fi
hrStorageAllocationUnits=$(echo "$diksMIB" | grep $OID_hrStorageAllocationUnits | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "hrStorageAllocationUnits: $hrStorageAllocationUnits" ; fi
hrStorageSize=$(echo "$diksMIB" | grep $OID_hrStorageSize | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "hrStorageSize: $hrStorageSize" ; fi
hrStorageUsed=$(echo "$diksMIB" | grep $OID_hrStorageUsed | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "hrStorageUsed: $hrStorageUsed" ; fi
diskIODevice=$(echo "$diksMIB" | grep $OID_diskIODevice | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "diskIODevice: $diskIODevice" ; fi
diskIONReadX=$(echo "$diksMIB" | grep $OID_diskIONReadX | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "diskIONReadX: $diskIONReadX" ; fi
diskIONWrittenX=$(echo "$diksMIB" | grep $OID_diskIONWrittenX | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "diskIONWrittenX: $diskIONWrittenX" ; fi
synoDisk=$(echo "$diksMIB" | grep $OID_synoDisk | cut -d "=" -f2)
if [ "$verbose" = "yes" ] ; then echo "synoDisk: $synoDisk" ; fi

17
syno/cpuinfo Normal file
View File

@@ -0,0 +1,17 @@
Processor : Marvell PJ4Bv7 Processor rev 2 (v7l)
processor : 0
BogoMIPS : 1332.01
processor : 1
BogoMIPS : 1332.01
Features : swp half thumb fastmult vfp edsp vfpv3 tls
CPU implementer : 0x56
CPU architecture: 7
CPU variant : 0x2
CPU part : 0x584
CPU revision : 2
Hardware : Marvell Armada XP Development Board
Revision : 0000
Serial : 0000000000000000

204
syno/disk_mac.sh Executable file
View File

@@ -0,0 +1,204 @@
#!/bin/bash
#cf test sur les strings
SNMPCOMMUNITY="public"
SNMPVERSION="2c"
SNMPWALK=$(which snmpwalk)
SNMPGET=$(which snmpget)
CMD_BC=$(which bc)
CMD_EXPR=$(which expr)
#HOSTNAME="localhost"
HOSTNAME="192.168.0.8"
WARNING=80
CRITICAL=90
STATE=$STATE_UNKNOWN
STATE_OK="OK"
STATE_WARNING="Warning"
STATE_CRITICAL="Critical"
STATE_UNKNOWN="Inconnu"
##############
# Disk MIB (no)
##############
OID_storage=""
OID_hrStorageIndex=".1.3.6.1.2.1.25.2.3.1.1"
#A description of the type and instance of the storage described by this entry
OID_hrStorageDescr=".1.3.6.1.2.1.25.2.3.1.3"
#The size, in bytes, of the data objects allocated from this pool
OID_hrStorageAllocationUnits=".1.3.6.1.2.1.25.2.3.1.4"
#The size of the storage represented by this entry, in units of hrStorageAllocationUnits
OID_hrStorageSize=".1.3.6.1.2.1.25.2.3.1.5"
#The amount of the storage represented by this entry
OID_hrStorageUsed=".1.3.6.1.2.1.25.2.3.1.6"
OID_diskIODevice=".1.3.6.1.4.1.2021.13.15.1.1.2"
OID_diskIONReadX=".1.3.6.1.4.1.2021.13.15.1.1.12"
OID_diskIONWrittenX=".1.3.6.1.4.1.2021.13.15.1.1.13"
OID_synoDisk=".1.3.6.1.4.1.6574.2"
nbStorage=`$SNMPWALK -OQne -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME $OID_hrStorageDescr 2> /dev/null | wc -l`
declare RESULT=()
while read -r LINE; do
RESULT[${#RESULT[@]}]=$LINE
index=`$SNMPGET -OQne -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME $OID_hrStorageIndex.$(($i)) 2> /dev/null`
OID_storage="$OID_storage $OID_hrStorageDescr.$(($LINE)) $OID_hrStorageAllocationUnits.$(($LINE)) $OID_hrStorageSize.$(($LINE)) $OID_hrStorageUsed.$(($LINE)) "
done < <($SNMPWALK -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME $OID_hrStorageIndex | awk '{print $4}')
diskMIB=`$SNMPGET -OQne -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME $OID_storage 2> /dev/null`
#OID_hrStorageIndex=".1.3.6.1.2.1.25.2.3.1.1"
#OID_hrStorageType=".1.3.6.1.2.1.25.2.3.1.2"
#OID_hrStorageDescr=".1.3.6.1.2.1.25.2.3.1.3"
#OID_hrStorageAllocationUnits=".1.3.6.1.2.1.25.2.3.1.4"
#OID_hrStorageSize=".1.3.6.1.2.1.25.2.3.1.5"
#OID_hrStorageUsed=".1.3.6.1.2.1.25.2.3.1.6"
#OID_diskIODevice=".1.3.6.1.4.1.2021.13.15.1.1.2"
#OID_diskIONReadX=".1.3.6.1.4.1.2021.13.15.1.1.12"
#OID_diskIONWrittenX=".1.3.6.1.4.1.2021.13.15.1.1.13"
#OID_synoDisk=".1.3.6.1.4.1.6574.2"
if [ "$?" != "0" ] ; then
echo "CRITICAL - Problem with SNMP request diksMIB"
#exit 2
fi
#echo $diskMIB
size_convert() {
if [ $VALUE -ge 1099511627776 ]; then
VALUE=`echo "scale=2 ; ( ( ( $VALUE / 1024 ) / 1024 ) / 1024 ) / 1024" | $CMD_BC`
VALUE="$VALUE To"
elif [ $VALUE -ge 1073741824 ]; then
VALUE=`echo "scale=2 ; ( ( $VALUE / 1024 ) / 1024 ) / 1024" | $CMD_BC`
VALUE="$VALUE Go"
elif [ $VALUE -ge 1048576 ]; then
VALUE=`echo "scale=2 ; ( $VALUE / 1024 ) / 1024" | $CMD_BC`
VALUE="$VALUE Mo"
else
VALUE=`echo "scale=2 ; $VALUE / 1024" | $CMD_BC`
VALUE="$VALUE Octets"
fi
}
size_fix() {
if [ ${VALUE: 0:1} = "-" ]; then
VALUE=`$CMD_EXPR 4294967294 - \( 0 - $VALUE \)`
fi
}
hrStorageDescr=""
hrStorageAllocationUnits=""
hrStorageSize=""
hrStorageUsed=""
i=0
j=0
declare RESULT=()
while read -r LINE; do
RESULT[${#RESULT[@]}]=$LINE
_hrStorageDescr=$(echo $LINE | grep $OID_hrStorageDescr | cut -d "=" -f2)
_hrStorageAllocationUnits=$(echo $LINE | grep $OID_hrStorageAllocationUnits | cut -d "=" -f2)
_hrStorageSize=$(echo $LINE | grep $OID_hrStorageSize | cut -d "=" -f2)
_hrStorageUsed=$(echo $LINE | grep $OID_hrStorageUsed | cut -d "=" -f2)
if [ -n "$_hrStorageDescr" ] ; then hrStorageDescr[$j]=$_hrStorageDescr ; fi
if [ -n "$_hrStorageAllocationUnits" ] ; then hrStorageAllocationUnits[$j]=$_hrStorageAllocationUnits ; fi
if [ -n "$_hrStorageSize" ] ; then hrStorageSize[$j]=$_hrStorageSize ; fi
if [ -n "$_hrStorageUsed" ] ; then
#hrStorageUsed[$j]=$_hrStorageUsed
VALUE=$_hrStorageUsed
#size_fix
#size_convert
hrStorageUsed[$j]=$VALUE
fi
((i=i+1))
if [ $i -eq "4" ]
then
i=0
((j=j+1))
fi
done < <($SNMPGET -OQne -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME $OID_storage)
for((i=0;i<$nbStorage;i++));
do
# // remove all spaces
#DISK_LABEL=${hrStorageDescr[i]// }
# remove leading and trailing spaces
DISK_LABEL=`echo ${hrStorageDescr[i]} | sed 's/^ *//g' | sed 's/ *$//g'`
DISK_UNIT=`echo ${hrStorageAllocationUnits[i]} | awk '{print $1}'`
DISK_TOTAL=${hrStorageSize[i]// }
DISK_USED=${hrStorageUsed[i]// }
# longeur de la chaine
#echo ${#DISK_USED}
# 1er caractère de la variable est -
#if [ ${VALUE: 0:1} = "-" ]; then
#echo "$DISK_LABEL"
# Swap space
#if [ "${DISK_LABEL}" == "Shared memory" ]; then
#echo "$DISK_TOTAL"
#echo "$DISK_USED"
#fi
if [ "${DISK_LABEL}" != "/dev" ] && [ "${DISK_LABEL}" != "/net" ] && [ "${DISK_LABEL}" != "/home" ] && [ "${DISK_LABEL}" != "Shared memory" ]; then
DISK_TOTAL=`$CMD_EXPR $DISK_TOTAL \* \( $DISK_UNIT \)`
DISK_USED=`$CMD_EXPR $DISK_USED \* \( $DISK_UNIT \)`
#echo "$DISK_TOTAL"
#echo "$DISK_USED"
PERFDATA_WARNING=0
PERFDATA_CRITICAL=0
if [ $WARNING != 0 ] || [ $CRITICAL != 0 ]; then
DISK_USED_POURCENT=`$CMD_EXPR \( $DISK_USED \* 100 \) / $DISK_TOTAL`
PERFDATA_WARNING=`$CMD_EXPR \( $DISK_TOTAL \* $WARNING \) / 100`
PERFDATA_CRITICAL=`$CMD_EXPR \( $DISK_TOTAL \* $CRITICAL \) / 100`
#echo "$PERFDATA_WARNING"
#echo "$PERFDATA_CRITICAL"
if [ $DISK_USED_POURCENT -gt $CRITICAL ] && [ $CRITICAL != 0 ]; then
STATE=$STATE_CRITICAL
elif [ $DISK_USED_POURCENT -gt $WARNING ] && [ $WARNING != 0 ]; then
STATE=$STATE_WARNING
else
STATE=$STATE_OK
fi
else
STATE=$STATE_OK
fi
VALUE=$DISK_TOTAL
size_convert
DISK_TOTAL_FORMAT=$VALUE
VALUE=$DISK_USED
size_convert
DISK_USED_FORMAT=$VALUE
printf "%s %s %s\n" "$DISK_LABEL $DISK_USED_FORMAT utilise sur $DISK_TOTAL_FORMAT (${DISK_USED_POURCENT}%) $STATE"
fi
done
#exit $STATE

56
syno/diskstats Normal file
View File

@@ -0,0 +1,56 @@
1 0 ram0 0 0 0 0 0 0 0 0 0 0 0
1 1 ram1 0 0 0 0 0 0 0 0 0 0 0
1 2 ram2 0 0 0 0 0 0 0 0 0 0 0
1 3 ram3 0 0 0 0 0 0 0 0 0 0 0
1 4 ram4 0 0 0 0 0 0 0 0 0 0 0
1 5 ram5 0 0 0 0 0 0 0 0 0 0 0
1 6 ram6 0 0 0 0 0 0 0 0 0 0 0
1 7 ram7 0 0 0 0 0 0 0 0 0 0 0
1 8 ram8 0 0 0 0 0 0 0 0 0 0 0
1 9 ram9 0 0 0 0 0 0 0 0 0 0 0
1 10 ram10 0 0 0 0 0 0 0 0 0 0 0
1 11 ram11 0 0 0 0 0 0 0 0 0 0 0
1 12 ram12 0 0 0 0 0 0 0 0 0 0 0
1 13 ram13 0 0 0 0 0 0 0 0 0 0 0
1 14 ram14 0 0 0 0 0 0 0 0 0 0 0
1 15 ram15 0 0 0 0 0 0 0 0 0 0 0
8 0 sda 798440 4175491 25051310 24737440 764667 7985160 69248440 36936410 0 13184110 61842370
8 1 sda1 39133 5998 1183342 1543860 199340 67520 2202944 3863880 0 4449410 5407660
8 2 sda2 177 70 1976 1230 1232 1196 19448 17130 0 17220 18380
8 5 sda5 759115 4169371 23865456 23192260 563575 7916444 67026040 33051040 0 9423930 56411850
8 16 sdb 841459 4197719 25502936 26886120 735045 7959471 68809400 37076320 0 13145480 64140360
8 17 sdb1 39920 6014 1219568 1623890 199426 67434 2202944 3954370 0 4469890 5578060
8 18 sdb2 42 71 904 560 1173 1254 19448 18620 0 18640 19200
8 21 sdb5 801482 4191582 24281928 25261590 533926 7890783 66587000 33098910 0 9304950 58538670
8 32 sdc 923512 4122134 25301128 25788470 754686 8009458 69368768 38966950 0 13353260 64938050
8 33 sdc1 40033 5473 1241730 1348070 199701 67158 2202944 3979580 0 4553870 5327650
8 34 sdc2 148 81 1832 28090 1266 1162 19448 17060 0 43960 45170
8 37 sdc5 883316 4116528 24057030 24412230 553199 7941138 67146368 34965730 0 9538540 59560700
8 48 sdd 757608 4117249 24693292 25590520 741663 8004580 69221976 35784750 0 13209970 61535250
8 49 sdd1 40628 6133 1297616 1488500 199925 66935 2202944 3986810 0 4607670 5475200
8 50 sdd2 113 562 5400 620 1259 1169 19448 17980 0 17760 18620
8 53 sdd5 716817 4110138 23386548 24101000 539899 7936476 66999576 31774140 0 9316050 56035360
31 0 mtdblock0 0 0 0 0 0 0 0 0 0 0 0
31 1 mtdblock1 0 0 0 0 0 0 0 0 0 0 0
31 2 mtdblock2 0 0 0 0 0 0 0 0 0 0 0
31 3 mtdblock3 0 0 0 0 0 0 0 0 0 0 0
31 4 mtdblock4 0 0 0 0 0 0 0 0 0 0 0
31 5 mtdblock5 0 0 0 0 0 0 0 0 0 0 0
31 6 mtdblock6 0 0 0 0 0 0 0 0 0 0 0
9 0 md0 184369 0 4940728 0 193589 0 1613424 0 0 0 0
9 1 md1 457 0 3656 0 2070 0 16552 0 0 0 0
9 2 md2 17355884 0 76405362 0 30079695 0 194258296 0 0 0 0
253 0 dm-0 17355718 0 76404034 153625380 30079695 0 194258296 4062776380 0 10558810 4216475080
253 1 dm-1 8287175 0 71907138 74937500 15413726 0 194258296 2076055230 0 10389900 2151074640
65 0 sdq 164 1097 7157 86320 58088 12 224 112580 0 166570 198810
65 1 sdq1 137 700 6733 60980 16 12 224 190 0 35270 61160
65 16 sdr 176685 213741 3124669 350600 23346 537973 4490552 1540650 0 207810 1890770
65 17 sdr1 176668 213705 3124245 328040 23346 537973 4490552 1540650 0 185250 1868210
7 0 loop0 0 0 0 0 0 0 0 0 0 0 0
7 1 loop1 0 0 0 0 0 0 0 0 0 0 0
7 2 loop2 0 0 0 0 0 0 0 0 0 0 0
7 3 loop3 0 0 0 0 0 0 0 0 0 0 0
7 4 loop4 0 0 0 0 0 0 0 0 0 0 0
7 5 loop5 0 0 0 0 0 0 0 0 0 0 0
7 6 loop6 0 0 0 0 0 0 0 0 0 0 0
7 7 loop7 0 0 0 0 0 0 0 0 0 0 0

28
syno/filesystems Normal file
View File

@@ -0,0 +1,28 @@
nodev sysfs
nodev rootfs
nodev bdev
nodev proc
nodev tmpfs
nodev sockfs
nodev pipefs
nodev anon_inodefs
nodev rpc_pipefs
nodev devpts
ext3
ext2
ext4
nodev ramfs
nodev nfs
nodev nfs4
nodev mqueue
nodev mtd_inodefs
nodev usbfs
nodev ecryptfs
vfat
fuseblk
nodev fuse
nodev fusectl
hfsplus
iso9660
udf
nodev cifs

11
syno/mdstat Normal file
View File

@@ -0,0 +1,11 @@
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4]
md2 : active raid5 sdb5[0] sdc5[2] sdd5[3] sda5[1]
8776594944 blocks super 1.2 level 5, 64k chunk, algorithm 2 [4/4] [UUUU]
md1 : active raid1 sda2[0] sdb2[1] sdc2[2] sdd2[3]
2097088 blocks [4/4] [UUUU]
md0 : active raid1 sda1[0] sdb1[1] sdc1[2] sdd1[3]
2490176 blocks [4/4] [UUUU]
unused devices: <none>

33
syno/meminfo Normal file
View File

@@ -0,0 +1,33 @@
MemTotal: 1033912 kB
MemFree: 39140 kB
Buffers: 104416 kB
Cached: 521708 kB
SwapCached: 1556 kB
Active: 210512 kB
Inactive: 530308 kB
Active(anon): 59288 kB
Inactive(anon): 97696 kB
Active(file): 151224 kB
Inactive(file): 432612 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 2097084 kB
SwapFree: 2090016 kB
Dirty: 16 kB
Writeback: 0 kB
AnonPages: 113364 kB
Mapped: 56040 kB
Shmem: 42256 kB
Slab: 221572 kB
SReclaimable: 182160 kB
SUnreclaim: 39412 kB
KernelStack: 2224 kB
PageTables: 4960 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 2614040 kB
Committed_AS: 1277952 kB
VmallocTotal: 950272 kB
VmallocUsed: 27368 kB
VmallocChunk: 860156 kB

34
syno/partitions Normal file
View File

@@ -0,0 +1,34 @@
major minor #blocks name
8 0 2930266584 sda
8 1 2490240 sda1
8 2 2097152 sda2
8 5 2925532864 sda5
8 16 2930266584 sdb
8 17 2490240 sdb1
8 18 2097152 sdb2
8 21 2925532864 sdb5
8 32 2930266584 sdc
8 33 2490240 sdc1
8 34 2097152 sdc2
8 37 2925532864 sdc5
8 48 2930266584 sdd
8 49 2490240 sdd1
8 50 2097152 sdd2
8 53 2925532864 sdd5
31 0 832 mtdblock0
31 1 2880 mtdblock1
31 2 4288 mtdblock2
31 3 64 mtdblock3
31 4 64 mtdblock4
31 5 64 mtdblock5
31 6 8192 mtdblock6
9 0 2490176 md0
9 1 2097088 md1
9 2 8776594944 md2
253 0 8776593408 dm-0
253 1 8776593408 dm-1
65 0 732574582 sdq
65 1 732571904 sdq1
65 16 1953514584 sdr
65 17 1953511904 sdr1

219
syno/script.sh Executable file
View File

@@ -0,0 +1,219 @@
#!/bin/bash
# check_snmp_disksize
# Description : Check the disk size of Windows server and Unix server
# Version : 1.6
# Author : Yoann LAMY
# Licence : GPLv2
# MacBook-Pro:syno bruno$ ./script.sh -H localhost -d /BOOTCAMP
# Commands
CMD_BASENAME="/usr/bin/basename"
CMD_SNMPGET="/usr/bin/snmpget"
CMD_SNMPWALK="/usr/bin/snmpwalk"
CMD_BC="/usr/bin/bc"
CMD_AWK="/usr/bin/awk"
CMD_GREP="/usr/bin/grep"
CMD_EXPR="/bin/expr"
# Script name
SCRIPTNAME=`$CMD_BASENAME $0`
# Version
VERSION="1.6"
# Plugin return codes
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
# 'hrStorageDescr', HOST-RESOURCES-MIB
OID_DESC=".1.3.6.1.2.1.25.2.3.1.3"
# 'hrStorageAllocationUnits', HOST-RESOURCES-MIB
OID_UNIT=".1.3.6.1.2.1.25.2.3.1.4"
# 'hrStorageSize', HOST-RESOURCES-MIB
OID_TOTAL=".1.3.6.1.2.1.25.2.3.1.5"
# 'hrStorageUsed', HOST-RESOURCES-MIB
OID_USED=".1.3.6.1.2.1.25.2.3.1.6"
# Default variables
DESCRIPTION="Unknown"
STATE=$STATE_UNKNOWN
CODE=0
# Default options
COMMUNITY="public"
HOSTNAME="127.0.0.1"
DISK=""
WARNING=20
CRITICAL=10
# Option processing
print_usage() {
echo "Usage: ./check_snmp_disksize -H 127.0.0.1 -C public -d C: -w 80 -c 90"
echo " $SCRIPTNAME -H ADDRESS"
echo " $SCRIPTNAME -C STRING"
echo " $SCRIPTNAME -d STRING"
echo " $SCRIPTNAME -w INTEGER"
echo " $SCRIPTNAME -c INTEGER"
echo " $SCRIPTNAME -h"
echo " $SCRIPTNAME -V"
}
print_version() {
echo $SCRIPTNAME version $VERSION
echo ""
echo "This nagios plugins comes with ABSOLUTELY NO WARRANTY."
echo "You may redistribute copies of the plugins under the terms of the GNU General Public License v2."
}
print_help() {
print_version
echo ""
print_usage
echo ""
echo "Check the disk size of Windows server and Unix server"
echo ""
echo "-H ADDRESS"
echo " Name or IP address of host (default: 127.0.0.1)"
echo "-C STRING"
echo " Community name for the host's SNMP agent (default: public)"
echo "-d STRING"
echo " Drive letter (C:) or mount point (/home)"
echo "-w INTEGER"
echo " Warning level for size in percent (default: 0)"
echo "-c INTEGER"
echo " Critical level for size in percent (default: 0)"
echo "-h"
echo " Print this help screen"
echo "-V"
echo " Print version and license information"
echo ""
echo ""
echo "This plugin uses the 'snmpget' command and the 'snmpwalk' command included with the NET-SNMP package."
echo "This plugin support performance data output."
echo "If the percentage of the warning and critical levels are set 0, then the script returns a OK state."
}
while getopts H:C:d:w:c:hV OPT
do
case $OPT in
H) HOSTNAME="$OPTARG" ;;
C) COMMUNITY="$OPTARG" ;;
d) DISK="$OPTARG" ;;
w) WARNING=$OPTARG ;;
c) CRITICAL=$OPTARG ;;
h)
print_help
exit $STATE_UNKNOWN
;;
V)
print_version
exit $STATE_UNKNOWN
;;
esac
done
# Plugin processing
if [ "${DISK: 0:1}" != "/" ]; then
if [ "${DISK: -1}" != ":" ]; then
DISK="${DISK}:"
fi
fi
size_convert() {
if [ $VALUE -ge 1099511627776 ]; then
VALUE=`echo "scale=2 ; ( ( ( $VALUE / 1024 ) / 1024 ) / 1024 ) / 1024" | $CMD_BC`
VALUE="$VALUE To"
elif [ $VALUE -ge 1073741824 ]; then
VALUE=`echo "scale=2 ; ( ( $VALUE / 1024 ) / 1024 ) / 1024" | $CMD_BC`
VALUE="$VALUE Go"
elif [ $VALUE -ge 1048576 ]; then
VALUE=`echo "scale=2 ; ( $VALUE / 1024 ) / 1024" | $CMD_BC`
VALUE="$VALUE Mo"
else
VALUE=`echo "scale=2 ; $VALUE / 1024" | $CMD_BC`
VALUE="$VALUE Octets"
fi
}
size_fix() {
if [ ${VALUE: 0:1} = "-" ]; then
VALUE=`$CMD_EXPR 4294967294 - \( 0 - $VALUE \)`
fi
}
DISK_DESC=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME "$OID_DESC" | $CMD_GREP "$DISK"`
#DISK_DESC=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME "$OID_DESC" | $CMD_GREP "DRIVE : $DISK"`
#DISK_DESC=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME "$OID_DESC"`
echo $DISK_DESC
if [ -n "$DISK_DESC" ]; then
DISK_ID=`echo $DISK_DESC | $CMD_AWK '{print $1}' | $CMD_AWK -F "." '{print $NF}'`
if [ ${DISK: 0:1} != "/" ]; then
DISK_LABEL=`echo $DISK_DESC | $CMD_AWK '{ print $5 }' | $CMD_AWK -F ':' '{ print $2 }'`
fi
DISK_UNIT=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME "${OID_UNIT}.${DISK_ID}"`
DISK_TOTAL=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME "${OID_TOTAL}.${DISK_ID}"`
DISK_USED=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -OvqU $HOSTNAME "${OID_USED}.${DISK_ID}"`
if [ $DISK_TOTAL != 0 ]; then
VALUE=$DISK_TOTAL
echo "VALUE (DISK_TOTAL): $VALUE"
size_fix
DISK_TOTAL=$VALUE
echo "DISK_TOTAL: $DISK_TOTAL"
VALUE=$DISK_USED
echo "VALUE (DISK_USED): $VALUE"
size_fix
DISK_USED=$VALUE
echo "DISK_USED: $DISK_USED"
echo "DISK_UNIT: $DISK_UNIT"
DISK_TOTAL=`$CMD_EXPR $DISK_TOTAL \* \( $DISK_UNIT \)`
DISK_USED=`$CMD_EXPR $DISK_USED \* \( $DISK_UNIT \)`
echo "DISK_TOTAL: $DISK_TOTAL"
echo "DISK_USED: $DISK_USED"
PERFDATA_WARNING=0
PERFDATA_CRITICAL=0
if [ $WARNING != 0 ] || [ $CRITICAL != 0 ]; then
DISK_USED_POURCENT=`$CMD_EXPR \( $DISK_USED \* 100 \) / $DISK_TOTAL`
PERFDATA_WARNING=`$CMD_EXPR \( $DISK_TOTAL \* $WARNING \) / 100`
PERFDATA_CRITICAL=`$CMD_EXPR \( $DISK_TOTAL \* $CRITICAL \) / 100`
if [ $DISK_USED_POURCENT -gt $CRITICAL ] && [ $CRITICAL != 0 ]; then
STATE=$STATE_CRITICAL
elif [ $DISK_USED_POURCENT -gt $WARNING ] && [ $WARNING != 0 ]; then
STATE=$STATE_WARNING
else
STATE=$STATE_OK
fi
else
STATE=$STATE_OK
fi
VALUE=$DISK_TOTAL
echo "VALUE (DISK_TOTAL): $VALUE"
size_convert
DISK_TOTAL_FORMAT=$VALUE
echo "DISK_TOTAL_FORMAT: $DISK_TOTAL_FORMAT"
VALUE=$DISK_USED
size_convert
DISK_USED_FORMAT=$VALUE
DESCRIPTION="Disk/partition usage '$DISK' $DISK_LABEL : $DISK_USED_FORMAT utilise sur $DISK_TOTAL_FORMAT (${DISK_USED_POURCENT}%) | total=${DISK_TOTAL}B;$PERFDATA_WARNING;$PERFDATA_CRITICAL;0 used=${DISK_USED}B;0;0;0"
fi
fi
echo $DESCRIPTION
exit $STATE

155
syno/script2.sh Executable file
View File

@@ -0,0 +1,155 @@
#!/bin/bash
#====================================================================
# Reads free diskspace on remote hosts via snmp.
#
# Requires Net-SNMP: http://net-snmp.sourceforge.net/
#
# Jonathan Baxter jbaxter@panscient.com 20080426
#
# Copyright (C) 2008, Jonathan Baxter
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#====================================================================
function usage() {
echo
echo "Usage: $0 [-cp] host [host...]";
echo "Print fixed disks on the specified host(s) with free space below threshold"
echo
echo " -c snmp community string (default: \"public\")"
echo " -p percent free threshold (default: 10%)"
echo
echo "Report bugs to jbaxter@panscient.com"
echo
}
#===================
# Process options
#===================
while getopts ":c:p:" option; do
case $option in
c ) community="$OPTARG"; shift $((OPTIND-1)); OPTIND=1;;
p ) percent_free_threshold="$OPTARG"; shift $((OPTIND-1)); OPTIND=1;;
h ) usage; exit 0;;
\? ) usage; exit 1;;
* ) usage; exit 1;;
esac
done
community=${community-public}
percent_free_threshold=${percent_free_threshold-10}
snmp_ver="1"
if [ "$1" = "" ]; then
echo $usage
exit 1
fi
#=============================================================================
# Reads the free space on fixed disks on the specified host
#
# $1: host
# return: line for each fixed disk: <name> <size MB> <used MB> <percent free>
#=============================================================================
function read_fixed_diskspace()
{
local data host type desc au size used
host=$1
data="$(snmpwalk -c public -v 1 -OqUes $host hrStorage 2>&1)"
if [ "$?" != "0" ]; then
echo -e "$data"
return 1;
fi
while read nameid value junk; do
name=${nameid%%.*}
#echo $name
id=${nameid/$name.}
lastid=$id
case "$name" in
"hrStorageType" ) type[$id]=$value;;
"hrStorageDescr" ) desc[$id]=$value;;
"hrStorageAllocationUnits" ) au[$id]=$value;;
"hrStorageSize" ) size[$id]=$value;;
"hrStorageUsed" ) used[$id]=$value;;
* ) ;;
esac
done < <(echo -e "$data")
i="0"
while [[ i -lt ${lastid} ]]; do
if [[ ("${type[$i]}" = "hrStorageFixedDisk") &&
("${size[$i]-0}" != "0") &&
("${au[$i]-0}" != "0") ]]; then
sizeMB=$(( (${au[$i]} * (${size[$i]} / 1024) / 1024) ))
usedMB=$(( (${au[$i]} * (${used[$i]} / 1024) / 1024) ))
percent_free=$((100 * ( $sizeMB - $usedMB ) / $sizeMB))
echo "${desc[$i]} ${sizeMB} ${usedMB} $percent_free\n"
fi
let i=i+1;
done
}
#============================================
# Insert commas as appropriate into integers
# $1: integer, eg: 5555555
# return: commaized integer, eg: 5,555,555
#============================================
function commaize() {
echo $1 | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'
}
#======================================
# Process the hosts on the commandline
#======================================
n="0"
num_bad_hosts="0"
for host in "$@"; do
data="$(read_fixed_diskspace $host)"
if [ "$?" != "0" ]; then
bad_hosts[$num_bad_hosts]=$host
last_bad_host=$host
let num_bad_hosts+=1
message[$n]="$host: $data"
let n+=1
else
while read desc size used percent_free junk; do
if [[ ("$percent_free" != "") &&
($percent_free -lt $percent_free_threshold) ]]; then
if [ "$host" != "$last_bad_host" ]; then
bad_hosts[$num_bad_hosts]=$host
last_bad_host=$host
let num_bad_hosts+=1
fi
message[$n]="$host:$desc is $(( 100 - $percent_free ))% full - \
$(commaize $used)M used out of $(commaize $size)M total"
let n+=1
fi
done < <(echo -e "$data")
fi
done
if [ "$num_bad_hosts" -gt "0" ]; then
# summary line: all bad hosts
echo "${bad_hosts[*]}"
# messages
lastn=$(( $n-1 ))
for i in $(seq 0 $lastn); do
echo ${message[$i]}
done
exit 1;
fi
exit 0;

377
syno/smart.sh Executable file
View File

@@ -0,0 +1,377 @@
#!/bin/bash
# http://fr.wikipedia.org/wiki/Self-Monitoring,_Analysis_and_Reporting_Technology
#Attributes names (this is deduced from ID by smartctl and may be incorrect, as it's highly vendor-specific)
#Flag values: if given in POSRCK+ format, the presence of each letter indicates that the flag is on.
#P: pre-failure warning ; O: updated continuously ; S: speed / performance attribute ; R: error rate ; C: event count K: auto-keep ; +: undocumented bits present
#Updated: the attribute is usually updated continuously, or during Offline Data Collection only.
#Type: alarm condition is reached when if normalized value becomes less than or equal to threshold. Type indicates whether it's a signal of drive's pre-failure time or just an old age.
#Raw value: as reported by drive. May or may not be sensible.
#Threshold for normalized value. Normalized value should be greater than threshold
#Worst normalized value recorded for this attribute during the drive's lifetime(with SMART enabled)
#Normalized value (highly vendor-specific; converted from Raw value by the drive's firmware)
#Failed when the normalized value became equal or less than threshold
bold=''
nobold=''
bgblue=''
bgnormal=''
italic=''
noitalic=''
under=''
nounder=''
#modelName=$(echo "$synoSystem" | grep $OID_modelName | cut -d "=" -f2)
# -P showall
#smart2=$(ssh root@192.168.0.8 "smartctl -a /dev/hda -d ata")
#Temp=$(echo "$smart2" | egrep "Model|Temp")
#echo "$Temp"
#WORST (le pire)
#THRESH (battre) threshold (seuil)
#smart3=$(ssh root@192.168.0.8 "find /dev/hd[a-d] -exec /usr/syno/bin/smartctl -iA -d ata {} \;")
#Serial=$(echo "$smart3" | egrep "Serial")
#echo "$Serial"
# fdisk -l ; df -h
# pour les pérfis ide: /dev/hd*
# pour les périferiques sata et usb: /dev/sd*
# fdisk -l | grep "^/dev/"
# df -h | grep "USB"
#sdq: Toshiba 750 Go (volumeUSB2)
#/usr/syno/bin/smartctl -aH -d sat /dev/sdq => OK
#sdr: Toshiba 2 To (volumeUSB1)
#/usr/syno/bin/smartctl -aH -d sat /dev/sdr => OK **
# -d TYPE, --device=TYPE
# Specify device type to one of: ata, scsi, sat[,auto][,N][+TYPE], usbcypress[,X], usbjmicron[,p][,x][,N], usbsunplus, marvell, areca,N/E, 3ware,N, hpt,L/M/N, megaraid,N, cciss,N, auto, test
model=""
serial=""
firmware=""
capacity=""
temperature=""
health=""
smart1=""
smart1v=""
smart1t=""
smart1w=""
smart2=""
smart2v=""
smart2t=""
smart2w=""
smart3=""
smart3v=""
smart3t=""
smart3w=""
smart4=""
smart4v=""
smart4t=""
smart4w=""
smart5=""
smart5v=""
smart5t=""
smart6w=""
smart6=""
smart6v=""
smart6t=""
smart6w=""
smart7=""
smart7v=""
smart7t=""
smart7w=""
smart8=""
smart8v=""
smart8t=""
smart8w=""
smart9=""
smart9v=""
smart9t=""
smart9w=""
smart10=""
smart10v=""
smart10t=""
smart10w=""
smart11=""
smart11v=""
smart11t=""
smart11w=""
smart12=""
smart12v=""
smart12t=""
smart12w=""
smart13=""
smart13v=""
smart13t=""
smart13w=""
smart14=""
smart14v=""
smart14t=""
smart14w=""
smart15=""
smart15v=""
smart15t=""
smart15w=""
i=0
j=0
declare RESULT=()
while read -r LINE; do
RESULT[${#RESULT[@]}]=$LINE
#echo $LINE
_model=$(echo $LINE | grep "Device Model"| cut -d ":" -f2)
if [ -n "$_model" ] ; then model[$i]=$_model ; fi
_serial=$(echo $LINE | grep "Serial Number"| cut -d ":" -f2)
if [ -n "$_serial" ] ; then serial[$i]=$_serial ; fi
_firmware=$(echo $LINE | grep "Firmware Version"| cut -d ":" -f2)
if [ -n "$_firmware" ] ; then firmware[$i]=$_firmware ; fi
# recherche chaine entre [] sed 's/.*\[//;s/\].*//'
_capacity=$(echo $LINE | grep "User Capacity"| cut -d ":" -f2 | sed 's/.*\[//;s/\].*//')
if [ -n "$_capacity" ] ; then capacity[$i]=$_capacity ; fi
_temperature=$(echo $LINE | grep "Temperature_Celsius"| cut -d " " -f10)
if [ -n "$_temperature" ] ; then temperature[$i]=$_temperature ; fi
_health=$(echo $LINE | grep "SMART overall-health"| cut -d ":" -f2 | sed 's/^ *//g')
if [ -n "$_health" ] ; then health[$i]=$_health ; fi
## SMART
_smart1=$(echo $LINE | grep "Raw_Read_Error_Rate") #1
if [ -n "$_smart1" ]
then
# VALUE WORST THRESH (valeur mini failed)
echo $_smart1
smart1[$i]=$(echo $_smart1 | awk '{print $10}')
smart1v[$i]=$(echo $_smart1 | awk '{print $4}')
smart1w[$i]=$(echo $_smart1 | awk '{print $5}')
smart1t[$i]=$(echo $_smart1 | awk '{print $6}')
fi
_smart2=$(echo $LINE | grep "Reallocated_Sector_Ct") #5
if [ -n "$_smart2" ]
then
smart2[$i]=$(echo $_smart2 | awk '{print $10}')
smart2v[$i]=$(echo $_smart2 | awk '{print $4}')
smart2w[$i]=$(echo $_smart2 | awk '{print $5}')
smart2t[$i]=$(echo $_smart2 | awk '{print $6}')
fi
_smart3=$(echo $LINE | grep "Spin_Retry_Count") #10
if [ -n "$_smart3" ]
then
smart3[$i]=$(echo $_smart3 | awk '{print $10}')
smart3v[$i]=$(echo $_smart3 | awk '{print $4}')
smart3w[$i]=$(echo $_smart3 | awk '{print $5}')
smart3t[$i]=$(echo $_smart3 | awk '{print $6}')
fi
_smart4=$(echo $LINE | grep "Command_Timeout") #188
if [ -n "$_smart4" ]
then
smart4[$i]=$(echo $_smart4 | awk '{print $10}')
smart4v[$i]=$(echo $_smart4 | awk '{print $4}')
smart4w[$i]=$(echo $_smart4 | awk '{print $5}')
smart4t[$i]=$(echo $_smart4 | awk '{print $6}')
fi
_smart5=$(echo $LINE | grep "Airflow_Temperature_Cel") #190
if [ -n "$_smart5" ]
then
smart5[$i]=$(echo $_smart5 | awk '{print $10}')
smart5v[$i]=$(echo $_smart5 | awk '{print $4}')
smart5w[$i]=$(echo $_smart5 | awk '{print $5}')
smart5t[$i]=$(echo $_smart5 | awk '{print $6}')
fi
_smart6=$(echo $LINE | grep "Reallocated_Event_Count") #196
if [ -n "$_smart6" ]
then
smart6[$i]=$(echo $_smart6 | awk '{print $10}')
smart6v[$i]=$(echo $_smart6 | awk '{print $4}')
smart6w[$i]=$(echo $_smart6 | awk '{print $5}')
smart6t[$i]=$(echo $_smart6 | awk '{print $6}')
fi
_smart7=$(echo $LINE | grep "Current_Pending_Sector") #197
if [ -n "$_smart7" ]
then
smart7[$i]=$(echo $_smart7 | awk '{print $10}')
smart7v[$i]=$(echo $_smart7 | awk '{print $4}')
smart7w[$i]=$(echo $_smart7 | awk '{print $5}')
smart7t[$i]=$(echo $_smart7 | awk '{print $6}')
fi
_smart8=$(echo $LINE | grep "Offline_Uncorrectable") #198
if [ -n "$_smart8" ]
then
smart8[$i]=$(echo $_smart8 | awk '{print $10}')
smart8v[$i]=$(echo $_smart8 | awk '{print $4}')
smart8w[$i]=$(echo $_smart8 | awk '{print $5}')
smart8t[$i]=$(echo $_smart8 | awk '{print $6}')
fi
_smart9=$(echo $LINE | grep "Soft_Read_Error_Rate") #201
if [ -n "$_smart9" ]
then
smart9[$i]=$(echo $_smart9 | awk '{print $10}')
smart9v[$i]=$(echo $_smart9 | awk '{print $4}')
smart9w[$i]=$(echo $_smart9 | awk '{print $5}')
smart9t[$i]=$(echo $_smart9 | awk '{print $6}')
fi
_smart10=$(echo $LINE | grep "Disk_Shift") #220
if [ -n "$_smart10" ]
then
smart10[$i]=$(echo $_smart10 | awk '{print $10}')
smart10v[$i]=$(echo $_smart10 | awk '{print $4}')
smart10w[$i]=$(echo $_smart10 | awk '{print $5}')
smart10t[$i]=$(echo $_smart10 | awk '{print $6}')
fi
## INFOS
_smart11=$(echo $LINE | grep "Start_Stop_Count") #4
if [ -n "$_smart11" ]
then
smart11[$i]=$(echo $_smart11 | awk '{print $10}')
smart11v[$i]=$(echo $_smart11 | awk '{print $4}')
smart11w[$i]=$(echo $_smart11 | awk '{print $5}')
smart11t[$i]=$(echo $_smart11 | awk '{print $6}')
fi
_smart12=$(echo $LINE | grep "Seek_Error_Rate") #7
if [ -n "$_smart12" ]
then
smart12[$i]=$(echo $_smart12 | awk '{print $10}')
smart12v[$i]=$(echo $_smart12 | awk '{print $4}')
smart12w[$i]=$(echo $_smart12 | awk '{print $5}')
smart12t[$i]=$(echo $_smart12 | awk '{print $6}')
fi
_smart13=$(echo $LINE | grep "Power_On_Hours") #9
if [ -n "$_smart13" ]
then
smart13[$i]=$(echo $_smart13 | awk '{print $10}')
smart13v[$i]=$(echo $_smart13 | awk '{print $4}')
smart13w[$i]=$(echo $_smart13 | awk '{print $5}')
smart13t[$i]=$(echo $_smart13 | awk '{print $6}')
fi
_smart14=$(echo $LINE | grep "Power_Cycle_Count") #12
if [ -n "$_smart14" ]
then
smart14[$i]=$(echo $_smart14 | awk '{print $10}')
smart14v[$i]=$(echo $_smart14 | awk '{print $4}')
smart14w[$i]=$(echo $_smart14 | awk '{print $5}')
smart14t[$i]=$(echo $_smart14 | awk '{print $6}')
fi
_smart15=$(echo $LINE | grep "UDMA_CRC_Error_Count") #199
if [ -n "$_smart15" ]
then
smart15[$i]=$(echo $_smart15 | awk '{print $10}')
smart15v[$i]=$(echo $_smart15 | awk '{print $4}')
smart15w[$i]=$(echo $_smart15 | awk '{print $5}')
smart15t[$i]=$(echo $_smart15 | awk '{print $6}')
fi
if [ -n "$(echo $LINE | grep "Copyright")" ] ; then ((i=i+1)) ; fi
#echo $i
done < <(ssh root@192.168.0.8 "find /dev/sd[a-d,q-r] -exec /usr/syno/bin/smartctl -a -v 9,minutes -d sat {} \;")
#done < <(find /dev/disk0 -exec smartctl -a -v 9,minutes -d sat {} \;)
for((j=1;j<=$i;j++));
do
echo "${bold}Disk $j [${health[j]}]:${nobold}"
echo " Modèle:${model[j]} N° serie:${serial[j]} Firmware:${firmware[j]} Capacité: ${capacity[j]}"
echo " Temp: ${temperature[j]}°C"
echo " ${under}Alarmes:${nounder}"
a=${smart1[j]}
#echo "Raw_Read_Error_Rate: $a"
if [[ -n $a && $a -gt 0 ]]; then echo " Raw_Read_Error_Rate: $a" ; fi
av=${smart1v[j]}
at=${smart1t[j]}
aw=${smart1w[j]}
echo "value: $av tresh: $at worst: $aw"
b=${smart2[j]}
#echo "Reallocated_Sector_Ct: $b"
if [[ -n $b && $b -gt 0 ]]; then echo " Reallocated_Sector_Ct: $b" ; fi
c=${smart3[j]}
#echo "Spin_Retry_Count: $c"
if [[ -n $c && $c -gt 0 ]]; then echo " Spin_Retry_Count: $c" ; fi
d=${smart4[j]}
#echo "Command_Timeout: $d"
if [[ -n $d && $d -gt 0 ]]; then echo " Command_Timeout: $d" ; fi
e=${smart5[j]}
#echo "Airflow_Temperature_Cel: $e"
if [[ -n $e && $e -gt 0 ]]; then echo " Airflow_Temperature_Cel: $e" ; fi
f=${smart6[j]}
#echo "Reallocated_Event_Count: $f"
if [[ -n $f && $f -gt 0 ]]; then echo " Reallocated_Event_Count: $f" ; fi #
g=${smart7[j]}
#echo "Current_Pending_Sector: $g"
if [[ -n $g && $g -gt 0 ]]; then echo " Current_Pending_Sector: $g" ; fi
h=${smart8[j]}
#echo "Offline_Uncorrectable: $h"
if [[ -n $h && $h -gt 0 ]]; then echo " Offline_Uncorrectable: $h" ; fi
k=${smart9[j]}
#echo "Soft_Read_Error_Rate: $k"
if [[ -n $k && $k -gt 0 ]]; then echo " Soft_Read_Error_Rate: $k" ; fi #
l=${smart10[j]}
#echo "Disk_Shift: $l"
if [[ -n $l && $l -gt 0 ]]; then echo " Disk_Shift: $l" ; fi #
echo " ${under}Infos:${nounder}"
m=${smart11[j]}
#echo "Start_Stop_Count: $m"
if [[ -n $m && $m -gt 0 ]]; then echo " Start_Stop_Count: $m" ; fi #
n=${smart12[j]}
#echo "Seek_Error_Rate: $n"
if [[ -n $n && $n -gt 0 ]]; then echo " Seek_Error_Rate: $n" ; fi #
o=${smart13[j]}
#echo "Power_On_Hours: $o"
if [[ -n $o && $o -gt 0 ]]; then echo " Power_On_Hours: $o" ; fi #
p=${smart14[j]}
#echo "Power_Cycle_Count: $p"
if [[ -n $p && $p -gt 0 ]]; then echo " Power_Cycle_Count: $p" ; fi #
q=${smart15[j]}
#echo "UDMA_CRC_Error_Count: $q"
if [[ -n $q && $q -gt 0 ]]; then echo " UDMA_CRC_Error_Count: $q" ; fi #
done
#for hd in /dev/hda*; do
#for hd in /dev/hd[a-z]; do
#for hd in /dev/disk[1-9]; do
#dd=$(ssh root@192.168.0.8 "for hd in /dev/hd[a-d]; do smartctl -A $hd -d ata; done")
#dd=$(ssh root@192.168.0.8 "for i in $(ls /dev/ | grep sd[a-d]\$) ; do /usr/syno/bin/smartctl -A /dev/$i -d ata; done")
#dd=$(ssh root@192.168.0.8 "for i in $(ls /dev/ | grep sd[a-d]\$) ; do /usr/syno/bin/smartctl -A /dev/sda -d ata; done")
#echo "$dd"
#VALUE="_AAAA"
#if [ ${VALUE: 1:3} = "AA" ]; then
#echo "oui"
#else
#echo "non"
#fi

33
syno/syno_cpu.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
ssh=admin@192.168.0.8
hostname=`ssh $ssh 'hostname'`
echo $hostname
#cpuinfo=`cat ./cpuinfo`
cpuinfo=`ssh $ssh 'cat /proc/cpuinfo'`
processor=`grep Processor cpuinfo | awk -F":" '{print $2}'`
hardware=`grep Hardware cpuinfo | awk -F":" '{print $2}'`
echo $processor
echo $hardware
#diskstats=`cat ./diskstats`
diskstats=`ssh $ssh 'cat /proc/diskstats'`
dk1=`grep sda diskstats`
echo $dk1
#meminfo=`cat ./meminfo`
meminfo=`ssh $ssh 'cat /proc/meminfo'`
MemTotal=`grep MemTotal meminfo | awk '{print $2}'`
echo $MemTotal
#version=`cat ./version`
version=`cat ./version | awk '{print $1} {print $2} {print $3}'`
#linux=
echo $version

18
syno/test.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
OID_model="1.3.6.1.4.1.6574.1.5.1.0"
OID_serialNumber="1.3.6.1.4.1.6574.1.5.2.0"
#syno=".1.3.6.1.4.1.6574.1.5.1.0 = \"DS414\" .1.3.6.1.4.1.6574.1.5.2.0 = \"13B0LUN002661\" .1.3.6.1.4.1.6574.1.5.3.0 = \"DSM 5.0-4493\" .1.3.6.1.4.1.6574.1.2.0 = 37 .1.3.6.1.4.1.6574.1.1.0 = 1 .1.3.6.1.4.1.6574.1.3.0 = 1 .1.3.6.1.4.1.6574.1.4.1.0 = 1 .1.3.6.1.4.1.6574.1.4.2.0 = 1 .1.3.6.1.4.1.6574.1.5.4.0 = 3"
syno=".1.3.6.1.4.1.6574.1.5.1.0 = "DS414" .1.3.6.1.4.1.6574.1.5.2.0 = "13B0LUN002661" .1.3.6.1.4.1.6574.1.5.3.0 = "DSM 5.0-4493" .1.3.6.1.4.1.6574.1.2.0 = 37 .1.3.6.1.4.1.6574.1.1.0 = 1 .1.3.6.1.4.1.6574.1.3.0 = 1 .1.3.6.1.4.1.6574.1.4.1.0 = 1 .1.3.6.1.4.1.6574.1.4.2.0 = 1 .1.3.6.1.4.1.6574.1.5.4.0 = 3"
#echo "$syno"
aa=$(echo "$syno" | grep $OID_model)
echo "$aa"
model=$(echo "$syno" | grep $OID_model | cut -d "=" -f2)
echo "Synology model: $model"
serialNumber=$(echo "$syno" | grep $OID_serialNumber | cut -d "=" -f2)
echo "Synology s/n: $serialNumber"

602
syno/tps Normal file
View File

@@ -0,0 +1,602 @@
#!/bin/sh
#==================================
# Script par Fredlime
# English Translation by Ikeke
#==================================
# Variables courantes du programme
#
model=`/bin/get_key_value /etc/synoinfo.conf upnpmodelname`
heure=`date +%Hh%M`
jour=`date +%d-%m-%Y`
script=`ps | grep $$ | grep -v grep | sed -e 's/^..*sh //' | awk '{print $1}'`
echo $script
#
#=====================================
# Creation du fichier de configuration
# si il n'existe pas => /etc/tps.conf
#=====================================
#
if test -f /etc/tps.conf
then
config="no"
else
config="yes"
printf "#\n# Script configuration of "$script"\n#\n" > /etc/tps.conf
#
if test -f /opt/bin/esmtp
then
echo "tps-mail=\"yes\"" >> /etc/tps.conf
else
echo "tps-mail=\"no\"" >> /etc/tps.conf
fi
#
if test -f /opt/bin/rrdtool
then
echo "tps-graph=\"yes\"" >> /etc/tps.conf
else
echo "tps-graph=\"no\"" >> /etc/tps.conf
fi
if test -d /volume1/web
then
echo "tps-image=\"/volume1/web\"" >> /etc/tps.conf
else
echo "tps-image=\"/tmp\"" >> /etc/tps.conf
fi
#
printf "#\ntps-temps=\"5\"\n#\n# Variables courantes\n#\ntps-jour=\""$jour"\"\n#\n" >> /etc/tps.conf
#
> /etc/tps.log
fi
#===================================
# Menu de configuration du script
# Cas ou on lance 'tps config'
# ou si premiere execution su script
#===================================
#
if test "$1" = "config" -o "$config" = "yes" -o "$1" = "info"
then
#-----------------------------
# recup des valeurs par defaut
#-----------------------------
tpsmail=`/bin/get_key_value /etc/tps.conf tps-mail`
tpsgraph=`/bin/get_key_value /etc/tps.conf tps-graph`
tpsimage=`/bin/get_key_value /etc/tps.conf tps-image`
tpstemps=`/bin/get_key_value /etc/tps.conf tps-temps`
jourlog=`/bin/get_key_value /etc/tps.conf tps-jour`
#
smtp=`/bin/get_key_value /etc/synoinfo.conf eventsmtp`
mail=`/bin/get_key_value /etc/synoinfo.conf eventmail1`
user=`/bin/get_key_value /etc/synoinfo.conf eventuser`
pass=`/bin/get_key_value /etc/synoinfo.conf eventpass`
#
#
if test "$1" = "info"
then
status=`cat /etc/crontab | grep $script | sed -e "s/^.*root sh //"`
if test "$status" = "$script"
then
status="Enabled"
else
status="Disabled"
fi
clear
echo "##################################################################"
echo " How to use the SCRIPT and informations about parameters to use "
echo ""
echo $script" config => Script configuration"
echo $script" stop => Disable this script"
echo $script" start => Enable this script"
echo $script" info => Script status"
echo $script" mail => Immediatly send an email"
echo $script" => Generate a temperature statement in database"
echo ""
echo "Send email => "$tpsmail
echo " MAIL => "$mail
echo " SMTP => "$smtp
echo " USER => "$user" useful with some I.S.P"
echo " PASS => "$pass" useful with some I.S.P"
echo ""
echo "Graph creation => "$tpsgraph
echo "Image folder => "$tpsimage
echo ""
echo "Time interval = "$tpstemps" minutes"
echo "Current day = "$jourlog
echo "Script status = "$status
echo ""
echo ""
exit
fi
#
if test -f /opt/bin/esmtp
then
echo
printf "Send eMail yes/no : ("$tpsmail") \c" ; read q
if test "$q" != ""
then
tpsmail=$q
cat /etc/tps.conf | sed -e 's/tps-mail="..*"/tps-mail="'$tpsmail'"/' > /etc/tps.conf
fi
echo
echo "Email address => "$mail
echo "Smtp Server => "$smtp
echo "Login => "$user
echo "Password => "$pass
fi
#
if test -f /opt/bin/rrdtool
then
printf "\nGraphical function yes/no : ("$tpsgraph") \c" ; read q
if test "$q" != ""
then
tpsgraph=$q
fi
if test "$tpsgraph" = "yes"
then
while test "$ok" != "ok"
do
printf "\nImage Folder, by default => "$tpsimage" : \c" ; read q
if test "$q" != ""
then
tpsimage=$q
fi
if test -d $tpsimage
then
ok="ok"
else
echo ""
echo "Error, entered path to store the "
echo "graph file doesn't exist !!"
echo ""
fi
done
fi
cat /etc/tps.conf | sed -e 's/tps-graph="..*"/tps-graph="'$tpsgraph'"/' > /etc/tps.conf
tpsimage="tps-image=\""`echo $tpsimage | sed -e "s/\//slash/g"`
cat /etc/tps.conf | sed -e 's/tps-image="..*/'$tpsimage'"/' | sed -e "s/slash/\//g" > /etc/tps.conf
fi
#
#
echo
printf "\nTime between each statements (minutes) : ("$tpstemps") \c" ; read q
if test "$q" != ""
then
tpstemps=$q
cat /etc/tps.conf | sed -e 's/tps-temps="..*"/tps-temps="'$tpstemps'"/' > /etc/tps.conf
fi
fi
#================================
# Cas ou on lance le script avec
# 'config' ou 'stop' ou 'start'
#================================
#
if test "$1" = "stop" -o "$1" = "start" -o "$config" = "yes"
then
/bin/killall crond
echo "Script halted"
#------------------------------------------------------
# Supression des lignes qui lancent le script dans
# le fichier /etc/rc.local => particularite du CS-406
# le fichier /etc/crontab => particularite des SYNO
#------------------------------------------------------
if test "$model" = "CS-406"
then
/bin/cat /etc/rc.local | grep -v $script > /etc/rc.local
fi
/bin/cat /etc/crontab | grep -v $script > /etc/crontab
#-------------------------------
# Cas ou on lance le script avec
# 'config' ou 'start'
#-------------------------------
if test "$1" = "start" -o "$config" = "yes"
then
echo "Script is starting !!"
tpstemps=`/bin/get_key_value /etc/tps.conf tps-temps`
if test "$model" = "CS-406"
then
echo "killall crond # "$script >> /etc/rc.local
echo "echo \"*/"$tpstemps" * * * * root sh "$script"\" >> /etc/crontab" >> /etc/rc.local
echo "/usr/sbin/crond # "$script >> /etc/rc.local
fi
echo "*/"$tpstemps" * * * * root sh "$script >> /etc/crontab
fi
#--------------------
# On sort du script
# et on relance crond
#--------------------
/usr/sbin/crond
exit
fi
#=================================================================================================
# Releve la temperature des disques
#=================================================================================================
#
cd /dev
nbrdisk=0
for bo in `/bin/ls hd?`
do
t=`/opt/sbin/smartctl -A $bo | grep "Temperature_Celsius" | awk '{print $10}'`
if test "$t" != ""
then
h=`/opt/sbin/smartctl -A $bo | grep "Power_On_Hours" | awk '{print $10}'`
nbrdisk=`expr $nbrdisk + 1`
temp=$temp" "$t
dure=$dure" disk"$nbrdisk"= "$h" "
fi
done
temp=`echo $temp | sed -e "s/^ //"`
Tmax=`echo $temp | awk '{print $1"\n"$2"\n"$3"\n"$4}' | sort | tail -1`
Tmin=`echo $temp | awk '{print $1"\n"$2"\n"$3"\n"$4}' | grep -v "^$" | sort -r | tail -1`
delta=`expr $Tmax - $Tmin`
Tmoy=`echo $temp | awk '{print ($1+$2+$3+$4)/'$nbrdisk' }'`
#
#=====================
# Traitement graphique
#=====================
tpsgraph=`/bin/get_key_value /etc/tps.conf tps-graph`
if test "$tpsgraph" = "yes"
then
tpsimage=`/bin/get_key_value /etc/tps.conf tps-image`"/tps-"`hostname`".png"
tempsrdd=`/opt/bin/rrdtool info /etc/tps.rrd 2> /dev/null | grep -i step | awk '{print $3 / 60}'`
tpstemps=`/bin/get_key_value /etc/tps.conf tps-temps`
#
#-------------------------------
# Test si la base existe avec
# le temps des releves, sinon
# creation de la base de donnees
#-------------------------------
if test "$tpstemps" = "$tempsrdd"
then
/opt/bin/rrdtool update /etc/tps.rrd N:$Tmoy:$delta
printf "Creation of the Temperature Graph \c"
#
#---------------------------------------------
# Generation du Graphique special Cube Station
# avec 1 ou plusieurs disques
#---------------------------------------------
if test "$model" = "CS-406"
then
#
/opt/bin/rrdtool graph $tpsimage -w 500 -h 100 \
--title `hostname`" => SYNOLOGY "$model" on "$jour" "$heure \
--vertical-label "Degrees C<>" \
--x-grid MINUTE:15:HOUR:1:HOUR:2:0:%Hh00 \
--imgformat PNG \
--color MGRID#337fbf \
--color FRAME#808080 \
--color ARROW#FF0099 \
DEF:disque=/etc/tps.rrd:disque:AVERAGE \
DEF:deltad=/etc/tps.rrd:deltad:AVERAGE \
VDEF:max=disque,MAXIMUM \
LINE2:max#ff0000 \
CDEF:flaming1=disque,40,*,100,/ \
CDEF:flaming2=disque,5,*,100,/ \
AREA:flaming1#ffff5f \
STACK:flaming2#fffc51 \
STACK:flaming2#fffc51 \
STACK:flaming2#fff046 \
STACK:flaming2#ffe95f \
STACK:flaming2#ffd237 \
STACK:flaming2#ffc832 \
STACK:flaming2#ffbe2d \
STACK:flaming2#ffaa23 \
STACK:flaming2#ff9619 \
STACK:flaming2#ff841e \
STACK:flaming2#ff841e \
STACK:flaming2#ff6600:"Disks Temperatures" \
GPRINT:disque:MAX:"Maxi %2.0lf<EFBFBD>" \
GPRINT:disque:MIN:"Mini %2.0lf<EFBFBD>" \
GPRINT:disque:AVERAGE:"Aver. %2.1lf<EFBFBD>" \
GPRINT:deltad:AVERAGE:"Max Diff. %2.1lf<EFBFBD>" \
GPRINT:disque:LAST:"Last measure %2.0lf<EFBFBD>" \
COMMENT:"\n" \
COMMENT:" ---------------------------- \n" \
COMMENT:" Time Counter $dure"
#
#
#---------------------------------------------
# Generation du Graphique pour les autres SYNO
# avec 1 disque uniquement
#---------------------------------------------
else
dure=`echo $dure | awk '{print $2}'`
/opt/bin/rrdtool graph $tpsimage -w 500 -h 100 \
--title `hostname`" => SYNOLOGY "$model" on "$jour" "$heure \
--vertical-label "Degrees C<>" \
--x-grid MINUTE:15:HOUR:1:HOUR:2:0:%Hh00 \
--imgformat PNG \
--color MGRID#337fbf \
--color FRAME#808080 \
--color ARROW#FF0099 \
DEF:disque=/etc/tps.rrd:disque:AVERAGE \
VDEF:max=disque,MAXIMUM \
LINE2:max#ff0000 \
CDEF:flaming1=disque,40,*,100,/ \
CDEF:flaming2=disque,5,*,100,/ \
AREA:flaming1#ffff5f \
STACK:flaming2#fffc51 \
STACK:flaming2#fffc51 \
STACK:flaming2#fff046 \
STACK:flaming2#ffe95f \
STACK:flaming2#ffd237 \
STACK:flaming2#ffc832 \
STACK:flaming2#ffbe2d \
STACK:flaming2#ffaa23 \
STACK:flaming2#ff9619 \
STACK:flaming2#ff841e \
STACK:flaming2#ff841e \
STACK:flaming2#ff6600:"Disk Temperature" \
GPRINT:disque:MAX:"Maxi %2.0lf<EFBFBD>" \
GPRINT:disque:MIN:"Mini %2.0lf<EFBFBD>" \
GPRINT:disque:AVERAGE:"Aver. %2.2lf<EFBFBD>" \
GPRINT:disque:LAST:"Last measure %2.0lf<EFBFBD> ("$dure" hours)"
#
fi
#
else
echo "Initialization of rrdtool database"
step=`expr $tpstemps \* 60`
inte=`expr $step \* 2`
/opt/bin/rrdtool create /etc/tps.rrd -s $step \
DS:disque:GAUGE:$inte:U:U \
DS:deltad:GAUGE:$inte:U:U \
RRA:AVERAGE:0.5:1:288
fi
fi
#
#=====================
# Traitement par Mail
#=====================
#
tpsmail=`/bin/get_key_value /etc/tps.conf tps-mail`
if test "$tpsmail" = "yes"
then
#
jourlog=`/bin/get_key_value /etc/tps.conf tps-jour`
tpstemps=`/bin/get_key_value /etc/tps.conf tps-temps`
#
if test -f /etc/tps.log
then
#
# test si le jour a change ou bien
# si on a lance le script avec l'option mail
#
if test "$jourlog" != "$jour" -o "$1" = "mail"
then
echo "Preparing email..."
#-----------------------------------------------
# Dans ce cas, on prepare le mail et on l'envoie
#-----------------------------------------------
/bin/cat /etc/tps.log | sed -e 's/ Delta.*//' | awk -F= '{print $2}' > /tmp/tps-moy.log
/bin/cat /etc/tps.log | sed -e 's/ Disks.*//' | awk -F= '{print $3}' > /tmp/tps-del.log
/bin/cat /etc/tps.log | sed -e 's/Ave.*Disks=//' | sed -e 's/ /<2F>/g' | sed -e "s/[0-9][0-9]h/~&/" > /tmp/tps-disk0.log
#
if test "$model" = "CS-406"
then
tab="4"
else
tab="6"
fi
col="1"
printf "Temperatures list of day "$jourlog" \n \n" > /tmp/tps-disk.log
for bo in `/bin/cat /tmp/tps-disk0.log`
do
if test "$col" != "$tab"
then
printf " "$bo" \c" >> /tmp/tps-disk.log
else
echo " "$bo >> /tmp/tps-disk.log
col="0"
fi
col=`expr $col + 1`
done
#
# Extraction des infos email, nom et domaine
#
smtp=`/bin/get_key_value /etc/synoinfo.conf eventsmtp`
mail=`/bin/get_key_value /etc/synoinfo.conf eventmail1`
user=`/bin/get_key_value /etc/synoinfo.conf eventuser`
pass=`/bin/get_key_value /etc/synoinfo.conf eventpass`
smtp=`/bin/get_key_value /etc/synoinfo.conf eventsmtp`
echo "hostname = "$smtp":25" > /opt/etc/esmtprc
echo "username = \""$user"\"" >> /opt/etc/esmtprc
echo "password = \""$pass"\"" >> /opt/etc/esmtprc
echo "mda = \"/opt/bin/procmail -d %T\"" >> /opt/etc/esmtprc
#
#-----------------------------
# Prepa entete du fichier mail
#-----------------------------
echo "FROM:SYNO "`hostname`"<"$mail">" > /tmp/ficmail
echo "TO:"`echo $mail | awk -F@ '{print $1}'`"<"$mail">" >> /tmp/ficmail
echo "SUBJECT: Disk diagnostic of "$jourlog >> /tmp/ficmail
echo "X-Priority: 1" >> /tmp/ficmail
echo "" >> /tmp/ficmail
#---------------------------------
# Infos SMART + Modele des disques
#---------------------------------
cd /dev
disque=0
> /tmp/tps-smart
> /tmp/tps-disk
# pour le CS-406
if test "$model" = "CS-406"
then
for bo in `/bin/ls hd?`
do
ph=`/opt/sbin/smartctl -A $bo | grep "Power_On_Hours" | awk '{ print $10 }'`
if test "$ph" != ""
then
disque=`expr $disque + 1`
pc=`/opt/sbin/smartctl -A $bo | grep "Power_Cycle_Count" | awk '{ print $10 }'`
echo "S.M.A.R.T values of DISQK number : "$disque" (/dev/"$bo")" >> /tmp/tps-smart
echo " " >> /tmp/tps-smart
/opt/sbin/smartctl -i $bo | grep -i "^[MDSU]" | grep -vi "smart" >> /tmp/tps-smart
echo " " >> /tmp/tps-smart
/opt/sbin/smartctl -A $bo | grep -i "ID#" >> /tmp/tps-smart
/opt/sbin/smartctl -A $bo | grep -i "^ *[0-9][0-9]* ..* 0x0" >> /tmp/tps-smart
echo "------------------------------------------------------------------------------------------------" >> /tmp/tps-smart
echo " " >> /tmp/tps-smart
echo "Disk n<>"$disque" : "$ph" hours / "$pc" starts." >> /tmp/tps-disk
fi
done
echo "Information of "`hostname`" with "$disque" disk(s) on "$jourlog >> /tmp/ficmail
# pour les autres syno
else
ph=`/opt/sbin/smartctl -A /dev/hda | grep "Power_On_Hours" | awk '{ print $10 }'`
pc=`/opt/sbin/smartctl -A /dev/hda | grep "Power_Cycle_Count" | awk '{ print $10 }'`
printf "S.M.A.R.T values of the DISK \n \n" >> /tmp/tps-smart
/opt/sbin/smartctl -i /dev/hda | grep -i "^[MDSU]" | grep -vi "smart" >> /tmp/tps-smart
echo " " >> /tmp/tps-smart
/opt/sbin/smartctl -A /dev/hda | grep -i "ID#" >> /tmp/tps-smart
/opt/sbin/smartctl -A /dev/hda | grep -i "^ *[0-9][0-9]* ..* 0x0" >> /tmp/tps-smart
echo "------------------------------------------------------------------------------------------------" >> /tmp/tps-smart
echo " " >> /tmp/tps-smart
echo "Internal hard disk : "$ph" hours / "$pc" starts." >> /tmp/tps-disk
echo "Information of "`hostname`" on "$jourlog >> /tmp/ficmail
fi
echo " " >> /tmp/ficmail
/bin/cat /tmp/tps-disk >> /tmp/ficmail
echo " " >> /tmp/ficmail
#----------------------
# Infos sur les volumes
#----------------------
cd /
> /tmp/tps-volume
for bo in `/bin/ls | grep volume`
do
echo `df -h $bo | grep $bo | awk '{print "Disk Usage. : "$2" - "$5" , "$4" available on "$6}'` >> /tmp/tps-volume
done
#----------------------------------------------------------------
# Temperature moyenne, mini, maxi, Heure les plus chaudes du jour
# Ecriture des infos
#----------------------------------------------------------------
nbr=`wc -l /tmp/tps-moy.log | awk '{print $1}'`
h=`echo $nbr | awk '{ print $1 / 60 * '$tpstemps'}' | awk -F. '{print $1}'`
m=`echo $nbr | awk '{ print (( $1 / 60 * '$tpstemps' ) - '$h') * 60 }' | awk -F. '{print $1}'`
Tmax=`cat /tmp/tps-moy.log | sort | tail -1`
Tmin=`cat /tmp/tps-moy.log | sort -r | tail -1`
HTmax=`cat /etc/tps.log | grep "Moyenne=$Tmax" | sed -e 's/^..* //'`
echo "Uptime : "$h" hour(s) "$m" minute(s)" >> /tmp/ficmail
#
# pour le CS-406
#
if test "$model" = "CS-406"
then
Delt=`cat /tmp/tps-del.log | sort | tail -1`
for bou in `/bin/cat /tmp/tps-moy.log`
do
t=`echo $bou | awk -F. '{print $1}'`
echo $t >> /tmp/tps.$t
done
echo "Min Average Temp. : "$Tmin"<22>" >> /tmp/ficmail
echo "Max Average Temp. : "$Tmax"<22>" >> /tmp/ficmail
echo "Max Diff./Disk : "$Delt"<22>" >> /tmp/ficmail
#
# pour les autres
#
else
Tmoy=0
for bou in `/bin/cat /tmp/tps-moy.log`
do
t=`echo $bou | awk -F. '{print $1}'`
Tmoy=`expr $Tmoy + $t`
echo $t >> /tmp/tps.$t
done
Tmoy=`echo $Tmoy | awk '{print $1 * 100 / '$nbr'}' | awk -F. '{print $1 / 100}'`
echo "Lowest Temperature : "$Tmin"<22>" >> /tmp/ficmail
echo "Highest Temperature : "$Tmax"<22>" >> /tmp/ficmail
echo "Average Temperature : "$Tmoy"<22>" >> /tmp/ficmail
fi
#
echo " " >> /tmp/ficmail
echo "Hottest ++ Hours : "$HTmax >> /tmp/ficmail
echo " " >> /tmp/ficmail
/bin/cat /tmp/tps-volume >> /tmp/ficmail
#-----------------------------------
# Tri du fichier de releve du jour
# et Stat temperature en % du temps
#-----------------------------------
#
echo " " >> /tmp/ficmail
echo "==== Distribution of reported temperature ====" >> /tmp/ficmail
echo " " >> /tmp/ficmail
for bou in `/bin/ls /tmp/tps.*`
do
t=`echo $bou | awk -F. '{ print $2 }'`
p=`wc -l $bou | awk '{print $1 * 10000 / '$nbr'}' | awk -F. '{print $1 / 100}'`
nbcar=`echo $p | awk -F. '{print $1}' | wc -c | awk '{print $1 - 1}'`
virgu=`echo $p | awk -F. '{print $2}' | wc -c | awk '{print $1 - 1}'`
if test "$virgu" = "0"
then
p=$p".00"
fi
if test "$nbcar" = "1"
then
echo $t"<22> ~~> " $p"% " >> /tmp/ficmail
else
echo $t"<22> ~~> " $p"% " >> /tmp/ficmail
fi
done
#
echo " " >> /tmp/ficmail
echo "=====================================================" >> /tmp/ficmail
echo " " >> /tmp/ficmail
/bin/cat /tmp/tps-smart >> /tmp/ficmail
#
/bin/cat /tmp/tps-disk.log | sed -e "s/~/ ~ /g" >> /tmp/ficmail
#
# Envoie du Mail avec test si connection OK
# sinon on sauvegarde le mail
#
connect=`ping -c 1 $smtp 2> /dev/null | grep -i "0% packet loss"`
#
if test "$connect" != ""
then
echo "Sending email to "$mail
/opt/bin/esmtp $mail < /tmp/ficmail
#
# envoie mail en retard
#
for bou in `/bin/ls /etc/tps.mail* 2> /dev/null`
do
/opt/bin/esmtp $mail < $bou
echo "Sending delayed email" $bou
rm -f $bou
done
#
# Sauvegarde du mail si pas de connexion
#
else
echo "Sending email to "$mail" impossible / delayed"
mv /tmp/ficmail /etc/tps.mail$jourlog
fi
#
# Nettoyage
#
rm -f /tmp/ficmail /tmp/tps*
#
# Initialisation des donnees temperatures
# et mise a jour de la date courante.
#
if test "$jourlog" != "$jour"
then
echo "Updating Temperature statements"
cat /etc/tps.conf | sed -e 's/tps-jour="..*"/tps-jour="'$jour'"/' > /tmp/tps.conf
mv /tmp/tps.conf /etc
> /etc/tps.log
fi
#
# Ecriture des donnees si le jour courant = base de donnee
#
else
echo "Average="$Tmoy" Delta="$delta" Disks="$temp" "$heure >> /etc/tps.log
fi
else
#
# cas ou le fichier de donnees temperatures
# n'existe pas
#
cat /etc/tps.conf | sed -e 's/tps-jour="..*"/tps-jour="'$jour'"/' > /tmp/tps.conf
mv /tmp/tps.conf /etc
> /etc/tps.log
fi
fi

1
syno/version Normal file
View File

@@ -0,0 +1 @@
Linux version 3.2.40 (root@build2) (gcc version 4.6.4 (Linaro GCC branch-4.6.4. Marvell GCC Dev 201310-2126.3d181f66 64K MAXPAGESIZE ALIGN) ) #4493 SMP Thu Aug 21 21:43:02 CST 2014