Category Archives: sadmin

sadmin

gnome-keyring-daemon not responding

На Gnome когато изключвам машината ми дрънчи следния прозорец

"
gnome-keyring-daemon
not responding
"

С други думи keyring-a не се shutdown-ва нормално. Ето го и решението:

killall -9 gnome-keyring-daemon
rm -rf ~/.gnome2/keyrings

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Инсталиране на Icinga Web на Debian -- (Install Icinga Web -- Debian)

##############################################################
1. Install  Icinga 1.4.1
##############################################################
apt-get install php5-cli php-pear php5-xmlrpc php5-xsl php5-ldap php5-gd php5-mysql

create mysql user:icinga_web , pass:icingapass
mysql -uroot icinga_web -p < /usr/src/icinga-1.4.1/module/idoutils/db/mysql/mysql.sql

cd /usr/src
wget 'http://sourceforge.net/projects/icinga/files/icinga/1.4.1/icinga-1.4.1.tar.gz/download' -O icinga-1.4.1.tar.gz
tar zxvf icinga-1.4.1.tar.gz
cd icinga-1.4.1
./configure --enable-idoutils
make all
make fullinstall

cd /usr/local/icinga/etc/;
cp idomod.cfg-sample idomod.cfg
cp ido2db.cfg-sample ido2db.cfg

vim ido2db.cfg
Change mysql db/user/pass

vim /usr/local/icinga/etc/icinga.cfg

Uncomment the line:

broker_module=/usr/local/icinga/bin/idomod.o config_file=/usr/local/icinga/etc/idomod.cfg

##############################################################
2. Install Icinga Web
##############################################################
cd /usr/src

wget http://sourceforge.net/projects/icinga/files/icinga-web/1.4.1/icinga-web-1.4.1.tar.gz/download -O icinga-web-1.4.1.tar.gz

wget http://sourceforge.net/projects/icinga/files/icinga-web/1.4.1/icinga-web-1.4.1.tar.gz.md5/download -O icinga-web-1.4.1.tar.gz.md5

md5sum -c icinga-web-1.4.1.tar.gz.md5

tar zxvf icinga-web-1.4.1.tar.gz
cd icinga-web-1.4.1

./configure --prefix=/usr/local/icinga-web --with-icinga-api=/usr/local/icinga/share/icinga-api --with-db-name=icinga_web --with-db-user=icinga_web --with-db-pass=icingapass

make install

make testdeps

make db-initialize

Use the db-user specified in icinga-webs database.xml (Needs create Database/create Table rights)?(n,y)? y

vi /usr/local/icinga-web/app/modules/Web/config/icinga-io.site.xml

<setting name="api.interfaces.data">
<ae:parameter name="api_type">IcingaApi::CONNECTION_IDO</ae:parameter>
<ae:parameter name="config_type">mysql</ae:parameter>
<ae:parameter name="config_host">127.0.0.1</ae:parameter>
<ae:parameter name="config_port">3306</ae:parameter>
<ae:parameter name="config_database">icinga</ae:parameter>
<ae:parameter name="config_user">icinga</ae:parameter>
<ae:parameter name="config_password">password</ae:parameter>
<ae:parameter name="config_table_prefix">icinga_</ae:parameter>
</setting>

/usr/local/icinga-web/bin/clearcache.sh

vi /etc/apache2/conf.d/icinga-web.conf

Alias /icinga-web /usr/local/icinga-web/pub
<directory /usr/local/icinga-web/pub>
AllowOverride All
</directory>

/etc/init.d/apache2 restart

http://172.16.2.2/icinga-web/

##############################################################
3. Install nagios plugins
##############################################################
cd /usr/src
wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz/download -O 'nagios-plugins-1.4.15.tar.gz'

tar zxvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --prefix=/usr/local/icinga --with-icinga-user=icinga
make
make install

##############################################################
4. Възникнали грешки
##############################################################

При използване на "Commands":

IcingaApiCommandSendPipeException: checkConfig(): Pipe "/usr/local/icinga/var/rw/icinga.cmd" is missing or not writable!

Решение:

chmod -R 777 /usr/local/icinga/var/rw/

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Rsync често използвани команди

Архивиране от локална в локална директория

$ rsync -vur --delete --exclude='cache' --exclude='2011-06' 1/ 2/

Архивиране от локална в отдалечена директория

$ rsync -r -a -v -e "ssh -l ssh_user" --delete  /local/webroot server.in:/webroot/

Архивиране от отдалечена в локална директория

$ rsync -r -a -v -e "ssh -l ssh_user" --delete server.in:/webroot  /local/webroot

