Monday, January 11, 2010

Melihat online user webmail di FreeBSD dengan sintak MySQL

Untuk melihat online user webmail dapat juga dilakukan melalui MySQL. Adapun caranya adalah sbb :

[root@serpong4] ~ # mysql -S /tmp/mysql.sock2 -u userdt -p userdt
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 317031 to server version: 5.0.27
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>

mysql> select * from onlineusers order by ou_user;
+--------------+----------+---------------------+
| ou_timestamp | ou_user | ou_right_main |
+--------------+----------+---------------------+
| 1263201975 | imank | /src/right_main.php |
| 1263201931 | imank | /src/right_main.php |
| 1263202006 | imank | /src/right_main.php |
| 1263202001 | imank | /src/right_main.php |
| 1263201912 | imank | /src/right_main.php |
| 1263201855 | khairul | /src/right_main.php |
| 1263201734 | khairul | /src/right_main.php |
| 1263201850 | khairul | /src/right_main.php |
| 1263201880 | khairul | /src/right_main.php |
| 1263201824 | msmunir | /src/right_main.php |
| 1263201739 | msmunir | /src/right_main.php |
| 1263201788 | msmunir | /src/right_main.php |
| 1263201727 | msmunir | /src/right_main.php |
| 1263201766 | msmunir | /src/right_main.php |
| 1263201756 | nu_rohma | /src/right_main.php |
| 1263202133 | setia | /src/right_main.php |
| 1263201611 | setia | /src/right_main.php |
| 1263201595 | setia | /src/right_main.php |
| 1263202130 | suprikeu | /src/right_main.php |
| 1263202074 | suprikeu | /src/right_main.php |
| 1263202090 | syahril | /src/right_main.php |
| 1263201591 | vendewi | /src/right_main.php |
| 1263201696 | vendewi | /src/right_main.php |
| 1263201634 | vendewi | /src/right_main.php |
| 1263201537 | vendewi | /src/right_main.php |
| 1263201556 | vendewi | /src/right_main.php |
| 1263201575 | vendewi | /src/right_main.php |
| 1263201607 | vendewi | /src/right_main.php |
| 1263201666 | vendewi | /src/right_main.php |
| 1263201650 | vendewi | /src/right_main.php |
| 1263202118 | yundi | /src/right_main.php |
| 1263202076 | yundi | /src/right_main.php |
| 1263201613 | zack | /src/right_main.php |
+--------------+----------+---------------------+
33 rows in set (0.00 sec)

mysql>

atau

mysql> select distinct ou_user from onlineusers order by ou_user;
+----------------------------+
| ou_user |
+----------------------------+
| agussy |
| agustin@batan.go.id |
| anis_rohanda |
| antie-p |
| baaseng |
| chevist |
| darbeny |
| darwis |
| frida |
| gunbki |
| hadi-susilo |
| hrdyanti |
| husenzam |
| ian |
| iis |
| imank |
| irawan |
| junaidis |
| june_mellawati@batan.go.id |
| makhsun |
| maruli |
| maskur |
| ppgn |
| rakhmats |
| ramon84 |
| tsalyo |
| wardojo |
| yesti |
| yulendya |
| yulianti |
+----------------------------+
30 rows in set (0.00 sec)

mysql>

Mencari pengguna :
mysql> select * from table1 where field1 like '%string%' order by field1 asc;
Misal mau mencari user yang ada kata 'sis' nya :
mysql> select * from mailbox where username like '%sis%' order by username asc;


Melihat struktur tabel
mysql> desc table;

Misal mau melihat struktur tabel mailbox :
mysql> desc mailbox;
+-----------+------------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+------------------+------+-----+---------------------+-------+
| username | varchar(255) | NO | PRI | | |
| password | varchar(255) | NO | | | |
| name | varchar(255) | NO | | | |
| nip | varchar(10) | YES | | NULL | |
| nip_baru | varchar(25) | YES | | NULL | |
| satker_id | int(10) unsigned | YES | | NULL | |
| maildir | varchar(255) | NO | | | |
| quota | bigint(10) | NO | | 0 | |
| domain | varchar(255) | NO | | | |
| created | datetime | NO | | 0000-00-00 00:00:00 | |
| modified | datetime | NO | | 0000-00-00 00:00:00 | |
| active | tinyint(1) | NO | | 1 | |
+-----------+------------------+------+-----+---------------------+-------+
12 rows in set (0.00 sec)

mysql>


Melihat user yang tidak aktif :
mysql> select * from mailbox where active = 0 order by username asc;

Keluar :

mysql>\quit


No comments:

Post a Comment