v-zhuravlev / zbx-smartctl

Templates and scripts for monitoring disks health with Zabbix and smartmontools
https://share.zabbix.com/storage-devices/smartmontools/smart-monitoring-with-smartmontools-lld
GNU General Public License v3.0
245 stars 127 forks source link

/etc/sudoers.d/sudoers_zabbix_smartctl: syntax error near line 6 <<< #149

Closed denisgolius closed 2 years ago

denisgolius commented 4 years ago

How to fix this file if you got an error:

sudo -i
>>> /etc/sudoers.d/sudoers_zabbix_smartctl: syntax error near line 6 <<<
sudo: parse error in /etc/sudoers.d/sudoers_zabbix_smartctl near line 6
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

This link will help to you - https://sergeymukhin.com/blog/povrezhdennyy-etc-sudoers-oshibka-v-sintaksise

There is my hack to resolve issue wtih syntax error near line 6 <<<

Cmnd_Alias SMARTCTL = /usr/sbin/smartctl
Cmnd_Alias SMARTCTL_DISCOVERY = /etc/zabbix/scripts/smartctl-disks-discovery.pl
zabbix ALL= (ALL) NOPASSWD: SMARTCTL, SMARTCTL_DISCOVERY
Defaults!SMARTCTL !logfile, !syslog, !pam_session
Defaults!SMARTCTL_DISCOVERY !logfile, !syslog, !pam_session

Add colons after word Defaults and before !SMARTCTL for two last lines

#!/bin/bash

Cmnd_Alias SMARTCTL = /usr/sbin/smartctl
Cmnd_Alias SMARTCTL_DISCOVERY = /etc/zabbix/scripts/smartctl-disks-discovery.pl
zabbix ALL= (ALL) NOPASSWD: SMARTCTL, SMARTCTL_DISCOVERY
Defaults:!SMARTCTL !logfile, !syslog, !pam_session
Defaults:!SMARTCTL_DISCOVERY !logfile, !syslog, !pam_session
gojmpz commented 2 years ago

Add an empty line at the end of file.