VN:F [1.9.22_1171]
Rating: 4.5/5 (2 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Малко полезни неща за Arris Corernerstone 1500 / Cadant C3

Arris CMTS Cadant C3:

Извеждане на power нивата на всеки upstream

sh conf | include power

Резултат:

DS/US     Prim Online    Timing Rec   CPE   IP address      MAC address    DOC
Interface SID  state     offset power
C1/0/U0.0 1    online      1445 9.8   1/2   30.1.36.123     0114.f8bd.2c5e D1.1
C1/0/U0.0 2    online      2225 10.2  0/2   30.1.30.85      003f.21cf.16f3 D1.1
C1/0/U2.0 3    online(d)   2206 9.8   0/2   30.1.30.194     050f.21cf.07de D1.1
C1/0/U0.0 4    online      2233 10.2  1/2   30.1.37.55      009f.21d5.8d08 D1.1

Извеждане на клиенти на конкретен Upstream. В случая Upstream 2

show cable modem | include U2

Резултат

C1/0/U2.0 3    online(d)   2206 9.8   0/2   30.1.30.194     280f.21cf.07de D1.1
C1/0/U2.0 19   online      1602 10.0  0/2   30.1.31.6       1300.cac9.0e7d D1.1
C1/0/U2.0 22   online      1433 10.2  0/2   30.1.35.210     1511.e621.fbf7 D1.1
C1/0/U2.0 31   online      1458 10.0  1/2   30.1.31.21      181e.6b25.ad5e D1.1
C1/0/U2.0 55   offline     1441 10.2  0/1   30.1.37.120     1922.3aff.ec3d D1.0
C1/0/U2.0 63   online      1425 7.0   1/2   30.1.35.215     2214.f8d2.b5d6 D1.1

Arris Cornerstone CMTS 1500

Първо трябва да се влезе в "Management subsystem" -> man

cable-level
upstream-list
show

Резултат

Upstream list

Channel  Status   Speed      In Octets   Mod Profile  Frequency  Power  Window
-------  -------  ---------  ----------  -----------  ---------  -----  ------
4        up       5120000    1327319160  1            30000000   0      120
5        up       5120000    2758304477  1            30500000   0      60
6        up       5120000    3025350475  1            31000000   0      60
7        up       5120000    0           1            31500000   0      120
8        up       5120000    3080412538  1            32000000   0      60
9        up       5120000    715961397   1            32500000   0      60
10       up       5120000    952901802   1            33000000   0      60
11       up       5120000    3043657984  1            33500000   0      60

Извеждане на подробна информация за модемите (може и без да се влиза в man mode само се изпълнява "modem")

man
cable-level
modem-list

Резултат:

Modems list

Modem  Mac Address        Ip Address       DnCh  UpCh  RxPwr  Status
-----  -----------------  ---------------  ----  ----  -----  ---------------
1      13:0a:73:f6:00:57  30.1.37.73       3     6     -1     regstr-complete
2      22:1e:6b:f7:b6:1d  30.1.36.168      3     4     -1     regstr-complete
3      13:0f:21:d5:8d:ad  30.1.33.20       3     4     1      regstr-complete
4      91:24:d1:a2:3c:04  30.1.35.198      3     6     0      regstr-complete
5      81:0f:21:cf:2a:1c  30.1.37.189      3     11    1      rng-aborted

Извеждане на обща статистика за ползваемостта на всичките upstream-и

modem total

Резултат

Channel    Active CMs   Registered CMs
-------    ----------   --------------
1           52             52
2            0              0
3           30             29
4            0              0
5           56             56
6           12             12
7           12             12
8           80             78
-------    ----------   --------------
TOTAL          242            239

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Vim -- Проблем с shell auto completion

Идеята е, че с VIM когато използвам шел "!sh" не ми прави допълване на командите с TAB за да се оправи това трябва да се коригира подразбиращия шел shell (него ползва vim shell). В моя случай е dash. Избран е този понеже от към бързина е по- добър от bash именно заради липсата на автоматично дописване. Сега ще го премахнем като default shell:

sudo dpkg-reconfigure dash

Избиране "No" и сме готови :)

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Проблем при ssh логване- Cannot determine realm for numeric host address

Проблема е, че при логване с ssh към машина извежда следното съобщение:

machine:~# time ssh [email protected] -p 33 -v
OpenSSH_4.3p2 Debian-9, OpenSSL 0.9.8c 05 Sep 2006
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 93.155.205.1 [93.155.205.1] port 33.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-5
debug1: match: OpenSSH_5.1p1 Debian-5 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.3p2 Debian-9
debug1: An invalid name was supplied
Cannot determine realm for numeric host address

debug1: An invalid name was supplied
A parameter was malformed
Validation error

debug1: An invalid name was supplied
Cannot determine realm for numeric host address

debug1: An invalid name was supplied
A parameter was malformed
Validation error

debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '93.155.205.1' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:4
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Next authentication method: password
[email protected]'s password:

real    0m15.717s
user    0m0.030s
sys    0m0.010s

Време за изпълнение 15 секунди

За да се коригира този проблем трябва да се изключи GSSAPIAuthentication (Керберос).
Временно се прави така:

machine:~# time ssh -o "GSSAPIAuthentication=no" [email protected] -p 33 -v
OpenSSH_4.3p2 Debian-9, OpenSSL 0.9.8c 05 Sep 2006
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.0.1 [192.168.0.1] port 33.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-5
debug1: match: OpenSSH_5.1p1 Debian-5 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.3p2 Debian-9
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '192.168.0.1' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:4
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Next authentication method: password
[email protected]'s password:

real    0m5.448s
user    0m0.030s
sys    0m0.000s

Виждаме, че времето от 15 секунди се свеждо до 5 секунди.

За се запише за постоянно се редактира файл: /etc/ssh/ssh_config
и стойността на "GSSAPIDelegateCredentials" се прави на "no"

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

MySQL бележки за работа с повече таблици :)

Прави се заявка за изтриване на всички таблици започващи с oc от база "comptech":

SELECT CONCAT("DROP TABLE ",GROUP_CONCAT(TABLE_NAME)) AS stmt FROM information_schema.TABLES WHERE
TABLE_SCHEMA = "comptech" AND TABLE_NAME LIKE "oc%";

Прави се заявка за изтриване на всички таблици от база "comptech" с изключение на foo,bar,baz

SELECT CONCAT('DROP TABLE ', TABLE_NAME, '; ')
FROM information_schema.tables
WHERE table_schema = 'comptech' AND table_name NOT IN ('foo', 'bar', 'baz');

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Промяна на Vbulletin парола през MySQL или phpMySQL

Идеята е на форум Vbulletin с userid ='1' да се сетна парола 'parola'(това е администратора):

UPDATE user set password = MD5(concat(MD5('parola'), user.salt)) WHERE userid = 1

Ако таблицата има префикс:

UPDATE labuser set password = MD5(concat(MD5('parola'), labuser.salt)) WHERE userid = 1

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Грешки при опит за ssh login

Когато се логвах на една машина на един приятел през SSH получих следните грешки. По- долу съм описал и техните решения.

Грешка 1: ssh_exchange_identification: Connection closed by remote host

Решение: Да се проверят следните файлове
/etc/hosts.deny и /etc/hosts.allow

Грешка 2: PTY allocation request failed on channel 0

Решение 2: rm -rf /dev/ptmx;mknod /dev/ptmx c 5 2;chmod 666 /dev/ptmx;umount /dev/pts;rm -rf /dev/pts;mkdir /dev/pts;mount /dev/pts;

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Инсталиране на php -- Image Magick на Cent OS

Основни пакети

1. yum install ImageMagick.i386
2. yum install ImageMagick-devel.i386
3. pecl install imagick

4. След като се инсталира imagick трябва да се зареди в php.ini
Kомпилирания модул може да се намери в /usr/lib/php/modules .

echo 'extension=imagick.so' >>  /etc/php.ini

6. Рестартиране на apache2

/etc/init.d/httpd restart

7. Проверяване дали всичко е инсталирано правилно:

Прави се файл info.php със съдържание:

<?php phpinfo(); ?>

Ако всичко е наред вътре ще има секция "imagick"

Грешки възникнали при изпълнение на публикацията:

В1. Няма инсталиран pecl

О1. yum install php-pear

В2. При инсталиране на imagick дава грешка

downloading imagick-3.0.1.tgz …
Starting to download imagick-3.0.1.tgz (93,920 bytes)
…………………done: 93,920 bytes
13 source files, building
running: phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
Please provide the prefix of Imagemagick installation [autodetect] :
building in /var/tmp/pear-build-root/imagick-3.0.1
running: /tmp/tmp2lZYQm/imagick-3.0.1/configure --with-imagick
checking for egrep… grep -E
checking for a sed that does not truncate output… /bin/sed
checking for cc… no
checking for gcc… no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
ERROR: `/tmp/tmp2lZYQm/imagick-3.0.1/configure --with-imagick' failed

О2. yum install gcc

В3. Втора грешка при инсталиране на imagick

sh: make: command not found
ERROR: `make' failed

О3. yum install make

Други интересни неща

За да се видят какви файлове са записани от пакета ImageMagick.i386

yum install yum-utils

repoquery --list ImageMagick.i386

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)